01: package org.apache.ojb.broker.metadata;
02:
03: import junit.framework.TestCase;
04: import org.apache.ojb.broker.PersistenceBroker;
05: import org.apache.ojb.broker.PersistenceBrokerFactory;
06: import org.apache.ojb.broker.ObjectRepository;
07: import org.apache.ojb.broker.metadata.fieldaccess.PersistentField;
08: import org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldFactory;
09:
10: /**
11: * Test used to check if it is possible to start OJB
12: * without defined descriptors.
13: * Before running this test delete/comment out all
14: * jdbc-connection-descriptors, class-descriptors in the
15: * repository file.
16: *
17: * @author <a href="mailto:armin@codeAuLait.de">Armin Waibel</a>
18: * @version $Id: RuntimeConfigurationTest.java,v 1.4 2004/03/15 00:32:20 baserose Exp $
19: */
20: public class RuntimeConfigurationTest extends TestCase {
21: public RuntimeConfigurationTest() {
22: }
23:
24: public RuntimeConfigurationTest(String s) {
25: super (s);
26: }
27:
28: public static void main(String[] args) {
29: String[] arr = { RuntimeConfigurationTest.class.getName() };
30: junit.textui.TestRunner.main(arr);
31: }
32:
33: public void testStartWithout() throws Exception {
34: ConnectionRepository cr = MetadataManager.getInstance()
35: .connectionRepository();
36: System.out.println("ConnectionRepository before add: "
37: + cr.toXML());
38: JdbcConnectionDescriptor jcd = new JdbcConnectionDescriptor();
39: jcd.setDbAlias("test");
40: jcd.setDbms("test2");
41: jcd.setDefaultConnection(true);
42: cr.addDescriptor(jcd);
43: System.out.println("ConnectionRepository after add: "
44: + cr.toXML());
45:
46: DescriptorRepository dr = MetadataManager.getInstance()
47: .getRepository();
48: System.out.println("DescriptorRepository before add: "
49: + dr.toXML());
50: ClassDescriptor cld = new ClassDescriptor(dr);
51: cld.setClassOfObject(ObjectRepository.A.class);
52: FieldDescriptor fd = new FieldDescriptor(cld, 1);
53: PersistentField pf = PersistentFieldFactory
54: .createPersistentField(ObjectRepository.A.class,
55: "someAField");
56: fd.setPersistentField(pf);
57: cld.addFieldDescriptor(fd);
58:
59: dr.setClassDescriptor(cld);
60: System.out.println("DescriptorRepository after add: "
61: + dr.toXML());
62: PersistenceBroker broker = PersistenceBrokerFactory
63: .defaultPersistenceBroker();
64: broker.close();
65: // Query query = QueryFactory.newQuery(A.class, (Criteria)null);
66: // broker.getCollectionByQuery(query);
67: }
68: }
|