1 64 65 package com.jcorporate.expresso.core.dbobj.tests; 66 67 import com.jcorporate.expresso.core.dbobj.AutoDBObject; 68 import com.jcorporate.expresso.core.dbobj.SecuredDBObject; 69 import com.jcorporate.expresso.core.misc.ConfigManager; 70 import com.jcorporate.expresso.services.dbobj.MimeTypes; 71 import com.jcorporate.expresso.services.test.ControllerTestSuite; 72 import com.jcorporate.expresso.services.test.ExpressoTestCase; 73 import com.jcorporate.expresso.services.test.TestSystemInitializer; 74 75 import java.util.ArrayList ; 76 77 78 84 public class AutoDBObjTest 85 extends ExpressoTestCase { 86 public AutoDBObjTest(String name) 87 throws Exception { 88 super(name); 89 } 90 91 public static void main(String [] args) 92 throws java.lang.Exception { 93 94 junit.textui.TestRunner.run(suite()); 96 } 97 98 102 public static junit.framework.Test suite() 103 throws Exception { 104 ControllerTestSuite cts = new ControllerTestSuite(); 105 cts.addTestSuite(AutoDBObjTest.class); 106 cts.addReadOnlySchemaDependency("com.jcorporate.expresso.core.ExpressoSchema"); 107 108 return cts; 109 } 110 111 117 public void testAutoDBObject() 118 throws Exception { 119 if ("org.hsqldb.jdbcDriver".equals(ConfigManager 120 .getContext(TestSystemInitializer 121 .getTestContext()).getJdbc().getDriver())) { 122 return; 123 } 124 AutoDBObject ad = new AutoDBObject(); 125 ad.setDataContext(TestSystemInitializer.getTestContext()); 126 ad.setTargetTable("MIMETYPES"); 127 128 ArrayList al = ad.getMetaData().getFieldListArray(); 129 assertTrue("Cannot Have a Null FieldListArray", al != null); 130 assertTrue("Must have a > zero length field list", al.size() > 0); 131 132 SecuredDBObject sl = new MimeTypes(SecuredDBObject.SYSTEM_ACCOUNT); 133 sl.setDataContext(TestSystemInitializer.getTestContext()); 134 135 ArrayList al2 = sl.getMetaData().getFieldListArray(); 136 assertTrue("MimeTypes cannot return a null FieldList", al2 != null); 137 assertTrue("MimeTypes and AutoDBObject Field List Sizes must be " + 138 "equal", al.size() == al2.size()); 139 140 for (int i = 0; i < al.size(); i++) { 142 assertTrue("Field List must be equal for i=" + i, 143 ((String ) al.get(i)).equalsIgnoreCase((String ) al2.get(i))); 144 } 145 } 146 } 147 | Popular Tags |