Skip to content

Commit

Permalink
#131: extended IT with IntegrationTestConfigurationCondition
Browse files Browse the repository at this point in the history
  • Loading branch information
AnastasiiaSergienko committed Apr 8, 2019
1 parent 56ada31 commit 9d7cff3
Show file tree
Hide file tree
Showing 12 changed files with 461 additions and 681 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
org.eclipse.jdt.ui.importorder=java;javax;org;com;
cleanup.add_default_serial_version_id=true
cleanup.add_generated_serial_version_id=false
cleanup.add_missing_annotations=true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
* This class checks the preconditions for running the integration tests.
*/
public class IntegrationTestConfigurationCondition implements ExecutionCondition {
private static final String INTEGRTION_TEST_CONFIGURATION_FILE_PROPERTY = "integrationtest.configfile";
private static final String INTEGRATION_TEST_CONFIGURATION_FILE_PROPERTY = "integrationtest.configfile";

@Override
public ConditionEvaluationResult evaluateExecutionCondition(final ExtensionContext context) {
if (System.getProperty(INTEGRTION_TEST_CONFIGURATION_FILE_PROPERTY) == null) {
return ConditionEvaluationResult.disabled("The property \"" + INTEGRTION_TEST_CONFIGURATION_FILE_PROPERTY
if (System.getProperty(INTEGRATION_TEST_CONFIGURATION_FILE_PROPERTY) == null) {
return ConditionEvaluationResult.disabled("The property \"" + INTEGRATION_TEST_CONFIGURATION_FILE_PROPERTY
+ "\" is not set. Integration test are disabled.");
} else {
return ConditionEvaluationResult.enabled("Integration tests are enabled");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import java.util.List;

import org.junit.Assume;
import org.junit.BeforeClass;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

Expand All @@ -17,17 +17,15 @@

/**
* Integration test for theDB2 SQL dialect
*
*/
@ExtendWith(IntegrationTestConfigurationCondition.class)
public class DB2SqlDialectIT extends AbstractIntegrationTest {

class DB2SqlDialectIT extends AbstractIntegrationTest {
private static final String VIRTUAL_SCHEMA = "DB2";
private static final String DB2_SCHEMA = "DB2TEST";
private static final boolean IS_LOCAL = false;

@BeforeClass
public static void setUpClass() throws FileNotFoundException, SQLException, ClassNotFoundException {
@BeforeAll
static void beforeAll() throws FileNotFoundException, SQLException, ClassNotFoundException {
Assume.assumeTrue(getConfig().DB2TestsRequested());
setConnection(connectToExa());

Expand All @@ -38,7 +36,7 @@ public static void setUpClass() throws FileNotFoundException, SQLException, Clas
}

@Test
public void testSelectNumericDataTypes() throws SQLException, ClassNotFoundException, FileNotFoundException {
void testSelectNumericDataTypes() throws SQLException {
final String query = "SELECT PRICE,PROMOPRICE FROM " + VIRTUAL_SCHEMA + ".PRODUCT WHERE pid = '100-100-01'";
final ResultSet result = executeQuery(query);
matchNextRow(result, new BigDecimal("9.99"), new BigDecimal("7.25"));
Expand All @@ -47,7 +45,7 @@ public void testSelectNumericDataTypes() throws SQLException, ClassNotFoundExcep
}

@Test
public void testLimit() throws SQLException, ClassNotFoundException, FileNotFoundException {
void testLimit() throws SQLException {
final String query = "SELECT * FROM (SELECT price,PROMOPRICE FROM DB2.PRODUCT) AS A LIMIT 1 ";
final ResultSet result = executeQuery(query);
matchNextRow(result, new BigDecimal("9.99"), new BigDecimal("7.25"));
Expand All @@ -56,7 +54,7 @@ public void testLimit() throws SQLException, ClassNotFoundException, FileNotFoun
}

@Test
public void testTimeDataTypeConversions() throws SQLException, ClassNotFoundException, FileNotFoundException {
void testTimeDataTypeConversions() throws SQLException {
final String query = "SELECT DETAIL_TIMESTAMP,UHRZEIT FROM " + VIRTUAL_SCHEMA
+ ".\"Additional_Datatypes\" WHERE DETAIL_TIMESTAMP = '2020-01-01-00.00.00.123456789123'";
final ResultSet result = executeQuery(query);
Expand All @@ -67,7 +65,7 @@ public void testTimeDataTypeConversions() throws SQLException, ClassNotFoundExce
}

@Test
public void testBitDataConversion() throws SQLException, ClassNotFoundException, FileNotFoundException {
void testBitDataConversion() throws SQLException {
final String query = "SELECT BIDATAVARCHAR,BIDATACHAR FROM " + VIRTUAL_SCHEMA
+ ".\"Additional_Datatypes\" WHERE DETAIL_TIMESTAMP = '2020-01-01-00.00.00.123456789123'";
final ResultSet result = executeQuery(query);
Expand All @@ -79,7 +77,7 @@ public void testBitDataConversion() throws SQLException, ClassNotFoundException,
}

@Test
public void testUnicode() throws SQLException, ClassNotFoundException, FileNotFoundException {
void testUnicode() throws SQLException {
final String query = "SELECT UNICODECOL FROM " + VIRTUAL_SCHEMA
+ ".\"Additional_Datatypes\" WHERE DETAIL_TIMESTAMP = '2020-01-01-00.00.00.123456789123'";
final ResultSet result = executeQuery(query);
Expand All @@ -90,7 +88,7 @@ public void testUnicode() throws SQLException, ClassNotFoundException, FileNotFo
}

@Test
public void testScalarFunctions() throws SQLException, ClassNotFoundException, FileNotFoundException {
void testScalarFunctions() throws SQLException {
final String query = "SELECT ADD_DAYS(DETAIL_TIMESTAMP,2),ADD_YEARS(DETAIL_TIMESTAMP,-2),SUBSTR(UNICODECOL,1,4) FROM "
+ VIRTUAL_SCHEMA
+ ".\"Additional_Datatypes\" WHERE DETAIL_TIMESTAMP = '2020-01-01-00.00.00.123456789123'";
Expand All @@ -111,5 +109,4 @@ private static void createDB2JDBCAdapter() throws SQLException, FileNotFoundExce
}
createJDBCAdapter(DB2Includes);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import java.util.List;

import org.junit.Assume;
import org.junit.BeforeClass;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

Expand All @@ -21,32 +21,32 @@
* Integration tests for the Exasol SQL dialect.
*/
@ExtendWith(IntegrationTestConfigurationCondition.class)
public class ExasolSqlDialectIT extends AbstractIntegrationTest {
class ExasolSqlDialectIT extends AbstractIntegrationTest {

public static class ConnectionBuilder {
private final String connectionName;
private final String connectionString;
private String connectionUser;
private String connectionPassword;

public ConnectionBuilder(final String connectionName, final String connectionString) {
ConnectionBuilder(final String connectionName, final String connectionString) {
this.connectionName = connectionName;
this.connectionString = connectionString;
this.connectionUser = "";
this.connectionPassword = "";
}

public ConnectionBuilder user(final String user) {
ConnectionBuilder user(final String user) {
this.connectionUser = user;
return this;
}

public ConnectionBuilder password(final String password) {
ConnectionBuilder password(final String password) {
this.connectionPassword = password;
return this;
}

public String getCreateConnection() {
String getCreateConnection() {
final StringBuilder createConnection = new StringBuilder();
createConnection.append("CREATE CONNECTION ");
createConnection.append(this.connectionName);
Expand All @@ -71,8 +71,8 @@ public String getCreateConnection() {
private static final String VIRTUAL_SCHEMA_JDBC = "VS_EXA_IT_JDBC";
private static final boolean IS_LOCAL = true;

@BeforeClass
public static void setUpClass() throws FileNotFoundException, SQLException, ClassNotFoundException {
@BeforeAll
static void beforeAll() throws FileNotFoundException, SQLException, ClassNotFoundException {
Assume.assumeTrue(getConfig().exasolTestsRequested());
setConnection(connectToExa());
final String connectionString = "jdbc:exa:localhost:" + getPortOfConnectedDatabase(); // connect via Virtual
Expand Down Expand Up @@ -138,7 +138,7 @@ private static void createTestSchema() throws SQLException {
}

@Test
public void testDataTypeMapping() throws SQLException {
void testDataTypeMapping() throws SQLException {
final ResultSet result = executeQuery(
"SELECT COLUMN_NAME, COLUMN_TYPE, COLUMN_MAXSIZE, COLUMN_NUM_PREC, COLUMN_NUM_SCALE, COLUMN_DEFAULT FROM EXA_DBA_COLUMNS WHERE COLUMN_SCHEMA = '"
+ VIRTUAL_SCHEMA + "' AND COLUMN_TABLE='ALL_EXA_TYPES' ORDER BY COLUMN_ORDINAL_POSITION");
Expand All @@ -156,51 +156,48 @@ public void testDataTypeMapping() throws SQLException {
"'2016-06-01 00:00:02.000'");
matchNextRow(result, "C12", "INTERVAL YEAR(2) TO MONTH", (long) 13, null, null, "'3-5'");
matchNextRow(result, "C13", "INTERVAL DAY(2) TO SECOND(3)", (long) 29, null, null, "'2 12:50:10.123'");
matchLastRow(result, "C14", "GEOMETRY(3857)", (long) 8000000, null, null, "'POINT(2 5)'"); // srid not yet
// supported, so will
// always default to
// 3857
matchLastRow(result, "C14", "GEOMETRY(3857)", (long) 8000000, null, null, "'POINT(2 5)'"); // srid not yet supported, so will always default to 3857
}

@Test
public void testDataTypeSelect() throws SQLException {
void testDataTypeSelect() throws SQLException {
final ResultSet result = executeQuery("SELECT * FROM " + VIRTUAL_SCHEMA + ".ALL_EXA_TYPES");
matchNextRow(result, "a茶", "b", "c茶 ", "d ", 123, new BigDecimal("123.456"), 2.2, false,
getSqlDate(2016, 8, 1), getSqlTimestamp(2016, 8, 1, 0, 0, 1, 0),
getSqlTimestamp(2016, 8, 1, 0, 0, 2, 0), "+04-06", "+03 12:50:10.123", "POINT (2 5)");
}

@Test
public void testIdentifierCaseSensitivityOnTable() throws SQLException {
void testIdentifierCaseSensitivityOnTable() throws SQLException {
final ResultSet result = executeQuery("SELECT * FROM " + VIRTUAL_SCHEMA_MIXED_CASE + ".\"Table_Mixed_Case\"");
matchLastRow(result, 1L, 2L, 3L);
}

@Test
public void testIdentifierCaseSensitivityOnColumns() throws SQLException {
void testIdentifierCaseSensitivityOnColumns() throws SQLException {
final ResultSet result = executeQuery(
"SELECT \"Column1\", \"column2\", COLUMN3 FROM " + VIRTUAL_SCHEMA_MIXED_CASE + ".\"Table_Mixed_Case\"");
matchLastRow(result, 1L, 2L, 3L);
}

@Test
public void assertUnquotedMixedCaseTableIsNotFound() throws SQLException {
void assertUnquotedMixedCaseTableIsNotFound() throws SQLException {
assertThrows(
SQLException.class, () -> executeQuery("SELECT \"Column1\", \"column2\", COLUMN3 FROM "
+ VIRTUAL_SCHEMA_MIXED_CASE + ".Table_Mixed_Case"),
"object VS_EXA_IT_MIXED_CASE.TABLE_MIXED_CASE not found");
}

@Test
public void assertUnquotedMixedCaseColumnIsNotFound() throws SQLException {
void assertUnquotedMixedCaseColumnIsNotFound() throws SQLException {
assertThrows(SQLException.class,
() -> executeQuery(
"SELECT Column1, column2, COLUMN3 FROM " + VIRTUAL_SCHEMA_MIXED_CASE + ".\"Table_Mixed_Case\""),
"object COLUMN1 not found");
}

@Test
public void testGroupConcat() throws SQLException {
void testGroupConcat() throws SQLException {
String query = "SELECT GROUP_CONCAT(A) FROM " + VIRTUAL_SCHEMA + ".SIMPLE_VALUES";
ResultSet result = executeQuery(query);
matchLastRow(result, "1,1,2,2,3,3");
Expand Down Expand Up @@ -235,7 +232,7 @@ public void testGroupConcat() throws SQLException {
}

@Test
public void testExtract() throws SQLException {
void testExtract() throws SQLException {
String query = "SELECT EXTRACT(MONTH FROM C9) FROM " + VIRTUAL_SCHEMA + ".ALL_EXA_TYPES";
ResultSet result = executeQuery(query);
matchLastRow(result, (short) 8);
Expand All @@ -249,7 +246,7 @@ public void testExtract() throws SQLException {
}

@Test
public void testCast() throws SQLException {
void testCast() throws SQLException {
String query = "SELECT CAST(A AS CHAR(15)) FROM " + VIRTUAL_SCHEMA + ".SIMPLE_VALUES";
ResultSet result = executeQuery(query);
matchNextRow(result, "1 ");
Expand Down Expand Up @@ -319,7 +316,7 @@ public void testCast() throws SQLException {
}

@Test
public void testCase() throws SQLException {
void testCase() throws SQLException {
String query = "SELECT CASE A WHEN 1 THEN 'YES' WHEN 2 THEN 'PERHAPS' ELSE 'NO' END FROM " + VIRTUAL_SCHEMA
+ ".SIMPLE_VALUES";
ResultSet result = executeQuery(query);
Expand All @@ -335,7 +332,7 @@ public void testCase() throws SQLException {
}

@Test
public void testErrorMessages() throws SQLException, FileNotFoundException {
void testErrorMessages() throws SQLException, FileNotFoundException {
assertThrows(Exception.class,
() -> createVirtualSchema("VS_EXA_IT_BROKEN", ExasolSqlDialect.getPublicName(), "", "NATIVE_EXA_IT",
"NO_CONNECTION", "", "", "ADAPTER.JDBC_ADAPTER", "", false, getConfig().debugAddress(), "",
Expand All @@ -344,7 +341,7 @@ public void testErrorMessages() throws SQLException, FileNotFoundException {
}

@Test
public void testVirtualSchemaImportFromJDBCWithConnectionName() throws SQLException, FileNotFoundException {
void testVirtualSchemaImportFromJDBCWithConnectionName() throws SQLException, FileNotFoundException {
final String connectionString = "jdbc:exa:localhost:" + getPortOfConnectedDatabase();
final ConnectionBuilder JDBCConnection = new ConnectionBuilder("VS_JDBC_WITH_CONNNAME_CONNECTION",
connectionString).user(getConfig().getExasolUser()).password(getConfig().getExasolPassword());
Expand All @@ -360,7 +357,7 @@ public void testVirtualSchemaImportFromJDBCWithConnectionName() throws SQLExcept
}

@Test
public void testVirtualSchemaImportFromEXAWithConnectionName() throws SQLException, FileNotFoundException {
void testVirtualSchemaImportFromEXAWithConnectionName() throws SQLException, FileNotFoundException {
final String connectionString = "jdbc:exa:localhost:" + getPortOfConnectedDatabase();
final ConnectionBuilder EXAConnection = new ConnectionBuilder("VS_EXA_WITH_CONNNAME_CONNECTION",
connectionString).user(getConfig().getExasolUser()).password(getConfig().getExasolPassword());
Expand All @@ -378,8 +375,7 @@ public void testVirtualSchemaImportFromEXAWithConnectionName() throws SQLExcepti
}

@Test
public void testVirtualSchemaImportFromJDBCWithConnectionStringUserPassword()
throws SQLException, FileNotFoundException {
void testVirtualSchemaImportFromJDBCWithConnectionStringUserPassword() throws SQLException, FileNotFoundException {
final String connectionString = "jdbc:exa:localhost:" + getPortOfConnectedDatabase();
createVirtualSchema("VS_JDBC_WITH_USER_PW", ExasolSqlDialect.getPublicName(), "", TEST_SCHEMA, "",
getConfig().getExasolUser(), getConfig().getExasolPassword(), "ADAPTER.JDBC_ADAPTER", connectionString,
Expand All @@ -393,8 +389,7 @@ public void testVirtualSchemaImportFromJDBCWithConnectionStringUserPassword()
}

@Test
public void testVirtualSchemaImportFromEXAWithConnectionStringUserPassword()
throws SQLException, FileNotFoundException {
void testVirtualSchemaImportFromEXAWithConnectionStringUserPassword() throws SQLException, FileNotFoundException {
final String connectionString = "jdbc:exa:localhost:" + getPortOfConnectedDatabase();
createVirtualSchema("VS_EXA_WITH_USER_PW", ExasolSqlDialect.getPublicName(), "", TEST_SCHEMA, "",
getConfig().getExasolUser(), getConfig().getExasolPassword(), "ADAPTER.JDBC_ADAPTER", connectionString,
Expand All @@ -411,7 +406,7 @@ public void testVirtualSchemaImportFromEXAWithConnectionStringUserPassword()

// Join Tests -------------------------------------------------------------
@Test
public void innerJoin() throws SQLException {
void innerJoin() throws SQLException {
final String query = String.format("SELECT * FROM %1$s.t1 a INNER JOIN %1$s.t2 b ON a.x=b.x",
VIRTUAL_SCHEMA_JDBC);
final ResultSet result = executeQuery(query);
Expand All @@ -420,7 +415,7 @@ public void innerJoin() throws SQLException {
}

@Test
public void innerJoinWithProjection() throws SQLException {
void innerJoinWithProjection() throws SQLException {
final String query = String.format(
"SELECT b.y || %1$s.t1.y FROM %1$s.t1 INNER JOIN %1$s.t2 b ON %1$s.t1.x=b.x", VIRTUAL_SCHEMA_JDBC);
final ResultSet result = executeQuery(query);
Expand All @@ -429,7 +424,7 @@ public void innerJoinWithProjection() throws SQLException {
}

@Test
public void leftJoin() throws SQLException {
void leftJoin() throws SQLException {
final String query = String.format(
"SELECT * FROM %1$s.t1 a LEFT OUTER JOIN %1$s.t2 b ON a.x=b.x ORDER BY a.x", VIRTUAL_SCHEMA_JDBC);
final ResultSet result = executeQuery(query);
Expand All @@ -439,7 +434,7 @@ public void leftJoin() throws SQLException {
}

@Test
public void rightJoin() throws SQLException {
void rightJoin() throws SQLException {
final String query = String.format(
"SELECT * FROM %1$s.t1 a RIGHT OUTER JOIN %1$s.t2 b ON a.x=b.x ORDER BY a.x", VIRTUAL_SCHEMA_JDBC);
final ResultSet result = executeQuery(query);
Expand All @@ -449,7 +444,7 @@ public void rightJoin() throws SQLException {
}

@Test
public void fullOuterJoin() throws SQLException {
void fullOuterJoin() throws SQLException {
final String query = String.format(
"SELECT * FROM %1$s.t1 a FULL OUTER JOIN %1$s.t2 b ON a.x=b.x ORDER BY a.x", VIRTUAL_SCHEMA_JDBC);
final ResultSet result = executeQuery(query);
Expand Down
Loading

0 comments on commit 9d7cff3

Please sign in to comment.