Merge pull request #1444 from OpenRefine/disable-database-tests-locally
Various fixes on the database tests
This commit is contained in:
commit
87ee584c3e
@ -20,6 +20,7 @@ before_install:
|
|||||||
- mysql -u root test_db < extensions/database/test/conf/travis-mysql.sql
|
- mysql -u root test_db < extensions/database/test/conf/travis-mysql.sql
|
||||||
- psql -c 'CREATE DATABASE test_db;' -U postgres
|
- psql -c 'CREATE DATABASE test_db;' -U postgres
|
||||||
- psql -U postgres test_db < extensions/database/test/conf/travis-pgsql.sql
|
- psql -U postgres test_db < extensions/database/test/conf/travis-pgsql.sql
|
||||||
|
- cp extensions/database/test/conf/travis_tests.xml extensions/database/test/conf/tests.xml
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- ./refine server_test
|
- ./refine server_test
|
||||||
|
36
appveyor.yml
36
appveyor.yml
@ -1,10 +1,15 @@
|
|||||||
version: 1.0.{build}
|
version: 1.0.{build}
|
||||||
|
|
||||||
|
services:
|
||||||
|
- mysql
|
||||||
|
- postgresql96
|
||||||
|
|
||||||
init:
|
init:
|
||||||
- cmd: java -version 2>&1 | find "version"
|
- cmd: java -version 2>&1 | find "version"
|
||||||
|
|
||||||
clone_script:
|
clone_depth: 5
|
||||||
- cmd: git clone --recursive https://github.com/OpenRefine/OpenRefine
|
skip_branch_with_pr: true
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
ANT_HOME: C:\apache-ant-1.10.1
|
ANT_HOME: C:\apache-ant-1.10.1
|
||||||
JAVA_HOME: C:\Program Files (x86)\Java\jdk1.8.0
|
JAVA_HOME: C:\Program Files (x86)\Java\jdk1.8.0
|
||||||
@ -20,17 +25,24 @@ cache:
|
|||||||
- apache-ant-1.10.1-bin.zip
|
- apache-ant-1.10.1-bin.zip
|
||||||
build: off
|
build: off
|
||||||
|
|
||||||
# scripts to run before build
|
# scripts to run before test
|
||||||
before_build:
|
before_test:
|
||||||
- cmd: echo Running scripts before build...
|
- cmd: echo Running scripts before build...
|
||||||
|
- cmd: |-
|
||||||
|
PATH=C:\Program Files\PostgreSQL\9.6\bin\;C:\Program Files\MySQL\MySQL Server 5.7\bin\;%PATH%
|
||||||
|
SET MYSQL_PWD=Password12!
|
||||||
|
mysql -u root --password=Password12! -e "create database test_db;"
|
||||||
|
mysql -u root test_db --password=Password12! < extensions\database\test\conf\travis-mysql.sql
|
||||||
|
echo "localhost:*:test_db:postgres:Password12!" > C:\Program Files\PostgreSQL\9.6\pgpass.conf
|
||||||
|
echo "localhost:*:test_db:postgres:Password12!" > pgpass.conf
|
||||||
|
echo "localhost:*:test_db:postgres:Password12!" > %userprofile%\pgpass.conf
|
||||||
|
SET PGPASSFILE=C:\Program Files\PostgreSQL\9.6\pgpass.conf
|
||||||
|
SET PGPASSWORD=Password12!
|
||||||
|
SET PGUSER=postgres
|
||||||
|
createdb test_db
|
||||||
|
psql -U postgres test_db < extensions\database\test\conf\travis-pgsql.sql
|
||||||
|
|
||||||
build_script:
|
copy extensions\database\test\conf\appveyor_tests.xml extensions\database\test\conf\tests.xml
|
||||||
# - cmd: >-
|
|
||||||
# echo Running refine build...
|
|
||||||
#
|
|
||||||
# cd OpenRefine
|
|
||||||
#
|
|
||||||
# refine build
|
|
||||||
|
|
||||||
test_script:
|
test_script:
|
||||||
- cmd: echo Running test_script...
|
- cmd: echo Running test_script...
|
||||||
@ -39,8 +51,6 @@ test_script:
|
|||||||
|
|
||||||
path
|
path
|
||||||
|
|
||||||
cd OpenRefine
|
|
||||||
|
|
||||||
refine server_test
|
refine server_test
|
||||||
|
|
||||||
refine extensions_test
|
refine extensions_test
|
||||||
|
@ -1,194 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
|
|
||||||
<!--+
|
|
||||||
|
|
|
||||||
| OpenRefine Database Extension Build File
|
|
||||||
|
|
|
||||||
+-->
|
|
||||||
|
|
||||||
<project name="refine-database-extension" default="build" basedir="." xmlns:jacoco="antlib:org.jacoco.ant">
|
|
||||||
|
|
||||||
<property environment="env"/>
|
|
||||||
|
|
||||||
<condition property="version" value="trunk">
|
|
||||||
<not><isset property="version"/></not>
|
|
||||||
</condition>
|
|
||||||
|
|
||||||
<condition property="revision" value="rXXXX">
|
|
||||||
<not><isset property="revision"/></not>
|
|
||||||
</condition>
|
|
||||||
|
|
||||||
<condition property="full_version" value="0.0.0.0">
|
|
||||||
<not><isset property="full_version"/></not>
|
|
||||||
</condition>
|
|
||||||
|
|
||||||
<condition property="dist.dir" value="dist">
|
|
||||||
<not><isset property="dist.dir"/></not>
|
|
||||||
</condition>
|
|
||||||
|
|
||||||
<property name="fullname" value="${name}-${version}-${revision}" />
|
|
||||||
<property name="java_version" value="1.8"/>
|
|
||||||
|
|
||||||
<property name="refine.dir" value="${basedir}/../../main" />
|
|
||||||
<property name="refine.webinf.dir" value="${refine.dir}/webapp/WEB-INF" />
|
|
||||||
<property name="refine.modinf.dir" value="${refine.dir}/webapp/modules/core/MOD-INF" />
|
|
||||||
<property name="refine.classes.dir" value="${refine.webinf.dir}/classes" />
|
|
||||||
<property name="refine.lib.dir" value="${refine.webinf.dir}/lib" />
|
|
||||||
|
|
||||||
<property name="refine.tests.lib.dir" value="${refine.dir}/tests/server/lib" />
|
|
||||||
|
|
||||||
<property name="src.dir" value="${basedir}/src" />
|
|
||||||
<property name="module.dir" value="${basedir}/module" />
|
|
||||||
<property name="modinf.dir" value="${module.dir}/MOD-INF" />
|
|
||||||
<property name="lib.dir" value="${modinf.dir}/lib" />
|
|
||||||
<property name="classes.dir" value="${modinf.dir}/classes" />
|
|
||||||
|
|
||||||
<property name="test.dir" value="${basedir}/test" />
|
|
||||||
<property name="test.src.dir" value="${test.dir}"/>
|
|
||||||
|
|
||||||
<property name="test.out.dir" value="${basedir}/test-out" />
|
|
||||||
<property name="test.build.dir" value="${test.out.dir}/build" />
|
|
||||||
|
|
||||||
<property name="test.classes.dir" value="${test.out.dir}/classes" />
|
|
||||||
<property name="test.report.dir" value="${test.out.dir}/report"/>
|
|
||||||
<property name="test.report.html.dir" value="${test.report.dir}/html"/>
|
|
||||||
<property name="test.report.xml.path" value="${test.report.dir}/jacoco.xml"/>
|
|
||||||
|
|
||||||
<path id="class.path">
|
|
||||||
<fileset dir="${lib.dir}">
|
|
||||||
<include name="**/*.jar" />
|
|
||||||
</fileset>
|
|
||||||
<fileset dir="${refine.lib.dir}">
|
|
||||||
<include name="**/*.jar" />
|
|
||||||
</fileset>
|
|
||||||
<fileset dir="${server.lib.dir}">
|
|
||||||
<include name="**/*.jar" />
|
|
||||||
</fileset>
|
|
||||||
<pathelement path="${refine.classes.dir}"/>
|
|
||||||
<pathelement path="${classes.dir}"/>
|
|
||||||
</path>
|
|
||||||
|
|
||||||
<path id="extension.tests.class.path">
|
|
||||||
<path refid="class.path"/>
|
|
||||||
<pathelement location="${test.classes.dir}"/>
|
|
||||||
<pathelement location="${refine.tests.lib.dir}/testng-6.8.jar"/>
|
|
||||||
<fileset dir="${refine.tests.lib.dir}">
|
|
||||||
<include name="**/*.jar" />
|
|
||||||
</fileset>
|
|
||||||
</path>
|
|
||||||
|
|
||||||
<taskdef resource="testngtasks" classpath="${refine.tests.lib.dir}/testng-6.8.jar"/>
|
|
||||||
<taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
|
|
||||||
<classpath path="${refine.tests.lib.dir}/jacocoant.jar"/>
|
|
||||||
</taskdef>
|
|
||||||
|
|
||||||
<target name="build_java">
|
|
||||||
<mkdir dir="${classes.dir}" />
|
|
||||||
<javac source="${java_version}" target="${java_version}" encoding="utf-8" destdir="${classes.dir}" debug="true" includeAntRuntime="no">
|
|
||||||
<src path="${src.dir}"/>
|
|
||||||
<classpath refid="class.path" />
|
|
||||||
</javac>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="build" depends="build_java"/>
|
|
||||||
|
|
||||||
<target name="build_tests" depends="clean, build">
|
|
||||||
<mkdir dir="${test.classes.dir}" />
|
|
||||||
<javac source="${java_version}" target="${java_version}" encoding="utf-8" srcdir="${test.src.dir}" destdir="${test.classes.dir}" debug="true" includeAntRuntime="no">
|
|
||||||
<classpath refid="extension.tests.class.path" />
|
|
||||||
</javac>
|
|
||||||
<copy file="${test.src.dir}/log4j-test.properties" tofile="${test.classes.dir}/log4j-test.properties"/>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<mkdir dir="${test.build.dir}" />
|
|
||||||
|
|
||||||
<target name="test" depends="build_tests">
|
|
||||||
<jacoco:coverage destfile="${test.report.dir}/jacoco.exec">
|
|
||||||
<testng verbose="2" haltOnFailure="true" workingdir="${test.build.dir}"
|
|
||||||
listener="org.testng.reporters.DotTestListener" excludedgroups="broken"
|
|
||||||
classpathref="extension.tests.class.path">
|
|
||||||
<xmlfileset file="${test.src.dir}/conf/int_tests.xml"/>
|
|
||||||
</testng>
|
|
||||||
</jacoco:coverage>
|
|
||||||
<jacoco:report>
|
|
||||||
<executiondata>
|
|
||||||
<file file="${test.report.dir}/jacoco.exec"/>
|
|
||||||
</executiondata>
|
|
||||||
|
|
||||||
<structure name="Database extension">
|
|
||||||
<classfiles>
|
|
||||||
<fileset dir="${classes.dir}"/>
|
|
||||||
</classfiles>
|
|
||||||
<sourcefiles encoding="UTF-8">
|
|
||||||
<fileset dir="${src.dir}"/>
|
|
||||||
</sourcefiles>
|
|
||||||
</structure>
|
|
||||||
<html destdir="${test.report.html.dir}"/>
|
|
||||||
<xml destfile="${test.report.xml.path}"/>
|
|
||||||
</jacoco:report>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="unit_test" depends="build_tests">
|
|
||||||
<jacoco:coverage destfile="${test.report.dir}/jacoco.exec">
|
|
||||||
<testng verbose="2" haltOnFailure="true" workingdir="${test.build.dir}"
|
|
||||||
listener="org.testng.reporters.DotTestListener" excludedgroups="broken"
|
|
||||||
classpathref="extension.tests.class.path">
|
|
||||||
<xmlfileset file="${test.src.dir}/conf/unit_tests.xml"/>
|
|
||||||
</testng>
|
|
||||||
</jacoco:coverage>
|
|
||||||
<jacoco:report>
|
|
||||||
<executiondata>
|
|
||||||
<file file="${test.report.dir}/jacoco.exec"/>
|
|
||||||
</executiondata>
|
|
||||||
|
|
||||||
<structure name="Database extension">
|
|
||||||
<classfiles>
|
|
||||||
<fileset dir="${classes.dir}"/>
|
|
||||||
</classfiles>
|
|
||||||
<sourcefiles encoding="UTF-8">
|
|
||||||
<fileset dir="${src.dir}"/>
|
|
||||||
</sourcefiles>
|
|
||||||
</structure>
|
|
||||||
<html destdir="${test.report.html.dir}"/>
|
|
||||||
<xml destfile="${test.report.xml.path}"/>
|
|
||||||
</jacoco:report>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
|
|
||||||
<target name="dist" depends="build">
|
|
||||||
<mkdir dir="${ext.dir}"/>
|
|
||||||
|
|
||||||
<copy todir="${ext.dir}/module">
|
|
||||||
<fileset dir="module">
|
|
||||||
<include name="**/*"/>
|
|
||||||
<exclude name="**/lib-src/*"/>
|
|
||||||
<exclude name="**/src/*"/>
|
|
||||||
</fileset>
|
|
||||||
</copy>
|
|
||||||
|
|
||||||
<copy todir="${ext.dir}/licenses">
|
|
||||||
<fileset dir="${basedir}/licenses">
|
|
||||||
<include name="**"/>
|
|
||||||
</fileset>
|
|
||||||
</copy>
|
|
||||||
<copy file="${basedir}/LICENSE.txt" tofile="${ext.dir}/LICENSE.txt"/>
|
|
||||||
<copy file="${basedir}/README.txt" tofile="${ext.dir}/README.txt"/>
|
|
||||||
|
|
||||||
<zip destfile="${dist.dir}/openrefine-${fullname}.zip">
|
|
||||||
<zipfileset dir="${ext.dir}/..">
|
|
||||||
<include name="**/**"/>
|
|
||||||
</zipfileset>
|
|
||||||
</zip>
|
|
||||||
|
|
||||||
<delete dir="${ext.dir}"/>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="clean">
|
|
||||||
<delete dir="${classes.dir}" />
|
|
||||||
<delete dir="${test.out.dir}" />
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="distclean">
|
|
||||||
<delete dir="${dist.dir}" />
|
|
||||||
</target>
|
|
||||||
</project>
|
|
@ -104,9 +104,9 @@
|
|||||||
<target name="test" depends="build_tests">
|
<target name="test" depends="build_tests">
|
||||||
<jacoco:coverage destfile="${test.report.dir}/jacoco.exec">
|
<jacoco:coverage destfile="${test.report.dir}/jacoco.exec">
|
||||||
<testng verbose="2" haltOnFailure="true" workingdir="${test.build.dir}"
|
<testng verbose="2" haltOnFailure="true" workingdir="${test.build.dir}"
|
||||||
listener="org.testng.reporters.DotTestListener" excludedgroups="broken"
|
listener="org.testng.reporters.DotTestListener"
|
||||||
classpathref="extension.tests.class.path">
|
classpathref="extension.tests.class.path">
|
||||||
<xmlfileset file="${test.src.dir}/conf/int_tests.xml"/>
|
<xmlfileset file="${test.src.dir}/conf/tests.xml"/>
|
||||||
</testng>
|
</testng>
|
||||||
</jacoco:coverage>
|
</jacoco:coverage>
|
||||||
<jacoco:report>
|
<jacoco:report>
|
||||||
@ -126,34 +126,6 @@
|
|||||||
<xml destfile="${test.report.xml.path}"/>
|
<xml destfile="${test.report.xml.path}"/>
|
||||||
</jacoco:report>
|
</jacoco:report>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<target name="unit_test" depends="build_tests">
|
|
||||||
<jacoco:coverage destfile="${test.report.dir}/jacoco.exec">
|
|
||||||
<testng verbose="2" haltOnFailure="true" workingdir="${test.build.dir}"
|
|
||||||
listener="org.testng.reporters.DotTestListener" excludedgroups="broken"
|
|
||||||
classpathref="extension.tests.class.path">
|
|
||||||
<xmlfileset file="${test.src.dir}/conf/unit_tests.xml"/>
|
|
||||||
</testng>
|
|
||||||
</jacoco:coverage>
|
|
||||||
<jacoco:report>
|
|
||||||
<executiondata>
|
|
||||||
<file file="${test.report.dir}/jacoco.exec"/>
|
|
||||||
</executiondata>
|
|
||||||
|
|
||||||
<structure name="Database extension">
|
|
||||||
<classfiles>
|
|
||||||
<fileset dir="${classes.dir}"/>
|
|
||||||
</classfiles>
|
|
||||||
<sourcefiles encoding="UTF-8">
|
|
||||||
<fileset dir="${src.dir}"/>
|
|
||||||
</sourcefiles>
|
|
||||||
</structure>
|
|
||||||
<html destdir="${test.report.html.dir}"/>
|
|
||||||
<xml destfile="${test.report.xml.path}"/>
|
|
||||||
</jacoco:report>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
|
|
||||||
<target name="dist" depends="build">
|
<target name="dist" depends="build">
|
||||||
<mkdir dir="${ext.dir}"/>
|
<mkdir dir="${ext.dir}"/>
|
||||||
|
|
||||||
|
@ -50,8 +50,11 @@ public class DBExtensionTestUtils {
|
|||||||
* Create Test Table with one row of Data
|
* Create Test Table with one row of Data
|
||||||
* @param dbConfig DatabaseConfiguration to test
|
* @param dbConfig DatabaseConfiguration to test
|
||||||
* @param tableName
|
* @param tableName
|
||||||
|
* @throws DatabaseServiceException
|
||||||
|
* @throws SQLException
|
||||||
*/
|
*/
|
||||||
public static void initTestData(DatabaseConfiguration dbConfig, String tableName) {
|
public static void initTestData(DatabaseConfiguration dbConfig, String tableName)
|
||||||
|
throws DatabaseServiceException, SQLException {
|
||||||
|
|
||||||
Statement stmt = null;
|
Statement stmt = null;
|
||||||
Connection conn = null;
|
Connection conn = null;
|
||||||
@ -87,16 +90,11 @@ public class DBExtensionTestUtils {
|
|||||||
|
|
||||||
logger.info("Database Test Init Data Created!!!");
|
logger.info("Database Test Init Data Created!!!");
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
if(stmt != null) {
|
if(stmt != null) {
|
||||||
try {
|
try {
|
||||||
stmt.close();
|
stmt.close();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -104,7 +102,6 @@ public class DBExtensionTestUtils {
|
|||||||
try {
|
try {
|
||||||
conn.close();
|
conn.close();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -113,7 +110,8 @@ public class DBExtensionTestUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void initTestData(DatabaseConfiguration dbConfig) {
|
public static void initTestData(DatabaseConfiguration dbConfig)
|
||||||
|
throws DatabaseServiceException, SQLException {
|
||||||
|
|
||||||
Statement stmt = null;
|
Statement stmt = null;
|
||||||
Connection conn = null;
|
Connection conn = null;
|
||||||
@ -149,10 +147,6 @@ public class DBExtensionTestUtils {
|
|||||||
|
|
||||||
logger.info("Database Test Init Data Created!!!");
|
logger.info("Database Test Init Data Created!!!");
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
if(stmt != null) {
|
if(stmt != null) {
|
||||||
try {
|
try {
|
||||||
@ -179,8 +173,11 @@ public class DBExtensionTestUtils {
|
|||||||
* Table name: test_data
|
* Table name: test_data
|
||||||
* @param sampleSize
|
* @param sampleSize
|
||||||
* @param batchSize
|
* @param batchSize
|
||||||
|
* @throws DatabaseServiceException
|
||||||
|
* @throws SQLException
|
||||||
*/
|
*/
|
||||||
public void generateMySQLTestData(int sampleSize, int batchSize) {
|
public void generateMySQLTestData(int sampleSize, int batchSize)
|
||||||
|
throws DatabaseServiceException, SQLException {
|
||||||
mncMap = new HashMap<Integer, Integer>();
|
mncMap = new HashMap<Integer, Integer>();
|
||||||
mccMap = new HashMap<Integer, Integer>();
|
mccMap = new HashMap<Integer, Integer>();
|
||||||
mccMap.put(0, 302);
|
mccMap.put(0, 302);
|
||||||
@ -208,9 +205,7 @@ public class DBExtensionTestUtils {
|
|||||||
+ "id, ue_id, start_time, end_date, bytes_upload, bytes_download, cell_id, mcc, mnc, lac, imei)"
|
+ "id, ue_id, start_time, end_date, bytes_upload, bytes_download, cell_id, mcc, mnc, lac, imei)"
|
||||||
+ " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);";
|
+ " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);";
|
||||||
|
|
||||||
Connection conn;
|
Connection conn = DatabaseService.get(MYSQL_DB_NAME).getConnection(dc);
|
||||||
try {
|
|
||||||
conn = DatabaseService.get(MYSQL_DB_NAME).getConnection(dc);
|
|
||||||
|
|
||||||
Statement truncateStmt = conn.createStatement();
|
Statement truncateStmt = conn.createStatement();
|
||||||
int result = truncateStmt.executeUpdate(truncateTableSQL);
|
int result = truncateStmt.executeUpdate(truncateTableSQL);
|
||||||
@ -250,23 +245,16 @@ public class DBExtensionTestUtils {
|
|||||||
System.out.println("Final Batch Executed "+(counter++)+" executed successfully");
|
System.out.println("Final Batch Executed "+(counter++)+" executed successfully");
|
||||||
conn.commit();
|
conn.commit();
|
||||||
conn.close();
|
conn.close();
|
||||||
|
|
||||||
} catch (DatabaseServiceException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (SQLException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param sampleSize
|
* @param sampleSize
|
||||||
* @param batchSize
|
* @param batchSize
|
||||||
|
* @throws DatabaseServiceException
|
||||||
|
* @throws SQLException
|
||||||
*/
|
*/
|
||||||
public void generatePgSQLTestData(int sampleSize, int batchSize) {
|
public void generatePgSQLTestData(int sampleSize, int batchSize) throws DatabaseServiceException, SQLException {
|
||||||
mncMap = new HashMap<Integer, Integer>();
|
mncMap = new HashMap<Integer, Integer>();
|
||||||
mccMap = new HashMap<Integer, Integer>();
|
mccMap = new HashMap<Integer, Integer>();
|
||||||
mccMap.put(0, 302);
|
mccMap.put(0, 302);
|
||||||
@ -294,9 +282,7 @@ public class DBExtensionTestUtils {
|
|||||||
+ "id, ue_id, start_time, end_date, bytes_upload, bytes_download, cell_id, mcc, mnc, lac, imei)"
|
+ "id, ue_id, start_time, end_date, bytes_upload, bytes_download, cell_id, mcc, mnc, lac, imei)"
|
||||||
+ " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);";
|
+ " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);";
|
||||||
|
|
||||||
Connection conn;
|
Connection conn = DatabaseService.get(PGSQL_DB_NAME).getConnection(dc);
|
||||||
try {
|
|
||||||
conn = DatabaseService.get(PGSQL_DB_NAME).getConnection(dc);
|
|
||||||
|
|
||||||
Statement truncateStmt = conn.createStatement();
|
Statement truncateStmt = conn.createStatement();
|
||||||
int result = truncateStmt.executeUpdate(truncateTableSQL);
|
int result = truncateStmt.executeUpdate(truncateTableSQL);
|
||||||
@ -337,14 +323,6 @@ public class DBExtensionTestUtils {
|
|||||||
conn.commit();
|
conn.commit();
|
||||||
conn.close();
|
conn.close();
|
||||||
|
|
||||||
} catch (DatabaseServiceException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (SQLException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getNextIMEI() {
|
private String getNextIMEI() {
|
||||||
@ -381,7 +359,7 @@ public class DBExtensionTestUtils {
|
|||||||
return "" + n;
|
return "" + n;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) throws DatabaseServiceException, SQLException {
|
||||||
DBExtensionTestUtils testUtil = new DBExtensionTestUtils();
|
DBExtensionTestUtils testUtil = new DBExtensionTestUtils();
|
||||||
testUtil.generatePgSQLTestData(SAMPLE_SIZE, BATCH_SIZE);
|
testUtil.generatePgSQLTestData(SAMPLE_SIZE, BATCH_SIZE);
|
||||||
// testUtil.generateMySQLTestData();
|
// testUtil.generateMySQLTestData();
|
||||||
@ -404,7 +382,7 @@ public class DBExtensionTestUtils {
|
|||||||
//System.out.println("Drop Table Result::" + dropResult);
|
//System.out.println("Drop Table Result::" + dropResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info("Database Test Cleanup Done!!!");
|
logger.info("Database Test Cleanup Done");
|
||||||
|
|
||||||
} catch (DatabaseServiceException e) {
|
} catch (DatabaseServiceException e) {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
|
@ -33,6 +33,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
|
|
||||||
package com.google.refine.extension.database;
|
package com.google.refine.extension.database;
|
||||||
|
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
public class DBExtensionTests {
|
public class DBExtensionTests {
|
||||||
@ -61,13 +63,8 @@ public class DBExtensionTests {
|
|||||||
|
|
||||||
protected final String DEFAULT_TEST_TABLE = "test_data";
|
protected final String DEFAULT_TEST_TABLE = "test_data";
|
||||||
|
|
||||||
|
protected Properties properties;
|
||||||
|
|
||||||
protected Logger logger;
|
protected Logger logger;
|
||||||
|
|
||||||
// @BeforeSuite
|
|
||||||
// public void init() {
|
|
||||||
// System.out.println("Log4j init...");
|
|
||||||
// System.setProperty("log4j.configuration", "log4j-test.properties");
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import java.io.IOException;
|
|||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
|
|
||||||
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
@ -35,7 +36,7 @@ import com.google.refine.model.Project;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Test(groups = { "requiresMySQL" })
|
||||||
public class DatabaseImportControllerTest extends DBExtensionTests{
|
public class DatabaseImportControllerTest extends DBExtensionTests{
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
@ -118,10 +119,9 @@ public class DatabaseImportControllerTest extends DBExtensionTests{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDoPostInvalidSubCommand() {
|
public void testDoPostInvalidSubCommand() throws IOException, ServletException, JSONException {
|
||||||
StringWriter sw = new StringWriter();
|
StringWriter sw = new StringWriter();
|
||||||
PrintWriter pw = new PrintWriter(sw);
|
PrintWriter pw = new PrintWriter(sw);
|
||||||
try {
|
|
||||||
when(request.getQueryString()).thenReturn(
|
when(request.getQueryString()).thenReturn(
|
||||||
"http://127.0.0.1:3333/command/core/importing-controller?controller=database/database-import-controller&subCommand=invalid-sub-command");
|
"http://127.0.0.1:3333/command/core/importing-controller?controller=database/database-import-controller&subCommand=invalid-sub-command");
|
||||||
|
|
||||||
@ -138,23 +138,16 @@ public class DatabaseImportControllerTest extends DBExtensionTests{
|
|||||||
Assert.assertNotNull(message);
|
Assert.assertNotNull(message);
|
||||||
Assert.assertEquals(code, "error");
|
Assert.assertEquals(code, "error");
|
||||||
Assert.assertEquals(message, "No such sub command");
|
Assert.assertEquals(message, "No such sub command");
|
||||||
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDoPostInitializeParser() {
|
public void testDoPostInitializeParser() throws ServletException, IOException, JSONException {
|
||||||
|
|
||||||
StringWriter sw = new StringWriter();
|
StringWriter sw = new StringWriter();
|
||||||
PrintWriter pw = new PrintWriter(sw);
|
PrintWriter pw = new PrintWriter(sw);
|
||||||
|
|
||||||
try {
|
|
||||||
when(request.getQueryString()).thenReturn(
|
when(request.getQueryString()).thenReturn(
|
||||||
"http://127.0.0.1:3333/command/core/importing-controller?controller=database/database-import-controller&subCommand=initialize-parser-ui");
|
"http://127.0.0.1:3333/command/core/importing-controller?controller=database/database-import-controller&subCommand=initialize-parser-ui");
|
||||||
when(response.getWriter()).thenReturn(pw);
|
when(response.getWriter()).thenReturn(pw);
|
||||||
@ -167,21 +160,14 @@ public class DatabaseImportControllerTest extends DBExtensionTests{
|
|||||||
String status = json.getString("status");
|
String status = json.getString("status");
|
||||||
//System.out.println("json::" + json);
|
//System.out.println("json::" + json);
|
||||||
Assert.assertEquals(status, "ok");
|
Assert.assertEquals(status, "ok");
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDoPostParsePreview() {
|
public void testDoPostParsePreview() throws IOException, ServletException, JSONException {
|
||||||
|
|
||||||
StringWriter sw = new StringWriter();
|
StringWriter sw = new StringWriter();
|
||||||
PrintWriter pw = new PrintWriter(sw);
|
PrintWriter pw = new PrintWriter(sw);
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
long jobId = job.id;
|
long jobId = job.id;
|
||||||
|
|
||||||
when(request.getQueryString()).thenReturn(
|
when(request.getQueryString()).thenReturn(
|
||||||
@ -207,21 +193,14 @@ public class DatabaseImportControllerTest extends DBExtensionTests{
|
|||||||
String status = json.getString("status");
|
String status = json.getString("status");
|
||||||
//System.out.println("json::" + json);
|
//System.out.println("json::" + json);
|
||||||
Assert.assertEquals(status, "ok");
|
Assert.assertEquals(status, "ok");
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDoPostCreateProject() {
|
public void testDoPostCreateProject() throws IOException, ServletException, JSONException {
|
||||||
|
|
||||||
StringWriter sw = new StringWriter();
|
StringWriter sw = new StringWriter();
|
||||||
PrintWriter pw = new PrintWriter(sw);
|
PrintWriter pw = new PrintWriter(sw);
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
long jobId = job.id;
|
long jobId = job.id;
|
||||||
|
|
||||||
when(request.getQueryString()).thenReturn(
|
when(request.getQueryString()).thenReturn(
|
||||||
@ -248,11 +227,6 @@ public class DatabaseImportControllerTest extends DBExtensionTests{
|
|||||||
String status = json.getString("status");
|
String status = json.getString("status");
|
||||||
//System.out.println("json::" + json);
|
//System.out.println("json::" + json);
|
||||||
Assert.assertEquals(status, "ok");
|
Assert.assertEquals(status, "ok");
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@BeforeTest
|
@BeforeTest
|
||||||
|
@ -62,16 +62,14 @@ public class DatabaseServiceTest extends DBExtensionTests{
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test(groups = {"requiresPgSQL"})
|
||||||
@Test
|
|
||||||
public void testGetPgSQLDBService() {
|
public void testGetPgSQLDBService() {
|
||||||
|
|
||||||
DatabaseService dbService = DatabaseService.get(PgSQLDatabaseService.DB_NAME);
|
DatabaseService dbService = DatabaseService.get(PgSQLDatabaseService.DB_NAME);
|
||||||
Assert.assertNotNull(dbService);
|
Assert.assertNotNull(dbService);
|
||||||
Assert.assertEquals(dbService.getClass(), PgSQLDatabaseService.class);
|
Assert.assertEquals(dbService.getClass(), PgSQLDatabaseService.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(groups = {"requiresMySQL"})
|
||||||
public void testGetMySQLDBService() {
|
public void testGetMySQLDBService() {
|
||||||
|
|
||||||
DatabaseService dbService = DatabaseService.get(MySQLDatabaseService.DB_NAME);
|
DatabaseService dbService = DatabaseService.get(MySQLDatabaseService.DB_NAME);
|
||||||
@ -79,7 +77,7 @@ public class DatabaseServiceTest extends DBExtensionTests{
|
|||||||
Assert.assertEquals(dbService.getClass(), MySQLDatabaseService.class);
|
Assert.assertEquals(dbService.getClass(), MySQLDatabaseService.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(groups = {"requiresMariaDB"})
|
||||||
public void testGetMariaDBSQLDBService() {
|
public void testGetMariaDBSQLDBService() {
|
||||||
|
|
||||||
DatabaseService dbService = DatabaseService.get(MariaDBDatabaseService.DB_NAME);
|
DatabaseService dbService = DatabaseService.get(MariaDBDatabaseService.DB_NAME);
|
||||||
@ -87,64 +85,34 @@ public class DatabaseServiceTest extends DBExtensionTests{
|
|||||||
Assert.assertEquals(dbService.getClass(), MariaDBDatabaseService.class);
|
Assert.assertEquals(dbService.getClass(), MariaDBDatabaseService.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(groups = {"requiresMySQL"})
|
||||||
public void testGetConnection() {
|
public void testGetConnection() throws DatabaseServiceException {
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
DatabaseService dbService = DatabaseService.get(testDbConfig.getDatabaseType());
|
DatabaseService dbService = DatabaseService.get(testDbConfig.getDatabaseType());
|
||||||
Connection conn = dbService.getConnection(testDbConfig);
|
Connection conn = dbService.getConnection(testDbConfig);
|
||||||
Assert.assertNotNull(conn);
|
Assert.assertNotNull(conn);
|
||||||
|
|
||||||
} catch (DatabaseServiceException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(groups = {"requiresMySQL"})
|
||||||
public void testTestConnection() {
|
public void testTestConnection() throws DatabaseServiceException {
|
||||||
|
|
||||||
try {
|
|
||||||
DatabaseService dbService = DatabaseService.get(testDbConfig.getDatabaseType());
|
DatabaseService dbService = DatabaseService.get(testDbConfig.getDatabaseType());
|
||||||
boolean result = dbService.testConnection(testDbConfig);
|
boolean result = dbService.testConnection(testDbConfig);
|
||||||
Assert.assertEquals(result, true);
|
Assert.assertEquals(result, true);
|
||||||
|
|
||||||
} catch (DatabaseServiceException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
@Test(groups = {"requiresMySQL"})
|
||||||
|
public void testConnect() throws DatabaseServiceException {
|
||||||
@Test
|
|
||||||
public void testConnect() {
|
|
||||||
|
|
||||||
try {
|
|
||||||
DatabaseService dbService = DatabaseService.get(testDbConfig.getDatabaseType());
|
DatabaseService dbService = DatabaseService.get(testDbConfig.getDatabaseType());
|
||||||
DatabaseInfo databaseInfo = dbService.connect(testDbConfig);
|
DatabaseInfo databaseInfo = dbService.connect(testDbConfig);
|
||||||
Assert.assertNotNull(databaseInfo);
|
Assert.assertNotNull(databaseInfo);
|
||||||
|
|
||||||
} catch (DatabaseServiceException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
@Test(groups = {"requiresMySQL"})
|
||||||
|
public void testExecuteQuery() throws DatabaseServiceException {
|
||||||
@Test
|
|
||||||
public void testExecuteQuery() {
|
|
||||||
|
|
||||||
try {
|
|
||||||
DatabaseService dbService = DatabaseService.get(testDbConfig.getDatabaseType());
|
DatabaseService dbService = DatabaseService.get(testDbConfig.getDatabaseType());
|
||||||
DatabaseInfo databaseInfo = dbService.testQuery(testDbConfig,
|
DatabaseInfo databaseInfo = dbService.testQuery(testDbConfig,
|
||||||
"SELECT * FROM " + testTable);
|
"SELECT * FROM " + testTable);
|
||||||
|
|
||||||
Assert.assertNotNull(databaseInfo);
|
Assert.assertNotNull(databaseInfo);
|
||||||
|
|
||||||
} catch (DatabaseServiceException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -157,44 +125,26 @@ public class DatabaseServiceTest extends DBExtensionTests{
|
|||||||
Assert.assertEquals(limitQuery, "SELECT * FROM " + testTable + " LIMIT " + 100 + " OFFSET " + 0 + ";");
|
Assert.assertEquals(limitQuery, "SELECT * FROM " + testTable + " LIMIT " + 100 + " OFFSET " + 0 + ";");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(groups = {"requiresMySQL"})
|
||||||
public void testGetColumns() {
|
public void testGetColumns() throws DatabaseServiceException {
|
||||||
List<DatabaseColumn> dbColumns;
|
List<DatabaseColumn> dbColumns;
|
||||||
|
|
||||||
try {
|
|
||||||
DatabaseService dbService = DatabaseService.get(testDbConfig.getDatabaseType());
|
DatabaseService dbService = DatabaseService.get(testDbConfig.getDatabaseType());
|
||||||
dbColumns = dbService.getColumns(testDbConfig,"SELECT * FROM " + testTable);
|
dbColumns = dbService.getColumns(testDbConfig,"SELECT * FROM " + testTable);
|
||||||
Assert.assertNotNull(dbColumns);
|
Assert.assertNotNull(dbColumns);
|
||||||
|
|
||||||
int cols = dbColumns.size();
|
int cols = dbColumns.size();
|
||||||
Assert.assertEquals(cols, 10);
|
Assert.assertEquals(cols, 10);
|
||||||
|
|
||||||
|
|
||||||
} catch (DatabaseServiceException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test(groups = {"requiresMySQL"})
|
||||||
}
|
public void testGetRows() throws DatabaseServiceException {
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testGetRows() {
|
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
DatabaseService dbService = DatabaseService.get(testDbConfig.getDatabaseType());
|
DatabaseService dbService = DatabaseService.get(testDbConfig.getDatabaseType());
|
||||||
List<DatabaseRow> dbRows = dbService.getRows(testDbConfig,
|
List<DatabaseRow> dbRows = dbService.getRows(testDbConfig,
|
||||||
"SELECT * FROM " + testTable);
|
"SELECT * FROM " + testTable);
|
||||||
|
|
||||||
Assert.assertNotNull(dbRows);
|
Assert.assertNotNull(dbRows);
|
||||||
Assert.assertEquals(dbRows.size(), 1);
|
Assert.assertEquals(dbRows.size(), 1);
|
||||||
|
|
||||||
} catch (DatabaseServiceException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.google.refine.extension.database;
|
package com.google.refine.extension.database;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
import org.testng.annotations.AfterSuite;
|
import org.testng.annotations.AfterSuite;
|
||||||
import org.testng.annotations.BeforeSuite;
|
import org.testng.annotations.BeforeSuite;
|
||||||
import org.testng.annotations.Optional;
|
import org.testng.annotations.Optional;
|
||||||
@ -30,7 +32,8 @@ public class DatabaseTestConfig extends DBExtensionTests {
|
|||||||
|
|
||||||
@Optional(DEFAULT_MARIADB_NAME) String mariadbDbName, @Optional(DEFAULT_MARIADB_HOST) String mariadbDbHost,
|
@Optional(DEFAULT_MARIADB_NAME) String mariadbDbName, @Optional(DEFAULT_MARIADB_HOST) String mariadbDbHost,
|
||||||
@Optional(DEFAULT_MARIADB_PORT) String mariadbDbPort, @Optional(DEFAULT_MARIADB_USER) String mariadbyDbUser,
|
@Optional(DEFAULT_MARIADB_PORT) String mariadbDbPort, @Optional(DEFAULT_MARIADB_USER) String mariadbyDbUser,
|
||||||
@Optional(DEFAULT_MARIADB_PASSWORD) String mariadbDbPassword, @Optional(DEFAULT_TEST_TABLE) String mariadbTestTable) {
|
@Optional(DEFAULT_MARIADB_PASSWORD) String mariadbDbPassword, @Optional(DEFAULT_TEST_TABLE) String mariadbTestTable)
|
||||||
|
throws DatabaseServiceException, SQLException {
|
||||||
|
|
||||||
//System.out.println("@BeforeSuite\n");
|
//System.out.println("@BeforeSuite\n");
|
||||||
mysqlDbConfig = new DatabaseConfiguration();
|
mysqlDbConfig = new DatabaseConfiguration();
|
||||||
|
@ -3,12 +3,15 @@ package com.google.refine.extension.database.cmd;
|
|||||||
|
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
|
|
||||||
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.MockitoAnnotations;
|
||||||
@ -24,6 +27,7 @@ import com.google.refine.extension.database.DatabaseService;
|
|||||||
import com.google.refine.extension.database.mysql.MySQLDatabaseService;
|
import com.google.refine.extension.database.mysql.MySQLDatabaseService;
|
||||||
|
|
||||||
|
|
||||||
|
@Test(groups = { "requiresMySQL" })
|
||||||
public class ConnectCommandTest extends DBExtensionTests {
|
public class ConnectCommandTest extends DBExtensionTests {
|
||||||
|
|
||||||
|
|
||||||
@ -63,7 +67,7 @@ public class ConnectCommandTest extends DBExtensionTests {
|
|||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDoPost() {
|
public void testDoPost() throws IOException, ServletException, JSONException {
|
||||||
|
|
||||||
when(request.getParameter("databaseType")).thenReturn(MySQLDatabaseService.DB_NAME);
|
when(request.getParameter("databaseType")).thenReturn(MySQLDatabaseService.DB_NAME);
|
||||||
when(request.getParameter("databaseServer")).thenReturn(testDbConfig.getDatabaseHost());
|
when(request.getParameter("databaseServer")).thenReturn(testDbConfig.getDatabaseHost());
|
||||||
@ -75,7 +79,6 @@ public class ConnectCommandTest extends DBExtensionTests {
|
|||||||
StringWriter sw = new StringWriter();
|
StringWriter sw = new StringWriter();
|
||||||
PrintWriter pw = new PrintWriter(sw);
|
PrintWriter pw = new PrintWriter(sw);
|
||||||
|
|
||||||
try {
|
|
||||||
when(response.getWriter()).thenReturn(pw);
|
when(response.getWriter()).thenReturn(pw);
|
||||||
ConnectCommand connectCommand = new ConnectCommand();
|
ConnectCommand connectCommand = new ConnectCommand();
|
||||||
|
|
||||||
@ -89,12 +92,6 @@ public class ConnectCommandTest extends DBExtensionTests {
|
|||||||
|
|
||||||
String databaseInfo = json.getString("databaseInfo");
|
String databaseInfo = json.getString("databaseInfo");
|
||||||
Assert.assertNotNull(databaseInfo);
|
Assert.assertNotNull(databaseInfo);
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2,12 +2,15 @@ package com.google.refine.extension.database.cmd;
|
|||||||
|
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
|
|
||||||
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.MockitoAnnotations;
|
||||||
@ -22,7 +25,7 @@ import com.google.refine.extension.database.DatabaseConfiguration;
|
|||||||
import com.google.refine.extension.database.DatabaseService;
|
import com.google.refine.extension.database.DatabaseService;
|
||||||
import com.google.refine.extension.database.mysql.MySQLDatabaseService;
|
import com.google.refine.extension.database.mysql.MySQLDatabaseService;
|
||||||
|
|
||||||
|
@Test(groups = { "requiresMySQL" })
|
||||||
public class ExecuteQueryCommandTest extends DBExtensionTests {
|
public class ExecuteQueryCommandTest extends DBExtensionTests {
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
@ -60,7 +63,7 @@ public class ExecuteQueryCommandTest extends DBExtensionTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDoPost() {
|
public void testDoPost() throws IOException, ServletException, JSONException {
|
||||||
|
|
||||||
when(request.getParameter("databaseType")).thenReturn(testDbConfig.getDatabaseType());
|
when(request.getParameter("databaseType")).thenReturn(testDbConfig.getDatabaseType());
|
||||||
when(request.getParameter("databaseServer")).thenReturn(testDbConfig.getDatabaseHost());
|
when(request.getParameter("databaseServer")).thenReturn(testDbConfig.getDatabaseHost());
|
||||||
@ -75,7 +78,6 @@ public class ExecuteQueryCommandTest extends DBExtensionTests {
|
|||||||
|
|
||||||
PrintWriter pw = new PrintWriter(sw);
|
PrintWriter pw = new PrintWriter(sw);
|
||||||
|
|
||||||
try {
|
|
||||||
when(response.getWriter()).thenReturn(pw);
|
when(response.getWriter()).thenReturn(pw);
|
||||||
ExecuteQueryCommand executeQueryCommand = new ExecuteQueryCommand();
|
ExecuteQueryCommand executeQueryCommand = new ExecuteQueryCommand();
|
||||||
|
|
||||||
@ -89,12 +91,6 @@ public class ExecuteQueryCommandTest extends DBExtensionTests {
|
|||||||
|
|
||||||
String queryResult = json.getString("QueryResult");
|
String queryResult = json.getString("QueryResult");
|
||||||
Assert.assertNotNull(queryResult);
|
Assert.assertNotNull(queryResult);
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ import java.io.IOException;
|
|||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
|
|
||||||
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
@ -135,7 +136,7 @@ public class SavedConnectionCommandTest extends DBExtensionTests{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDoPost() {
|
public void testDoPost() throws IOException, ServletException, JSONException {
|
||||||
|
|
||||||
when(request.getParameter("connectionName")).thenReturn("test-db-name");
|
when(request.getParameter("connectionName")).thenReturn("test-db-name");
|
||||||
when(request.getParameter("databaseType")).thenReturn(MySQLDatabaseService.DB_NAME);
|
when(request.getParameter("databaseType")).thenReturn(MySQLDatabaseService.DB_NAME);
|
||||||
@ -148,7 +149,6 @@ public class SavedConnectionCommandTest extends DBExtensionTests{
|
|||||||
StringWriter sw = new StringWriter();
|
StringWriter sw = new StringWriter();
|
||||||
PrintWriter pw = new PrintWriter(sw);
|
PrintWriter pw = new PrintWriter(sw);
|
||||||
|
|
||||||
try {
|
|
||||||
when(response.getWriter()).thenReturn(pw);
|
when(response.getWriter()).thenReturn(pw);
|
||||||
|
|
||||||
SUT.doPost(request, response);
|
SUT.doPost(request, response);
|
||||||
@ -163,18 +163,10 @@ public class SavedConnectionCommandTest extends DBExtensionTests{
|
|||||||
int len = savedConnections.length();
|
int len = savedConnections.length();
|
||||||
|
|
||||||
Assert.assertEquals(len, 1);
|
Assert.assertEquals(len, 1);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDoGet() {
|
public void testDoGet() throws IOException, ServletException, JSONException {
|
||||||
String testDbName = "testLocalDb";
|
String testDbName = "testLocalDb";
|
||||||
//add saved connection
|
//add saved connection
|
||||||
saveDatabaseConfiguration(testDbName);
|
saveDatabaseConfiguration(testDbName);
|
||||||
@ -191,7 +183,6 @@ public class SavedConnectionCommandTest extends DBExtensionTests{
|
|||||||
StringWriter sw = new StringWriter();
|
StringWriter sw = new StringWriter();
|
||||||
PrintWriter pw = new PrintWriter(sw);
|
PrintWriter pw = new PrintWriter(sw);
|
||||||
|
|
||||||
try {
|
|
||||||
when(response.getWriter()).thenReturn(pw);
|
when(response.getWriter()).thenReturn(pw);
|
||||||
|
|
||||||
SUT.doGet(request, response);
|
SUT.doGet(request, response);
|
||||||
@ -207,16 +198,10 @@ public class SavedConnectionCommandTest extends DBExtensionTests{
|
|||||||
// System.out.println("sc" + sc);
|
// System.out.println("sc" + sc);
|
||||||
String connName = sc.getString("connectionName");
|
String connName = sc.getString("connectionName");
|
||||||
Assert.assertEquals(connName, testDbName);
|
Assert.assertEquals(connName, testDbName);
|
||||||
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDoPut() {
|
public void testDoPut() throws IOException, ServletException, JSONException {
|
||||||
String testDbName = "testLocalDb";
|
String testDbName = "testLocalDb";
|
||||||
saveDatabaseConfiguration(testDbName);
|
saveDatabaseConfiguration(testDbName);
|
||||||
|
|
||||||
@ -224,7 +209,6 @@ public class SavedConnectionCommandTest extends DBExtensionTests{
|
|||||||
StringWriter sw = new StringWriter();
|
StringWriter sw = new StringWriter();
|
||||||
PrintWriter pw = new PrintWriter(sw);
|
PrintWriter pw = new PrintWriter(sw);
|
||||||
|
|
||||||
try {
|
|
||||||
when(response.getWriter()).thenReturn(pw);
|
when(response.getWriter()).thenReturn(pw);
|
||||||
|
|
||||||
//modify database config
|
//modify database config
|
||||||
@ -249,12 +233,6 @@ public class SavedConnectionCommandTest extends DBExtensionTests{
|
|||||||
System.out.println("sc" + sc);
|
System.out.println("sc" + sc);
|
||||||
String newDbHost = sc.getString("databaseHost");
|
String newDbHost = sc.getString("databaseHost");
|
||||||
Assert.assertEquals(newDbHost, newHost);
|
Assert.assertEquals(newDbHost, newHost);
|
||||||
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -2,12 +2,15 @@ package com.google.refine.extension.database.cmd;
|
|||||||
|
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
|
|
||||||
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.MockitoAnnotations;
|
||||||
@ -23,7 +26,7 @@ import com.google.refine.extension.database.DatabaseService;
|
|||||||
import com.google.refine.extension.database.mysql.MySQLDatabaseService;
|
import com.google.refine.extension.database.mysql.MySQLDatabaseService;
|
||||||
|
|
||||||
|
|
||||||
|
@Test(groups = { "requiresMySQL" })
|
||||||
public class TestConnectCommandTest extends DBExtensionTests{
|
public class TestConnectCommandTest extends DBExtensionTests{
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
@ -63,7 +66,7 @@ public class TestConnectCommandTest extends DBExtensionTests{
|
|||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDoPost() {
|
public void testDoPost() throws IOException, ServletException, JSONException {
|
||||||
|
|
||||||
when(request.getParameter("databaseType")).thenReturn(MySQLDatabaseService.DB_NAME);
|
when(request.getParameter("databaseType")).thenReturn(MySQLDatabaseService.DB_NAME);
|
||||||
when(request.getParameter("databaseServer")).thenReturn(testDbConfig.getDatabaseHost());
|
when(request.getParameter("databaseServer")).thenReturn(testDbConfig.getDatabaseHost());
|
||||||
@ -77,7 +80,6 @@ public class TestConnectCommandTest extends DBExtensionTests{
|
|||||||
|
|
||||||
PrintWriter pw = new PrintWriter(sw);
|
PrintWriter pw = new PrintWriter(sw);
|
||||||
|
|
||||||
try {
|
|
||||||
when(response.getWriter()).thenReturn(pw);
|
when(response.getWriter()).thenReturn(pw);
|
||||||
TestConnectCommand connectCommand = new TestConnectCommand();
|
TestConnectCommand connectCommand = new TestConnectCommand();
|
||||||
|
|
||||||
@ -89,12 +91,6 @@ public class TestConnectCommandTest extends DBExtensionTests{
|
|||||||
String code = json.getString("code");
|
String code = json.getString("code");
|
||||||
Assert.assertEquals(code, "ok");
|
Assert.assertEquals(code, "ok");
|
||||||
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,12 +2,15 @@ package com.google.refine.extension.database.cmd;
|
|||||||
|
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
|
|
||||||
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.MockitoAnnotations;
|
||||||
@ -22,7 +25,7 @@ import com.google.refine.extension.database.DatabaseConfiguration;
|
|||||||
import com.google.refine.extension.database.DatabaseService;
|
import com.google.refine.extension.database.DatabaseService;
|
||||||
import com.google.refine.extension.database.mysql.MySQLDatabaseService;
|
import com.google.refine.extension.database.mysql.MySQLDatabaseService;
|
||||||
|
|
||||||
|
@Test(groups = { "requiresMySQL" })
|
||||||
public class TestQueryCommandTest extends DBExtensionTests {
|
public class TestQueryCommandTest extends DBExtensionTests {
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
@ -61,7 +64,7 @@ public class TestQueryCommandTest extends DBExtensionTests {
|
|||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDoPost() {
|
public void testDoPost() throws IOException, ServletException, JSONException {
|
||||||
|
|
||||||
when(request.getParameter("databaseType")).thenReturn(testDbConfig.getDatabaseType());
|
when(request.getParameter("databaseType")).thenReturn(testDbConfig.getDatabaseType());
|
||||||
when(request.getParameter("databaseServer")).thenReturn(testDbConfig.getDatabaseHost());
|
when(request.getParameter("databaseServer")).thenReturn(testDbConfig.getDatabaseHost());
|
||||||
@ -76,7 +79,6 @@ public class TestQueryCommandTest extends DBExtensionTests {
|
|||||||
|
|
||||||
PrintWriter pw = new PrintWriter(sw);
|
PrintWriter pw = new PrintWriter(sw);
|
||||||
|
|
||||||
try {
|
|
||||||
when(response.getWriter()).thenReturn(pw);
|
when(response.getWriter()).thenReturn(pw);
|
||||||
TestQueryCommand executeQueryCommand = new TestQueryCommand();
|
TestQueryCommand executeQueryCommand = new TestQueryCommand();
|
||||||
|
|
||||||
@ -91,11 +93,6 @@ public class TestQueryCommandTest extends DBExtensionTests {
|
|||||||
String queryResult = json.getString("QueryResult");
|
String queryResult = json.getString("QueryResult");
|
||||||
Assert.assertNotNull(queryResult);
|
Assert.assertNotNull(queryResult);
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.google.refine.extension.database.mariadb;
|
package com.google.refine.extension.database.mariadb;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.MockitoAnnotations;
|
||||||
import org.testng.Assert;
|
import org.testng.Assert;
|
||||||
@ -14,7 +15,7 @@ import com.google.refine.extension.database.DatabaseConfiguration;
|
|||||||
import com.google.refine.extension.database.DatabaseService;
|
import com.google.refine.extension.database.DatabaseService;
|
||||||
import com.google.refine.extension.database.DatabaseServiceException;
|
import com.google.refine.extension.database.DatabaseServiceException;
|
||||||
|
|
||||||
|
@Test(groups = { "requiresMariaDB" })
|
||||||
public class MariaDBConnectionManagerTest extends DBExtensionTests {
|
public class MariaDBConnectionManagerTest extends DBExtensionTests {
|
||||||
|
|
||||||
|
|
||||||
@ -48,35 +49,19 @@ public class MariaDBConnectionManagerTest extends DBExtensionTests {
|
|||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTestConnection() {
|
public void testTestConnection() throws DatabaseServiceException {
|
||||||
|
|
||||||
try {
|
|
||||||
boolean conn = MariaDBConnectionManager.getInstance().testConnection(testDbConfig);
|
boolean conn = MariaDBConnectionManager.getInstance().testConnection(testDbConfig);
|
||||||
Assert.assertEquals(conn, true);
|
Assert.assertEquals(conn, true);
|
||||||
|
|
||||||
} catch (DatabaseServiceException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetConnection() {
|
public void testGetConnection() throws DatabaseServiceException {
|
||||||
|
|
||||||
try {
|
|
||||||
Connection conn = MariaDBConnectionManager.getInstance().getConnection(testDbConfig, true);
|
Connection conn = MariaDBConnectionManager.getInstance().getConnection(testDbConfig, true);
|
||||||
Assert.assertNotNull(conn);
|
Assert.assertNotNull(conn);
|
||||||
|
|
||||||
} catch (DatabaseServiceException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testShutdown() {
|
public void testShutdown() throws DatabaseServiceException, SQLException {
|
||||||
|
|
||||||
try {
|
|
||||||
Connection conn = MariaDBConnectionManager.getInstance().getConnection(testDbConfig, true);
|
Connection conn = MariaDBConnectionManager.getInstance().getConnection(testDbConfig, true);
|
||||||
Assert.assertNotNull(conn);
|
Assert.assertNotNull(conn);
|
||||||
|
|
||||||
@ -86,11 +71,6 @@ public class MariaDBConnectionManagerTest extends DBExtensionTests {
|
|||||||
Assert.assertEquals(conn.isClosed(), true);
|
Assert.assertEquals(conn.isClosed(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ import com.google.refine.extension.database.model.DatabaseColumn;
|
|||||||
import com.google.refine.extension.database.model.DatabaseInfo;
|
import com.google.refine.extension.database.model.DatabaseInfo;
|
||||||
import com.google.refine.extension.database.model.DatabaseRow;
|
import com.google.refine.extension.database.model.DatabaseRow;
|
||||||
|
|
||||||
|
@Test(groups = { "requiresMariaDB" })
|
||||||
public class MariaDBDatabaseServiceTest extends DBExtensionTests{
|
public class MariaDBDatabaseServiceTest extends DBExtensionTests{
|
||||||
|
|
||||||
|
|
||||||
@ -63,60 +63,35 @@ public class MariaDBDatabaseServiceTest extends DBExtensionTests{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetConnection() {
|
public void testGetConnection() throws DatabaseServiceException {
|
||||||
try {
|
|
||||||
|
|
||||||
MariaDBDatabaseService pgSqlService = (MariaDBDatabaseService)DatabaseService.get(MariaDBDatabaseService.DB_NAME);
|
MariaDBDatabaseService pgSqlService = (MariaDBDatabaseService)DatabaseService.get(MariaDBDatabaseService.DB_NAME);
|
||||||
Connection conn = pgSqlService.getConnection(testDbConfig);
|
Connection conn = pgSqlService.getConnection(testDbConfig);
|
||||||
|
|
||||||
Assert.assertNotNull(conn);
|
Assert.assertNotNull(conn);
|
||||||
|
|
||||||
} catch (DatabaseServiceException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTestConnection() {
|
public void testTestConnection() throws DatabaseServiceException {
|
||||||
try {
|
|
||||||
MariaDBDatabaseService pgSqlService = (MariaDBDatabaseService)DatabaseService.get(MariaDBDatabaseService.DB_NAME);
|
MariaDBDatabaseService pgSqlService = (MariaDBDatabaseService)DatabaseService.get(MariaDBDatabaseService.DB_NAME);
|
||||||
|
|
||||||
boolean result = pgSqlService.testConnection(testDbConfig);
|
boolean result = pgSqlService.testConnection(testDbConfig);
|
||||||
Assert.assertEquals(result, true);
|
Assert.assertEquals(result, true);
|
||||||
|
|
||||||
} catch (DatabaseServiceException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testConnect() {
|
public void testConnect() throws DatabaseServiceException {
|
||||||
try {
|
|
||||||
MariaDBDatabaseService pgSqlService = (MariaDBDatabaseService)DatabaseService.get(MariaDBDatabaseService.DB_NAME);
|
MariaDBDatabaseService pgSqlService = (MariaDBDatabaseService)DatabaseService.get(MariaDBDatabaseService.DB_NAME);
|
||||||
DatabaseInfo databaseInfo = pgSqlService.connect(testDbConfig);
|
DatabaseInfo databaseInfo = pgSqlService.connect(testDbConfig);
|
||||||
Assert.assertNotNull(databaseInfo);
|
Assert.assertNotNull(databaseInfo);
|
||||||
|
|
||||||
} catch (DatabaseServiceException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testExecuteQuery() {
|
public void testExecuteQuery() throws DatabaseServiceException {
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
MariaDBDatabaseService pgSqlService = (MariaDBDatabaseService) DatabaseService
|
MariaDBDatabaseService pgSqlService = (MariaDBDatabaseService) DatabaseService
|
||||||
.get(MariaDBDatabaseService.DB_NAME);
|
.get(MariaDBDatabaseService.DB_NAME);
|
||||||
DatabaseInfo databaseInfo = pgSqlService.testQuery(testDbConfig, "SELECT * FROM " + testTable);
|
DatabaseInfo databaseInfo = pgSqlService.testQuery(testDbConfig, "SELECT * FROM " + testTable);
|
||||||
|
|
||||||
Assert.assertNotNull(databaseInfo);
|
Assert.assertNotNull(databaseInfo);
|
||||||
|
|
||||||
} catch (DatabaseServiceException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -130,18 +105,12 @@ public class MariaDBDatabaseServiceTest extends DBExtensionTests{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetRows() {
|
public void testGetRows() throws DatabaseServiceException {
|
||||||
try {
|
|
||||||
MariaDBDatabaseService pgSqlService = (MariaDBDatabaseService) DatabaseService
|
MariaDBDatabaseService pgSqlService = (MariaDBDatabaseService) DatabaseService
|
||||||
.get(MariaDBDatabaseService.DB_NAME);
|
.get(MariaDBDatabaseService.DB_NAME);
|
||||||
List<DatabaseRow> dbRows = pgSqlService.getRows(testDbConfig, "SELECT * FROM " + testTable);
|
List<DatabaseRow> dbRows = pgSqlService.getRows(testDbConfig, "SELECT * FROM " + testTable);
|
||||||
|
|
||||||
Assert.assertNotNull(dbRows);
|
Assert.assertNotNull(dbRows);
|
||||||
|
|
||||||
} catch (DatabaseServiceException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -151,21 +120,15 @@ public class MariaDBDatabaseServiceTest extends DBExtensionTests{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetColumns() {
|
public void testGetColumns() throws DatabaseServiceException {
|
||||||
List<DatabaseColumn> dbColumns;
|
List<DatabaseColumn> dbColumns;
|
||||||
|
|
||||||
try {
|
|
||||||
MariaDBDatabaseService pgSqlService = (MariaDBDatabaseService) DatabaseService
|
MariaDBDatabaseService pgSqlService = (MariaDBDatabaseService) DatabaseService
|
||||||
.get(MariaDBDatabaseService.DB_NAME);
|
.get(MariaDBDatabaseService.DB_NAME);
|
||||||
|
|
||||||
dbColumns = pgSqlService.getColumns(testDbConfig, "SELECT * FROM " + testTable);
|
dbColumns = pgSqlService.getColumns(testDbConfig, "SELECT * FROM " + testTable);
|
||||||
|
|
||||||
Assert.assertNotNull(dbColumns);
|
Assert.assertNotNull(dbColumns);
|
||||||
|
|
||||||
} catch (DatabaseServiceException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.google.refine.extension.database.mysql;
|
package com.google.refine.extension.database.mysql;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.MockitoAnnotations;
|
||||||
import org.testng.Assert;
|
import org.testng.Assert;
|
||||||
@ -14,6 +15,7 @@ import com.google.refine.extension.database.DatabaseConfiguration;
|
|||||||
import com.google.refine.extension.database.DatabaseService;
|
import com.google.refine.extension.database.DatabaseService;
|
||||||
import com.google.refine.extension.database.DatabaseServiceException;
|
import com.google.refine.extension.database.DatabaseServiceException;
|
||||||
|
|
||||||
|
@Test(groups = { "requiresMySQL" })
|
||||||
public class MySQLConnectionManagerTest extends DBExtensionTests {
|
public class MySQLConnectionManagerTest extends DBExtensionTests {
|
||||||
|
|
||||||
private DatabaseConfiguration testDbConfig;
|
private DatabaseConfiguration testDbConfig;
|
||||||
@ -45,35 +47,22 @@ public class MySQLConnectionManagerTest extends DBExtensionTests {
|
|||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTestConnection() {
|
public void testTestConnection() throws DatabaseServiceException {
|
||||||
|
|
||||||
try {
|
|
||||||
boolean conn = MySQLConnectionManager.getInstance().testConnection(testDbConfig);
|
boolean conn = MySQLConnectionManager.getInstance().testConnection(testDbConfig);
|
||||||
Assert.assertEquals(conn, true);
|
Assert.assertEquals(conn, true);
|
||||||
|
|
||||||
} catch (DatabaseServiceException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetConnection() {
|
public void testGetConnection() throws DatabaseServiceException {
|
||||||
|
|
||||||
try {
|
|
||||||
Connection conn = MySQLConnectionManager.getInstance().getConnection(testDbConfig, true);
|
Connection conn = MySQLConnectionManager.getInstance().getConnection(testDbConfig, true);
|
||||||
Assert.assertNotNull(conn);
|
Assert.assertNotNull(conn);
|
||||||
|
|
||||||
} catch (DatabaseServiceException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testShutdown() {
|
public void testShutdown() throws DatabaseServiceException, SQLException {
|
||||||
|
|
||||||
try {
|
|
||||||
Connection conn = MySQLConnectionManager.getInstance().getConnection(testDbConfig, true);
|
Connection conn = MySQLConnectionManager.getInstance().getConnection(testDbConfig, true);
|
||||||
Assert.assertNotNull(conn);
|
Assert.assertNotNull(conn);
|
||||||
|
|
||||||
@ -82,12 +71,6 @@ public class MySQLConnectionManagerTest extends DBExtensionTests {
|
|||||||
if(conn != null) {
|
if(conn != null) {
|
||||||
Assert.assertEquals(conn.isClosed(), true);
|
Assert.assertEquals(conn.isClosed(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ import com.google.refine.extension.database.model.DatabaseInfo;
|
|||||||
import com.google.refine.extension.database.model.DatabaseRow;
|
import com.google.refine.extension.database.model.DatabaseRow;
|
||||||
|
|
||||||
|
|
||||||
|
@Test(groups = { "requiresMySQL" })
|
||||||
public class MySQLDatabaseServiceTest extends DBExtensionTests{
|
public class MySQLDatabaseServiceTest extends DBExtensionTests{
|
||||||
|
|
||||||
private DatabaseConfiguration testDbConfig;
|
private DatabaseConfiguration testDbConfig;
|
||||||
@ -62,60 +62,36 @@ public class MySQLDatabaseServiceTest extends DBExtensionTests{
|
|||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetConnection() {
|
public void testGetConnection() throws DatabaseServiceException {
|
||||||
try {
|
|
||||||
|
|
||||||
MySQLDatabaseService pgSqlService = (MySQLDatabaseService)DatabaseService.get(MySQLDatabaseService.DB_NAME);
|
MySQLDatabaseService pgSqlService = (MySQLDatabaseService)DatabaseService.get(MySQLDatabaseService.DB_NAME);
|
||||||
Connection conn = pgSqlService.getConnection(testDbConfig);
|
Connection conn = pgSqlService.getConnection(testDbConfig);
|
||||||
|
|
||||||
Assert.assertNotNull(conn);
|
Assert.assertNotNull(conn);
|
||||||
|
|
||||||
} catch (DatabaseServiceException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTestConnection() {
|
public void testTestConnection() throws DatabaseServiceException {
|
||||||
try {
|
|
||||||
MySQLDatabaseService pgSqlService = (MySQLDatabaseService)DatabaseService.get(MySQLDatabaseService.DB_NAME);
|
MySQLDatabaseService pgSqlService = (MySQLDatabaseService)DatabaseService.get(MySQLDatabaseService.DB_NAME);
|
||||||
|
|
||||||
boolean result = pgSqlService.testConnection(testDbConfig);
|
boolean result = pgSqlService.testConnection(testDbConfig);
|
||||||
Assert.assertEquals(result, true);
|
Assert.assertEquals(result, true);
|
||||||
|
|
||||||
} catch (DatabaseServiceException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testConnect() {
|
public void testConnect() throws DatabaseServiceException {
|
||||||
try {
|
|
||||||
MySQLDatabaseService pgSqlService = (MySQLDatabaseService)DatabaseService.get(MySQLDatabaseService.DB_NAME);
|
MySQLDatabaseService pgSqlService = (MySQLDatabaseService)DatabaseService.get(MySQLDatabaseService.DB_NAME);
|
||||||
DatabaseInfo databaseInfo = pgSqlService.connect(testDbConfig);
|
DatabaseInfo databaseInfo = pgSqlService.connect(testDbConfig);
|
||||||
Assert.assertNotNull(databaseInfo);
|
Assert.assertNotNull(databaseInfo);
|
||||||
|
|
||||||
} catch (DatabaseServiceException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testExecuteQuery() {
|
public void testExecuteQuery() throws DatabaseServiceException {
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
MySQLDatabaseService pgSqlService = (MySQLDatabaseService) DatabaseService
|
MySQLDatabaseService pgSqlService = (MySQLDatabaseService) DatabaseService
|
||||||
.get(MySQLDatabaseService.DB_NAME);
|
.get(MySQLDatabaseService.DB_NAME);
|
||||||
DatabaseInfo databaseInfo = pgSqlService.testQuery(testDbConfig, "SELECT * FROM " + testTable);
|
DatabaseInfo databaseInfo = pgSqlService.testQuery(testDbConfig, "SELECT * FROM " + testTable);
|
||||||
|
|
||||||
Assert.assertNotNull(databaseInfo);
|
Assert.assertNotNull(databaseInfo);
|
||||||
|
|
||||||
} catch (DatabaseServiceException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -129,18 +105,12 @@ public class MySQLDatabaseServiceTest extends DBExtensionTests{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetRows() {
|
public void testGetRows() throws DatabaseServiceException {
|
||||||
try {
|
|
||||||
MySQLDatabaseService pgSqlService = (MySQLDatabaseService) DatabaseService
|
MySQLDatabaseService pgSqlService = (MySQLDatabaseService) DatabaseService
|
||||||
.get(MySQLDatabaseService.DB_NAME);
|
.get(MySQLDatabaseService.DB_NAME);
|
||||||
List<DatabaseRow> dbRows = pgSqlService.getRows(testDbConfig, "SELECT * FROM " + testTable);
|
List<DatabaseRow> dbRows = pgSqlService.getRows(testDbConfig, "SELECT * FROM " + testTable);
|
||||||
|
|
||||||
Assert.assertNotNull(dbRows);
|
Assert.assertNotNull(dbRows);
|
||||||
|
|
||||||
} catch (DatabaseServiceException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -150,21 +120,14 @@ public class MySQLDatabaseServiceTest extends DBExtensionTests{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetColumns() {
|
public void testGetColumns() throws DatabaseServiceException {
|
||||||
List<DatabaseColumn> dbColumns;
|
List<DatabaseColumn> dbColumns;
|
||||||
|
|
||||||
try {
|
|
||||||
MySQLDatabaseService pgSqlService = (MySQLDatabaseService) DatabaseService
|
MySQLDatabaseService pgSqlService = (MySQLDatabaseService) DatabaseService
|
||||||
.get(MySQLDatabaseService.DB_NAME);
|
.get(MySQLDatabaseService.DB_NAME);
|
||||||
|
|
||||||
dbColumns = pgSqlService.getColumns(testDbConfig, "SELECT * FROM " + testTable);
|
dbColumns = pgSqlService.getColumns(testDbConfig, "SELECT * FROM " + testTable);
|
||||||
|
|
||||||
Assert.assertNotNull(dbColumns);
|
Assert.assertNotNull(dbColumns);
|
||||||
|
|
||||||
} catch (DatabaseServiceException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.google.refine.extension.database.pgsql;
|
package com.google.refine.extension.database.pgsql;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.MockitoAnnotations;
|
||||||
import org.testng.Assert;
|
import org.testng.Assert;
|
||||||
@ -15,7 +16,7 @@ import com.google.refine.extension.database.DatabaseService;
|
|||||||
import com.google.refine.extension.database.DatabaseServiceException;
|
import com.google.refine.extension.database.DatabaseServiceException;
|
||||||
|
|
||||||
|
|
||||||
|
@Test(groups = { "requiresPgSQL" })
|
||||||
public class PgSQLConnectionManagerTest extends DBExtensionTests {
|
public class PgSQLConnectionManagerTest extends DBExtensionTests {
|
||||||
|
|
||||||
private DatabaseConfiguration testDbConfig;
|
private DatabaseConfiguration testDbConfig;
|
||||||
@ -48,35 +49,22 @@ public class PgSQLConnectionManagerTest extends DBExtensionTests {
|
|||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTestConnection() {
|
public void testTestConnection() throws DatabaseServiceException {
|
||||||
|
|
||||||
try {
|
|
||||||
boolean isConnected = PgSQLConnectionManager.getInstance().testConnection(testDbConfig);
|
boolean isConnected = PgSQLConnectionManager.getInstance().testConnection(testDbConfig);
|
||||||
Assert.assertEquals(isConnected, true);
|
Assert.assertEquals(isConnected, true);
|
||||||
|
|
||||||
} catch (DatabaseServiceException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetConnection() {
|
public void testGetConnection() throws DatabaseServiceException {
|
||||||
|
|
||||||
try {
|
|
||||||
Connection conn = PgSQLConnectionManager.getInstance().getConnection(testDbConfig, true);
|
Connection conn = PgSQLConnectionManager.getInstance().getConnection(testDbConfig, true);
|
||||||
Assert.assertNotNull(conn);
|
Assert.assertNotNull(conn);
|
||||||
|
|
||||||
} catch (DatabaseServiceException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testShutdown() {
|
public void testShutdown() throws DatabaseServiceException, SQLException {
|
||||||
|
|
||||||
try {
|
|
||||||
Connection conn = PgSQLConnectionManager.getInstance().getConnection(testDbConfig, true);
|
Connection conn = PgSQLConnectionManager.getInstance().getConnection(testDbConfig, true);
|
||||||
Assert.assertNotNull(conn);
|
Assert.assertNotNull(conn);
|
||||||
|
|
||||||
@ -86,11 +74,6 @@ public class PgSQLConnectionManagerTest extends DBExtensionTests {
|
|||||||
Assert.assertEquals(conn.isClosed(), true);
|
Assert.assertEquals(conn.isClosed(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ import com.google.refine.extension.database.model.DatabaseColumn;
|
|||||||
import com.google.refine.extension.database.model.DatabaseInfo;
|
import com.google.refine.extension.database.model.DatabaseInfo;
|
||||||
import com.google.refine.extension.database.model.DatabaseRow;
|
import com.google.refine.extension.database.model.DatabaseRow;
|
||||||
|
|
||||||
|
@Test(groups = { "requiresPgSQL" })
|
||||||
public class PgSQLDatabaseServiceTest extends DBExtensionTests{
|
public class PgSQLDatabaseServiceTest extends DBExtensionTests{
|
||||||
|
|
||||||
private DatabaseConfiguration testDbConfig;
|
private DatabaseConfiguration testDbConfig;
|
||||||
@ -61,60 +61,38 @@ public class PgSQLDatabaseServiceTest extends DBExtensionTests{
|
|||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetConnection() {
|
public void testGetConnection() throws DatabaseServiceException {
|
||||||
try {
|
|
||||||
|
|
||||||
PgSQLDatabaseService pgSqlService = (PgSQLDatabaseService)DatabaseService.get(PgSQLDatabaseService.DB_NAME);
|
PgSQLDatabaseService pgSqlService = (PgSQLDatabaseService)DatabaseService.get(PgSQLDatabaseService.DB_NAME);
|
||||||
Connection conn = pgSqlService.getConnection(testDbConfig);
|
Connection conn = pgSqlService.getConnection(testDbConfig);
|
||||||
|
|
||||||
Assert.assertNotNull(conn);
|
Assert.assertNotNull(conn);
|
||||||
|
|
||||||
} catch (DatabaseServiceException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTestConnection() {
|
public void testTestConnection() throws DatabaseServiceException {
|
||||||
try {
|
|
||||||
PgSQLDatabaseService pgSqlService = (PgSQLDatabaseService)DatabaseService.get(PgSQLDatabaseService.DB_NAME);
|
PgSQLDatabaseService pgSqlService = (PgSQLDatabaseService)DatabaseService.get(PgSQLDatabaseService.DB_NAME);
|
||||||
|
|
||||||
boolean result = pgSqlService.testConnection(testDbConfig);
|
boolean result = pgSqlService.testConnection(testDbConfig);
|
||||||
Assert.assertEquals(result, true);
|
Assert.assertEquals(result, true);
|
||||||
|
|
||||||
} catch (DatabaseServiceException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testConnect() {
|
public void testConnect() throws DatabaseServiceException {
|
||||||
try {
|
|
||||||
PgSQLDatabaseService pgSqlService = (PgSQLDatabaseService)DatabaseService.get(PgSQLDatabaseService.DB_NAME);
|
PgSQLDatabaseService pgSqlService = (PgSQLDatabaseService)DatabaseService.get(PgSQLDatabaseService.DB_NAME);
|
||||||
DatabaseInfo databaseInfo = pgSqlService.connect(testDbConfig);
|
DatabaseInfo databaseInfo = pgSqlService.connect(testDbConfig);
|
||||||
Assert.assertNotNull(databaseInfo);
|
Assert.assertNotNull(databaseInfo);
|
||||||
|
|
||||||
} catch (DatabaseServiceException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testExecuteQuery() {
|
public void testExecuteQuery() throws DatabaseServiceException {
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
PgSQLDatabaseService pgSqlService = (PgSQLDatabaseService) DatabaseService
|
PgSQLDatabaseService pgSqlService = (PgSQLDatabaseService) DatabaseService
|
||||||
.get(PgSQLDatabaseService.DB_NAME);
|
.get(PgSQLDatabaseService.DB_NAME);
|
||||||
DatabaseInfo databaseInfo = pgSqlService.testQuery(testDbConfig, "SELECT * FROM " + testTable);
|
DatabaseInfo databaseInfo = pgSqlService.testQuery(testDbConfig, "SELECT * FROM " + testTable);
|
||||||
|
|
||||||
Assert.assertNotNull(databaseInfo);
|
Assert.assertNotNull(databaseInfo);
|
||||||
|
|
||||||
} catch (DatabaseServiceException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -128,18 +106,12 @@ public class PgSQLDatabaseServiceTest extends DBExtensionTests{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetRows() {
|
public void testGetRows() throws DatabaseServiceException {
|
||||||
try {
|
|
||||||
PgSQLDatabaseService pgSqlService = (PgSQLDatabaseService) DatabaseService
|
PgSQLDatabaseService pgSqlService = (PgSQLDatabaseService) DatabaseService
|
||||||
.get(PgSQLDatabaseService.DB_NAME);
|
.get(PgSQLDatabaseService.DB_NAME);
|
||||||
List<DatabaseRow> dbRows = pgSqlService.getRows(testDbConfig, "SELECT * FROM " + testTable);
|
List<DatabaseRow> dbRows = pgSqlService.getRows(testDbConfig, "SELECT * FROM " + testTable);
|
||||||
|
|
||||||
Assert.assertNotNull(dbRows);
|
Assert.assertNotNull(dbRows);
|
||||||
|
|
||||||
} catch (DatabaseServiceException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -149,10 +121,9 @@ public class PgSQLDatabaseServiceTest extends DBExtensionTests{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetColumns() {
|
public void testGetColumns() throws DatabaseServiceException {
|
||||||
List<DatabaseColumn> dbColumns;
|
List<DatabaseColumn> dbColumns;
|
||||||
|
|
||||||
try {
|
|
||||||
PgSQLDatabaseService pgSqlService = (PgSQLDatabaseService) DatabaseService
|
PgSQLDatabaseService pgSqlService = (PgSQLDatabaseService) DatabaseService
|
||||||
.get(PgSQLDatabaseService.DB_NAME);
|
.get(PgSQLDatabaseService.DB_NAME);
|
||||||
|
|
||||||
@ -160,10 +131,6 @@ public class PgSQLDatabaseServiceTest extends DBExtensionTests{
|
|||||||
|
|
||||||
Assert.assertNotNull(dbColumns);
|
Assert.assertNotNull(dbColumns);
|
||||||
|
|
||||||
} catch (DatabaseServiceException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
50
extensions/database/test/conf/appveyor_tests.xml
Normal file
50
extensions/database/test/conf/appveyor_tests.xml
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<suite name="DatabaseExtensionUnitTestSuite">
|
||||||
|
<!--
|
||||||
|
These settings are for the Appveyor CI service.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<parameter name = "mySqlDbName" value="test_db"/>
|
||||||
|
<parameter name = "mySqlDbHost" value="127.0.0.1"/>
|
||||||
|
<parameter name = "mySqlDbPort" value="3306"/>
|
||||||
|
<parameter name = "mySqlDbUser" value="root"/>
|
||||||
|
<parameter name = "mySqlDbPassword" value="Password12!"/>
|
||||||
|
<parameter name = "mySqlTestTable" value="test_table"/>
|
||||||
|
|
||||||
|
<parameter name = "pgSqlDbName" value="test_db"/>
|
||||||
|
<parameter name = "pgSqlDbHost" value="127.0.0.1"/>
|
||||||
|
<parameter name = "pgSqlDbPort" value="5432"/>
|
||||||
|
<parameter name = "pgSqlDbUser" value="postgres"/>
|
||||||
|
<parameter name = "pgSqlDbPassword" value="Password12!"/>
|
||||||
|
<parameter name = "pgSqlTestTable" value="test_table"/>
|
||||||
|
|
||||||
|
<parameter name = "mariaDbName" value="test_db"/>
|
||||||
|
<parameter name = "mariaDbHost" value="127.0.0.1"/>
|
||||||
|
<parameter name = "mariadbDbPort" value="3306"/>
|
||||||
|
<parameter name = "mariaDbUser" value="root"/>
|
||||||
|
<parameter name = "mariaDbPassword" value=""/>
|
||||||
|
<parameter name = "mariaDbTestTable" value="test_table"/>
|
||||||
|
<test name="DatabaseExtensionUnitTest">
|
||||||
|
<groups>
|
||||||
|
<run>
|
||||||
|
<exclude name="requiresMariaDB" />
|
||||||
|
</run>
|
||||||
|
</groups>
|
||||||
|
<classes>
|
||||||
|
<class name="com.google.refine.extension.database.DatabaseImportControllerTest"/>
|
||||||
|
<class name="com.google.refine.extension.database.DatabaseServiceTest"/>
|
||||||
|
<class name="com.google.refine.extension.database.SimpleTextEncryptorTest"/>
|
||||||
|
<class name="com.google.refine.extension.database.cmd.ConnectCommandTest"/>
|
||||||
|
<class name="com.google.refine.extension.database.cmd.ExecuteQueryCommandTest"/>
|
||||||
|
<class name="com.google.refine.extension.database.cmd.SavedConnectionCommandTest"/>
|
||||||
|
<class name="com.google.refine.extension.database.cmd.TestConnectCommandTest"/>
|
||||||
|
<class name="com.google.refine.extension.database.cmd.TestQueryCommandTest"/>
|
||||||
|
<class name="com.google.refine.extension.database.mariadb.MariaDBConnectionManagerTest"/>
|
||||||
|
<class name="com.google.refine.extension.database.mariadb.MariaDBDatabaseServiceTest"/>
|
||||||
|
<class name="com.google.refine.extension.database.mysql.MySQLConnectionManagerTest"/>
|
||||||
|
<class name="com.google.refine.extension.database.mysql.MySQLDatabaseServiceTest"/>
|
||||||
|
<class name="com.google.refine.extension.database.pgsql.PgSQLConnectionManagerTest"/>
|
||||||
|
<class name="com.google.refine.extension.database.pgsql.PgSQLDatabaseServiceTest" />
|
||||||
|
</classes>
|
||||||
|
</test>
|
||||||
|
</suite>
|
56
extensions/database/test/conf/tests.xml
Normal file
56
extensions/database/test/conf/tests.xml
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<suite name="DatabaseExtensionUnitTestSuite">
|
||||||
|
<!--
|
||||||
|
To test the database extension against a particular
|
||||||
|
database, provide the connection settings below,
|
||||||
|
and remove the <exclude /> tag which corresponds
|
||||||
|
to the database to test. All tests which rely on
|
||||||
|
this database will then run.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<parameter name = "mySqlDbName" value="test_db"/>
|
||||||
|
<parameter name = "mySqlDbHost" value="127.0.0.1"/>
|
||||||
|
<parameter name = "mySqlDbPort" value="3306"/>
|
||||||
|
<parameter name = "mySqlDbUser" value="root"/>
|
||||||
|
<parameter name = "mySqlDbPassword" value=""/>
|
||||||
|
<parameter name = "mySqlTestTable" value="test_table"/>
|
||||||
|
|
||||||
|
<parameter name = "pgSqlDbName" value="test_db"/>
|
||||||
|
<parameter name = "pgSqlDbHost" value="127.0.0.1"/>
|
||||||
|
<parameter name = "pgSqlDbPort" value="5432"/>
|
||||||
|
<parameter name = "pgSqlDbUser" value="postgres"/>
|
||||||
|
<parameter name = "pgSqlDbPassword" value=""/>
|
||||||
|
<parameter name = "pgSqlTestTable" value="test_table"/>
|
||||||
|
|
||||||
|
<parameter name = "mariaDbName" value="test_db"/>
|
||||||
|
<parameter name = "mariaDbHost" value="127.0.0.1"/>
|
||||||
|
<parameter name = "mariadbDbPort" value="3306"/>
|
||||||
|
<parameter name = "mariaDbUser" value="root"/>
|
||||||
|
<parameter name = "mariaDbPassword" value=""/>
|
||||||
|
<parameter name = "mariaDbTestTable" value="test_table"/>
|
||||||
|
<test name="DatabaseExtensionUnitTest">
|
||||||
|
<groups>
|
||||||
|
<run>
|
||||||
|
<exclude name="requiresMySQL"/>
|
||||||
|
<exclude name="requiresPgSQL"/>
|
||||||
|
<exclude name="requiresMariaDB" />
|
||||||
|
</run>
|
||||||
|
</groups>
|
||||||
|
<classes>
|
||||||
|
<class name="com.google.refine.extension.database.DatabaseImportControllerTest"/>
|
||||||
|
<class name="com.google.refine.extension.database.DatabaseServiceTest"/>
|
||||||
|
<class name="com.google.refine.extension.database.SimpleTextEncryptorTest"/>
|
||||||
|
<class name="com.google.refine.extension.database.cmd.ConnectCommandTest"/>
|
||||||
|
<class name="com.google.refine.extension.database.cmd.ExecuteQueryCommandTest"/>
|
||||||
|
<class name="com.google.refine.extension.database.cmd.SavedConnectionCommandTest"/>
|
||||||
|
<class name="com.google.refine.extension.database.cmd.TestConnectCommandTest"/>
|
||||||
|
<class name="com.google.refine.extension.database.cmd.TestQueryCommandTest"/>
|
||||||
|
<class name="com.google.refine.extension.database.mariadb.MariaDBConnectionManagerTest"/>
|
||||||
|
<class name="com.google.refine.extension.database.mariadb.MariaDBDatabaseServiceTest"/>
|
||||||
|
<class name="com.google.refine.extension.database.mysql.MySQLConnectionManagerTest"/>
|
||||||
|
<class name="com.google.refine.extension.database.mysql.MySQLDatabaseServiceTest"/>
|
||||||
|
<class name="com.google.refine.extension.database.pgsql.PgSQLConnectionManagerTest"/>
|
||||||
|
<class name="com.google.refine.extension.database.pgsql.PgSQLDatabaseServiceTest" />
|
||||||
|
</classes>
|
||||||
|
</test>
|
||||||
|
</suite>
|
@ -1,42 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<suite name="DatabaseExtensionUnitTestSuite">
|
|
||||||
<parameter name = "mySqlDbName" value="test_db"/>
|
|
||||||
<parameter name = "mySqlDbHost" value="127.0.0.1"/>
|
|
||||||
<parameter name = "mySqlDbPort" value="3306"/>
|
|
||||||
<parameter name = "mySqlDbUser" value="root"/>
|
|
||||||
<parameter name = "mySqlDbPassword" value="secret"/>
|
|
||||||
<parameter name = "mySqlTestTable" value="test_table"/>
|
|
||||||
|
|
||||||
<parameter name = "pgSqlDbName" value="test_db"/>
|
|
||||||
<parameter name = "pgSqlDbHost" value="127.0.0.1"/>
|
|
||||||
<parameter name = "pgSqlDbPort" value="5432"/>
|
|
||||||
<parameter name = "pgSqlDbUser" value="postgres"/>
|
|
||||||
<parameter name = "pgSqlDbPassword" value=""/>
|
|
||||||
<parameter name = "pgSqlTestTable" value="test_table"/>
|
|
||||||
|
|
||||||
<parameter name = "mariaDbName" value="test_db"/>
|
|
||||||
<parameter name = "mariaDbHost" value="127.0.0.1"/>
|
|
||||||
<parameter name = "mariadbDbPort" value="3306"/>
|
|
||||||
<parameter name = "mariaDbUser" value="root"/>
|
|
||||||
<parameter name = "mariaDbPassword" value="secret"/>
|
|
||||||
<parameter name = "mariaDbTestTable" value="test_table"/>
|
|
||||||
<test name="DatabaseExtensionUnitTest">
|
|
||||||
<classes>
|
|
||||||
<class name="com.google.refine.extension.database.DatabaseTestConfig"/>
|
|
||||||
<class name="com.google.refine.extension.database.DatabaseImportControllerTest"/>
|
|
||||||
<class name="com.google.refine.extension.database.DatabaseServiceTest"/>
|
|
||||||
<class name="com.google.refine.extension.database.SimpleTextEncryptorTest"/>
|
|
||||||
<class name="com.google.refine.extension.database.cmd.ConnectCommandTest"/>
|
|
||||||
<class name="com.google.refine.extension.database.cmd.ExecuteQueryCommandTest"/>
|
|
||||||
<class name="com.google.refine.extension.database.cmd.SavedConnectionCommandTest"/>
|
|
||||||
<class name="com.google.refine.extension.database.cmd.TestConnectCommandTest"/>
|
|
||||||
<class name="com.google.refine.extension.database.cmd.TestQueryCommandTest"/>
|
|
||||||
<class name="com.google.refine.extension.database.mariadb.MariaDBConnectionManagerTest"/>
|
|
||||||
<class name="com.google.refine.extension.database.mariadb.MariaDBDatabaseServiceTest"/>
|
|
||||||
<class name="com.google.refine.extension.database.mysql.MySQLConnectionManagerTest"/>
|
|
||||||
<class name="com.google.refine.extension.database.mysql.MySQLDatabaseServiceTest"/>
|
|
||||||
<class name="com.google.refine.extension.database.pgsql.PgSQLConnectionManagerTest"/>
|
|
||||||
<class name="com.google.refine.extension.database.pgsql.PgSQLDatabaseServiceTest" />
|
|
||||||
</classes>
|
|
||||||
</test>
|
|
||||||
</suite>
|
|
Loading…
Reference in New Issue
Block a user