KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ojb > broker > metadata > RuntimeConfigurationTest


1 package org.apache.ojb.broker.metadata;
2
3 import junit.framework.TestCase;
4 import org.apache.ojb.broker.PersistenceBroker;
5 import org.apache.ojb.broker.PersistenceBrokerFactory;
6 import org.apache.ojb.broker.ObjectRepository;
7 import org.apache.ojb.broker.metadata.fieldaccess.PersistentField;
8 import org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldFactory;
9
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 {
22     public RuntimeConfigurationTest()
23     {
24     }
25
26     public RuntimeConfigurationTest(String JavaDoc s)
27     {
28         super(s);
29     }
30
31     public static void main(String JavaDoc[] args)
32     {
33         String JavaDoc[] arr = {RuntimeConfigurationTest.class.getName()};
34         junit.textui.TestRunner.main(arr);
35     }
36
37     public void testStartWithout() throws Exception JavaDoc
38     {
39         ConnectionRepository cr = MetadataManager.getInstance().connectionRepository();
40         System.out.println("ConnectionRepository before add: "+cr.toXML());
41         JdbcConnectionDescriptor jcd = new JdbcConnectionDescriptor();
42         jcd.setDbAlias("test");
43         jcd.setDbms("test2");
44         jcd.setDefaultConnection(true);
45         cr.addDescriptor(jcd);
46         System.out.println("ConnectionRepository after add: "+cr.toXML());
47
48         DescriptorRepository dr = MetadataManager.getInstance().getRepository();
49         System.out.println("DescriptorRepository before add: "+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.createPersistentField(ObjectRepository.A.class, "someAField");
54         fd.setPersistentField(pf);
55         cld.addFieldDescriptor(fd);
56
57         dr.setClassDescriptor(cld);
58         System.out.println("DescriptorRepository after add: "+dr.toXML());
59         PersistenceBroker broker = PersistenceBrokerFactory.defaultPersistenceBroker();
60         broker.close();
61 // Query query = QueryFactory.newQuery(A.class, (Criteria)null);
62
// broker.getCollectionByQuery(query);
63
}
64 }
65
Popular Tags