1 package xdoclet.modules.ojb.tests; 2 3 17 18 import java.util.HashMap ; 19 20 25 public class ClassTagRowReaderAttributeTests extends OjbTestBase 26 { 27 public ClassTagRowReaderAttributeTests(String name) 28 { 29 super(name); 30 } 31 32 public void testRowReader1() 34 { 35 addClass( 36 "test.A", 37 "package test;\n"+ 38 "/** @ojb.class row-reader=\"\" */\n"+ 39 "public class A {}\n"); 40 41 assertEqualsOjbDescriptorFile( 42 "<class-descriptor\n"+ 43 " class=\"test.A\"\n"+ 44 " table=\"A\"\n"+ 45 ">\n"+ 46 "</class-descriptor>", 47 runOjbXDoclet(OJB_DEST_FILE)); 48 assertEqualsTorqueSchemaFile( 49 "<database name=\"ojbtest\">\n"+ 50 " <table name=\"A\">\n"+ 51 " </table>\n"+ 52 "</database>", 53 runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 54 } 55 56 public void testRowReader2() 58 { 59 addClass( 60 "test.A", 61 "package test;\n"+ 62 "/** @ojb.class row-reader=\"org.apache.ojb.broker.accesslayer.RowReaderDefaultImpl\" */\n"+ 63 "public class A {}\n"); 64 65 assertEqualsOjbDescriptorFile( 66 "<class-descriptor\n"+ 67 " class=\"test.A\"\n"+ 68 " table=\"A\"\n"+ 69 " row-reader=\"org.apache.ojb.broker.accesslayer.RowReaderDefaultImpl\"\n"+ 70 ">\n"+ 71 "</class-descriptor>", 72 runOjbXDoclet(OJB_DEST_FILE)); 73 assertEqualsTorqueSchemaFile( 74 "<database name=\"ojbtest\">\n"+ 75 " <table name=\"A\">\n"+ 76 " </table>\n"+ 77 "</database>", 78 runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 79 } 80 81 public void testRowReader3() 83 { 84 addClass( 85 "test.A", 86 "package test;\n"+ 87 "/** @ojb.class row-reader=\""+TestRowReader.class.getName()+"\" */\n"+ 88 "public class A {}\n"); 89 90 assertEqualsOjbDescriptorFile( 91 "<class-descriptor\n"+ 92 " class=\"test.A\"\n"+ 93 " table=\"A\"\n"+ 94 " row-reader=\""+TestRowReader.class.getName()+"\"\n"+ 95 ">\n"+ 96 "</class-descriptor>", 97 runOjbXDoclet(OJB_DEST_FILE)); 98 assertEqualsTorqueSchemaFile( 99 "<database name=\"ojbtest\">\n"+ 100 " <table name=\"A\">\n"+ 101 " </table>\n"+ 102 "</database>", 103 runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 104 } 105 106 public void testRowReader4() 108 { 109 addClass( 110 "test.A", 111 "package test;\n"+ 112 "/** @ojb.class row-reader=\"test.RowReader\" */\n"+ 113 "public class A {}\n"); 114 115 assertNull(runOjbXDoclet(OJB_DEST_FILE)); 116 assertNull(runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 117 } 118 119 public void testRowReader5() 121 { 122 addClass( 123 "test.A", 124 "package test;\n"+ 125 "/** @ojb.class row-reader=\"java.lang.String\" */\n"+ 126 "public class A {}\n"); 127 128 assertNull(runOjbXDoclet(OJB_DEST_FILE)); 129 assertNull(runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 130 } 131 132 public void testRowReader6() 134 { 135 addClass( 136 "test.A", 137 "package test;\n"+ 138 "/** @ojb.class row-reader=\"SomeClass\" */\n"+ 139 "public class A {}\n"); 140 141 HashMap taskProps = new HashMap (); 142 HashMap torqueSubTaskProps = new HashMap (); 143 144 taskProps.put(PROPERTY_CHECKS, "basic"); 145 torqueSubTaskProps.put(PROPERTY_DATABASENAME, "ojbtest"); 146 147 assertEqualsOjbDescriptorFile( 148 "<class-descriptor\n"+ 149 " class=\"test.A\"\n"+ 150 " table=\"A\"\n"+ 151 " row-reader=\"SomeClass\"\n"+ 152 ">\n"+ 153 "</class-descriptor>", 154 runOjbXDoclet(OJB_DEST_FILE, taskProps, null)); 155 assertEqualsTorqueSchemaFile( 156 "<database name=\"ojbtest\">\n"+ 157 " <table name=\"A\">\n"+ 158 " </table>\n"+ 159 "</database>", 160 runTorqueXDoclet(TORQUE_DEST_FILE, taskProps, torqueSubTaskProps)); 161 } 162 } 163 | Popular Tags |