1 23 24 package org.objectweb.jorm.xml2mi.lib; 25 26 import junit.framework.Test; 27 import junit.framework.TestCase; 28 import junit.framework.TestSuite; 29 import junit.textui.TestRunner; 30 import org.objectweb.jorm.metainfo.api.Manager; 31 import org.objectweb.jorm.metainfo.lib.JormManager; 32 import org.objectweb.jorm.xml2mi.api.Parser; 33 import org.objectweb.jorm.util.lib.BasicClassLoader; 34 import org.objectweb.jorm.util.lib.CompilerLogger; 35 import org.objectweb.util.monolog.api.BasicLevel; 36 import org.objectweb.util.monolog.api.Logger; 37 import org.objectweb.jorm.compiler.lib.Compiler; 38 import org.objectweb.jorm.cmdline.api.CmdLineParser; 39 40 import java.util.Vector ; 41 42 60 public class EmptyObject extends TestCase { 61 62 65 private static String prefix = 66 "test/deviance/org/objectweb/jorm/parser/lib/"; 67 68 71 private static String properties = 72 prefix + "jorm.properties"; 73 74 78 private static String mapperOption = 79 "org.objectweb.jorm.cmdline.rdb.RdbMapperOption"; 80 81 85 private static String dbprop = "DBName"; 86 87 90 private static String dbname = "postgres"; 91 92 95 public EmptyObject(String name) { 96 super(name); 97 } 98 99 102 public static void main(String [] args) { 103 TestRunner.run(suite()); 104 } 105 106 109 protected void setUp() { 110 } 111 112 115 public static Test suite() { 116 return new TestSuite(EmptyObject.class); 117 } 118 119 122 public void testEmptyClass() { 123 try { 124 Compiler comp = new Compiler (properties,"config/logSystem.properties"); 125 comp.addInputFileName(prefix+"EmptyClass.pd"); 126 CmdLineParser clp = (CmdLineParser) 127 comp.getClassLoader().load(mapperOption); 128 comp.getCompilerParameter().addCPExtension( 129 mapperOption,clp); 130 131 clp.parseProperty(dbprop, dbname); 132 assertTrue("an empty Class does not work", comp.execute()); 133 } catch (Exception e) { 134 135 } 136 137 138 } 139 140 143 public void testEmptyGenClass() { 144 try { 145 Compiler comp = new Compiler (properties,"config/logSystem.properties"); 146 comp.addInputFileName(prefix+"EmptyGenClass.pd"); 147 148 CmdLineParser clp = (CmdLineParser) 149 comp.getClassLoader().load(mapperOption); 150 comp.getCompilerParameter().addCPExtension( 151 mapperOption,clp); 152 153 clp.parseProperty(dbprop, dbname); 154 assertTrue("an empty GenClass does not work", comp.execute()); 155 } catch (Exception e) { 156 157 } 158 } 159 160 164 public void testEmptyPrimitiveType() { 165 try { 166 Compiler comp = new Compiler (properties,"config/logSystem.properties"); 167 comp.addInputFileName(prefix+"EmptyPrimitiveType.pd"); 168 169 CmdLineParser clp = (CmdLineParser) 170 comp.getClassLoader().load(mapperOption); 171 comp.getCompilerParameter().addCPExtension( 172 mapperOption,clp); 173 174 clp.parseProperty(dbprop, dbname); 175 assertTrue("an empty PrimitiveType does not work", comp.execute()); 176 } catch (Exception e) { 177 178 } 179 } 180 181 188 public void testMappingWithoutRdb() { 189 try { 190 Compiler comp = new Compiler (properties,"config/logSystem.properties"); 191 comp.addInputFileName(prefix+"MappingWithoutRdb.pd"); 192 193 CmdLineParser clp = (CmdLineParser) 194 comp.getClassLoader().load(mapperOption); 195 comp.getCompilerParameter().addCPExtension( 196 mapperOption,clp); 197 198 clp.parseProperty(dbprop, dbname); 199 assertTrue("A ValueMapping without RdbValueMapping does not work", 200 comp.execute()); 201 } catch (Exception e) { 202 203 } 204 } 205 206 213 public void testRdbMappingWithoutColumn() { 214 try { 215 Compiler comp = new Compiler (properties,"config/logSystem.properties"); 216 comp.addInputFileName(prefix+"RdbMappingWithoutColumn.pd"); 217 218 CmdLineParser clp = (CmdLineParser) 219 comp.getClassLoader().load(mapperOption); 220 comp.getCompilerParameter().addCPExtension( 221 mapperOption,clp); 222 223 clp.parseProperty(dbprop, dbname); 224 assertTrue("An RdbValueMapping without RdbColumnSpec does not work", 225 comp.execute()); 226 } catch (Exception e) { 227 228 } 229 } 230 231 236 public void testWithoutNameDef() { 237 try { 238 Compiler comp = new Compiler (properties,"config/logSystem.properties"); 239 comp.addInputFileName(prefix+"WithoutNameDef.pd"); 240 241 CmdLineParser clp = (CmdLineParser) 242 comp.getClassLoader().load(mapperOption); 243 comp.getCompilerParameter().addCPExtension( 244 mapperOption,clp); 245 246 clp.parseProperty(dbprop, dbname); 247 assertTrue("Without NameDef does not work", comp.execute()); 248 } catch (Exception e) { 249 250 } 251 } 252 253 258 public void testWithoutNameDefClassMapping() { 259 try { 260 Compiler comp = new Compiler (properties,"config/logSystem.properties"); 261 comp.addInputFileName(prefix+"WithoutNameDefClassMapping.pd"); 262 263 CmdLineParser clp = (CmdLineParser) 264 comp.getClassLoader().load(mapperOption); 265 comp.getCompilerParameter().addCPExtension( 266 mapperOption,clp); 267 268 clp.parseProperty(dbprop, dbname); 269 assertTrue("Without NameDef and ClassMapping does not work", 270 comp.execute()); 271 } catch (Exception e) { 272 273 } 274 } 275 276 280 public void testWithoutSchema() { 281 try { 282 Compiler comp = new Compiler (properties,"config/logSystem.properties"); 283 comp.addInputFileName(prefix+"WithoutSchema.pd"); 284 285 CmdLineParser clp = (CmdLineParser) 286 comp.getClassLoader().load(mapperOption); 287 comp.getCompilerParameter().addCPExtension( 288 mapperOption,clp); 289 290 clp.parseProperty(dbprop, dbname); 291 assertTrue("Without Package does not work", comp.execute()); 292 } catch (Exception e) { 293 294 } 295 } 296 297 303 public void testScalarWithoutMapping() { 304 try { 305 Compiler comp = new Compiler (properties,"config/logSystem.properties"); 306 comp.addInputFileName(prefix+"ScalarWithoutMapping.pd"); 307 308 CmdLineParser clp = (CmdLineParser) 309 comp.getClassLoader().load(mapperOption); 310 comp.getCompilerParameter().addCPExtension( 311 mapperOption,clp); 312 313 clp.parseProperty(dbprop, dbname); 314 assertTrue("ScalarField Without ValueMapping does not work", comp.execute()); 315 } catch (Exception e) { 316 317 } 318 } 319 } 320 | Popular Tags |