1 package xdoclet.modules.ojb.tests; 2 3 17 18 23 public class CollectionTagDocumentationAttributeTests extends OjbTestBase 24 { 25 public CollectionTagDocumentationAttributeTests(String name) 26 { 27 super(name); 28 } 29 30 public void testDocumentatation1() 32 { 33 addClass( 34 "test.A", 35 "package test;\n"+ 36 "/** @ojb.class */\n"+ 37 "public class A {\n"+ 38 "/** @ojb.field primarykey=\"true\" */\n"+ 39 " private int id;\n"+ 40 "/** @ojb.collection element-class-ref=\"test.B\"\n"+ 41 " * foreignkey=\"aid\"\n"+ 42 " * documentation=\"\"\n"+ 43 " */\n"+ 44 " private java.util.List objs;\n"+ 45 "}\n"); 46 addClass( 47 "test.B", 48 "package test;\n"+ 49 "/** @ojb.class */\n"+ 50 "public class B {\n"+ 51 "/** @ojb.field */\n"+ 52 " private int aid;\n"+ 53 "}\n"); 54 55 assertEqualsOjbDescriptorFile( 56 "<class-descriptor\n"+ 57 " class=\"test.A\"\n"+ 58 " table=\"A\"\n"+ 59 ">\n"+ 60 " <field-descriptor\n"+ 61 " name=\"id\"\n"+ 62 " column=\"id\"\n"+ 63 " jdbc-type=\"INTEGER\"\n"+ 64 " primarykey=\"true\"\n"+ 65 " >\n"+ 66 " </field-descriptor>\n"+ 67 " <collection-descriptor\n"+ 68 " name=\"objs\"\n"+ 69 " element-class-ref=\"test.B\"\n"+ 70 " >\n"+ 71 " <inverse-foreignkey field-ref=\"aid\"/>\n"+ 72 " </collection-descriptor>\n"+ 73 "</class-descriptor>\n"+ 74 "<class-descriptor\n"+ 75 " class=\"test.B\"\n"+ 76 " table=\"B\"\n"+ 77 ">\n"+ 78 " <field-descriptor\n"+ 79 " name=\"aid\"\n"+ 80 " column=\"aid\"\n"+ 81 " jdbc-type=\"INTEGER\"\n"+ 82 " >\n"+ 83 " </field-descriptor>\n"+ 84 "</class-descriptor>", 85 runOjbXDoclet(OJB_DEST_FILE)); 86 assertEqualsTorqueSchemaFile( 87 "<database name=\"ojbtest\">\n"+ 88 " <table name=\"A\">\n"+ 89 " <column name=\"id\"\n"+ 90 " javaName=\"id\"\n"+ 91 " type=\"INTEGER\"\n"+ 92 " primaryKey=\"true\"\n"+ 93 " required=\"true\"\n"+ 94 " />\n"+ 95 " </table>\n"+ 96 " <table name=\"B\">\n"+ 97 " <column name=\"aid\"\n"+ 98 " javaName=\"aid\"\n"+ 99 " type=\"INTEGER\"\n"+ 100 " />\n"+ 101 " <foreign-key foreignTable=\"A\">\n"+ 102 " <reference local=\"aid\" foreign=\"id\"/>\n"+ 103 " </foreign-key>\n"+ 104 " </table>\n"+ 105 "</database>", 106 runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 107 } 108 109 public void testDocumentatation2() 111 { 112 addClass( 113 "test.A", 114 "package test;\n"+ 115 "/** @ojb.class */\n"+ 116 "public class A {\n"+ 117 "/** @ojb.field primarykey=\"true\" */\n"+ 118 " private int id;\n"+ 119 "/** @ojb.collection element-class-ref=\"test.B\"\n"+ 120 " * foreignkey=\"aid\"\n"+ 121 " * documentation=\"Some important documentation\"\n"+ 122 " */\n"+ 123 " private java.util.List objs;\n"+ 124 "}\n"); 125 addClass( 126 "test.B", 127 "package test;\n"+ 128 "/** @ojb.class */\n"+ 129 "public class B {\n"+ 130 "/** @ojb.field */\n"+ 131 " private int aid;\n"+ 132 "}\n"); 133 134 assertEqualsOjbDescriptorFile( 135 "<class-descriptor\n"+ 136 " class=\"test.A\"\n"+ 137 " table=\"A\"\n"+ 138 ">\n"+ 139 " <field-descriptor\n"+ 140 " name=\"id\"\n"+ 141 " column=\"id\"\n"+ 142 " jdbc-type=\"INTEGER\"\n"+ 143 " primarykey=\"true\"\n"+ 144 " >\n"+ 145 " </field-descriptor>\n"+ 146 " <collection-descriptor\n"+ 147 " name=\"objs\"\n"+ 148 " element-class-ref=\"test.B\"\n"+ 149 " >\n"+ 150 " <documentation>Some important documentation</documentation>\n"+ 151 " <inverse-foreignkey field-ref=\"aid\"/>\n"+ 152 " </collection-descriptor>\n"+ 153 "</class-descriptor>\n"+ 154 "<class-descriptor\n"+ 155 " class=\"test.B\"\n"+ 156 " table=\"B\"\n"+ 157 ">\n"+ 158 " <field-descriptor\n"+ 159 " name=\"aid\"\n"+ 160 " column=\"aid\"\n"+ 161 " jdbc-type=\"INTEGER\"\n"+ 162 " >\n"+ 163 " </field-descriptor>\n"+ 164 "</class-descriptor>", 165 runOjbXDoclet(OJB_DEST_FILE)); 166 assertEqualsTorqueSchemaFile( 167 "<database name=\"ojbtest\">\n"+ 168 " <table name=\"A\">\n"+ 169 " <column name=\"id\"\n"+ 170 " javaName=\"id\"\n"+ 171 " type=\"INTEGER\"\n"+ 172 " primaryKey=\"true\"\n"+ 173 " required=\"true\"\n"+ 174 " />\n"+ 175 " </table>\n"+ 176 " <table name=\"B\">\n"+ 177 " <column name=\"aid\"\n"+ 178 " javaName=\"aid\"\n"+ 179 " type=\"INTEGER\"\n"+ 180 " />\n"+ 181 " <foreign-key foreignTable=\"A\">\n"+ 182 " <reference local=\"aid\" foreign=\"id\"/>\n"+ 183 " </foreign-key>\n"+ 184 " </table>\n"+ 185 "</database>", 186 runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 187 } 188 189 public void testDocumentatation3() 191 { 192 addClass( 193 "test.A", 194 "package test;\n"+ 195 "/** @ojb.class */\n"+ 196 "public class A {\n"+ 197 "/** @ojb.field primarykey=\"true\" */\n"+ 198 " private int id;\n"+ 199 "/** @ojb.collection element-class-ref=\"test.B\"\n"+ 200 " * foreignkey=\"aid\"\n"+ 201 " * documentation=\"Some important documentation\"\n"+ 202 " * database-foreignkey=\"false\"\n"+ 203 " */\n"+ 204 " private java.util.List objs;\n"+ 205 "}\n"); 206 addClass( 207 "test.B", 208 "package test;\n"+ 209 "/** @ojb.class */\n"+ 210 "public class B {\n"+ 211 "/** @ojb.field */\n"+ 212 " private int aid;\n"+ 213 "}\n"); 214 addClass( 215 "test.C", 216 "package test;\n"+ 217 "/** @ojb.class */\n"+ 218 "public class C extends A {}\n"); 219 220 assertEqualsOjbDescriptorFile( 221 "<class-descriptor\n"+ 222 " class=\"test.A\"\n"+ 223 " table=\"A\"\n"+ 224 ">\n"+ 225 " <extent-class class-ref=\"test.C\"/>\n"+ 226 " <field-descriptor\n"+ 227 " name=\"id\"\n"+ 228 " column=\"id\"\n"+ 229 " jdbc-type=\"INTEGER\"\n"+ 230 " primarykey=\"true\"\n"+ 231 " >\n"+ 232 " </field-descriptor>\n"+ 233 " <collection-descriptor\n"+ 234 " name=\"objs\"\n"+ 235 " element-class-ref=\"test.B\"\n"+ 236 " >\n"+ 237 " <documentation>Some important documentation</documentation>\n"+ 238 " <inverse-foreignkey field-ref=\"aid\"/>\n"+ 239 " </collection-descriptor>\n"+ 240 "</class-descriptor>\n"+ 241 "<class-descriptor\n"+ 242 " class=\"test.B\"\n"+ 243 " table=\"B\"\n"+ 244 ">\n"+ 245 " <field-descriptor\n"+ 246 " name=\"aid\"\n"+ 247 " column=\"aid\"\n"+ 248 " jdbc-type=\"INTEGER\"\n"+ 249 " >\n"+ 250 " </field-descriptor>\n"+ 251 "</class-descriptor>\n"+ 252 "<class-descriptor\n"+ 253 " class=\"test.C\"\n"+ 254 " table=\"C\"\n"+ 255 ">\n"+ 256 " <field-descriptor\n"+ 257 " name=\"id\"\n"+ 258 " column=\"id\"\n"+ 259 " jdbc-type=\"INTEGER\"\n"+ 260 " primarykey=\"true\"\n"+ 261 " >\n"+ 262 " </field-descriptor>\n"+ 263 " <collection-descriptor\n"+ 264 " name=\"objs\"\n"+ 265 " element-class-ref=\"test.B\"\n"+ 266 " >\n"+ 267 " <documentation>Some important documentation</documentation>\n"+ 268 " <inverse-foreignkey field-ref=\"aid\"/>\n"+ 269 " </collection-descriptor>\n"+ 270 "</class-descriptor>", 271 runOjbXDoclet(OJB_DEST_FILE)); 272 assertEqualsTorqueSchemaFile( 273 "<database name=\"ojbtest\">\n"+ 274 " <table name=\"A\">\n"+ 275 " <column name=\"id\"\n"+ 276 " javaName=\"id\"\n"+ 277 " type=\"INTEGER\"\n"+ 278 " primaryKey=\"true\"\n"+ 279 " required=\"true\"\n"+ 280 " />\n"+ 281 " </table>\n"+ 282 " <table name=\"B\">\n"+ 283 " <column name=\"aid\"\n"+ 284 " javaName=\"aid\"\n"+ 285 " type=\"INTEGER\"\n"+ 286 " />\n"+ 287 " </table>\n"+ 288 " <table name=\"C\">\n"+ 289 " <column name=\"id\"\n"+ 290 " javaName=\"id\"\n"+ 291 " type=\"INTEGER\"\n"+ 292 " primaryKey=\"true\"\n"+ 293 " required=\"true\"\n"+ 294 " />\n"+ 295 " </table>\n"+ 296 "</database>", 297 runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 298 } 299 } 300 | Popular Tags |