1 package xdoclet.modules.ojb.tests; 2 3 17 18 23 public class FieldTagColumnAttributeTests extends OjbTestBase 24 { 25 public FieldTagColumnAttributeTests(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 column=\"\" */\n"+ 39 " private int attr;\n"+ 40 "}\n"); 41 42 assertEqualsOjbDescriptorFile( 43 "<class-descriptor\n"+ 44 " class=\"test.A\"\n"+ 45 " table=\"A\"\n"+ 46 ">\n"+ 47 " <field-descriptor\n"+ 48 " name=\"attr\"\n"+ 49 " column=\"attr\"\n"+ 50 " jdbc-type=\"INTEGER\"\n"+ 51 " >\n"+ 52 " </field-descriptor>\n"+ 53 "</class-descriptor>", 54 runOjbXDoclet(OJB_DEST_FILE)); 55 assertEqualsTorqueSchemaFile( 56 "<database name=\"ojbtest\">\n"+ 57 " <table name=\"A\">\n"+ 58 " <column name=\"attr\"\n"+ 59 " javaName=\"attr\"\n"+ 60 " type=\"INTEGER\"\n"+ 61 " />\n"+ 62 " </table>\n"+ 63 "</database>", 64 runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 65 } 66 67 public void testColumn2() 69 { 70 addClass( 71 "test.A", 72 "package test;\n"+ 73 "/** @ojb.class */\n"+ 74 "public class A {\n"+ 75 "/** @ojb.field column=\"B\" */\n"+ 76 " private int attr;\n"+ 77 "}\n"); 78 79 assertEqualsOjbDescriptorFile( 80 "<class-descriptor\n"+ 81 " class=\"test.A\"\n"+ 82 " table=\"A\"\n"+ 83 ">\n"+ 84 " <field-descriptor\n"+ 85 " name=\"attr\"\n"+ 86 " column=\"B\"\n"+ 87 " jdbc-type=\"INTEGER\"\n"+ 88 " >\n"+ 89 " </field-descriptor>\n"+ 90 "</class-descriptor>", 91 runOjbXDoclet(OJB_DEST_FILE)); 92 assertEqualsTorqueSchemaFile( 93 "<database name=\"ojbtest\">\n"+ 94 " <table name=\"A\">\n"+ 95 " <column name=\"B\"\n"+ 96 " javaName=\"attr\"\n"+ 97 " type=\"INTEGER\"\n"+ 98 " />\n"+ 99 " </table>\n"+ 100 "</database>", 101 runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 102 } 103 104 public void testColumn3() 106 { 107 addClass( 108 "test.A", 109 "package test;\n"+ 110 "/** @ojb.class */\n"+ 111 "public class A {\n"+ 112 "/** @ojb.field column=\"A\" */\n"+ 113 " private int attr;\n"+ 114 "}\n"); 115 addClass( 116 "test.B", 117 "package test;\n"+ 118 "/** @ojb.class */\n"+ 119 "public class B extends A {}\n"); 120 121 assertEqualsOjbDescriptorFile( 122 "<class-descriptor\n"+ 123 " class=\"test.A\"\n"+ 124 " table=\"A\"\n"+ 125 ">\n"+ 126 " <extent-class class-ref=\"test.B\"/>\n"+ 127 " <field-descriptor\n"+ 128 " name=\"attr\"\n"+ 129 " column=\"A\"\n"+ 130 " jdbc-type=\"INTEGER\"\n"+ 131 " >\n"+ 132 " </field-descriptor>\n"+ 133 "</class-descriptor>\n"+ 134 "<class-descriptor\n"+ 135 " class=\"test.B\"\n"+ 136 " table=\"B\"\n"+ 137 ">\n"+ 138 " <field-descriptor\n"+ 139 " name=\"attr\"\n"+ 140 " column=\"A\"\n"+ 141 " jdbc-type=\"INTEGER\"\n"+ 142 " >\n"+ 143 " </field-descriptor>\n"+ 144 "</class-descriptor>", 145 runOjbXDoclet(OJB_DEST_FILE)); 146 assertEqualsTorqueSchemaFile( 147 "<database name=\"ojbtest\">\n"+ 148 " <table name=\"A\">\n"+ 149 " <column name=\"A\"\n"+ 150 " javaName=\"attr\"\n"+ 151 " type=\"INTEGER\"\n"+ 152 " />\n"+ 153 " </table>\n"+ 154 " <table name=\"B\">\n"+ 155 " <column name=\"A\"\n"+ 156 " javaName=\"attr\"\n"+ 157 " type=\"INTEGER\"\n"+ 158 " />\n"+ 159 " </table>\n"+ 160 "</database>", 161 runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 162 } 163 } 164 | Popular Tags |