From 78ee4389c0e46bb4c3fad7a7a64424304a3b8a36 Mon Sep 17 00:00:00 2001 From: Cho HyunJong Date: Sat, 30 May 2015 13:01:38 +0900 Subject: [PATCH] make test code --- .../META-INF/MANIFEST.MF | 7 +- .../core/spaitaldb/MSSQLSpatialDBTest.java | 136 ++++++++++++++++++ .../spaitaldb/OracleSQLSpatialDBTest.java | 131 +++++++++++++++++ .../spaitaldb/PostgreSQLSpatialDBTest.java | 132 +++++++++++++++++ .../META-INF/MANIFEST.MF | 3 + 5 files changed, 408 insertions(+), 1 deletion(-) create mode 100644 com.gaia3d.tadpole.spatial.data.core.test/src/com/gaia3d/tadpole/spatial/data/core/spaitaldb/MSSQLSpatialDBTest.java create mode 100644 com.gaia3d.tadpole.spatial.data.core.test/src/com/gaia3d/tadpole/spatial/data/core/spaitaldb/OracleSQLSpatialDBTest.java create mode 100644 com.gaia3d.tadpole.spatial.data.core.test/src/com/gaia3d/tadpole/spatial/data/core/spaitaldb/PostgreSQLSpatialDBTest.java diff --git a/com.gaia3d.tadpole.spatial.data.core.test/META-INF/MANIFEST.MF b/com.gaia3d.tadpole.spatial.data.core.test/META-INF/MANIFEST.MF index c773015..327415e 100644 --- a/com.gaia3d.tadpole.spatial.data.core.test/META-INF/MANIFEST.MF +++ b/com.gaia3d.tadpole.spatial.data.core.test/META-INF/MANIFEST.MF @@ -6,6 +6,11 @@ Bundle-Version: 1.0.0.qualifier Bundle-Activator: com.gaia3d.tadpole.spatial.data.core.test.Activator Bundle-Vendor: Gaia3D, Inc. Require-Bundle: org.eclipse.core.runtime, - org.eclipse.rap.ui;bundle-version="2.3.1" + org.eclipse.rap.ui;bundle-version="2.3.1", + org.junit;bundle-version="4.12.0", + com.gaia3d.tadpole.spatial.data.core;bundle-version="1.0.0", + com.hangum.tadpole.commons.libs;bundle-version="2.0.0", + com.hangum.tadpole.commons.utils;bundle-version="2.0.0", + com.hangum.tadpole.engine;bundle-version="1.0.0" Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Bundle-ActivationPolicy: lazy diff --git a/com.gaia3d.tadpole.spatial.data.core.test/src/com/gaia3d/tadpole/spatial/data/core/spaitaldb/MSSQLSpatialDBTest.java b/com.gaia3d.tadpole.spatial.data.core.test/src/com/gaia3d/tadpole/spatial/data/core/spaitaldb/MSSQLSpatialDBTest.java new file mode 100644 index 0000000..6b9b5d6 --- /dev/null +++ b/com.gaia3d.tadpole.spatial.data.core.test/src/com/gaia3d/tadpole/spatial/data/core/spaitaldb/MSSQLSpatialDBTest.java @@ -0,0 +1,136 @@ +/******************************************************************************* + * Copyright (c) 2012 - 2015 hangum. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * hangum - initial API and implementation + ******************************************************************************/ +package com.gaia3d.tadpole.spatial.data.core.spaitaldb; + +import static org.junit.Assert.*; + +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.junit.Before; +import org.junit.Test; + +import com.gaia3d.tadpole.spatial.data.core.spaitaldb.dao.RequestSpatialQueryDAO; +import com.gaia3d.tadpole.spatial.data.core.spaitaldb.db.SpatialDB; +import com.hangum.tadpole.engine.define.DBDefine; +import com.hangum.tadpole.engine.query.dao.system.UserDBDAO; + +/** + * MSSQL spatial db test + * + * + * @author hangum + * @version 1.6.1 + * @since 2015. 5. 30. + * + */ +public class MSSQLSpatialDBTest { + SpatialDB spatialDB = null; + + /** + * @throws java.lang.Exception + */ + @Before + public void setUp() throws Exception { + UserDBDAO userDB = new UserDBDAO(); + + final String dbUrl = String.format( + DBDefine.MSSQL_DEFAULT.getDB_URL_INFO(), + "172.16.187.132", "1433", "northwind"); + + + userDB.setDbms_type(DBDefine.MSSQL_DEFAULT.getDBToString()); + userDB.setUrl(dbUrl); + userDB.setDb("northwind"); + userDB.setDisplay_name("junit test"); + userDB.setHost("172.16.187.132"); + userDB.setPort("1433"); + userDB.setUsers("sa"); + userDB.setPasswd("tadpole"); + + userDB.setLocale(""); + + SpatiaDBFactory factory = new SpatiaDBFactory(); + spatialDB = factory.getSpatialDB(userDB); + } + + /** + * Test method for {@link com.gaia3d.tadpole.spatial.data.core.spaitaldb.MSSQLSpatialDB#MSSQLSpatialDB(com.hangum.tadpole.engine.query.dao.system.UserDBDAO)}. + */ + @Test + public void testMSSQLSpatialDB() { + if(spatialDB == null) fail("do not support spatial database"); + + assertTrue(true); + } + +// /** +// * image는 이클립스가 동작해야해서 막아놓습니다. +// * +// * Test method for {@link com.gaia3d.tadpole.spatial.data.core.spaitaldb.MSSQLSpatialDB#isSpatialDBImage()}. +// */ +// @Test +// public void testIsSpatialDBImage() { +// Image img = spatialDB.isSpatialDBImage(); +//// if(img == null) fail("Do not support spatial database"); +// +// assertTrue(true); +// } + + /** + * Test method for {@link com.gaia3d.tadpole.spatial.data.core.spaitaldb.MSSQLSpatialDB#getSpatialTableColumn()}. + */ + @Test + public void testGetSpatialTableColumn() { + Map> mapSpatialTableColumn = spatialDB.getSpatialTableColumn(); + if(mapSpatialTableColumn.isEmpty()) fail("Do not support spaatial database"); + + boolean isRiseError = false; + Set tableColumn = mapSpatialTableColumn.keySet(); + for (String strTable : tableColumn) { + List listSpatialColumn = mapSpatialTableColumn.get(strTable); + + if(listSpatialColumn.isEmpty()) { + isRiseError = true; + fail(strTable + " is not found spatial columns."); + } + } + } + + /** + * Test method for {@link com.gaia3d.tadpole.spatial.data.core.spaitaldb.MSSQLSpatialDB#makeSpatialQuery(com.gaia3d.tadpole.spatial.data.core.spaitaldb.dao.RequestSpatialQueryDAO)}. + */ + @Test + public void testMakeSpatialQuery() { + String strUserQuery = "SELECT fid, name, aliases, num_lanes, centerline FROM dbo.road_segments"; + + try { + RequestSpatialQueryDAO dao = new RequestSpatialQueryDAO(strUserQuery); + dao = spatialDB.makeSpatialQuery(dao); + + // count geo column + List listSpatialColumn = dao.getListRealGisColumnIndex(); + // fully get query + String strFullyQuery = dao.getTadpoleFullyQuery(); + if(strFullyQuery.equals("")) fail("This query not is spatial"); + else { + System.out.println("count of get column is " + listSpatialColumn.size()); + System.out.println("fully get query is \n" + strFullyQuery); + } + } catch(Exception e) { + e.printStackTrace(); + + fail(e.getMessage()); + } + + } +} diff --git a/com.gaia3d.tadpole.spatial.data.core.test/src/com/gaia3d/tadpole/spatial/data/core/spaitaldb/OracleSQLSpatialDBTest.java b/com.gaia3d.tadpole.spatial.data.core.test/src/com/gaia3d/tadpole/spatial/data/core/spaitaldb/OracleSQLSpatialDBTest.java new file mode 100644 index 0000000..c3d3f95 --- /dev/null +++ b/com.gaia3d.tadpole.spatial.data.core.test/src/com/gaia3d/tadpole/spatial/data/core/spaitaldb/OracleSQLSpatialDBTest.java @@ -0,0 +1,131 @@ +/******************************************************************************* + * Copyright (c) 2012 - 2015 hangum. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * hangum - initial API and implementation + ******************************************************************************/ +package com.gaia3d.tadpole.spatial.data.core.spaitaldb; + +import static org.junit.Assert.*; + +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.junit.Before; +import org.junit.Test; + +import com.gaia3d.tadpole.spatial.data.core.spaitaldb.dao.RequestSpatialQueryDAO; +import com.gaia3d.tadpole.spatial.data.core.spaitaldb.db.SpatialDB; +import com.hangum.tadpole.engine.define.DBDefine; +import com.hangum.tadpole.engine.query.dao.system.UserDBDAO; + +/** + * oracle spatial db test + * + * + * @author hangum + * @version 1.6.1 + * @since 2015. 5. 30. + * + */ +public class OracleSQLSpatialDBTest { + SpatialDB spatialDB = null; + + /** + * @throws java.lang.Exception + */ + @Before + public void setUp() throws Exception { + UserDBDAO userDB = new UserDBDAO(); + + final String dbUrl = String.format( + DBDefine.ORACLE_DEFAULT.getDB_URL_INFO(), + "172.16.187.132", "1521", "XE"); + + + userDB.setDbms_type(DBDefine.ORACLE_DEFAULT.getDBToString()); + userDB.setUrl(dbUrl); + userDB.setDb("XE"); + userDB.setDisplay_name("junit test"); + userDB.setHost("172.16.187.132"); + userDB.setPort("1521"); + userDB.setUsers("HR"); + userDB.setPasswd("tadpole"); + + userDB.setLocale(""); + + SpatiaDBFactory factory = new SpatiaDBFactory(); + spatialDB = factory.getSpatialDB(userDB); + } + + /** + * Test method for {@link com.gaia3d.tadpole.spatial.data.core.spaitaldb.OracleSQLSpatialDB#OracleSQLSpatialDB(com.hangum.tadpole.engine.query.dao.system.UserDBDAO)}. + */ + @Test + public void testPostgreSQLSpatialDB() { + if(spatialDB == null) fail("do not support spatial database"); + + assertTrue(true); + } + +// /** +// * image는 이클립스가 동작해야해서 막아놓습니다. +// * +// * Test method for {@link com.gaia3d.tadpole.spatial.data.core.spaitaldb.OracleSQLSpatialDB#isSpatialDBImage()}. +// */ +// @Test +// public void testIsSpatialDBImage() { +// Image img = spatialDB.isSpatialDBImage(); +//// if(img == null) fail("Do not support spatial database"); +// +// assertTrue(true); +// } + + /** + * Test method for {@link com.gaia3d.tadpole.spatial.data.core.spaitaldb.OracleSQLSpatialDB#getSpatialTableColumn()}. + */ + @Test + public void testGetSpatialTableColumn() { + Map> mapSpatialTableColumn = spatialDB.getSpatialTableColumn(); + if(mapSpatialTableColumn.isEmpty()) fail("Do not support spaatial database"); + + boolean isRiseError = false; + Set tableColumn = mapSpatialTableColumn.keySet(); + for (String strTable : tableColumn) { + List listSpatialColumn = mapSpatialTableColumn.get(strTable); + + if(listSpatialColumn.isEmpty()) { + isRiseError = true; + fail(strTable + " is not found spatial columns."); + } + } + } + + /** + * Test method for {@link com.gaia3d.tadpole.spatial.data.core.spaitaldb.OracleSQLSpatialDB#makeSpatialQuery(com.gaia3d.tadpole.spatial.data.core.spaitaldb.dao.RequestSpatialQueryDAO)}. + */ + @Test + public void testMakeSpatialQuery() { + String strUserQuery = "SELECT gid, city, latitude, country, rank, population, longitude, geom FROM world_cities"; + + RequestSpatialQueryDAO dao = new RequestSpatialQueryDAO(strUserQuery); + dao = spatialDB.makeSpatialQuery(dao); + + // count geo column + List listSpatialColumn = dao.getListRealGisColumnIndex(); + // fully get query + String strFullyQuery = dao.getTadpoleFullyQuery(); + if(strFullyQuery.equals("")) fail("This query not is spatial"); + else { + System.out.println("count of get column is " + listSpatialColumn.size()); + System.out.println("fully get query is \n" + strFullyQuery); + } + + } + +} diff --git a/com.gaia3d.tadpole.spatial.data.core.test/src/com/gaia3d/tadpole/spatial/data/core/spaitaldb/PostgreSQLSpatialDBTest.java b/com.gaia3d.tadpole.spatial.data.core.test/src/com/gaia3d/tadpole/spatial/data/core/spaitaldb/PostgreSQLSpatialDBTest.java new file mode 100644 index 0000000..6334c0c --- /dev/null +++ b/com.gaia3d.tadpole.spatial.data.core.test/src/com/gaia3d/tadpole/spatial/data/core/spaitaldb/PostgreSQLSpatialDBTest.java @@ -0,0 +1,132 @@ +/******************************************************************************* + * Copyright (c) 2012 - 2015 hangum. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * hangum - initial API and implementation + ******************************************************************************/ +package com.gaia3d.tadpole.spatial.data.core.spaitaldb; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.junit.Before; +import org.junit.Test; + +import com.gaia3d.tadpole.spatial.data.core.spaitaldb.dao.RequestSpatialQueryDAO; +import com.gaia3d.tadpole.spatial.data.core.spaitaldb.db.SpatialDB; +import com.hangum.tadpole.engine.define.DBDefine; +import com.hangum.tadpole.engine.query.dao.system.UserDBDAO; + +/** + * postgresql spatial db test + * + * + * @author hangum + * @version 1.6.1 + * @since 2015. 5. 30. + * + */ +public class PostgreSQLSpatialDBTest { + SpatialDB spatialDB = null; + + /** + * @throws java.lang.Exception + */ + @Before + public void setUp() throws Exception { + UserDBDAO userDB = new UserDBDAO(); + + final String dbUrl = String.format( + DBDefine.POSTGRE_DEFAULT.getDB_URL_INFO(), + "127.0.0.1", "5432", "tadpole"); + + + userDB.setDbms_type(DBDefine.POSTGRE_DEFAULT.getDBToString()); + userDB.setUrl(dbUrl); + userDB.setDb("tadpole"); + userDB.setDisplay_name("junit test"); + userDB.setHost("127.0.0.1"); + userDB.setPort("5432"); + userDB.setUsers("postgres"); + userDB.setPasswd("tadpole"); + + userDB.setLocale(""); + + SpatiaDBFactory factory = new SpatiaDBFactory(); + spatialDB = factory.getSpatialDB(userDB); + } + + /** + * Test method for {@link com.gaia3d.tadpole.spatial.data.core.spaitaldb.PostgreSQLSpatialDB#PostgreSQLSpatialDB(com.hangum.tadpole.engine.query.dao.system.UserDBDAO)}. + */ + @Test + public void testPostgreSQLSpatialDB() { + if(spatialDB == null) fail("do not support spatial database"); + + assertTrue(true); + } + +// /** +// * image는 이클립스가 동작해야해서 막아놓습니다. +// * +// * Test method for {@link com.gaia3d.tadpole.spatial.data.core.spaitaldb.PostgreSQLSpatialDB#isSpatialDBImage()}. +// */ +// @Test +// public void testIsSpatialDBImage() { +// Image img = spatialDB.isSpatialDBImage(); +//// if(img == null) fail("Do not support spatial database"); +// +// assertTrue(true); +// } + + /** + * Test method for {@link com.gaia3d.tadpole.spatial.data.core.spaitaldb.PostgreSQLSpatialDB#getSpatialTableColumn()}. + */ + @Test + public void testGetSpatialTableColumn() { + Map> mapSpatialTableColumn = spatialDB.getSpatialTableColumn(); + if(mapSpatialTableColumn.isEmpty()) fail("Do not support spaatial database"); + + boolean isRiseError = false; + Set tableColumn = mapSpatialTableColumn.keySet(); + for (String strTable : tableColumn) { + List listSpatialColumn = mapSpatialTableColumn.get(strTable); + + if(listSpatialColumn.isEmpty()) { + isRiseError = true; + fail(strTable + " is not found spatial columns."); + } + } + } + + /** + * Test method for {@link com.gaia3d.tadpole.spatial.data.core.spaitaldb.PostgreSQLSpatialDB#makeSpatialQuery(com.gaia3d.tadpole.spatial.data.core.spaitaldb.dao.RequestSpatialQueryDAO)}. + */ + @Test + public void testMakeSpatialQuery() { + String strUserQuery = "SELECT gid, city, latitude, country, rank, population, longitude, geom FROM world_cities"; + + RequestSpatialQueryDAO dao = new RequestSpatialQueryDAO(strUserQuery); + dao = spatialDB.makeSpatialQuery(dao); + + // count geo column + List listSpatialColumn = dao.getListRealGisColumnIndex(); + // fully get query + String strFullyQuery = dao.getTadpoleFullyQuery(); + if(strFullyQuery.equals("")) fail("This query not is spatial"); + else { + System.out.println("count of get column is " + listSpatialColumn.size()); + System.out.println("fully get query is \n" + strFullyQuery); + } + + } + +} diff --git a/com.gaia3d.tadpole.spatial.data.core/META-INF/MANIFEST.MF b/com.gaia3d.tadpole.spatial.data.core/META-INF/MANIFEST.MF index 43fec6f..7685064 100644 --- a/com.gaia3d.tadpole.spatial.data.core/META-INF/MANIFEST.MF +++ b/com.gaia3d.tadpole.spatial.data.core/META-INF/MANIFEST.MF @@ -25,3 +25,6 @@ Bundle-ClassPath: ., libs/jts/jts2geojson-0.4.0.jar, libs/oracle/sdoapi-11.2.0.jar, libs/oracle/sdoutl-11.2.0.jar +Export-Package: com.gaia3d.tadpole.spatial.data.core.spaitaldb, + com.gaia3d.tadpole.spatial.data.core.spaitaldb.dao, + com.gaia3d.tadpole.spatial.data.core.spaitaldb.db