You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by jh...@apache.org on 2015/04/17 20:35:41 UTC
[2/8] incubator-calcite git commit: Add H2 integration test
Add H2 integration test
The test expects to find either ../calcite-test-dataset or ../../calcite-test-dataset with the test data
Add explicit dependencies (Julian Hyde)
Project: http://git-wip-us.apache.org/repos/asf/incubator-calcite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-calcite/commit/b2b53b19
Tree: http://git-wip-us.apache.org/repos/asf/incubator-calcite/tree/b2b53b19
Diff: http://git-wip-us.apache.org/repos/asf/incubator-calcite/diff/b2b53b19
Branch: refs/heads/master
Commit: b2b53b19a8a2d4975a447692eeefc572230567dd
Parents: 4c0cf67
Author: Vladimir Sitnikov <si...@gmail.com>
Authored: Tue Feb 10 12:51:21 2015 +0300
Committer: Julian Hyde <jh...@apache.org>
Committed: Thu Apr 16 02:21:43 2015 -0700
----------------------------------------------------------------------
.../calcite/avatica/RemoteDriverTest.java | 3 ++
core/pom.xml | 34 ++++++++++++++++++--
.../java/org/apache/calcite/sql/SqlDialect.java | 4 +++
.../org/apache/calcite/test/CalciteAssert.java | 22 +++++++++++++
pom.xml | 12 +++----
5 files changed, 67 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/b2b53b19/avatica-server/src/test/java/org/apache/calcite/avatica/RemoteDriverTest.java
----------------------------------------------------------------------
diff --git a/avatica-server/src/test/java/org/apache/calcite/avatica/RemoteDriverTest.java b/avatica-server/src/test/java/org/apache/calcite/avatica/RemoteDriverTest.java
index 20c3601..9cc18b4 100644
--- a/avatica-server/src/test/java/org/apache/calcite/avatica/RemoteDriverTest.java
+++ b/avatica-server/src/test/java/org/apache/calcite/avatica/RemoteDriverTest.java
@@ -393,6 +393,9 @@ public class RemoteDriverTest {
}
@Test public void testConnectionIsolation() throws Exception {
+ // Wait 5s for all other tests to finish. (Sorry! Hack!)
+ Thread.sleep(5000);
+
final String sql = "select * from (values (1, 'a'))";
Connection conn1 = ljs();
Connection conn2 = ljs();
http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/b2b53b19/core/pom.xml
----------------------------------------------------------------------
diff --git a/core/pom.xml b/core/pom.xml
index 010ed8b..be7343a 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -76,6 +76,11 @@ limitations under the License.
<artifactId>guava</artifactId>
</dependency>
<dependency>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
@@ -136,6 +141,11 @@ limitations under the License.
<groupId>org.pentaho</groupId>
<artifactId>pentaho-aggdesigner-algorithm</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.postgresql</groupId>
+ <artifactId>postgresql</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
@@ -229,9 +239,11 @@ limitations under the License.
<failOnWarning>true</failOnWarning>
<!-- ignore "unused but declared" warnings -->
<ignoredUnusedDeclaredDependencies>
+ <ignoredUnusedDeclaredDependency>com.h2database:h2</ignoredUnusedDeclaredDependency>
+ <ignoredUnusedDeclaredDependency>mysql:mysql-connector-java</ignoredUnusedDeclaredDependency>
<ignoredUnusedDeclaredDependency>net.hydromatic:scott-data-hsqldb</ignoredUnusedDeclaredDependency>
<ignoredUnusedDeclaredDependency>net.hydromatic:foodmart-data-hsqldb</ignoredUnusedDeclaredDependency>
- <ignoredUnusedDeclaredDependency>mysql:mysql-connector-java</ignoredUnusedDeclaredDependency>
+ <ignoredUnusedDeclaredDependency>org.postgresql:postgresql</ignoredUnusedDeclaredDependency>
</ignoredUnusedDeclaredDependencies>
</configuration>
</execution>
@@ -266,7 +278,9 @@ limitations under the License.
<executions>
<execution>
<id>failsafe-integration-test</id>
- <phase/>
+ <!-- Disable the integration test inherited from the parent pom
+ so that we can run multiple tests, one per database. -->
+ <phase>none</phase>
</execution>
<execution>
<id>failsafe-test-mysql</id>
@@ -300,6 +314,22 @@ limitations under the License.
</systemPropertyVariables>
</configuration>
</execution>
+ <execution>
+ <id>failsafe-test-h2</id>
+ <goals>
+ <goal>integration-test</goal>
+ </goals>
+ <phase>integration-test</phase>
+ <configuration>
+ <includes>
+ <include>org/apache/calcite/test/JdbcAdapterTest.java</include>
+ <include>org/apache/calcite/test/JdbcTest.java</include>
+ </includes>
+ <systemPropertyVariables>
+ <calcite.test.db>h2</calcite.test.db>
+ </systemPropertyVariables>
+ </configuration>
+ </execution>
</executions>
</plugin>
</plugins>
http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/b2b53b19/core/src/main/java/org/apache/calcite/sql/SqlDialect.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql/SqlDialect.java b/core/src/main/java/org/apache/calcite/sql/SqlDialect.java
index 8f85b1d..586e18f 100644
--- a/core/src/main/java/org/apache/calcite/sql/SqlDialect.java
+++ b/core/src/main/java/org/apache/calcite/sql/SqlDialect.java
@@ -181,6 +181,8 @@ public class SqlDialect {
return DatabaseProduct.TERADATA;
} else if (upperProductName.contains("HSQL")) {
return DatabaseProduct.HSQLDB;
+ } else if (upperProductName.contains("H2")) {
+ return DatabaseProduct.H2;
} else if (upperProductName.contains("VERTICA")) {
return DatabaseProduct.VERTICA;
} else {
@@ -407,6 +409,7 @@ public class SqlDialect {
public boolean supportsCharSet() {
switch (databaseProduct) {
case MYSQL:
+ case H2:
case HSQLDB:
case PHOENIX:
case POSTGRESQL:
@@ -483,6 +486,7 @@ public class SqlDialect {
DERBY("Apache Derby", null),
DB2("IBM DB2", null),
FIREBIRD("Firebird", null),
+ H2("H2", "\""),
HIVE("Apache Hive", null),
INFORMIX("Informix", null),
INGRES("Ingres", null),
http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/b2b53b19/core/src/test/java/org/apache/calcite/test/CalciteAssert.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/calcite/test/CalciteAssert.java b/core/src/test/java/org/apache/calcite/test/CalciteAssert.java
index 89fbba2..cc4e1f2 100644
--- a/core/src/test/java/org/apache/calcite/test/CalciteAssert.java
+++ b/core/src/test/java/org/apache/calcite/test/CalciteAssert.java
@@ -53,6 +53,7 @@ import com.google.common.collect.Lists;
import net.hydromatic.foodmart.data.hsqldb.FoodmartHsqldb;
import net.hydromatic.scott.data.hsqldb.ScottHsqldb;
+import java.io.File;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.lang.reflect.InvocationTargetException;
@@ -1483,6 +1484,10 @@ public class CalciteAssert {
"org.hsqldb.jdbcDriver"),
new ConnectionSpec(ScottHsqldb.URI, ScottHsqldb.USER,
ScottHsqldb.PASSWORD, "org.hsqldb.jdbcDriver")),
+ H2(
+ new ConnectionSpec("jdbc:h2:" + getDataSetPath()
+ + "/h2/target/foodmart;user=foodmart;password=foodmart",
+ "foodmart", "foodmart", "org.h2.Driver"), null),
MYSQL(
new ConnectionSpec("jdbc:mysql://localhost/foodmart", "foodmart",
"foodmart", "com.mysql.jdbc.Driver"), null),
@@ -1494,6 +1499,23 @@ public class CalciteAssert {
public final ConnectionSpec foodmart;
public final ConnectionSpec scott;
+ private static String getDataSetPath() {
+ String path = System.getProperty("calcite.test.dataset");
+ if (path != null) {
+ return path;
+ }
+ final String[] dirs = {
+ "../calcite-test-dataset",
+ "../../calcite-test-dataset"
+ };
+ for (String s : dirs) {
+ if (new File(s).exists() && new File(s, "vm").exists()) {
+ return s;
+ }
+ }
+ return ".";
+ }
+
DatabaseInstance(ConnectionSpec foodmart, ConnectionSpec scott) {
this.foodmart = foodmart;
this.scott = scott;
http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/b2b53b19/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index ea2b0b5..fd79cdb 100644
--- a/pom.xml
+++ b/pom.xml
@@ -157,6 +157,12 @@ limitations under the License.
<version>14.0.1</version>
</dependency>
<dependency>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ <version>1.4.185</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
@@ -248,12 +254,6 @@ limitations under the License.
<version>2.3.1</version>
</dependency>
<dependency>
- <groupId>com.h2database</groupId>
- <artifactId>h2</artifactId>
- <version>1.4.185</version>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>org.incava</groupId>
<artifactId>java-diff</artifactId>
<version>1.1</version>