use of ch.ehi.ili2db.gui.Config in project ili2db by claeis.
the class SRSVerificationTest method srsAuthLowerCase_False.
@Test
public void srsAuthLowerCase_False() throws Exception {
Connection jdbcConnection = null;
try {
Class driverClass = Class.forName("org.postgresql.Driver");
jdbcConnection = DriverManager.getConnection(dburl, dbuser, dbpwd);
Statement stmt = jdbcConnection.createStatement();
stmt.execute("DROP SCHEMA IF EXISTS " + DBSCHEMA + " CASCADE");
{
File data = new File("test/data/SRSVerification/ModelA.ili");
Config config = initConfig(data.getPath(), DBSCHEMA, data.getPath() + ".log");
config.setFunction(Config.FC_SCHEMAIMPORT);
config.setDbschema(DBSCHEMA);
config.setCreateFk(config.CREATE_FK_YES);
config.setDefaultSrsAuthority("epsg");
config.setDefaultSrsCode("2000");
Ili2db.readSettingsFromDb(config);
try {
Ili2db.run(config, null);
fail();
} catch (Ili2dbException e) {
Assert.assertEquals("epsg/2000 does not exist", e.getMessage());
}
}
} finally {
if (jdbcConnection != null) {
jdbcConnection.close();
}
}
}
use of ch.ehi.ili2db.gui.Config in project ili2db by claeis.
the class BlackBoxTypes23Test method exportXtf.
@Test
public void exportXtf() throws Exception {
Connection jdbcConnection = null;
try {
Class driverClass = Class.forName("org.postgresql.Driver");
jdbcConnection = DriverManager.getConnection(dburl, dbuser, dbpwd);
stmt = jdbcConnection.createStatement();
stmt.execute("DROP SCHEMA IF EXISTS " + DBSCHEMA + " CASCADE");
DbUtility.executeSqlScript(jdbcConnection, new java.io.FileReader("test/data/BlackBoxTypes23/CreateTable.sql"));
DbUtility.executeSqlScript(jdbcConnection, new java.io.FileReader("test/data/BlackBoxTypes23/InsertIntoTable.sql"));
File data = new File("test/data/BlackBoxTypes23/BlackBoxTypes23a-out.xtf");
Config config = initConfig(data.getPath(), DBSCHEMA, data.getPath() + ".log");
config.setModels("BlackBoxTypes23");
config.setFunction(Config.FC_EXPORT);
Ili2db.readSettingsFromDb(config);
Ili2db.run(config, null);
// read objects of db and write objectValue to HashMap
HashMap<String, IomObject> objs = new HashMap<String, IomObject>();
XtfReader reader = new XtfReader(data);
IoxEvent event = null;
do {
event = reader.read();
if (event instanceof StartTransferEvent) {
} else if (event instanceof StartBasketEvent) {
} else if (event instanceof ObjectEvent) {
IomObject iomObj = ((ObjectEvent) event).getIomObject();
if (iomObj.getobjectoid() != null) {
objs.put(iomObj.getobjectoid(), iomObj);
}
} else if (event instanceof EndBasketEvent) {
} else if (event instanceof EndTransferEvent) {
}
} while (!(event instanceof EndTransferEvent));
{
IomObject obj0 = objs.get("o0");
Assert.assertNotNull(obj0);
Assert.assertEquals("BlackBoxTypes23.Topic.ClassA", obj0.getobjecttag());
}
{
IomObject obj1 = objs.get("o1");
Assert.assertNotNull(obj1);
Assert.assertEquals("BlackBoxTypes23.Topic.ClassA", obj1.getobjecttag());
Assert.assertEquals("AAAA", obj1.getattrvalue("binbox"));
}
} finally {
if (jdbcConnection != null) {
jdbcConnection.close();
}
}
}
use of ch.ehi.ili2db.gui.Config in project ili2db by claeis.
the class BlackBoxTypes23Test method importIli.
@Test
public void importIli() throws Exception {
EhiLogger.getInstance().setTraceFilter(false);
Connection jdbcConnection = null;
try {
Class driverClass = Class.forName("org.postgresql.Driver");
jdbcConnection = DriverManager.getConnection(dburl, dbuser, dbpwd);
stmt = jdbcConnection.createStatement();
stmt.execute("DROP SCHEMA IF EXISTS " + DBSCHEMA + " CASCADE");
{
File data = new File("test/data/BlackBoxTypes23/BlackBoxTypes23.ili");
Config config = initConfig(data.getPath(), DBSCHEMA, data.getPath() + ".log");
config.setFunction(Config.FC_SCHEMAIMPORT);
config.setCreateFk(config.CREATE_FK_YES);
config.setTidHandling(Config.TID_HANDLING_PROPERTY);
config.setBasketHandling(config.BASKET_HANDLING_READWRITE);
config.setCatalogueRefTrafo(null);
config.setMultiSurfaceTrafo(null);
config.setMultilingualTrafo(null);
config.setInheritanceTrafo(null);
Ili2db.readSettingsFromDb(config);
Ili2db.run(config, null);
{
String stmtTxt = "SELECT data_type FROM information_schema.columns WHERE table_schema ='blackboxtypes23' AND table_name = 'classa' AND column_name = 'xmlbox'";
Assert.assertTrue(stmt.execute(stmtTxt));
ResultSet rs = stmt.getResultSet();
Assert.assertTrue(rs.next());
Assert.assertEquals("xml", rs.getString("data_type"));
}
{
String stmtTxt = "SELECT data_type FROM information_schema.columns WHERE table_schema ='blackboxtypes23' AND table_name = 'classa' AND column_name = 'binbox'";
Assert.assertTrue(stmt.execute(stmtTxt));
ResultSet rs = stmt.getResultSet();
Assert.assertTrue(rs.next());
Assert.assertEquals("bytea", rs.getString("data_type"));
}
}
} finally {
if (jdbcConnection != null) {
jdbcConnection.close();
}
}
}
use of ch.ehi.ili2db.gui.Config in project ili2db by claeis.
the class BlackBoxTypes23Test method importXtf.
@Test
public void importXtf() throws Exception {
EhiLogger.getInstance().setTraceFilter(false);
Connection jdbcConnection = null;
try {
Class driverClass = Class.forName("org.postgresql.Driver");
jdbcConnection = DriverManager.getConnection(dburl, dbuser, dbpwd);
stmt = jdbcConnection.createStatement();
stmt.execute("DROP SCHEMA IF EXISTS " + DBSCHEMA + " CASCADE");
{
File data = new File("test/data/BlackBoxTypes23/BlackBoxTypes23a.xtf");
Config config = initConfig(data.getPath(), DBSCHEMA, data.getPath() + ".log");
config.setFunction(Config.FC_IMPORT);
config.setCreateFk(config.CREATE_FK_YES);
config.setTidHandling(Config.TID_HANDLING_PROPERTY);
config.setBasketHandling(config.BASKET_HANDLING_READWRITE);
config.setCatalogueRefTrafo(null);
config.setMultiSurfaceTrafo(null);
config.setMultilingualTrafo(null);
config.setInheritanceTrafo(null);
config.setModels("BlackBoxTypes23");
Ili2db.readSettingsFromDb(config);
Ili2db.run(config, null);
{
String stmtTxt = "SELECT data_type FROM information_schema.columns WHERE table_schema ='blackboxtypes23' AND table_name = 'classa' AND column_name = 'xmlbox'";
Assert.assertTrue(stmt.execute(stmtTxt));
ResultSet rs = stmt.getResultSet();
Assert.assertTrue(rs.next());
Assert.assertEquals("xml", rs.getString("data_type"));
}
{
String stmtTxt = "SELECT data_type FROM information_schema.columns WHERE table_schema ='blackboxtypes23' AND table_name = 'classa' AND column_name = 'binbox'";
Assert.assertTrue(stmt.execute(stmtTxt));
ResultSet rs = stmt.getResultSet();
Assert.assertTrue(rs.next());
Assert.assertEquals("bytea", rs.getString("data_type"));
}
}
} finally {
if (jdbcConnection != null) {
jdbcConnection.close();
}
}
}
use of ch.ehi.ili2db.gui.Config in project ili2db by claeis.
the class BlackBoxTypes23GpkgTest method initConfig.
public Config initConfig(String xtfFilename, String logfile) {
Config config = new Config();
new ch.ehi.ili2gpkg.GpkgMain().initConfig(config);
config.setDbfile(gpkgFileName);
config.setDburl("jdbc:sqlite:" + gpkgFileName);
if (logfile != null) {
config.setLogfile(logfile);
}
config.setXtffile(xtfFilename);
if (xtfFilename != null && Ili2db.isItfFilename(xtfFilename)) {
config.setItfTransferfile(true);
}
return config;
}
Aggregations