1 package xdoclet.modules.ojb.tests; 2 3 17 18 23 public class ModifyInheritedTagLockingAttributeTests extends OjbTestBase 24 { 25 public ModifyInheritedTagLockingAttributeTests(String name) 26 { 27 super(name); 28 } 29 30 public void testLocking1() 32 { 33 addClass( 34 "test.A", 35 "package test;\n"+ 36 "/** @ojb.class */\n" + 37 "public class A {\n"+ 38 " /** @ojb.field */\n"+ 39 " private int attr;\n"+ 40 "}"); 41 addClass( 42 "test.B", 43 "package test;\n"+ 44 "/** @ojb.class\n" + 45 " * @ojb.modify-inherited name=\"attr\"\n"+ 46 " * locking=\"true\"\n"+ 47 " */\n"+ 48 "public class B extends A {}\n"); 49 50 assertEqualsOjbDescriptorFile( 51 "<class-descriptor\n"+ 52 " class=\"test.A\"\n"+ 53 " table=\"A\"\n"+ 54 ">\n"+ 55 " <extent-class class-ref=\"test.B\"/>\n"+ 56 " <field-descriptor\n"+ 57 " name=\"attr\"\n"+ 58 " column=\"attr\"\n"+ 59 " jdbc-type=\"INTEGER\"\n"+ 60 " >\n"+ 61 " </field-descriptor>\n"+ 62 "</class-descriptor>\n"+ 63 "<class-descriptor\n"+ 64 " class=\"test.B\"\n"+ 65 " table=\"B\"\n"+ 66 ">\n"+ 67 " <field-descriptor\n"+ 68 " name=\"attr\"\n"+ 69 " column=\"attr\"\n"+ 70 " jdbc-type=\"INTEGER\"\n"+ 71 " locking=\"true\"\n"+ 72 " >\n"+ 73 " </field-descriptor>\n"+ 74 "</class-descriptor>", 75 runOjbXDoclet(OJB_DEST_FILE)); 76 assertEqualsTorqueSchemaFile( 77 "<database name=\"ojbtest\">\n"+ 78 " <table name=\"A\">\n"+ 79 " <column name=\"attr\"\n"+ 80 " javaName=\"attr\"\n"+ 81 " type=\"INTEGER\"\n"+ 82 " />\n"+ 83 " </table>\n"+ 84 " <table name=\"B\">\n"+ 85 " <column name=\"attr\"\n"+ 86 " javaName=\"attr\"\n"+ 87 " type=\"INTEGER\"\n"+ 88 " />\n"+ 89 " </table>\n"+ 90 "</database>", 91 runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 92 } 93 94 public void testLocking2() 96 { 97 addClass( 98 "test.A", 99 "package test;\n"+ 100 "/** @ojb.class */\n" + 101 "public class A {\n"+ 102 " /** @ojb.field */\n"+ 103 " private int bid;\n"+ 104 " /** @ojb.reference foreignkey=\"bid\" */\n"+ 105 " private B b;\n"+ 106 "}"); 107 addClass( 108 "test.B", 109 "package test;\n"+ 110 "/** @ojb.class */\n" + 111 "public class B {\n"+ 112 " /** @ojb.field primarykey=\"true\" */\n"+ 113 " private int id;\n"+ 114 "}"); 115 addClass( 116 "test.C", 117 "package test;\n"+ 118 "/** @ojb.class\n" + 119 " * @ojb.modify-inherited name=\"b\"\n"+ 120 " * locking=\"false\"\n"+ 121 " */\n"+ 122 "public class C extends A {}\n"); 123 124 assertNull(runOjbXDoclet(OJB_DEST_FILE)); 125 assertNull(runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 126 } 127 128 public void testLocking3() 130 { 131 addClass( 132 "test.A", 133 "package test;\n"+ 134 "/** @ojb.class */\n" + 135 "public class A {\n"+ 136 " /** @ojb.field primarykey=\"true\" */\n"+ 137 " private int id;\n"+ 138 " /** @ojb.collection element-class-ref=\"test.B\"\n"+ 139 " * foreignkey=\"aid\"\n"+ 140 " */\n"+ 141 " private java.util.Collection bs;\n"+ 142 "}"); 143 addClass( 144 "test.B", 145 "package test;\n"+ 146 "/** @ojb.class */\n" + 147 "public class B {\n"+ 148 " /** @ojb.field */\n"+ 149 " private int aid;\n"+ 150 "}"); 151 addClass( 152 "test.C", 153 "package test;\n"+ 154 "/** @ojb.class\n" + 155 " * @ojb.modify-inherited name=\"bs\"\n"+ 156 " * locking=\"true\"\n"+ 157 " */\n"+ 158 "public class C extends A {}\n"); 159 160 assertNull(runOjbXDoclet(OJB_DEST_FILE)); 161 assertNull(runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 162 } 163 164 public void testLocking4() 166 { 167 addClass( 168 "test.A", 169 "package test;\n"+ 170 "/** @ojb.class\n"+ 171 " * @ojb.field name=\"attr\"\n"+ 172 " * jdbc-type=\"INTEGER\"\n"+ 173 " */\n" + 174 "public class A {}"); 175 addClass( 176 "test.B", 177 "package test;\n"+ 178 "/** @ojb.class\n" + 179 " * @ojb.modify-inherited name=\"attr\"\n"+ 180 " * locking=\"false\"\n"+ 181 " */\n"+ 182 "public class B extends A {}\n"); 183 184 assertEqualsOjbDescriptorFile( 185 "<class-descriptor\n"+ 186 " class=\"test.A\"\n"+ 187 " table=\"A\"\n"+ 188 ">\n"+ 189 " <extent-class class-ref=\"test.B\"/>\n"+ 190 " <field-descriptor\n"+ 191 " name=\"attr\"\n"+ 192 " column=\"attr\"\n"+ 193 " jdbc-type=\"INTEGER\"\n"+ 194 " access=\"anonymous\"\n"+ 195 " >\n"+ 196 " </field-descriptor>\n"+ 197 "</class-descriptor>\n"+ 198 "<class-descriptor\n"+ 199 " class=\"test.B\"\n"+ 200 " table=\"B\"\n"+ 201 ">\n"+ 202 " <field-descriptor\n"+ 203 " name=\"attr\"\n"+ 204 " column=\"attr\"\n"+ 205 " jdbc-type=\"INTEGER\"\n"+ 206 " locking=\"false\"\n"+ 207 " access=\"anonymous\"\n"+ 208 " >\n"+ 209 " </field-descriptor>\n"+ 210 "</class-descriptor>", 211 runOjbXDoclet(OJB_DEST_FILE)); 212 assertEqualsTorqueSchemaFile( 213 "<database name=\"ojbtest\">\n"+ 214 " <table name=\"A\">\n"+ 215 " <column name=\"attr\"\n"+ 216 " javaName=\"attr\"\n"+ 217 " type=\"INTEGER\"\n"+ 218 " />\n"+ 219 " </table>\n"+ 220 " <table name=\"B\">\n"+ 221 " <column name=\"attr\"\n"+ 222 " javaName=\"attr\"\n"+ 223 " type=\"INTEGER\"\n"+ 224 " />\n"+ 225 " </table>\n"+ 226 "</database>", 227 runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 228 } 229 230 public void testLocking5() 232 { 233 addClass( 234 "test.A", 235 "package test;\n"+ 236 "/** @ojb.class */\n" + 237 "public class A {\n"+ 238 " /** @ojb.field */\n"+ 239 " private int attr;\n"+ 240 "}"); 241 addClass( 242 "test.B", 243 "package test;\n"+ 244 "/** @ojb.class\n" + 245 " * @ojb.modify-inherited name=\"attr\"\n"+ 246 " * locking=\"yes\"\n"+ 247 " */\n"+ 248 "public class B extends A {}\n"); 249 250 assertNull(runOjbXDoclet(OJB_DEST_FILE)); 251 assertNull(runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 252 } 253 } 254 | Popular Tags |