1 package xdoclet.modules.ojb.tests; 2 3 17 18 23 public class FieldTagDefaultFetchAttributeTests extends OjbTestBase 24 { 25 public FieldTagDefaultFetchAttributeTests(String name) 26 { 27 super(name); 28 } 29 30 public void testDefaultFetch1() 32 { 33 addClass( 34 "test.A", 35 "package test;\n"+ 36 "/** @ojb.class */\n"+ 37 "public class A {\n"+ 38 "/** @ojb.field default-fetch=\"\" */\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 testDefaultFetch2() 48 { 49 addClass( 50 "test.A", 51 "package test;\n"+ 52 "/** @ojb.class */\n"+ 53 "public class A {\n"+ 54 "/** @ojb.field default-fetch=\"yes\" */\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 testDefaultFetch3() 64 { 65 addClass( 66 "test.A", 67 "package test;\n"+ 68 "/** @ojb.class */\n"+ 69 "public class A {\n"+ 70 "/** @ojb.field default-fetch=\"true\" */\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 " default-fetch=\"true\"\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 testDefaultFetch4() 102 { 103 addClass( 104 "test.A", 105 "package test;\n"+ 106 "/** @ojb.class */\n"+ 107 "public class A {\n"+ 108 "/** @ojb.field default-fetch=\"false\" */\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 " default-fetch=\"false\"\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 testDefaultFetch5() 140 { 141 addClass( 142 "test.A", 143 "package test;\n"+ 144 "/** @ojb.class */\n"+ 145 "public class A {\n"+ 146 "/** @ojb.field default-fetch=\"true\" */\n"+ 147 " private int attr;\n"+ 148 "}\n"); 149 addClass( 150 "test.B", 151 "package test;\n"+ 152 "public class B extends A {}\n"); 153 addClass( 154 "test.C", 155 "package test;\n"+ 156 "/** @ojb.class */\n"+ 157 "public class C extends B {}\n"); 158 159 assertEqualsOjbDescriptorFile( 160 "<class-descriptor\n"+ 161 " class=\"test.A\"\n"+ 162 " table=\"A\"\n"+ 163 ">\n"+ 164 " <extent-class class-ref=\"test.C\"/>\n"+ 165 " <field-descriptor\n"+ 166 " name=\"attr\"\n"+ 167 " column=\"attr\"\n"+ 168 " jdbc-type=\"INTEGER\"\n"+ 169 " default-fetch=\"true\"\n"+ 170 " >\n"+ 171 " </field-descriptor>\n"+ 172 "</class-descriptor>\n"+ 173 "<class-descriptor\n"+ 174 " class=\"test.C\"\n"+ 175 " table=\"C\"\n"+ 176 ">\n"+ 177 " <field-descriptor\n"+ 178 " name=\"attr\"\n"+ 179 " column=\"attr\"\n"+ 180 " jdbc-type=\"INTEGER\"\n"+ 181 " default-fetch=\"true\"\n"+ 182 " >\n"+ 183 " </field-descriptor>\n"+ 184 "</class-descriptor>", 185 runOjbXDoclet(OJB_DEST_FILE)); 186 assertEqualsTorqueSchemaFile( 187 "<database name=\"ojbtest\">\n"+ 188 " <table name=\"A\">\n"+ 189 " <column name=\"attr\"\n"+ 190 " javaName=\"attr\"\n"+ 191 " type=\"INTEGER\"\n"+ 192 " />\n"+ 193 " </table>\n"+ 194 " <table name=\"C\">\n"+ 195 " <column name=\"attr\"\n"+ 196 " javaName=\"attr\"\n"+ 197 " type=\"INTEGER\"\n"+ 198 " />\n"+ 199 " </table>\n"+ 200 "</database>", 201 runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 202 } 203 } 204 | Popular Tags |