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 20 public class RuntimeConfigurationTest extends TestCase 21 { 22 public RuntimeConfigurationTest() 23 { 24 } 25 26 public RuntimeConfigurationTest(String s) 27 { 28 super(s); 29 } 30 31 public static void main(String [] args) 32 { 33 String [] arr = {RuntimeConfigurationTest.class.getName()}; 34 junit.textui.TestRunner.main(arr); 35 } 36 37 public void testStartWithout() throws Exception 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 } 64 } 65 | Popular Tags |