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
|
||||
- psql -c 'CREATE DATABASE test_db;' -U postgres
|
||||
- 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:
|
||||
- ./refine server_test
|
||||
|
38
appveyor.yml
38
appveyor.yml
@ -1,10 +1,15 @@
|
||||
version: 1.0.{build}
|
||||
|
||||
services:
|
||||
- mysql
|
||||
- postgresql96
|
||||
|
||||
init:
|
||||
- cmd: java -version 2>&1 | find "version"
|
||||
|
||||
clone_script:
|
||||
- cmd: git clone --recursive https://github.com/OpenRefine/OpenRefine
|
||||
clone_depth: 5
|
||||
skip_branch_with_pr: true
|
||||
|
||||
environment:
|
||||
ANT_HOME: C:\apache-ant-1.10.1
|
||||
JAVA_HOME: C:\Program Files (x86)\Java\jdk1.8.0
|
||||
@ -20,17 +25,24 @@ cache:
|
||||
- apache-ant-1.10.1-bin.zip
|
||||
build: off
|
||||
|
||||
# scripts to run before build
|
||||
before_build:
|
||||
# scripts to run before test
|
||||
before_test:
|
||||
- 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:
|
||||
# - cmd: >-
|
||||
# echo Running refine build...
|
||||
#
|
||||
# cd OpenRefine
|
||||
#
|
||||
# refine build
|
||||
copy extensions\database\test\conf\appveyor_tests.xml extensions\database\test\conf\tests.xml
|
||||
|
||||
test_script:
|
||||
- cmd: echo Running test_script...
|
||||
@ -39,8 +51,6 @@ test_script:
|
||||
|
||||
path
|
||||
|
||||
cd OpenRefine
|
||||
|
||||
refine server_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">
|
||||
<jacoco:coverage destfile="${test.report.dir}/jacoco.exec">
|
||||
<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">
|
||||
<xmlfileset file="${test.src.dir}/conf/int_tests.xml"/>
|
||||
<xmlfileset file="${test.src.dir}/conf/tests.xml"/>
|
||||
</testng>
|
||||
</jacoco:coverage>
|
||||
<jacoco:report>
|
||||
@ -126,34 +126,6 @@
|
||||
<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}"/>
|
||||
|
||||
|
@ -50,8 +50,11 @@ public class DBExtensionTestUtils {
|
||||
* Create Test Table with one row of Data
|
||||
* @param dbConfig DatabaseConfiguration to test
|
||||
* @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;
|
||||
Connection conn = null;
|
||||
@ -87,16 +90,11 @@ public class DBExtensionTestUtils {
|
||||
|
||||
logger.info("Database Test Init Data Created!!!");
|
||||
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
|
||||
} finally {
|
||||
if(stmt != null) {
|
||||
try {
|
||||
stmt.close();
|
||||
} catch (SQLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@ -104,7 +102,6 @@ public class DBExtensionTestUtils {
|
||||
try {
|
||||
conn.close();
|
||||
} catch (SQLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
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;
|
||||
Connection conn = null;
|
||||
@ -148,11 +146,7 @@ public class DBExtensionTestUtils {
|
||||
// System.out.println("Insert Data Result::" + insertResult);
|
||||
|
||||
logger.info("Database Test Init Data Created!!!");
|
||||
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
|
||||
|
||||
} finally {
|
||||
if(stmt != null) {
|
||||
try {
|
||||
@ -179,8 +173,11 @@ public class DBExtensionTestUtils {
|
||||
* Table name: test_data
|
||||
* @param sampleSize
|
||||
* @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>();
|
||||
mccMap = new HashMap<Integer, Integer>();
|
||||
mccMap.put(0, 302);
|
||||
@ -208,65 +205,56 @@ public class DBExtensionTestUtils {
|
||||
+ "id, ue_id, start_time, end_date, bytes_upload, bytes_download, cell_id, mcc, mnc, lac, imei)"
|
||||
+ " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);";
|
||||
|
||||
Connection conn;
|
||||
try {
|
||||
conn = DatabaseService.get(MYSQL_DB_NAME).getConnection(dc);
|
||||
Connection conn = DatabaseService.get(MYSQL_DB_NAME).getConnection(dc);
|
||||
|
||||
Statement truncateStmt = conn.createStatement();
|
||||
int result = truncateStmt.executeUpdate(truncateTableSQL);
|
||||
System.out.println("Truncate Table Result::" + result);
|
||||
truncateStmt.close();
|
||||
|
||||
|
||||
conn.setAutoCommit(false);
|
||||
|
||||
PreparedStatement stmt = conn.prepareStatement(insertTableSQL);
|
||||
|
||||
int counter=1;
|
||||
for (int i = 0; i < sampleSize; i++) {
|
||||
stmt.setLong(1, i);
|
||||
stmt.setString(2, getNextUeId());
|
||||
stmt.setDate(3, getNextStartDate());
|
||||
stmt.setDate(4, getNextEndDate());
|
||||
stmt.setInt(5, rand.nextInt());
|
||||
stmt.setInt(6, rand.nextInt());
|
||||
stmt.setInt(7, rand.nextInt(10));
|
||||
stmt.setInt(8, getMCC());
|
||||
stmt.setInt(9, getMNC());
|
||||
stmt.setInt(10, rand.nextInt(100));
|
||||
stmt.setString(11, getNextIMEI());
|
||||
|
||||
stmt.addBatch();
|
||||
|
||||
//Execute batch of 1000 records
|
||||
if(i%batchSize==0){
|
||||
stmt.executeBatch();
|
||||
conn.commit();
|
||||
System.out.println("Batch "+(counter++)+" executed successfully");
|
||||
}
|
||||
}
|
||||
//execute final batch
|
||||
stmt.executeBatch();
|
||||
System.out.println("Final Batch Executed "+(counter++)+" executed successfully");
|
||||
conn.commit();
|
||||
conn.close();
|
||||
Statement truncateStmt = conn.createStatement();
|
||||
int result = truncateStmt.executeUpdate(truncateTableSQL);
|
||||
System.out.println("Truncate Table Result::" + result);
|
||||
truncateStmt.close();
|
||||
|
||||
|
||||
conn.setAutoCommit(false);
|
||||
|
||||
PreparedStatement stmt = conn.prepareStatement(insertTableSQL);
|
||||
|
||||
int counter=1;
|
||||
for (int i = 0; i < sampleSize; i++) {
|
||||
stmt.setLong(1, i);
|
||||
stmt.setString(2, getNextUeId());
|
||||
stmt.setDate(3, getNextStartDate());
|
||||
stmt.setDate(4, getNextEndDate());
|
||||
stmt.setInt(5, rand.nextInt());
|
||||
stmt.setInt(6, rand.nextInt());
|
||||
stmt.setInt(7, rand.nextInt(10));
|
||||
stmt.setInt(8, getMCC());
|
||||
stmt.setInt(9, getMNC());
|
||||
stmt.setInt(10, rand.nextInt(100));
|
||||
stmt.setString(11, getNextIMEI());
|
||||
|
||||
} catch (DatabaseServiceException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (SQLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
stmt.addBatch();
|
||||
|
||||
//Execute batch of 1000 records
|
||||
if(i%batchSize==0){
|
||||
stmt.executeBatch();
|
||||
conn.commit();
|
||||
System.out.println("Batch "+(counter++)+" executed successfully");
|
||||
}
|
||||
}
|
||||
|
||||
//execute final batch
|
||||
stmt.executeBatch();
|
||||
System.out.println("Final Batch Executed "+(counter++)+" executed successfully");
|
||||
conn.commit();
|
||||
conn.close();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param sampleSize
|
||||
* @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>();
|
||||
mccMap = new HashMap<Integer, Integer>();
|
||||
mccMap.put(0, 302);
|
||||
@ -294,56 +282,46 @@ public class DBExtensionTestUtils {
|
||||
+ "id, ue_id, start_time, end_date, bytes_upload, bytes_download, cell_id, mcc, mnc, lac, imei)"
|
||||
+ " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);";
|
||||
|
||||
Connection conn;
|
||||
try {
|
||||
conn = DatabaseService.get(PGSQL_DB_NAME).getConnection(dc);
|
||||
Connection conn = DatabaseService.get(PGSQL_DB_NAME).getConnection(dc);
|
||||
|
||||
Statement truncateStmt = conn.createStatement();
|
||||
int result = truncateStmt.executeUpdate(truncateTableSQL);
|
||||
System.out.println("Truncate Table Result::" + result);
|
||||
truncateStmt.close();
|
||||
|
||||
|
||||
conn.setAutoCommit(false);
|
||||
|
||||
PreparedStatement stmt = conn.prepareStatement(insertTableSQL);
|
||||
|
||||
int counter=1;
|
||||
for (int i = 0; i < sampleSize; i++) {
|
||||
stmt.setLong(1, i);
|
||||
stmt.setString(2, getNextUeId());
|
||||
stmt.setDate(3, getNextStartDate());
|
||||
stmt.setDate(4, getNextEndDate());
|
||||
stmt.setInt(5, rand.nextInt());
|
||||
stmt.setInt(6, rand.nextInt());
|
||||
stmt.setInt(7, rand.nextInt(10));
|
||||
stmt.setInt(8, getMCC());
|
||||
stmt.setInt(9, getMNC());
|
||||
stmt.setInt(10, rand.nextInt(100));
|
||||
stmt.setString(11, getNextIMEI());
|
||||
|
||||
stmt.addBatch();
|
||||
|
||||
//Execute batch of 1000 records
|
||||
if(i%batchSize==0){
|
||||
stmt.executeBatch();
|
||||
conn.commit();
|
||||
System.out.println("Batch "+(counter++)+" executed successfully");
|
||||
}
|
||||
}
|
||||
//execute final batch
|
||||
stmt.executeBatch();
|
||||
System.out.println("Final Batch Executed "+(counter++)+" executed successfully");
|
||||
conn.commit();
|
||||
conn.close();
|
||||
Statement truncateStmt = conn.createStatement();
|
||||
int result = truncateStmt.executeUpdate(truncateTableSQL);
|
||||
System.out.println("Truncate Table Result::" + result);
|
||||
truncateStmt.close();
|
||||
|
||||
|
||||
conn.setAutoCommit(false);
|
||||
|
||||
PreparedStatement stmt = conn.prepareStatement(insertTableSQL);
|
||||
|
||||
int counter=1;
|
||||
for (int i = 0; i < sampleSize; i++) {
|
||||
stmt.setLong(1, i);
|
||||
stmt.setString(2, getNextUeId());
|
||||
stmt.setDate(3, getNextStartDate());
|
||||
stmt.setDate(4, getNextEndDate());
|
||||
stmt.setInt(5, rand.nextInt());
|
||||
stmt.setInt(6, rand.nextInt());
|
||||
stmt.setInt(7, rand.nextInt(10));
|
||||
stmt.setInt(8, getMCC());
|
||||
stmt.setInt(9, getMNC());
|
||||
stmt.setInt(10, rand.nextInt(100));
|
||||
stmt.setString(11, getNextIMEI());
|
||||
|
||||
} catch (DatabaseServiceException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (SQLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
stmt.addBatch();
|
||||
|
||||
//Execute batch of 1000 records
|
||||
if(i%batchSize==0){
|
||||
stmt.executeBatch();
|
||||
conn.commit();
|
||||
System.out.println("Batch "+(counter++)+" executed successfully");
|
||||
}
|
||||
}
|
||||
//execute final batch
|
||||
stmt.executeBatch();
|
||||
System.out.println("Final Batch Executed "+(counter++)+" executed successfully");
|
||||
conn.commit();
|
||||
conn.close();
|
||||
|
||||
}
|
||||
|
||||
@ -381,7 +359,7 @@ public class DBExtensionTestUtils {
|
||||
return "" + n;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
public static void main(String[] args) throws DatabaseServiceException, SQLException {
|
||||
DBExtensionTestUtils testUtil = new DBExtensionTestUtils();
|
||||
testUtil.generatePgSQLTestData(SAMPLE_SIZE, BATCH_SIZE);
|
||||
// testUtil.generateMySQLTestData();
|
||||
@ -404,7 +382,7 @@ public class DBExtensionTestUtils {
|
||||
//System.out.println("Drop Table Result::" + dropResult);
|
||||
}
|
||||
|
||||
logger.info("Database Test Cleanup Done!!!");
|
||||
logger.info("Database Test Cleanup Done");
|
||||
|
||||
} catch (DatabaseServiceException e) {
|
||||
// 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;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
|
||||
public class DBExtensionTests {
|
||||
@ -60,14 +62,9 @@ public class DBExtensionTests {
|
||||
protected final String DEFAULT_MARIADB_NAME = "testdb";
|
||||
|
||||
protected final String DEFAULT_TEST_TABLE = "test_data";
|
||||
|
||||
protected Properties properties;
|
||||
|
||||
protected Logger logger;
|
||||
|
||||
// @BeforeSuite
|
||||
// public void init() {
|
||||
// System.out.println("Log4j init...");
|
||||
// System.setProperty("log4j.configuration", "log4j-test.properties");
|
||||
// }
|
||||
|
||||
protected Logger logger;
|
||||
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
@ -35,7 +36,7 @@ import com.google.refine.model.Project;
|
||||
|
||||
|
||||
|
||||
|
||||
@Test(groups = { "requiresMySQL" })
|
||||
public class DatabaseImportControllerTest extends DBExtensionTests{
|
||||
|
||||
@Mock
|
||||
@ -118,141 +119,114 @@ public class DatabaseImportControllerTest extends DBExtensionTests{
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDoPostInvalidSubCommand() {
|
||||
public void testDoPostInvalidSubCommand() throws IOException, ServletException, JSONException {
|
||||
StringWriter sw = new StringWriter();
|
||||
PrintWriter pw = new PrintWriter(sw);
|
||||
try {
|
||||
when(request.getQueryString()).thenReturn(
|
||||
"http://127.0.0.1:3333/command/core/importing-controller?controller=database/database-import-controller&subCommand=invalid-sub-command");
|
||||
|
||||
when(response.getWriter()).thenReturn(pw);
|
||||
//test
|
||||
SUT.doPost(request, response);
|
||||
|
||||
String result = sw.getBuffer().toString().trim();
|
||||
JSONObject json = new JSONObject(result);
|
||||
|
||||
String code = json.getString("status");
|
||||
String message = json.getString("message");
|
||||
Assert.assertNotNull(code);
|
||||
Assert.assertNotNull(message);
|
||||
Assert.assertEquals(code, "error");
|
||||
Assert.assertEquals(message, "No such sub command");
|
||||
|
||||
when(request.getQueryString()).thenReturn(
|
||||
"http://127.0.0.1:3333/command/core/importing-controller?controller=database/database-import-controller&subCommand=invalid-sub-command");
|
||||
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
when(response.getWriter()).thenReturn(pw);
|
||||
//test
|
||||
SUT.doPost(request, response);
|
||||
|
||||
String result = sw.getBuffer().toString().trim();
|
||||
JSONObject json = new JSONObject(result);
|
||||
|
||||
String code = json.getString("status");
|
||||
String message = json.getString("message");
|
||||
Assert.assertNotNull(code);
|
||||
Assert.assertNotNull(message);
|
||||
Assert.assertEquals(code, "error");
|
||||
Assert.assertEquals(message, "No such sub command");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void testDoPostInitializeParser() {
|
||||
public void testDoPostInitializeParser() throws ServletException, IOException, JSONException {
|
||||
|
||||
StringWriter sw = new StringWriter();
|
||||
PrintWriter pw = new PrintWriter(sw);
|
||||
|
||||
try {
|
||||
when(request.getQueryString()).thenReturn(
|
||||
"http://127.0.0.1:3333/command/core/importing-controller?controller=database/database-import-controller&subCommand=initialize-parser-ui");
|
||||
when(response.getWriter()).thenReturn(pw);
|
||||
|
||||
SUT.doPost(request, response);
|
||||
|
||||
String result = sw.getBuffer().toString().trim();
|
||||
JSONObject json = new JSONObject(result);
|
||||
when(request.getQueryString()).thenReturn(
|
||||
"http://127.0.0.1:3333/command/core/importing-controller?controller=database/database-import-controller&subCommand=initialize-parser-ui");
|
||||
when(response.getWriter()).thenReturn(pw);
|
||||
|
||||
SUT.doPost(request, response);
|
||||
|
||||
String status = json.getString("status");
|
||||
//System.out.println("json::" + json);
|
||||
Assert.assertEquals(status, "ok");
|
||||
String result = sw.getBuffer().toString().trim();
|
||||
JSONObject json = new JSONObject(result);
|
||||
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
String status = json.getString("status");
|
||||
//System.out.println("json::" + json);
|
||||
Assert.assertEquals(status, "ok");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDoPostParsePreview() {
|
||||
public void testDoPostParsePreview() throws IOException, ServletException, JSONException {
|
||||
|
||||
StringWriter sw = new StringWriter();
|
||||
PrintWriter pw = new PrintWriter(sw);
|
||||
|
||||
try {
|
||||
|
||||
long jobId = job.id;
|
||||
|
||||
when(request.getQueryString()).thenReturn(
|
||||
"http://127.0.0.1:3333/command/core/importing-controller?controller=database%2Fdatabase-import-controller&jobID="
|
||||
+ jobId + "&subCommand=parse-preview");
|
||||
when(response.getWriter()).thenReturn(pw);
|
||||
|
||||
|
||||
when(request.getParameter("databaseType")).thenReturn(testDbConfig.getDatabaseType());
|
||||
when(request.getParameter("databaseServer")).thenReturn(testDbConfig.getDatabaseHost());
|
||||
when(request.getParameter("databasePort")).thenReturn("" + testDbConfig.getDatabasePort());
|
||||
when(request.getParameter("databaseUser")).thenReturn(testDbConfig.getDatabaseUser());
|
||||
when(request.getParameter("databasePassword")).thenReturn(testDbConfig.getDatabasePassword());
|
||||
when(request.getParameter("initialDatabase")).thenReturn(testDbConfig.getDatabaseName());
|
||||
when(request.getParameter("query")).thenReturn(query);
|
||||
when(request.getParameter("options")).thenReturn(JSON_OPTION);
|
||||
|
||||
SUT.doPost(request, response);
|
||||
|
||||
String result = sw.getBuffer().toString().trim();
|
||||
JSONObject json = new JSONObject(result);
|
||||
|
||||
String status = json.getString("status");
|
||||
//System.out.println("json::" + json);
|
||||
Assert.assertEquals(status, "ok");
|
||||
long jobId = job.id;
|
||||
|
||||
when(request.getQueryString()).thenReturn(
|
||||
"http://127.0.0.1:3333/command/core/importing-controller?controller=database%2Fdatabase-import-controller&jobID="
|
||||
+ jobId + "&subCommand=parse-preview");
|
||||
when(response.getWriter()).thenReturn(pw);
|
||||
|
||||
|
||||
when(request.getParameter("databaseType")).thenReturn(testDbConfig.getDatabaseType());
|
||||
when(request.getParameter("databaseServer")).thenReturn(testDbConfig.getDatabaseHost());
|
||||
when(request.getParameter("databasePort")).thenReturn("" + testDbConfig.getDatabasePort());
|
||||
when(request.getParameter("databaseUser")).thenReturn(testDbConfig.getDatabaseUser());
|
||||
when(request.getParameter("databasePassword")).thenReturn(testDbConfig.getDatabasePassword());
|
||||
when(request.getParameter("initialDatabase")).thenReturn(testDbConfig.getDatabaseName());
|
||||
when(request.getParameter("query")).thenReturn(query);
|
||||
when(request.getParameter("options")).thenReturn(JSON_OPTION);
|
||||
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
SUT.doPost(request, response);
|
||||
|
||||
String result = sw.getBuffer().toString().trim();
|
||||
JSONObject json = new JSONObject(result);
|
||||
|
||||
String status = json.getString("status");
|
||||
//System.out.println("json::" + json);
|
||||
Assert.assertEquals(status, "ok");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDoPostCreateProject() {
|
||||
public void testDoPostCreateProject() throws IOException, ServletException, JSONException {
|
||||
|
||||
StringWriter sw = new StringWriter();
|
||||
PrintWriter pw = new PrintWriter(sw);
|
||||
|
||||
try {
|
||||
|
||||
long jobId = job.id;
|
||||
|
||||
when(request.getQueryString()).thenReturn(
|
||||
"http://127.0.0.1:3333/command/core/importing-controller?controller=database%2Fdatabase-import-controller&jobID="
|
||||
+ jobId + "&subCommand=create-project");
|
||||
when(response.getWriter()).thenReturn(pw);
|
||||
|
||||
|
||||
when(request.getParameter("databaseType")).thenReturn(testDbConfig.getDatabaseType());
|
||||
when(request.getParameter("databaseServer")).thenReturn(testDbConfig.getDatabaseHost());
|
||||
when(request.getParameter("databasePort")).thenReturn("" + testDbConfig.getDatabasePort());
|
||||
when(request.getParameter("databaseUser")).thenReturn(testDbConfig.getDatabaseUser());
|
||||
when(request.getParameter("databasePassword")).thenReturn(testDbConfig.getDatabasePassword());
|
||||
when(request.getParameter("initialDatabase")).thenReturn(testDbConfig.getDatabaseName());
|
||||
when(request.getParameter("query")).thenReturn(query);
|
||||
when(request.getParameter("options")).thenReturn(JSON_OPTION);
|
||||
|
||||
|
||||
SUT.doPost(request, response);
|
||||
|
||||
String result = sw.getBuffer().toString().trim();
|
||||
JSONObject json = new JSONObject(result);
|
||||
long jobId = job.id;
|
||||
|
||||
when(request.getQueryString()).thenReturn(
|
||||
"http://127.0.0.1:3333/command/core/importing-controller?controller=database%2Fdatabase-import-controller&jobID="
|
||||
+ jobId + "&subCommand=create-project");
|
||||
when(response.getWriter()).thenReturn(pw);
|
||||
|
||||
|
||||
when(request.getParameter("databaseType")).thenReturn(testDbConfig.getDatabaseType());
|
||||
when(request.getParameter("databaseServer")).thenReturn(testDbConfig.getDatabaseHost());
|
||||
when(request.getParameter("databasePort")).thenReturn("" + testDbConfig.getDatabasePort());
|
||||
when(request.getParameter("databaseUser")).thenReturn(testDbConfig.getDatabaseUser());
|
||||
when(request.getParameter("databasePassword")).thenReturn(testDbConfig.getDatabasePassword());
|
||||
when(request.getParameter("initialDatabase")).thenReturn(testDbConfig.getDatabaseName());
|
||||
when(request.getParameter("query")).thenReturn(query);
|
||||
when(request.getParameter("options")).thenReturn(JSON_OPTION);
|
||||
|
||||
|
||||
String status = json.getString("status");
|
||||
//System.out.println("json::" + json);
|
||||
Assert.assertEquals(status, "ok");
|
||||
SUT.doPost(request, response);
|
||||
|
||||
String result = sw.getBuffer().toString().trim();
|
||||
JSONObject json = new JSONObject(result);
|
||||
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
String status = json.getString("status");
|
||||
//System.out.println("json::" + json);
|
||||
Assert.assertEquals(status, "ok");
|
||||
}
|
||||
|
||||
@BeforeTest
|
||||
|
@ -62,16 +62,14 @@ public class DatabaseServiceTest extends DBExtensionTests{
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
@Test(groups = {"requiresPgSQL"})
|
||||
public void testGetPgSQLDBService() {
|
||||
|
||||
DatabaseService dbService = DatabaseService.get(PgSQLDatabaseService.DB_NAME);
|
||||
Assert.assertNotNull(dbService);
|
||||
Assert.assertEquals(dbService.getClass(), PgSQLDatabaseService.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Test(groups = {"requiresMySQL"})
|
||||
public void testGetMySQLDBService() {
|
||||
|
||||
DatabaseService dbService = DatabaseService.get(MySQLDatabaseService.DB_NAME);
|
||||
@ -79,7 +77,7 @@ public class DatabaseServiceTest extends DBExtensionTests{
|
||||
Assert.assertEquals(dbService.getClass(), MySQLDatabaseService.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Test(groups = {"requiresMariaDB"})
|
||||
public void testGetMariaDBSQLDBService() {
|
||||
|
||||
DatabaseService dbService = DatabaseService.get(MariaDBDatabaseService.DB_NAME);
|
||||
@ -87,64 +85,34 @@ public class DatabaseServiceTest extends DBExtensionTests{
|
||||
Assert.assertEquals(dbService.getClass(), MariaDBDatabaseService.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetConnection() {
|
||||
|
||||
try {
|
||||
|
||||
DatabaseService dbService = DatabaseService.get(testDbConfig.getDatabaseType());
|
||||
Connection conn = dbService.getConnection(testDbConfig);
|
||||
Assert.assertNotNull(conn);
|
||||
|
||||
} catch (DatabaseServiceException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
@Test(groups = {"requiresMySQL"})
|
||||
public void testGetConnection() throws DatabaseServiceException {
|
||||
DatabaseService dbService = DatabaseService.get(testDbConfig.getDatabaseType());
|
||||
Connection conn = dbService.getConnection(testDbConfig);
|
||||
Assert.assertNotNull(conn);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTestConnection() {
|
||||
|
||||
try {
|
||||
DatabaseService dbService = DatabaseService.get(testDbConfig.getDatabaseType());
|
||||
boolean result = dbService.testConnection(testDbConfig);
|
||||
Assert.assertEquals(result, true);
|
||||
|
||||
} catch (DatabaseServiceException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@Test(groups = {"requiresMySQL"})
|
||||
public void testTestConnection() throws DatabaseServiceException {
|
||||
DatabaseService dbService = DatabaseService.get(testDbConfig.getDatabaseType());
|
||||
boolean result = dbService.testConnection(testDbConfig);
|
||||
Assert.assertEquals(result, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConnect() {
|
||||
|
||||
try {
|
||||
DatabaseService dbService = DatabaseService.get(testDbConfig.getDatabaseType());
|
||||
DatabaseInfo databaseInfo = dbService.connect(testDbConfig);
|
||||
Assert.assertNotNull(databaseInfo);
|
||||
|
||||
} catch (DatabaseServiceException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@Test(groups = {"requiresMySQL"})
|
||||
public void testConnect() throws DatabaseServiceException {
|
||||
DatabaseService dbService = DatabaseService.get(testDbConfig.getDatabaseType());
|
||||
DatabaseInfo databaseInfo = dbService.connect(testDbConfig);
|
||||
Assert.assertNotNull(databaseInfo);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExecuteQuery() {
|
||||
@Test(groups = {"requiresMySQL"})
|
||||
public void testExecuteQuery() throws DatabaseServiceException {
|
||||
DatabaseService dbService = DatabaseService.get(testDbConfig.getDatabaseType());
|
||||
DatabaseInfo databaseInfo = dbService.testQuery(testDbConfig,
|
||||
"SELECT * FROM " + testTable);
|
||||
|
||||
try {
|
||||
DatabaseService dbService = DatabaseService.get(testDbConfig.getDatabaseType());
|
||||
DatabaseInfo databaseInfo = dbService.testQuery(testDbConfig,
|
||||
"SELECT * FROM " + testTable);
|
||||
|
||||
Assert.assertNotNull(databaseInfo);
|
||||
|
||||
} catch (DatabaseServiceException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
Assert.assertNotNull(databaseInfo);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -157,44 +125,26 @@ public class DatabaseServiceTest extends DBExtensionTests{
|
||||
Assert.assertEquals(limitQuery, "SELECT * FROM " + testTable + " LIMIT " + 100 + " OFFSET " + 0 + ";");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetColumns() {
|
||||
@Test(groups = {"requiresMySQL"})
|
||||
public void testGetColumns() throws DatabaseServiceException {
|
||||
List<DatabaseColumn> dbColumns;
|
||||
|
||||
try {
|
||||
DatabaseService dbService = DatabaseService.get(testDbConfig.getDatabaseType());
|
||||
dbColumns = dbService.getColumns(testDbConfig,"SELECT * FROM " + testTable);
|
||||
Assert.assertNotNull(dbColumns);
|
||||
|
||||
int cols = dbColumns.size();
|
||||
Assert.assertEquals(cols, 10);
|
||||
|
||||
|
||||
} catch (DatabaseServiceException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
DatabaseService dbService = DatabaseService.get(testDbConfig.getDatabaseType());
|
||||
dbColumns = dbService.getColumns(testDbConfig,"SELECT * FROM " + testTable);
|
||||
Assert.assertNotNull(dbColumns);
|
||||
|
||||
|
||||
int cols = dbColumns.size();
|
||||
Assert.assertEquals(cols, 10);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetRows() {
|
||||
@Test(groups = {"requiresMySQL"})
|
||||
public void testGetRows() throws DatabaseServiceException {
|
||||
DatabaseService dbService = DatabaseService.get(testDbConfig.getDatabaseType());
|
||||
List<DatabaseRow> dbRows = dbService.getRows(testDbConfig,
|
||||
"SELECT * FROM " + testTable);
|
||||
|
||||
try {
|
||||
|
||||
DatabaseService dbService = DatabaseService.get(testDbConfig.getDatabaseType());
|
||||
List<DatabaseRow> dbRows = dbService.getRows(testDbConfig,
|
||||
"SELECT * FROM " + testTable);
|
||||
|
||||
Assert.assertNotNull(dbRows);
|
||||
Assert.assertEquals(dbRows.size(), 1);
|
||||
|
||||
} catch (DatabaseServiceException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
Assert.assertNotNull(dbRows);
|
||||
Assert.assertEquals(dbRows.size(), 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package com.google.refine.extension.database;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.testng.annotations.AfterSuite;
|
||||
import org.testng.annotations.BeforeSuite;
|
||||
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_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");
|
||||
mysqlDbConfig = new DatabaseConfiguration();
|
||||
|
@ -3,12 +3,15 @@ package com.google.refine.extension.database.cmd;
|
||||
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
@ -24,6 +27,7 @@ import com.google.refine.extension.database.DatabaseService;
|
||||
import com.google.refine.extension.database.mysql.MySQLDatabaseService;
|
||||
|
||||
|
||||
@Test(groups = { "requiresMySQL" })
|
||||
public class ConnectCommandTest extends DBExtensionTests {
|
||||
|
||||
|
||||
@ -63,7 +67,7 @@ public class ConnectCommandTest extends DBExtensionTests {
|
||||
|
||||
|
||||
@Test
|
||||
public void testDoPost() {
|
||||
public void testDoPost() throws IOException, ServletException, JSONException {
|
||||
|
||||
when(request.getParameter("databaseType")).thenReturn(MySQLDatabaseService.DB_NAME);
|
||||
when(request.getParameter("databaseServer")).thenReturn(testDbConfig.getDatabaseHost());
|
||||
@ -75,26 +79,19 @@ public class ConnectCommandTest extends DBExtensionTests {
|
||||
StringWriter sw = new StringWriter();
|
||||
PrintWriter pw = new PrintWriter(sw);
|
||||
|
||||
try {
|
||||
when(response.getWriter()).thenReturn(pw);
|
||||
ConnectCommand connectCommand = new ConnectCommand();
|
||||
|
||||
connectCommand.doPost(request, response);
|
||||
|
||||
String result = sw.getBuffer().toString().trim();
|
||||
JSONObject json = new JSONObject(result);
|
||||
when(response.getWriter()).thenReturn(pw);
|
||||
ConnectCommand connectCommand = new ConnectCommand();
|
||||
|
||||
String code = json.getString("code");
|
||||
Assert.assertEquals(code, "ok");
|
||||
|
||||
String databaseInfo = json.getString("databaseInfo");
|
||||
Assert.assertNotNull(databaseInfo);
|
||||
connectCommand.doPost(request, response);
|
||||
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
String result = sw.getBuffer().toString().trim();
|
||||
JSONObject json = new JSONObject(result);
|
||||
|
||||
String code = json.getString("code");
|
||||
Assert.assertEquals(code, "ok");
|
||||
|
||||
String databaseInfo = json.getString("databaseInfo");
|
||||
Assert.assertNotNull(databaseInfo);
|
||||
}
|
||||
|
||||
|
||||
|
@ -2,12 +2,15 @@ package com.google.refine.extension.database.cmd;
|
||||
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.mockito.Mock;
|
||||
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.mysql.MySQLDatabaseService;
|
||||
|
||||
|
||||
@Test(groups = { "requiresMySQL" })
|
||||
public class ExecuteQueryCommandTest extends DBExtensionTests {
|
||||
|
||||
@Mock
|
||||
@ -60,7 +63,7 @@ public class ExecuteQueryCommandTest extends DBExtensionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDoPost() {
|
||||
public void testDoPost() throws IOException, ServletException, JSONException {
|
||||
|
||||
when(request.getParameter("databaseType")).thenReturn(testDbConfig.getDatabaseType());
|
||||
when(request.getParameter("databaseServer")).thenReturn(testDbConfig.getDatabaseHost());
|
||||
@ -74,27 +77,20 @@ public class ExecuteQueryCommandTest extends DBExtensionTests {
|
||||
StringWriter sw = new StringWriter();
|
||||
|
||||
PrintWriter pw = new PrintWriter(sw);
|
||||
|
||||
try {
|
||||
when(response.getWriter()).thenReturn(pw);
|
||||
ExecuteQueryCommand executeQueryCommand = new ExecuteQueryCommand();
|
||||
|
||||
executeQueryCommand.doPost(request, response);
|
||||
|
||||
String result = sw.getBuffer().toString().trim();
|
||||
JSONObject json = new JSONObject(result);
|
||||
|
||||
String code = json.getString("code");
|
||||
Assert.assertEquals(code, "ok");
|
||||
|
||||
String queryResult = json.getString("QueryResult");
|
||||
Assert.assertNotNull(queryResult);
|
||||
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
when(response.getWriter()).thenReturn(pw);
|
||||
ExecuteQueryCommand executeQueryCommand = new ExecuteQueryCommand();
|
||||
|
||||
executeQueryCommand.doPost(request, response);
|
||||
|
||||
String result = sw.getBuffer().toString().trim();
|
||||
JSONObject json = new JSONObject(result);
|
||||
|
||||
String code = json.getString("code");
|
||||
Assert.assertEquals(code, "ok");
|
||||
|
||||
String queryResult = json.getString("QueryResult");
|
||||
Assert.assertNotNull(queryResult);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
@ -135,7 +136,7 @@ public class SavedConnectionCommandTest extends DBExtensionTests{
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDoPost() {
|
||||
public void testDoPost() throws IOException, ServletException, JSONException {
|
||||
|
||||
when(request.getParameter("connectionName")).thenReturn("test-db-name");
|
||||
when(request.getParameter("databaseType")).thenReturn(MySQLDatabaseService.DB_NAME);
|
||||
@ -148,33 +149,24 @@ public class SavedConnectionCommandTest extends DBExtensionTests{
|
||||
StringWriter sw = new StringWriter();
|
||||
PrintWriter pw = new PrintWriter(sw);
|
||||
|
||||
try {
|
||||
when(response.getWriter()).thenReturn(pw);
|
||||
|
||||
SUT.doPost(request, response);
|
||||
|
||||
String result = sw.getBuffer().toString().trim();
|
||||
|
||||
JSONObject json = new JSONObject(result);
|
||||
|
||||
JSONArray savedConnections = json.getJSONArray("savedConnections");
|
||||
Assert.assertNotNull(savedConnections);
|
||||
|
||||
int len = savedConnections.length();
|
||||
|
||||
Assert.assertEquals(len, 1);
|
||||
|
||||
|
||||
when(response.getWriter()).thenReturn(pw);
|
||||
|
||||
SUT.doPost(request, response);
|
||||
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
String result = sw.getBuffer().toString().trim();
|
||||
|
||||
JSONObject json = new JSONObject(result);
|
||||
|
||||
JSONArray savedConnections = json.getJSONArray("savedConnections");
|
||||
Assert.assertNotNull(savedConnections);
|
||||
|
||||
int len = savedConnections.length();
|
||||
|
||||
Assert.assertEquals(len, 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDoGet() {
|
||||
public void testDoGet() throws IOException, ServletException, JSONException {
|
||||
String testDbName = "testLocalDb";
|
||||
//add saved connection
|
||||
saveDatabaseConfiguration(testDbName);
|
||||
@ -191,32 +183,25 @@ public class SavedConnectionCommandTest extends DBExtensionTests{
|
||||
StringWriter sw = new StringWriter();
|
||||
PrintWriter pw = new PrintWriter(sw);
|
||||
|
||||
try {
|
||||
when(response.getWriter()).thenReturn(pw);
|
||||
|
||||
SUT.doGet(request, response);
|
||||
|
||||
JSONObject json = new JSONObject(sw.getBuffer().toString().trim());
|
||||
|
||||
JSONArray savedConnections = json.getJSONArray("savedConnections");
|
||||
Assert.assertNotNull(savedConnections);
|
||||
|
||||
Assert.assertEquals(savedConnections.length(), 1);
|
||||
|
||||
JSONObject sc = (JSONObject)savedConnections.get(0);
|
||||
// System.out.println("sc" + sc);
|
||||
String connName = sc.getString("connectionName");
|
||||
Assert.assertEquals(connName, testDbName);
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
when(response.getWriter()).thenReturn(pw);
|
||||
|
||||
SUT.doGet(request, response);
|
||||
|
||||
JSONObject json = new JSONObject(sw.getBuffer().toString().trim());
|
||||
|
||||
JSONArray savedConnections = json.getJSONArray("savedConnections");
|
||||
Assert.assertNotNull(savedConnections);
|
||||
|
||||
Assert.assertEquals(savedConnections.length(), 1);
|
||||
|
||||
JSONObject sc = (JSONObject)savedConnections.get(0);
|
||||
// System.out.println("sc" + sc);
|
||||
String connName = sc.getString("connectionName");
|
||||
Assert.assertEquals(connName, testDbName);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDoPut() {
|
||||
public void testDoPut() throws IOException, ServletException, JSONException {
|
||||
String testDbName = "testLocalDb";
|
||||
saveDatabaseConfiguration(testDbName);
|
||||
|
||||
@ -224,37 +209,30 @@ public class SavedConnectionCommandTest extends DBExtensionTests{
|
||||
StringWriter sw = new StringWriter();
|
||||
PrintWriter pw = new PrintWriter(sw);
|
||||
|
||||
try {
|
||||
when(response.getWriter()).thenReturn(pw);
|
||||
|
||||
//modify database config
|
||||
String newHost = "localhost";
|
||||
when(request.getParameter("connectionName")).thenReturn(testDbName);
|
||||
when(request.getParameter("databaseType")).thenReturn(MySQLDatabaseService.DB_NAME);
|
||||
when(request.getParameter("databaseServer")).thenReturn(newHost);
|
||||
when(request.getParameter("databasePort")).thenReturn("" + testDbConfig.getDatabasePort());
|
||||
when(request.getParameter("databaseUser")).thenReturn(testDbConfig.getDatabaseUser());
|
||||
when(request.getParameter("databasePassword")).thenReturn(testDbConfig.getDatabasePassword());
|
||||
when(request.getParameter("initialDatabase")).thenReturn(testDbConfig.getDatabaseName());
|
||||
|
||||
SUT.doPut(request, response);
|
||||
|
||||
JSONObject json = new JSONObject(sw.getBuffer().toString().trim());
|
||||
JSONArray savedConnections = json.getJSONArray("savedConnections");
|
||||
Assert.assertNotNull(savedConnections);
|
||||
|
||||
Assert.assertEquals(savedConnections.length(), 1);
|
||||
|
||||
JSONObject sc = (JSONObject)savedConnections.get(0);
|
||||
System.out.println("sc" + sc);
|
||||
String newDbHost = sc.getString("databaseHost");
|
||||
Assert.assertEquals(newDbHost, newHost);
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
when(response.getWriter()).thenReturn(pw);
|
||||
|
||||
//modify database config
|
||||
String newHost = "localhost";
|
||||
when(request.getParameter("connectionName")).thenReturn(testDbName);
|
||||
when(request.getParameter("databaseType")).thenReturn(MySQLDatabaseService.DB_NAME);
|
||||
when(request.getParameter("databaseServer")).thenReturn(newHost);
|
||||
when(request.getParameter("databasePort")).thenReturn("" + testDbConfig.getDatabasePort());
|
||||
when(request.getParameter("databaseUser")).thenReturn(testDbConfig.getDatabaseUser());
|
||||
when(request.getParameter("databasePassword")).thenReturn(testDbConfig.getDatabasePassword());
|
||||
when(request.getParameter("initialDatabase")).thenReturn(testDbConfig.getDatabaseName());
|
||||
|
||||
SUT.doPut(request, response);
|
||||
|
||||
JSONObject json = new JSONObject(sw.getBuffer().toString().trim());
|
||||
JSONArray savedConnections = json.getJSONArray("savedConnections");
|
||||
Assert.assertNotNull(savedConnections);
|
||||
|
||||
Assert.assertEquals(savedConnections.length(), 1);
|
||||
|
||||
JSONObject sc = (JSONObject)savedConnections.get(0);
|
||||
System.out.println("sc" + sc);
|
||||
String newDbHost = sc.getString("databaseHost");
|
||||
Assert.assertEquals(newDbHost, newHost);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -2,12 +2,15 @@ package com.google.refine.extension.database.cmd;
|
||||
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
@ -23,7 +26,7 @@ import com.google.refine.extension.database.DatabaseService;
|
||||
import com.google.refine.extension.database.mysql.MySQLDatabaseService;
|
||||
|
||||
|
||||
|
||||
@Test(groups = { "requiresMySQL" })
|
||||
public class TestConnectCommandTest extends DBExtensionTests{
|
||||
|
||||
@Mock
|
||||
@ -63,7 +66,7 @@ public class TestConnectCommandTest extends DBExtensionTests{
|
||||
|
||||
|
||||
@Test
|
||||
public void testDoPost() {
|
||||
public void testDoPost() throws IOException, ServletException, JSONException {
|
||||
|
||||
when(request.getParameter("databaseType")).thenReturn(MySQLDatabaseService.DB_NAME);
|
||||
when(request.getParameter("databaseServer")).thenReturn(testDbConfig.getDatabaseHost());
|
||||
@ -77,23 +80,16 @@ public class TestConnectCommandTest extends DBExtensionTests{
|
||||
|
||||
PrintWriter pw = new PrintWriter(sw);
|
||||
|
||||
try {
|
||||
when(response.getWriter()).thenReturn(pw);
|
||||
TestConnectCommand connectCommand = new TestConnectCommand();
|
||||
|
||||
connectCommand.doPost(request, response);
|
||||
|
||||
String result = sw.getBuffer().toString().trim();
|
||||
JSONObject json = new JSONObject(result);
|
||||
when(response.getWriter()).thenReturn(pw);
|
||||
TestConnectCommand connectCommand = new TestConnectCommand();
|
||||
|
||||
String code = json.getString("code");
|
||||
Assert.assertEquals(code, "ok");
|
||||
|
||||
connectCommand.doPost(request, response);
|
||||
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
String result = sw.getBuffer().toString().trim();
|
||||
JSONObject json = new JSONObject(result);
|
||||
|
||||
String code = json.getString("code");
|
||||
Assert.assertEquals(code, "ok");
|
||||
|
||||
}
|
||||
|
||||
|
@ -2,12 +2,15 @@ package com.google.refine.extension.database.cmd;
|
||||
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.mockito.Mock;
|
||||
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.mysql.MySQLDatabaseService;
|
||||
|
||||
|
||||
@Test(groups = { "requiresMySQL" })
|
||||
public class TestQueryCommandTest extends DBExtensionTests {
|
||||
|
||||
@Mock
|
||||
@ -61,7 +64,7 @@ public class TestQueryCommandTest extends DBExtensionTests {
|
||||
|
||||
|
||||
@Test
|
||||
public void testDoPost() {
|
||||
public void testDoPost() throws IOException, ServletException, JSONException {
|
||||
|
||||
when(request.getParameter("databaseType")).thenReturn(testDbConfig.getDatabaseType());
|
||||
when(request.getParameter("databaseServer")).thenReturn(testDbConfig.getDatabaseHost());
|
||||
@ -76,25 +79,19 @@ public class TestQueryCommandTest extends DBExtensionTests {
|
||||
|
||||
PrintWriter pw = new PrintWriter(sw);
|
||||
|
||||
try {
|
||||
when(response.getWriter()).thenReturn(pw);
|
||||
TestQueryCommand executeQueryCommand = new TestQueryCommand();
|
||||
|
||||
executeQueryCommand.doPost(request, response);
|
||||
|
||||
String result = sw.getBuffer().toString().trim();
|
||||
JSONObject json = new JSONObject(result);
|
||||
when(response.getWriter()).thenReturn(pw);
|
||||
TestQueryCommand executeQueryCommand = new TestQueryCommand();
|
||||
|
||||
String code = json.getString("code");
|
||||
Assert.assertEquals(code, "ok");
|
||||
|
||||
String queryResult = json.getString("QueryResult");
|
||||
Assert.assertNotNull(queryResult);
|
||||
executeQueryCommand.doPost(request, response);
|
||||
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
String result = sw.getBuffer().toString().trim();
|
||||
JSONObject json = new JSONObject(result);
|
||||
|
||||
String code = json.getString("code");
|
||||
Assert.assertEquals(code, "ok");
|
||||
|
||||
String queryResult = json.getString("QueryResult");
|
||||
Assert.assertNotNull(queryResult);
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.google.refine.extension.database.mariadb;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.mockito.MockitoAnnotations;
|
||||
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.DatabaseServiceException;
|
||||
|
||||
|
||||
@Test(groups = { "requiresMariaDB" })
|
||||
public class MariaDBConnectionManagerTest extends DBExtensionTests {
|
||||
|
||||
|
||||
@ -48,48 +49,27 @@ public class MariaDBConnectionManagerTest extends DBExtensionTests {
|
||||
|
||||
|
||||
@Test
|
||||
public void testTestConnection() {
|
||||
|
||||
try {
|
||||
boolean conn = MariaDBConnectionManager.getInstance().testConnection(testDbConfig);
|
||||
Assert.assertEquals(conn, true);
|
||||
|
||||
} catch (DatabaseServiceException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
public void testTestConnection() throws DatabaseServiceException {
|
||||
boolean conn = MariaDBConnectionManager.getInstance().testConnection(testDbConfig);
|
||||
Assert.assertEquals(conn, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetConnection() {
|
||||
|
||||
try {
|
||||
Connection conn = MariaDBConnectionManager.getInstance().getConnection(testDbConfig, true);
|
||||
Assert.assertNotNull(conn);
|
||||
|
||||
} catch (DatabaseServiceException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
public void testGetConnection() throws DatabaseServiceException {
|
||||
Connection conn = MariaDBConnectionManager.getInstance().getConnection(testDbConfig, true);
|
||||
Assert.assertNotNull(conn);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testShutdown() {
|
||||
|
||||
try {
|
||||
Connection conn = MariaDBConnectionManager.getInstance().getConnection(testDbConfig, true);
|
||||
Assert.assertNotNull(conn);
|
||||
|
||||
MariaDBConnectionManager.getInstance().shutdown();
|
||||
|
||||
if(conn != null) {
|
||||
Assert.assertEquals(conn.isClosed(), true);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
public void testShutdown() throws DatabaseServiceException, SQLException {
|
||||
Connection conn = MariaDBConnectionManager.getInstance().getConnection(testDbConfig, true);
|
||||
Assert.assertNotNull(conn);
|
||||
|
||||
MariaDBConnectionManager.getInstance().shutdown();
|
||||
|
||||
if(conn != null) {
|
||||
Assert.assertEquals(conn.isClosed(), true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -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.DatabaseRow;
|
||||
|
||||
|
||||
@Test(groups = { "requiresMariaDB" })
|
||||
public class MariaDBDatabaseServiceTest extends DBExtensionTests{
|
||||
|
||||
|
||||
@ -63,60 +63,35 @@ public class MariaDBDatabaseServiceTest extends DBExtensionTests{
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetConnection() {
|
||||
try {
|
||||
|
||||
MariaDBDatabaseService pgSqlService = (MariaDBDatabaseService)DatabaseService.get(MariaDBDatabaseService.DB_NAME);
|
||||
Connection conn = pgSqlService.getConnection(testDbConfig);
|
||||
|
||||
Assert.assertNotNull(conn);
|
||||
|
||||
} catch (DatabaseServiceException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
public void testGetConnection() throws DatabaseServiceException {
|
||||
MariaDBDatabaseService pgSqlService = (MariaDBDatabaseService)DatabaseService.get(MariaDBDatabaseService.DB_NAME);
|
||||
Connection conn = pgSqlService.getConnection(testDbConfig);
|
||||
|
||||
Assert.assertNotNull(conn);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTestConnection() {
|
||||
try {
|
||||
MariaDBDatabaseService pgSqlService = (MariaDBDatabaseService)DatabaseService.get(MariaDBDatabaseService.DB_NAME);
|
||||
|
||||
boolean result = pgSqlService.testConnection(testDbConfig);
|
||||
Assert.assertEquals(result, true);
|
||||
|
||||
} catch (DatabaseServiceException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
public void testTestConnection() throws DatabaseServiceException {
|
||||
MariaDBDatabaseService pgSqlService = (MariaDBDatabaseService)DatabaseService.get(MariaDBDatabaseService.DB_NAME);
|
||||
|
||||
boolean result = pgSqlService.testConnection(testDbConfig);
|
||||
Assert.assertEquals(result, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConnect() {
|
||||
try {
|
||||
MariaDBDatabaseService pgSqlService = (MariaDBDatabaseService)DatabaseService.get(MariaDBDatabaseService.DB_NAME);
|
||||
DatabaseInfo databaseInfo = pgSqlService.connect(testDbConfig);
|
||||
Assert.assertNotNull(databaseInfo);
|
||||
|
||||
} catch (DatabaseServiceException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
public void testConnect() throws DatabaseServiceException {
|
||||
MariaDBDatabaseService pgSqlService = (MariaDBDatabaseService)DatabaseService.get(MariaDBDatabaseService.DB_NAME);
|
||||
DatabaseInfo databaseInfo = pgSqlService.connect(testDbConfig);
|
||||
Assert.assertNotNull(databaseInfo);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExecuteQuery() {
|
||||
public void testExecuteQuery() throws DatabaseServiceException {
|
||||
MariaDBDatabaseService pgSqlService = (MariaDBDatabaseService) DatabaseService
|
||||
.get(MariaDBDatabaseService.DB_NAME);
|
||||
DatabaseInfo databaseInfo = pgSqlService.testQuery(testDbConfig, "SELECT * FROM " + testTable);
|
||||
|
||||
try {
|
||||
|
||||
MariaDBDatabaseService pgSqlService = (MariaDBDatabaseService) DatabaseService
|
||||
.get(MariaDBDatabaseService.DB_NAME);
|
||||
DatabaseInfo databaseInfo = pgSqlService.testQuery(testDbConfig, "SELECT * FROM " + testTable);
|
||||
|
||||
Assert.assertNotNull(databaseInfo);
|
||||
|
||||
} catch (DatabaseServiceException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Assert.assertNotNull(databaseInfo);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -130,18 +105,12 @@ public class MariaDBDatabaseServiceTest extends DBExtensionTests{
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetRows() {
|
||||
try {
|
||||
MariaDBDatabaseService pgSqlService = (MariaDBDatabaseService) DatabaseService
|
||||
public void testGetRows() throws DatabaseServiceException {
|
||||
MariaDBDatabaseService pgSqlService = (MariaDBDatabaseService) DatabaseService
|
||||
.get(MariaDBDatabaseService.DB_NAME);
|
||||
List<DatabaseRow> dbRows = pgSqlService.getRows(testDbConfig, "SELECT * FROM " + testTable);
|
||||
|
||||
Assert.assertNotNull(dbRows);
|
||||
|
||||
} catch (DatabaseServiceException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -151,21 +120,15 @@ public class MariaDBDatabaseServiceTest extends DBExtensionTests{
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetColumns() {
|
||||
public void testGetColumns() throws DatabaseServiceException {
|
||||
List<DatabaseColumn> dbColumns;
|
||||
|
||||
try {
|
||||
MariaDBDatabaseService pgSqlService = (MariaDBDatabaseService) DatabaseService
|
||||
.get(MariaDBDatabaseService.DB_NAME);
|
||||
MariaDBDatabaseService pgSqlService = (MariaDBDatabaseService) DatabaseService
|
||||
.get(MariaDBDatabaseService.DB_NAME);
|
||||
|
||||
dbColumns = pgSqlService.getColumns(testDbConfig, "SELECT * FROM " + testTable);
|
||||
dbColumns = pgSqlService.getColumns(testDbConfig, "SELECT * FROM " + testTable);
|
||||
|
||||
Assert.assertNotNull(dbColumns);
|
||||
|
||||
} catch (DatabaseServiceException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
Assert.assertNotNull(dbColumns);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.google.refine.extension.database.mysql;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.mockito.MockitoAnnotations;
|
||||
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.DatabaseServiceException;
|
||||
|
||||
@Test(groups = { "requiresMySQL" })
|
||||
public class MySQLConnectionManagerTest extends DBExtensionTests {
|
||||
|
||||
private DatabaseConfiguration testDbConfig;
|
||||
@ -45,49 +47,30 @@ public class MySQLConnectionManagerTest extends DBExtensionTests {
|
||||
|
||||
|
||||
@Test
|
||||
public void testTestConnection() {
|
||||
public void testTestConnection() throws DatabaseServiceException {
|
||||
|
||||
try {
|
||||
boolean conn = MySQLConnectionManager.getInstance().testConnection(testDbConfig);
|
||||
Assert.assertEquals(conn, true);
|
||||
|
||||
} catch (DatabaseServiceException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
boolean conn = MySQLConnectionManager.getInstance().testConnection(testDbConfig);
|
||||
Assert.assertEquals(conn, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetConnection() {
|
||||
public void testGetConnection() throws DatabaseServiceException {
|
||||
|
||||
try {
|
||||
Connection conn = MySQLConnectionManager.getInstance().getConnection(testDbConfig, true);
|
||||
Assert.assertNotNull(conn);
|
||||
|
||||
} catch (DatabaseServiceException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
Connection conn = MySQLConnectionManager.getInstance().getConnection(testDbConfig, true);
|
||||
Assert.assertNotNull(conn);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testShutdown() {
|
||||
public void testShutdown() throws DatabaseServiceException, SQLException {
|
||||
|
||||
try {
|
||||
Connection conn = MySQLConnectionManager.getInstance().getConnection(testDbConfig, true);
|
||||
Assert.assertNotNull(conn);
|
||||
|
||||
MySQLConnectionManager.getInstance().shutdown();
|
||||
|
||||
if(conn != null) {
|
||||
Assert.assertEquals(conn.isClosed(), true);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
Connection conn = MySQLConnectionManager.getInstance().getConnection(testDbConfig, true);
|
||||
Assert.assertNotNull(conn);
|
||||
|
||||
MySQLConnectionManager.getInstance().shutdown();
|
||||
|
||||
if(conn != null) {
|
||||
Assert.assertEquals(conn.isClosed(), true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ import com.google.refine.extension.database.model.DatabaseInfo;
|
||||
import com.google.refine.extension.database.model.DatabaseRow;
|
||||
|
||||
|
||||
|
||||
@Test(groups = { "requiresMySQL" })
|
||||
public class MySQLDatabaseServiceTest extends DBExtensionTests{
|
||||
|
||||
private DatabaseConfiguration testDbConfig;
|
||||
@ -62,60 +62,36 @@ public class MySQLDatabaseServiceTest extends DBExtensionTests{
|
||||
|
||||
|
||||
@Test
|
||||
public void testGetConnection() {
|
||||
try {
|
||||
|
||||
MySQLDatabaseService pgSqlService = (MySQLDatabaseService)DatabaseService.get(MySQLDatabaseService.DB_NAME);
|
||||
Connection conn = pgSqlService.getConnection(testDbConfig);
|
||||
|
||||
Assert.assertNotNull(conn);
|
||||
|
||||
} catch (DatabaseServiceException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
public void testGetConnection() throws DatabaseServiceException {
|
||||
MySQLDatabaseService pgSqlService = (MySQLDatabaseService)DatabaseService.get(MySQLDatabaseService.DB_NAME);
|
||||
Connection conn = pgSqlService.getConnection(testDbConfig);
|
||||
|
||||
Assert.assertNotNull(conn);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTestConnection() {
|
||||
try {
|
||||
MySQLDatabaseService pgSqlService = (MySQLDatabaseService)DatabaseService.get(MySQLDatabaseService.DB_NAME);
|
||||
|
||||
boolean result = pgSqlService.testConnection(testDbConfig);
|
||||
Assert.assertEquals(result, true);
|
||||
|
||||
} catch (DatabaseServiceException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
public void testTestConnection() throws DatabaseServiceException {
|
||||
MySQLDatabaseService pgSqlService = (MySQLDatabaseService)DatabaseService.get(MySQLDatabaseService.DB_NAME);
|
||||
|
||||
boolean result = pgSqlService.testConnection(testDbConfig);
|
||||
Assert.assertEquals(result, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConnect() {
|
||||
try {
|
||||
MySQLDatabaseService pgSqlService = (MySQLDatabaseService)DatabaseService.get(MySQLDatabaseService.DB_NAME);
|
||||
DatabaseInfo databaseInfo = pgSqlService.connect(testDbConfig);
|
||||
Assert.assertNotNull(databaseInfo);
|
||||
|
||||
} catch (DatabaseServiceException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
public void testConnect() throws DatabaseServiceException {
|
||||
MySQLDatabaseService pgSqlService = (MySQLDatabaseService)DatabaseService.get(MySQLDatabaseService.DB_NAME);
|
||||
DatabaseInfo databaseInfo = pgSqlService.connect(testDbConfig);
|
||||
Assert.assertNotNull(databaseInfo);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExecuteQuery() {
|
||||
public void testExecuteQuery() throws DatabaseServiceException {
|
||||
|
||||
try {
|
||||
MySQLDatabaseService pgSqlService = (MySQLDatabaseService) DatabaseService
|
||||
.get(MySQLDatabaseService.DB_NAME);
|
||||
DatabaseInfo databaseInfo = pgSqlService.testQuery(testDbConfig, "SELECT * FROM " + testTable);
|
||||
|
||||
MySQLDatabaseService pgSqlService = (MySQLDatabaseService) DatabaseService
|
||||
.get(MySQLDatabaseService.DB_NAME);
|
||||
DatabaseInfo databaseInfo = pgSqlService.testQuery(testDbConfig, "SELECT * FROM " + testTable);
|
||||
|
||||
Assert.assertNotNull(databaseInfo);
|
||||
|
||||
} catch (DatabaseServiceException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Assert.assertNotNull(databaseInfo);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -129,18 +105,12 @@ public class MySQLDatabaseServiceTest extends DBExtensionTests{
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetRows() {
|
||||
try {
|
||||
MySQLDatabaseService pgSqlService = (MySQLDatabaseService) DatabaseService
|
||||
.get(MySQLDatabaseService.DB_NAME);
|
||||
List<DatabaseRow> dbRows = pgSqlService.getRows(testDbConfig, "SELECT * FROM " + testTable);
|
||||
public void testGetRows() throws DatabaseServiceException {
|
||||
MySQLDatabaseService pgSqlService = (MySQLDatabaseService) DatabaseService
|
||||
.get(MySQLDatabaseService.DB_NAME);
|
||||
List<DatabaseRow> dbRows = pgSqlService.getRows(testDbConfig, "SELECT * FROM " + testTable);
|
||||
|
||||
Assert.assertNotNull(dbRows);
|
||||
|
||||
} catch (DatabaseServiceException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
Assert.assertNotNull(dbRows);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -150,21 +120,14 @@ public class MySQLDatabaseServiceTest extends DBExtensionTests{
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetColumns() {
|
||||
public void testGetColumns() throws DatabaseServiceException {
|
||||
List<DatabaseColumn> dbColumns;
|
||||
MySQLDatabaseService pgSqlService = (MySQLDatabaseService) DatabaseService
|
||||
.get(MySQLDatabaseService.DB_NAME);
|
||||
|
||||
try {
|
||||
MySQLDatabaseService pgSqlService = (MySQLDatabaseService) DatabaseService
|
||||
.get(MySQLDatabaseService.DB_NAME);
|
||||
dbColumns = pgSqlService.getColumns(testDbConfig, "SELECT * FROM " + testTable);
|
||||
|
||||
dbColumns = pgSqlService.getColumns(testDbConfig, "SELECT * FROM " + testTable);
|
||||
|
||||
Assert.assertNotNull(dbColumns);
|
||||
|
||||
} catch (DatabaseServiceException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
Assert.assertNotNull(dbColumns);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.google.refine.extension.database.pgsql;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.testng.Assert;
|
||||
@ -15,7 +16,7 @@ import com.google.refine.extension.database.DatabaseService;
|
||||
import com.google.refine.extension.database.DatabaseServiceException;
|
||||
|
||||
|
||||
|
||||
@Test(groups = { "requiresPgSQL" })
|
||||
public class PgSQLConnectionManagerTest extends DBExtensionTests {
|
||||
|
||||
private DatabaseConfiguration testDbConfig;
|
||||
@ -48,48 +49,30 @@ public class PgSQLConnectionManagerTest extends DBExtensionTests {
|
||||
|
||||
|
||||
@Test
|
||||
public void testTestConnection() {
|
||||
public void testTestConnection() throws DatabaseServiceException {
|
||||
|
||||
try {
|
||||
boolean isConnected = PgSQLConnectionManager.getInstance().testConnection(testDbConfig);
|
||||
Assert.assertEquals(isConnected, true);
|
||||
|
||||
} catch (DatabaseServiceException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
boolean isConnected = PgSQLConnectionManager.getInstance().testConnection(testDbConfig);
|
||||
Assert.assertEquals(isConnected, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetConnection() {
|
||||
public void testGetConnection() throws DatabaseServiceException {
|
||||
|
||||
try {
|
||||
Connection conn = PgSQLConnectionManager.getInstance().getConnection(testDbConfig, true);
|
||||
Assert.assertNotNull(conn);
|
||||
|
||||
} catch (DatabaseServiceException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
Connection conn = PgSQLConnectionManager.getInstance().getConnection(testDbConfig, true);
|
||||
Assert.assertNotNull(conn);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testShutdown() {
|
||||
public void testShutdown() throws DatabaseServiceException, SQLException {
|
||||
|
||||
try {
|
||||
Connection conn = PgSQLConnectionManager.getInstance().getConnection(testDbConfig, true);
|
||||
Assert.assertNotNull(conn);
|
||||
|
||||
PgSQLConnectionManager.getInstance().shutdown();
|
||||
|
||||
if(conn != null) {
|
||||
Assert.assertEquals(conn.isClosed(), true);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
Connection conn = PgSQLConnectionManager.getInstance().getConnection(testDbConfig, true);
|
||||
Assert.assertNotNull(conn);
|
||||
|
||||
PgSQLConnectionManager.getInstance().shutdown();
|
||||
|
||||
if(conn != null) {
|
||||
Assert.assertEquals(conn.isClosed(), true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -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.DatabaseRow;
|
||||
|
||||
|
||||
@Test(groups = { "requiresPgSQL" })
|
||||
public class PgSQLDatabaseServiceTest extends DBExtensionTests{
|
||||
|
||||
private DatabaseConfiguration testDbConfig;
|
||||
@ -61,60 +61,38 @@ public class PgSQLDatabaseServiceTest extends DBExtensionTests{
|
||||
|
||||
|
||||
@Test
|
||||
public void testGetConnection() {
|
||||
try {
|
||||
|
||||
PgSQLDatabaseService pgSqlService = (PgSQLDatabaseService)DatabaseService.get(PgSQLDatabaseService.DB_NAME);
|
||||
Connection conn = pgSqlService.getConnection(testDbConfig);
|
||||
|
||||
Assert.assertNotNull(conn);
|
||||
|
||||
} catch (DatabaseServiceException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
public void testGetConnection() throws DatabaseServiceException {
|
||||
|
||||
PgSQLDatabaseService pgSqlService = (PgSQLDatabaseService)DatabaseService.get(PgSQLDatabaseService.DB_NAME);
|
||||
Connection conn = pgSqlService.getConnection(testDbConfig);
|
||||
|
||||
Assert.assertNotNull(conn);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTestConnection() {
|
||||
try {
|
||||
PgSQLDatabaseService pgSqlService = (PgSQLDatabaseService)DatabaseService.get(PgSQLDatabaseService.DB_NAME);
|
||||
|
||||
boolean result = pgSqlService.testConnection(testDbConfig);
|
||||
Assert.assertEquals(result, true);
|
||||
|
||||
} catch (DatabaseServiceException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
public void testTestConnection() throws DatabaseServiceException {
|
||||
PgSQLDatabaseService pgSqlService = (PgSQLDatabaseService)DatabaseService.get(PgSQLDatabaseService.DB_NAME);
|
||||
|
||||
boolean result = pgSqlService.testConnection(testDbConfig);
|
||||
Assert.assertEquals(result, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConnect() {
|
||||
try {
|
||||
PgSQLDatabaseService pgSqlService = (PgSQLDatabaseService)DatabaseService.get(PgSQLDatabaseService.DB_NAME);
|
||||
DatabaseInfo databaseInfo = pgSqlService.connect(testDbConfig);
|
||||
Assert.assertNotNull(databaseInfo);
|
||||
|
||||
} catch (DatabaseServiceException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
public void testConnect() throws DatabaseServiceException {
|
||||
|
||||
PgSQLDatabaseService pgSqlService = (PgSQLDatabaseService)DatabaseService.get(PgSQLDatabaseService.DB_NAME);
|
||||
DatabaseInfo databaseInfo = pgSqlService.connect(testDbConfig);
|
||||
Assert.assertNotNull(databaseInfo);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExecuteQuery() {
|
||||
public void testExecuteQuery() throws DatabaseServiceException {
|
||||
|
||||
try {
|
||||
PgSQLDatabaseService pgSqlService = (PgSQLDatabaseService) DatabaseService
|
||||
.get(PgSQLDatabaseService.DB_NAME);
|
||||
DatabaseInfo databaseInfo = pgSqlService.testQuery(testDbConfig, "SELECT * FROM " + testTable);
|
||||
|
||||
PgSQLDatabaseService pgSqlService = (PgSQLDatabaseService) DatabaseService
|
||||
.get(PgSQLDatabaseService.DB_NAME);
|
||||
DatabaseInfo databaseInfo = pgSqlService.testQuery(testDbConfig, "SELECT * FROM " + testTable);
|
||||
|
||||
Assert.assertNotNull(databaseInfo);
|
||||
|
||||
} catch (DatabaseServiceException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Assert.assertNotNull(databaseInfo);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -128,18 +106,12 @@ public class PgSQLDatabaseServiceTest extends DBExtensionTests{
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetRows() {
|
||||
try {
|
||||
PgSQLDatabaseService pgSqlService = (PgSQLDatabaseService) DatabaseService
|
||||
.get(PgSQLDatabaseService.DB_NAME);
|
||||
List<DatabaseRow> dbRows = pgSqlService.getRows(testDbConfig, "SELECT * FROM " + testTable);
|
||||
public void testGetRows() throws DatabaseServiceException {
|
||||
PgSQLDatabaseService pgSqlService = (PgSQLDatabaseService) DatabaseService
|
||||
.get(PgSQLDatabaseService.DB_NAME);
|
||||
List<DatabaseRow> dbRows = pgSqlService.getRows(testDbConfig, "SELECT * FROM " + testTable);
|
||||
|
||||
Assert.assertNotNull(dbRows);
|
||||
|
||||
} catch (DatabaseServiceException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
Assert.assertNotNull(dbRows);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -149,21 +121,16 @@ public class PgSQLDatabaseServiceTest extends DBExtensionTests{
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetColumns() {
|
||||
public void testGetColumns() throws DatabaseServiceException {
|
||||
List<DatabaseColumn> dbColumns;
|
||||
|
||||
try {
|
||||
PgSQLDatabaseService pgSqlService = (PgSQLDatabaseService) DatabaseService
|
||||
.get(PgSQLDatabaseService.DB_NAME);
|
||||
PgSQLDatabaseService pgSqlService = (PgSQLDatabaseService) DatabaseService
|
||||
.get(PgSQLDatabaseService.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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
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