1 package xdoclet.modules.ojb.tests; 2 3 17 18 23 public class ClassTagAttributesAttributeTests extends OjbTestBase 24 { 25 public ClassTagAttributesAttributeTests(String name) 26 { 27 super(name); 28 } 29 30 public void testAttributes1() 32 { 33 addClass( 34 "A", 35 "/** @ojb.class attributes=\"\" */\n"+ 36 "public class A {}\n"); 37 38 assertEqualsOjbDescriptorFile( 39 "<class-descriptor\n"+ 40 " class=\"A\"\n"+ 41 " table=\"A\"\n"+ 42 ">\n"+ 43 "</class-descriptor>", 44 runOjbXDoclet(OJB_DEST_FILE)); 45 assertEqualsTorqueSchemaFile( 46 "<database name=\"ojbtest\">\n"+ 47 " <table name=\"A\">\n"+ 48 " </table>\n"+ 49 "</database>", 50 runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 51 } 52 53 public void testAttributes2() 55 { 56 addClass( 57 "A", 58 "/** @ojb.class attributes=\"name=value\" */\n"+ 59 "public class A {}\n"); 60 61 assertEqualsOjbDescriptorFile( 62 "<class-descriptor\n"+ 63 " class=\"A\"\n"+ 64 " table=\"A\"\n"+ 65 ">\n"+ 66 " <attribute attribute-name=\"name\" attribute-value=\"value\"/>\n"+ 67 "</class-descriptor>", 68 runOjbXDoclet(OJB_DEST_FILE)); 69 assertEqualsTorqueSchemaFile( 70 "<database name=\"ojbtest\">\n"+ 71 " <table name=\"A\">\n"+ 72 " </table>\n"+ 73 "</database>", 74 runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 75 } 76 77 public void testAttributes3() 79 { 80 addClass( 81 "A", 82 "/** @ojb.class attributes=\"name=\" */\n"+ 83 "public class A {}\n"); 84 85 assertEqualsOjbDescriptorFile( 86 "<class-descriptor\n"+ 87 " class=\"A\"\n"+ 88 " table=\"A\"\n"+ 89 ">\n"+ 90 " <attribute attribute-name=\"name\" attribute-value=\"\"/>\n"+ 91 "</class-descriptor>", 92 runOjbXDoclet(OJB_DEST_FILE)); 93 assertEqualsTorqueSchemaFile( 94 "<database name=\"ojbtest\">\n"+ 95 " <table name=\"A\">\n"+ 96 " </table>\n"+ 97 "</database>", 98 runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 99 } 100 101 public void testAttributes4() 103 { 104 addClass( 105 "A", 106 "/** @ojb.class attributes=\"name1=value1,name2=,name3=value3\" */\n"+ 107 "public class A {}\n"); 108 109 assertEqualsOjbDescriptorFile( 110 "<class-descriptor\n"+ 111 " class=\"A\"\n"+ 112 " table=\"A\"\n"+ 113 ">\n"+ 114 " <attribute attribute-name=\"name1\" attribute-value=\"value1\"/>\n"+ 115 " <attribute attribute-name=\"name2\" attribute-value=\"\"/>\n"+ 116 " <attribute attribute-name=\"name3\" attribute-value=\"value3\"/>\n"+ 117 "</class-descriptor>", 118 runOjbXDoclet(OJB_DEST_FILE)); 119 assertEqualsTorqueSchemaFile( 120 "<database name=\"ojbtest\">\n"+ 121 " <table name=\"A\">\n"+ 122 " </table>\n"+ 123 "</database>", 124 runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 125 } 126 127 public void testAttributes5() 129 { 130 addClass( 131 "A", 132 "/** @ojb.class attributes=\"name=value\" */\n"+ 133 "public class A {}\n"); 134 addClass( 135 "B", 136 "/** @ojb.class */\n"+ 137 "public class B extends A {}\n"); 138 139 assertEqualsOjbDescriptorFile( 140 "<class-descriptor\n"+ 141 " class=\"A\"\n"+ 142 " table=\"A\"\n"+ 143 ">\n"+ 144 " <extent-class class-ref=\"B\"/>\n"+ 145 " <attribute attribute-name=\"name\" attribute-value=\"value\"/>\n"+ 146 "</class-descriptor>\n"+ 147 "<class-descriptor\n"+ 148 " class=\"B\"\n"+ 149 " table=\"B\"\n"+ 150 ">\n"+ 151 "</class-descriptor>", 152 runOjbXDoclet(OJB_DEST_FILE)); 153 assertEqualsTorqueSchemaFile( 154 "<database name=\"ojbtest\">\n"+ 155 " <table name=\"A\">\n"+ 156 " </table>\n"+ 157 " <table name=\"B\">\n"+ 158 " </table>\n"+ 159 "</database>", 160 runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 161 } 162 163 } 164 | Popular Tags |