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.jorm.util.api.Loggable; 36 import org.objectweb.util.monolog.api.BasicLevel; 37 import org.objectweb.util.monolog.api.Logger; 38 import org.objectweb.jorm.compiler.lib.Compiler; 39 import org.objectweb.jorm.cmdline.api.CmdLineParser; 40 41 import java.util.Vector ; 42 import java.util.Properties ; 43 import java.io.FileInputStream ; 44 45 55 public class SameObject extends TestCase { 56 57 60 private static String prefix = 61 "test/deviance/org/objectweb/jorm/parser/lib/"; 62 63 66 private static String properties = 67 prefix + "jorm.properties"; 68 69 73 private static String mapperOption = 74 "org.objectweb.jorm.cmdline.rdb.RdbMapperOption"; 75 76 80 private static String dbprop = "DBName"; 81 82 85 private static String dbname = "postgres"; 86 87 90 public SameObject(String name) { 91 super(name); 92 } 93 94 97 public static void main(String [] args) { 98 TestRunner.run(suite()); 99 } 100 101 104 protected void setUp() { 105 } 106 107 110 public static Test suite() { 111 return new TestSuite(SameObject.class); 112 } 113 114 117 public void test2Primitive() { 118 try { 119 Compiler comp = new Compiler (properties,"config/logSystem.properties"); 120 comp.addInputFileName(prefix+"2Primitive.pd"); 121 122 CmdLineParser clp = (CmdLineParser) 123 comp.getClassLoader().load(mapperOption); 124 Logger logger = null; 125 try { 126 Properties p = new Properties (); 127 p.load(new FileInputStream ("config/logSystem.properties")); 128 CompilerLogger.configure(p); 129 logger = 130 CompilerLogger.getLoggerFactory(). 131 getLogger("org.objectweb.jorm.compiler"); 132 133 } catch (Exception e) {} 134 135 comp.getCompilerParameter().addCPExtension( 136 mapperOption,clp); 137 138 clp.parseProperty(dbprop, dbname); 139 assertTrue("2 identical primitive type must be catched", 140 comp.execute()); 141 } catch (Exception e) { 142 143 } 144 145 } 146 147 151 public void testNot2Primitive() { 152 try { 153 Compiler comp = new Compiler (properties,"config/logSystem.properties"); 154 comp.addInputFileName(prefix+"Not2Primitive.pd"); 155 156 CmdLineParser clp = (CmdLineParser) 157 comp.getClassLoader().load(mapperOption); 158 159 Logger logger = null; 160 try { 161 Properties p = new Properties (); 162 p.load(new FileInputStream ("config/logSystem.properties")); 163 CompilerLogger.configure(p); 164 logger = 165 CompilerLogger.getLoggerFactory(). 166 getLogger("org.objectweb.jorm.compiler"); 167 168 } catch (Exception e) {} 169 170 comp.getCompilerParameter().addCPExtension( 171 mapperOption,clp); 172 173 clp.parseProperty(dbprop, dbname); 174 175 assertTrue("2 identical primitive name type must be catched", 176 comp.execute()); 177 } catch (Exception e) { 178 179 } 180 } 181 182 186 public void testSameNameDef() { 187 try { 188 Compiler comp = new Compiler (properties,"config/logSystem.properties"); 189 comp.addInputFileName(prefix+"SameNameDef.pd"); 190 191 CmdLineParser clp = (CmdLineParser) 192 comp.getClassLoader().load(mapperOption); 193 194 Logger logger = null; 195 try { 196 Properties p = new Properties (); 197 p.load(new FileInputStream ("config/logSystem.properties")); 198 CompilerLogger.configure(p); 199 logger = 200 CompilerLogger.getLoggerFactory(). 201 getLogger("org.objectweb.jorm.compiler"); 202 203 } catch (Exception e) {} 204 205 comp.getCompilerParameter().addCPExtension( 206 mapperOption,clp); 207 208 clp.parseProperty(dbprop, dbname); 209 assertTrue("2 identical NameDef must be catched", 210 comp.execute()); 211 } catch (Exception e) { 212 213 } 214 } 215 216 220 public void test2ScalarField() { 221 try { 222 Compiler comp = new Compiler (properties,"config/logSystem.properties"); 223 comp.addInputFileName(prefix+"2ScalarField.pd"); 224 225 CmdLineParser clp = (CmdLineParser) 226 comp.getClassLoader().load(mapperOption); 227 228 Logger logger = null; 229 try { 230 Properties p = new Properties (); 231 p.load(new FileInputStream ("config/logSystem.properties")); 232 CompilerLogger.configure(p); 233 logger = 234 CompilerLogger.getLoggerFactory(). 235 getLogger("org.objectweb.jorm.compiler"); 236 237 } catch (Exception e) {} 238 239 comp.getCompilerParameter().addCPExtension( 240 mapperOption,clp); 241 242 clp.parseProperty(dbprop, dbname); 243 assertTrue("2 identical ScalarField must be catched", 244 comp.execute()); 245 246 } catch (Exception e) { 247 248 } 249 } 250 } 251 | Popular Tags |