1 package xdoclet.modules.ojb.tests; 2 3 17 18 23 public class ModifyInheritedTagColumnAttributeTests extends OjbTestBase 24 { 25 public ModifyInheritedTagColumnAttributeTests(String name) 26 { 27 super(name); 28 } 29 30 public void testColumn1() 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 " * column=\"attrB\"\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=\"attrB\"\n"+ 70 " jdbc-type=\"INTEGER\"\n"+ 71 " >\n"+ 72 " </field-descriptor>\n"+ 73 "</class-descriptor>", 74 runOjbXDoclet(OJB_DEST_FILE)); 75 assertEqualsTorqueSchemaFile( 76 "<database name=\"ojbtest\">\n"+ 77 " <table name=\"A\">\n"+ 78 " <column name=\"attr\"\n"+ 79 " javaName=\"attr\"\n"+ 80 " type=\"INTEGER\"\n"+ 81 " />\n"+ 82 " </table>\n"+ 83 " <table name=\"B\">\n"+ 84 " <column name=\"attrB\"\n"+ 85 " javaName=\"attr\"\n"+ 86 " type=\"INTEGER\"\n"+ 87 " />\n"+ 88 " </table>\n"+ 89 "</database>", 90 runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 91 } 92 93 public void testColumn2() 95 { 96 addClass( 97 "test.A", 98 "package test;\n"+ 99 "/** @ojb.class */\n" + 100 "public class A {\n"+ 101 " /** @ojb.field */\n"+ 102 " private int bid;\n"+ 103 " /** @ojb.reference foreignkey=\"bid\" */\n"+ 104 " private B b;\n"+ 105 "}"); 106 addClass( 107 "test.B", 108 "package test;\n"+ 109 "/** @ojb.class */\n" + 110 "public class B {\n"+ 111 " /** @ojb.field primarykey=\"true\" */\n"+ 112 " private int id;\n"+ 113 "}"); 114 addClass( 115 "test.C", 116 "package test;\n"+ 117 "/** @ojb.class\n" + 118 " * @ojb.modify-inherited name=\"b\"\n"+ 119 " * column=\"b1\"\n"+ 120 " */\n"+ 121 "public class C extends A {}\n"); 122 123 assertNull(runOjbXDoclet(OJB_DEST_FILE)); 124 assertNull(runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 125 } 126 127 public void testColumn3() 129 { 130 addClass( 131 "test.A", 132 "package test;\n"+ 133 "/** @ojb.class */\n" + 134 "public class A {\n"+ 135 " /** @ojb.field primarykey=\"true\" */\n"+ 136 " private int id;\n"+ 137 " /** @ojb.collection element-class-ref=\"test.B\"\n"+ 138 " * foreignkey=\"aid\"\n"+ 139 " */\n"+ 140 " private java.util.Collection bs;\n"+ 141 "}"); 142 addClass( 143 "test.B", 144 "package test;\n"+ 145 "/** @ojb.class */\n" + 146 "public class B {\n"+ 147 " /** @ojb.field */\n"+ 148 " private int aid;\n"+ 149 "}"); 150 addClass( 151 "test.C", 152 "package test;\n"+ 153 "/** @ojb.class\n" + 154 " * @ojb.modify-inherited name=\"bs\"\n"+ 155 " * column=\"bs1\"\n"+ 156 " */\n"+ 157 "public class C extends A {}\n"); 158 159 assertNull(runOjbXDoclet(OJB_DEST_FILE)); 160 assertNull(runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 161 } 162 163 public void testColumn4() 165 { 166 addClass( 167 "test.A", 168 "package test;\n"+ 169 "/** @ojb.class\n"+ 170 " * @ojb.field name=\"attr\"\n"+ 171 " * jdbc-type=\"INTEGER\"\n"+ 172 " */\n" + 173 "public class A {}"); 174 addClass( 175 "test.B", 176 "package test;\n"+ 177 "/** @ojb.class\n" + 178 " * @ojb.modify-inherited name=\"attr\"\n"+ 179 " * column=\"attrB\"\n"+ 180 " */\n"+ 181 "public class B extends A {}\n"); 182 183 assertEqualsOjbDescriptorFile( 184 "<class-descriptor\n"+ 185 " class=\"test.A\"\n"+ 186 " table=\"A\"\n"+ 187 ">\n"+ 188 " <extent-class class-ref=\"test.B\"/>\n"+ 189 " <field-descriptor\n"+ 190 " name=\"attr\"\n"+ 191 " column=\"attr\"\n"+ 192 " jdbc-type=\"INTEGER\"\n"+ 193 " access=\"anonymous\"\n"+ 194 " >\n"+ 195 " </field-descriptor>\n"+ 196 "</class-descriptor>\n"+ 197 "<class-descriptor\n"+ 198 " class=\"test.B\"\n"+ 199 " table=\"B\"\n"+ 200 ">\n"+ 201 " <field-descriptor\n"+ 202 " name=\"attr\"\n"+ 203 " column=\"attrB\"\n"+ 204 " jdbc-type=\"INTEGER\"\n"+ 205 " access=\"anonymous\"\n"+ 206 " >\n"+ 207 " </field-descriptor>\n"+ 208 "</class-descriptor>", 209 runOjbXDoclet(OJB_DEST_FILE)); 210 assertEqualsTorqueSchemaFile( 211 "<database name=\"ojbtest\">\n"+ 212 " <table name=\"A\">\n"+ 213 " <column name=\"attr\"\n"+ 214 " javaName=\"attr\"\n"+ 215 " type=\"INTEGER\"\n"+ 216 " />\n"+ 217 " </table>\n"+ 218 " <table name=\"B\">\n"+ 219 " <column name=\"attrB\"\n"+ 220 " javaName=\"attr\"\n"+ 221 " type=\"INTEGER\"\n"+ 222 " />\n"+ 223 " </table>\n"+ 224 "</database>", 225 runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 226 } 227 228 public void testColumn5() 230 { 231 addClass( 232 "test.A", 233 "package test;\n"+ 234 "/** @ojb.class */\n" + 235 "public class A {\n"+ 236 " /** @ojb.field column=\"ATTR1\" */\n"+ 237 " private int attr;\n"+ 238 "}"); 239 addClass( 240 "test.B", 241 "package test;\n"+ 242 "/** @ojb.class\n" + 243 " * @ojb.modify-inherited name=\"attr\"\n"+ 244 " * column=\"\"\n"+ 245 " */\n"+ 246 "public class B extends A {}\n"); 247 248 assertEqualsOjbDescriptorFile( 249 "<class-descriptor\n"+ 250 " class=\"test.A\"\n"+ 251 " table=\"A\"\n"+ 252 ">\n"+ 253 " <extent-class class-ref=\"test.B\"/>\n"+ 254 " <field-descriptor\n"+ 255 " name=\"attr\"\n"+ 256 " column=\"ATTR1\"\n"+ 257 " jdbc-type=\"INTEGER\"\n"+ 258 " >\n"+ 259 " </field-descriptor>\n"+ 260 "</class-descriptor>\n"+ 261 "<class-descriptor\n"+ 262 " class=\"test.B\"\n"+ 263 " table=\"B\"\n"+ 264 ">\n"+ 265 " <field-descriptor\n"+ 266 " name=\"attr\"\n"+ 267 " column=\"attr\"\n"+ 268 " jdbc-type=\"INTEGER\"\n"+ 269 " >\n"+ 270 " </field-descriptor>\n"+ 271 "</class-descriptor>", 272 runOjbXDoclet(OJB_DEST_FILE)); 273 assertEqualsTorqueSchemaFile( 274 "<database name=\"ojbtest\">\n"+ 275 " <table name=\"A\">\n"+ 276 " <column name=\"ATTR1\"\n"+ 277 " javaName=\"attr\"\n"+ 278 " type=\"INTEGER\"\n"+ 279 " />\n"+ 280 " </table>\n"+ 281 " <table name=\"B\">\n"+ 282 " <column name=\"attr\"\n"+ 283 " javaName=\"attr\"\n"+ 284 " type=\"INTEGER\"\n"+ 285 " />\n"+ 286 " </table>\n"+ 287 "</database>", 288 runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 289 } 290 } 291 | Popular Tags |