1 package xdoclet.modules.ojb.tests; 2 3 17 18 23 public class ModifyInheritedTagAccessAttributeTests extends OjbTestBase 24 { 25 public ModifyInheritedTagAccessAttributeTests(String name) 26 { 27 super(name); 28 } 29 30 public void testAccess1() 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 " * access=\"readonly\"\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 " access=\"readonly\"\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 testAccess2() 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 attrKey;\n"+ 104 " /** @ojb.reference foreignkey=\"attrKey\" */\n"+ 105 " private test.B attr;\n"+ 106 "}\n"); 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 "}\n"); 115 addClass( 116 "test.C", 117 "package test;\n"+ 118 "/** @ojb.class\n" + 119 " * @ojb.modify-inherited name=\"attr\"\n"+ 120 " * access=\"readwrite\"\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 testAccess3() 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.List objs;\n"+ 142 "}\n"); 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 "}\n"); 151 addClass( 152 "test.C", 153 "package test;\n"+ 154 "/** @ojb.class\n" + 155 " * @ojb.modify-inherited name=\"objs\"\n"+ 156 " * access=\"readonly\"\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 testAccess4() 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 " * access=\"readonly\"\n"+ 181 " */\n"+ 182 "public class B extends A {}\n"); 183 184 assertNull(runOjbXDoclet(OJB_DEST_FILE)); 185 assertNull(runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 186 } 187 188 public void testAccess5() 190 { 191 addClass( 192 "test.A", 193 "package test;\n"+ 194 "/** @ojb.class */\n" + 195 "public class A {\n"+ 196 " /** @ojb.field */\n"+ 197 " private int attr;\n"+ 198 "}"); 199 addClass( 200 "test.B", 201 "package test;\n"+ 202 "/** @ojb.class\n" + 203 " * @ojb.modify-inherited name=\"attr\"\n"+ 204 " * access=\"whatever\"\n"+ 205 " */\n"+ 206 "public class B extends A {}\n"); 207 208 assertNull(runOjbXDoclet(OJB_DEST_FILE)); 209 assertNull(runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 210 } 211 212 public void testAccess6() 214 { 215 addClass( 216 "test.A", 217 "package test;\n"+ 218 "/** @ojb.class */\n" + 219 "public class A {\n"+ 220 " /** @ojb.field */\n"+ 221 " private int attr;\n"+ 222 "}"); 223 addClass( 224 "test.B", 225 "package test;\n"+ 226 "/** @ojb.class\n" + 227 " * @ojb.modify-inherited name=\"attr\"\n"+ 228 " * access=\"anonymous\"\n"+ 229 " */\n"+ 230 "public class B extends A {}\n"); 231 232 assertNull(runOjbXDoclet(OJB_DEST_FILE)); 233 assertNull(runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 234 } 235 } 236 | Popular Tags |