1 package xdoclet.modules.ojb.tests; 2 3 17 18 23 public class FieldTagAccessAttributeTests extends OjbTestBase 24 { 25 public FieldTagAccessAttributeTests(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 access=\"\" */\n"+ 39 " private int attr;\n"+ 40 "}\n"); 41 42 assertNull(runOjbXDoclet(OJB_DEST_FILE)); 43 assertNull(runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 44 } 45 46 public void testAccess2() 48 { 49 addClass( 50 "test.A", 51 "package test;\n"+ 52 "/** @ojb.class */\n"+ 53 "public class A {\n"+ 54 "/** @ojb.field access=\"don't know\" */\n"+ 55 " private int attr;\n"+ 56 "}\n"); 57 58 assertNull(runOjbXDoclet(OJB_DEST_FILE)); 59 assertNull(runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 60 } 61 62 public void testAccess3() 64 { 65 addClass( 66 "test.A", 67 "package test;\n"+ 68 "/** @ojb.class */\n"+ 69 "public class A {\n"+ 70 "/** @ojb.field access=\"readonly\" */\n"+ 71 " private int attr;\n"+ 72 "}\n"); 73 74 assertEqualsOjbDescriptorFile( 75 "<class-descriptor\n"+ 76 " class=\"test.A\"\n"+ 77 " table=\"A\"\n"+ 78 ">\n"+ 79 " <field-descriptor\n"+ 80 " name=\"attr\"\n"+ 81 " column=\"attr\"\n"+ 82 " jdbc-type=\"INTEGER\"\n"+ 83 " access=\"readonly\"\n"+ 84 " >\n"+ 85 " </field-descriptor>\n"+ 86 "</class-descriptor>", 87 runOjbXDoclet(OJB_DEST_FILE)); 88 assertEqualsTorqueSchemaFile( 89 "<database name=\"ojbtest\">\n"+ 90 " <table name=\"A\">\n"+ 91 " <column name=\"attr\"\n"+ 92 " javaName=\"attr\"\n"+ 93 " type=\"INTEGER\"\n"+ 94 " />\n"+ 95 " </table>\n"+ 96 "</database>", 97 runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 98 } 99 100 public void testAccess4() 102 { 103 addClass( 104 "test.A", 105 "package test;\n"+ 106 "/** @ojb.class */\n"+ 107 "public class A {\n"+ 108 "/** @ojb.field access=\"readwrite\" */\n"+ 109 " private int attr;\n"+ 110 "}\n"); 111 112 assertEqualsOjbDescriptorFile( 113 "<class-descriptor\n"+ 114 " class=\"test.A\"\n"+ 115 " table=\"A\"\n"+ 116 ">\n"+ 117 " <field-descriptor\n"+ 118 " name=\"attr\"\n"+ 119 " column=\"attr\"\n"+ 120 " jdbc-type=\"INTEGER\"\n"+ 121 " access=\"readwrite\"\n"+ 122 " >\n"+ 123 " </field-descriptor>\n"+ 124 "</class-descriptor>", 125 runOjbXDoclet(OJB_DEST_FILE)); 126 assertEqualsTorqueSchemaFile( 127 "<database name=\"ojbtest\">\n"+ 128 " <table name=\"A\">\n"+ 129 " <column name=\"attr\"\n"+ 130 " javaName=\"attr\"\n"+ 131 " type=\"INTEGER\"\n"+ 132 " />\n"+ 133 " </table>\n"+ 134 "</database>", 135 runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 136 } 137 138 public void testAccess5() 140 { 141 addClass( 142 "test.A", 143 "package test;\n"+ 144 "/** @ojb.class */\n"+ 145 "public class A {\n"+ 146 "/** @ojb.field access=\"anonymous\" */\n"+ 147 " private int attr;\n"+ 148 "}\n"); 149 150 assertNull(runOjbXDoclet(OJB_DEST_FILE)); 151 assertNull(runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 152 } 153 154 public void testAccess6() 156 { 157 addClass( 158 "test.A", 159 "package test;\n"+ 160 "/** @ojb.class */\n"+ 161 "public class A {\n"+ 162 "/** @ojb.field access=\"readonly\" */\n"+ 163 " private int attr;\n"+ 164 "}\n"); 165 addClass( 166 "test.B", 167 "package test;\n"+ 168 "public class B extends A {}\n"); 169 addClass( 170 "test.C", 171 "package test;\n"+ 172 "/** @ojb.class */\n"+ 173 "public class C extends B {}\n"); 174 175 assertEqualsOjbDescriptorFile( 176 "<class-descriptor\n"+ 177 " class=\"test.A\"\n"+ 178 " table=\"A\"\n"+ 179 ">\n"+ 180 " <extent-class class-ref=\"test.C\"/>\n"+ 181 " <field-descriptor\n"+ 182 " name=\"attr\"\n"+ 183 " column=\"attr\"\n"+ 184 " jdbc-type=\"INTEGER\"\n"+ 185 " access=\"readonly\"\n"+ 186 " >\n"+ 187 " </field-descriptor>\n"+ 188 "</class-descriptor>\n"+ 189 "<class-descriptor\n"+ 190 " class=\"test.C\"\n"+ 191 " table=\"C\"\n"+ 192 ">\n"+ 193 " <field-descriptor\n"+ 194 " name=\"attr\"\n"+ 195 " column=\"attr\"\n"+ 196 " jdbc-type=\"INTEGER\"\n"+ 197 " access=\"readonly\"\n"+ 198 " >\n"+ 199 " </field-descriptor>\n"+ 200 "</class-descriptor>", 201 runOjbXDoclet(OJB_DEST_FILE)); 202 assertEqualsTorqueSchemaFile( 203 "<database name=\"ojbtest\">\n"+ 204 " <table name=\"A\">\n"+ 205 " <column name=\"attr\"\n"+ 206 " javaName=\"attr\"\n"+ 207 " type=\"INTEGER\"\n"+ 208 " />\n"+ 209 " </table>\n"+ 210 " <table name=\"C\">\n"+ 211 " <column name=\"attr\"\n"+ 212 " javaName=\"attr\"\n"+ 213 " type=\"INTEGER\"\n"+ 214 " />\n"+ 215 " </table>\n"+ 216 "</database>", 217 runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 218 } 219 } 220 | Popular Tags |