1 package xdoclet.modules.ojb.tests; 2 3 17 18 import java.util.HashMap ; 19 20 25 public class ClassTagInitializationMethodAttributeTests extends OjbTestBase 26 { 27 public ClassTagInitializationMethodAttributeTests(String name) 28 { 29 super(name); 30 } 31 32 public void testInitializationMethod1() 34 { 35 addClass( 36 "test.A", 37 "package test;\n"+ 38 "/** @ojb.class initialization-method=\"\" */\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 testInitializationMethod2() 58 { 59 addClass( 62 TestClass.class.getName(), 63 "package "+TestClass.class.getPackage().getName()+";\n"+ 64 "/** @ojb.class initialization-method=\"initMethod1\" */\n"+ 65 "public class "+TestClass.getShortName()+" {}\n"); 66 67 assertEqualsOjbDescriptorFile( 68 "<class-descriptor\n"+ 69 " class=\""+TestClass.class.getName()+"\"\n"+ 70 " table=\""+TestClass.getShortName()+"\"\n"+ 71 " initialization-method=\"initMethod1\"\n"+ 72 ">\n"+ 73 "</class-descriptor>", 74 runOjbXDoclet(OJB_DEST_FILE)); 75 assertEqualsTorqueSchemaFile( 76 "<database name=\"ojbtest\">\n"+ 77 " <table name=\""+TestClass.getShortName()+"\">\n"+ 78 " </table>\n"+ 79 "</database>", 80 runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 81 } 82 83 public void testInitializationMethod3() 85 { 86 addClass( 89 TestClass.class.getName(), 90 "package "+TestClass.class.getPackage().getName()+";\n"+ 91 "/** @ojb.class initialization-method=\"initMethod\" */\n"+ 92 "public class "+TestClass.getShortName()+" {}\n"); 93 94 assertNull(runOjbXDoclet(OJB_DEST_FILE)); 95 assertNull(runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 96 } 97 98 public void testInitializationMethod4() 100 { 101 addClass( 104 TestClass.class.getName(), 105 "package "+TestClass.class.getPackage().getName()+";\n"+ 106 "/** @ojb.class initialization-method=\"initMethod2\" */\n"+ 107 "public class "+TestClass.getShortName()+" {}\n"); 108 109 assertNull(runOjbXDoclet(OJB_DEST_FILE)); 110 assertNull(runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 111 } 112 113 public void testInitializationMethod5() 115 { 116 addClass( 119 TestClass.class.getName(), 120 "package "+TestClass.class.getPackage().getName()+";\n"+ 121 "/** @ojb.class initialization-method=\"initMethod3\" */\n"+ 122 "public class "+TestClass.getShortName()+" {}\n"); 123 124 assertNull(runOjbXDoclet(OJB_DEST_FILE)); 125 assertNull(runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 126 } 127 128 public void testInitializationMethod6() 130 { 131 addClass( 132 "test.A", 133 "package test;\n"+ 134 "/** @ojb.class initialization-method=\"someMethod\" */\n"+ 135 "public class A {}\n"); 136 137 HashMap taskProps = new HashMap (); 138 HashMap torqueSubTaskProps = new HashMap (); 139 140 taskProps.put(PROPERTY_CHECKS, "basic"); 141 torqueSubTaskProps.put(PROPERTY_DATABASENAME, "ojbtest"); 142 143 assertEqualsOjbDescriptorFile( 144 "<class-descriptor\n"+ 145 " class=\"test.A\"\n"+ 146 " table=\"A\"\n"+ 147 " initialization-method=\"someMethod\"\n"+ 148 ">\n"+ 149 "</class-descriptor>", 150 runOjbXDoclet(OJB_DEST_FILE, taskProps, null)); 151 assertEqualsTorqueSchemaFile( 152 "<database name=\"ojbtest\">\n"+ 153 " <table name=\"A\">\n"+ 154 " </table>\n"+ 155 "</database>", 156 runTorqueXDoclet(TORQUE_DEST_FILE, taskProps, torqueSubTaskProps)); 157 } 158 } 159 | Popular Tags |