1 package xdoclet.modules.ojb.tests; 2 3 17 18 import java.util.HashMap ; 19 20 25 public class ClassTagFactoryClassAndMethodAttributeTests extends OjbTestBase 26 { 27 public ClassTagFactoryClassAndMethodAttributeTests(String name) 28 { 29 super(name); 30 } 31 32 public void testFactoryClassAndMethod1() 34 { 35 addClass( 36 "test.A", 37 "package test;\n"+ 38 "/** @ojb.class factory-class=\"\" */\n"+ 39 "public class A {}\n"); 40 41 assertEqualsOjbDescriptorFile( 42 "<class-descriptor\n"+ 43 " class=\"test.A\"\n"+ 44 " table=\"A\"\n"+ 45 ">\n"+ 46 "</class-descriptor>", 47 runOjbXDoclet(OJB_DEST_FILE)); 48 assertEqualsTorqueSchemaFile( 49 "<database name=\"ojbtest\">\n"+ 50 " <table name=\"A\">\n"+ 51 " </table>\n"+ 52 "</database>", 53 runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 54 } 55 56 public void testFactoryClassAndMethod2() 58 { 59 addClass( 62 TestClass.class.getName(), 63 "package "+TestClass.class.getPackage().getName()+";\n"+ 64 "/** @ojb.class factory-class=\"\"\n"+ 65 " * factory-method=\"create"+TestClass.getShortName()+"\"\n"+ 66 " */\n"+ 67 "public class "+TestClass.getShortName()+" {}\n"); 68 69 assertNull(runOjbXDoclet(OJB_DEST_FILE)); 70 assertNull(runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 71 } 72 73 public void testFactoryClassAndMethod3() 75 { 76 addClass( 79 TestClass.class.getName(), 80 "package "+TestClass.class.getPackage().getName()+";\n"+ 81 "/** @ojb.class factory-class=\""+TestFactoryClass.class.getName()+"\"\n"+ 82 " * factory-method=\"\"\n"+ 83 " */\n"+ 84 "public class "+TestClass.getShortName()+" {}\n"); 85 86 assertNull(runOjbXDoclet(OJB_DEST_FILE)); 87 assertNull(runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 88 } 89 90 public void testFactoryClassAndMethod4() 92 { 93 addClass( 96 TestClass.class.getName(), 97 "package "+TestClass.class.getPackage().getName()+";\n"+ 98 "/** @ojb.class factory-class=\""+TestFactoryClass.class.getName()+"\"\n"+ 99 " * factory-method=\"create"+TestClass.getShortName()+"\"\n"+ 100 " */\n"+ 101 "public class "+TestClass.getShortName()+" {}\n"); 102 103 assertEqualsOjbDescriptorFile( 104 "<class-descriptor\n"+ 105 " class=\""+TestClass.class.getName()+"\"\n"+ 106 " table=\""+TestClass.getShortName()+"\"\n"+ 107 " factory-class=\""+TestFactoryClass.class.getName()+"\"\n"+ 108 " factory-method=\"create"+TestClass.getShortName()+"\"\n"+ 109 ">\n"+ 110 "</class-descriptor>", 111 runOjbXDoclet(OJB_DEST_FILE)); 112 assertEqualsTorqueSchemaFile( 113 "<database name=\"ojbtest\">\n"+ 114 " <table name=\""+TestClass.getShortName()+"\">\n"+ 115 " </table>\n"+ 116 "</database>", 117 runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 118 } 119 120 public void testFactoryClassAndMethod5() 122 { 123 addClass( 124 "test.A", 125 "package test;\n"+ 126 "/** @ojb.class factory-class=\"test.SomeClass\"\n"+ 127 " * factory-method=\"someMethod\"\n"+ 128 " */\n"+ 129 "public class A {}\n"); 130 131 assertNull(runOjbXDoclet(OJB_DEST_FILE)); 132 assertNull(runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 133 } 134 135 public void testFactoryClassAndMethod6() 137 { 138 addClass( 141 TestClass.class.getName(), 142 "package "+TestClass.class.getPackage().getName()+";\n"+ 143 "/** @ojb.class factory-class=\""+TestFactoryClass.class.getName()+"\"\n"+ 144 " * factory-method=\"make"+TestClass.getShortName()+"\"\n"+ 145 " */\n"+ 146 "public class "+TestClass.getShortName()+" {}\n"); 147 148 assertNull(runOjbXDoclet(OJB_DEST_FILE)); 149 assertNull(runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 150 } 151 152 public void testFactoryClassAndMethod7() 154 { 155 addClass( 158 TestClass.class.getName(), 159 "package "+TestClass.class.getPackage().getName()+";\n"+ 160 "/** @ojb.class factory-class=\""+TestFactoryClass.class.getName()+"\"\n"+ 161 " * factory-method=\"createNew"+TestClass.getShortName()+"\"\n"+ 162 " */\n"+ 163 "public class "+TestClass.getShortName()+" {}\n"); 164 165 assertNull(runOjbXDoclet(OJB_DEST_FILE)); 166 assertNull(runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 167 } 168 169 public void testFactoryClassAndMethod8() 171 { 172 addClass( 175 TestClass.class.getName(), 176 "package "+TestClass.class.getPackage().getName()+";\n"+ 177 "/** @ojb.class factory-class=\""+TestFactoryClass.class.getName()+"\"\n"+ 178 " * factory-method=\"makeNew"+TestClass.getShortName()+"\"\n"+ 179 " */\n"+ 180 "public class "+TestClass.getShortName()+" {}\n"); 181 182 assertNull(runOjbXDoclet(OJB_DEST_FILE)); 183 assertNull(runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 184 } 185 186 public void testFactoryClassAndMethod9() 188 { 189 addClass( 190 "test.A", 191 "package test;\n"+ 192 "/** @ojb.class factory-class=\"SomeClass\"\n"+ 193 " * factory-method=\"someMethod\"\n"+ 194 " */\n"+ 195 "public class A {}\n"); 196 197 HashMap taskProps = new HashMap (); 198 HashMap torqueSubTaskProps = new HashMap (); 199 200 taskProps.put(PROPERTY_CHECKS, "basic"); 201 torqueSubTaskProps.put(PROPERTY_DATABASENAME, "ojbtest"); 202 203 assertEqualsOjbDescriptorFile( 204 "<class-descriptor\n"+ 205 " class=\"test.A\"\n"+ 206 " table=\"A\"\n"+ 207 " factory-class=\"SomeClass\"\n"+ 208 " factory-method=\"someMethod\"\n"+ 209 ">\n"+ 210 "</class-descriptor>", 211 runOjbXDoclet(OJB_DEST_FILE, taskProps, null)); 212 assertEqualsTorqueSchemaFile( 213 "<database name=\"ojbtest\">\n"+ 214 " <table name=\"A\">\n"+ 215 " </table>\n"+ 216 "</database>", 217 runTorqueXDoclet(TORQUE_DEST_FILE, taskProps, torqueSubTaskProps)); 218 } 219 } 220 | Popular Tags |