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/03 15:02:35 UTC
[02/10] incubator-calcite git commit: [CALCITE-652] Move server
pieces of avatica into avatica-server (Nick Dimiduk)
http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/fa9bdc4a/avatica/src/main/java/org/apache/calcite/avatica/jdbc/JdbcResultSet.java
----------------------------------------------------------------------
diff --git a/avatica/src/main/java/org/apache/calcite/avatica/jdbc/JdbcResultSet.java b/avatica/src/main/java/org/apache/calcite/avatica/jdbc/JdbcResultSet.java
deleted file mode 100644
index 827f31d..0000000
--- a/avatica/src/main/java/org/apache/calcite/avatica/jdbc/JdbcResultSet.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.calcite.avatica.jdbc;
-
-import org.apache.calcite.avatica.Meta;
-
-import java.sql.ResultSet;
-import java.sql.ResultSetMetaData;
-import java.sql.SQLException;
-import java.sql.Types;
-import java.util.ArrayList;
-import java.util.List;
-
-/** Implementation of {@link org.apache.calcite.avatica.Meta.MetaResultSet}
- * upon a JDBC {@link java.sql.ResultSet}.
- *
- * @see org.apache.calcite.avatica.jdbc.JdbcMeta */
-class JdbcResultSet extends Meta.MetaResultSet {
- protected JdbcResultSet(String connectionId, int statementId,
- boolean ownStatement, Meta.Signature signature, Meta.Frame firstFrame) {
- super(connectionId, statementId, ownStatement, signature, firstFrame);
- }
-
- /** Creates a result set. */
- public static JdbcResultSet create(String connectionId, int statementId,
- ResultSet resultSet) {
- try {
- Meta.Signature sig = JdbcMeta.signature(resultSet.getMetaData());
- final Meta.Frame firstFrame = frame(resultSet, 0, -1);
- resultSet.close();
- return new JdbcResultSet(connectionId, statementId, true, sig,
- firstFrame);
- } catch (SQLException e) {
- throw new RuntimeException(e);
- }
- }
-
- /** Creates a frame containing a given number or unlimited number of rows
- * from a result set. */
- static Meta.Frame frame(ResultSet resultSet, int offset,
- int fetchMaxRowCount) throws SQLException {
- final ResultSetMetaData metaData = resultSet.getMetaData();
- final int columnCount = metaData.getColumnCount();
- final int[] types = new int[columnCount];
- for (int i = 0; i < types.length; i++) {
- types[i] = metaData.getColumnType(i + 1);
- }
- final List<Object> rows = new ArrayList<>();
- boolean done = false;
- for (int i = 0; fetchMaxRowCount < 0 || i < fetchMaxRowCount; i++) {
- if (!resultSet.next()) {
- done = true;
- break;
- }
- Object[] columns = new Object[columnCount];
- for (int j = 0; j < columnCount; j++) {
- columns[j] = getValue(resultSet, types[j], j);
- }
- rows.add(columns);
- }
- return new Meta.Frame(offset, done, rows);
- }
-
- private static Object getValue(ResultSet resultSet, int type, int j)
- throws SQLException {
- switch (type) {
- case Types.BIGINT:
- final long aLong = resultSet.getLong(j + 1);
- return aLong == 0 && resultSet.wasNull() ? null : aLong;
- case Types.INTEGER:
- final int anInt = resultSet.getInt(j + 1);
- return anInt == 0 && resultSet.wasNull() ? null : anInt;
- case Types.SMALLINT:
- final short aShort = resultSet.getShort(j + 1);
- return aShort == 0 && resultSet.wasNull() ? null : aShort;
- case Types.TINYINT:
- final byte aByte = resultSet.getByte(j + 1);
- return aByte == 0 && resultSet.wasNull() ? null : aByte;
- case Types.DOUBLE:
- case Types.FLOAT:
- final double aDouble = resultSet.getDouble(j + 1);
- return aDouble == 0D && resultSet.wasNull() ? null : aDouble;
- case Types.REAL:
- final float aFloat = resultSet.getFloat(j + 1);
- return aFloat == 0D && resultSet.wasNull() ? null : aFloat;
- default:
- return resultSet.getObject(j + 1);
- }
- }
-}
-
-// End JdbcResultSet.java
http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/fa9bdc4a/avatica/src/main/java/org/apache/calcite/avatica/jdbc/package-info.java
----------------------------------------------------------------------
diff --git a/avatica/src/main/java/org/apache/calcite/avatica/jdbc/package-info.java b/avatica/src/main/java/org/apache/calcite/avatica/jdbc/package-info.java
deleted file mode 100644
index 8b8fb76..0000000
--- a/avatica/src/main/java/org/apache/calcite/avatica/jdbc/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/** Implements an Avatica provider on top of an existing JDBC data source. */
-package org.apache.calcite.avatica.jdbc;
-
-
-// End package-info.java
http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/fa9bdc4a/avatica/src/test/java/org/apache/calcite/avatica/test/AvaticaSuite.java
----------------------------------------------------------------------
diff --git a/avatica/src/test/java/org/apache/calcite/avatica/test/AvaticaSuite.java b/avatica/src/test/java/org/apache/calcite/avatica/test/AvaticaSuite.java
deleted file mode 100644
index 3f25225..0000000
--- a/avatica/src/test/java/org/apache/calcite/avatica/test/AvaticaSuite.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.calcite.avatica.test;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-/**
- * Avatica test suite.
- */
-@RunWith(Suite.class)
-@Suite.SuiteClasses({
- ConnectStringParserTest.class,
- RemoteDriverTest.class
-})
-public class AvaticaSuite {
-}
-
-// End AvaticaSuite.java
http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/fa9bdc4a/avatica/src/test/java/org/apache/calcite/avatica/test/RemoteDriverTest.java
----------------------------------------------------------------------
diff --git a/avatica/src/test/java/org/apache/calcite/avatica/test/RemoteDriverTest.java b/avatica/src/test/java/org/apache/calcite/avatica/test/RemoteDriverTest.java
deleted file mode 100644
index 0f6ab8d..0000000
--- a/avatica/src/test/java/org/apache/calcite/avatica/test/RemoteDriverTest.java
+++ /dev/null
@@ -1,435 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.calcite.avatica.test;
-
-import org.apache.calcite.avatica.AvaticaConnection;
-import org.apache.calcite.avatica.AvaticaPreparedStatement;
-import org.apache.calcite.avatica.AvaticaStatement;
-import org.apache.calcite.avatica.Meta;
-import org.apache.calcite.avatica.jdbc.JdbcMeta;
-import org.apache.calcite.avatica.remote.LocalJsonService;
-import org.apache.calcite.avatica.remote.LocalService;
-import org.apache.calcite.avatica.remote.MockJsonService;
-import org.apache.calcite.avatica.remote.Service;
-
-import com.google.common.cache.Cache;
-
-import net.hydromatic.scott.data.hsqldb.ScottHsqldb;
-
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-
-import java.lang.reflect.Field;
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.ParameterMetaData;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.ResultSetMetaData;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.Map;
-
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-/**
- * Unit test for Avatica Remote JDBC driver.
- */
-public class RemoteDriverTest {
- public static final String MJS =
- MockJsonService.Factory.class.getName();
-
- public static final String LJS =
- LocalJdbcServiceFactory.class.getName();
-
- public static final String QRJS =
- QuasiRemoteJdbcServiceFactory.class.getName();
-
- private static final ConnectionSpec CONNECTION_SPEC = ConnectionSpec.HSQLDB;
-
- private Connection mjs() throws SQLException {
- return DriverManager.getConnection("jdbc:avatica:remote:factory=" + MJS);
- }
-
- private Connection ljs() throws SQLException {
- return DriverManager.getConnection("jdbc:avatica:remote:factory=" + QRJS);
- }
-
- @Before
- public void before() throws Exception {
- QuasiRemoteJdbcServiceFactory.initService();
- }
-
- @Test public void testRegister() throws Exception {
- final Connection connection =
- DriverManager.getConnection("jdbc:avatica:remote:");
- assertThat(connection.isClosed(), is(false));
- connection.close();
- assertThat(connection.isClosed(), is(true));
- }
-
- @Test public void testSchemas() throws Exception {
- final Connection connection = mjs();
- final ResultSet resultSet =
- connection.getMetaData().getSchemas(null, null);
- assertFalse(resultSet.next());
- final ResultSetMetaData metaData = resultSet.getMetaData();
- assertTrue(metaData.getColumnCount() >= 2);
- assertEquals("TABLE_CATALOG", metaData.getColumnName(1));
- assertEquals("TABLE_SCHEM", metaData.getColumnName(2));
- resultSet.close();
- connection.close();
- }
-
- @Test public void testTables() throws Exception {
- final Connection connection = mjs();
- final ResultSet resultSet =
- connection.getMetaData().getTables(null, null, null, new String[0]);
- assertFalse(resultSet.next());
- final ResultSetMetaData metaData = resultSet.getMetaData();
- assertTrue(metaData.getColumnCount() >= 3);
- assertEquals("TABLE_CAT", metaData.getColumnName(1));
- assertEquals("TABLE_SCHEM", metaData.getColumnName(2));
- assertEquals("TABLE_NAME", metaData.getColumnName(3));
- resultSet.close();
- connection.close();
- }
-
- @Ignore
- @Test public void testNoFactory() throws Exception {
- final Connection connection =
- DriverManager.getConnection("jdbc:avatica:remote:");
- assertThat(connection.isClosed(), is(false));
- final ResultSet resultSet = connection.getMetaData().getSchemas();
- assertFalse(resultSet.next());
- final ResultSetMetaData metaData = resultSet.getMetaData();
- assertEquals(2, metaData.getColumnCount());
- assertEquals("TABLE_SCHEM", metaData.getColumnName(1));
- assertEquals("TABLE_CATALOG", metaData.getColumnName(2));
- resultSet.close();
- connection.close();
- assertThat(connection.isClosed(), is(true));
- }
-
- @Ignore
- @Test public void testCatalogsMock() throws Exception {
- final Connection connection = mjs();
- assertThat(connection.isClosed(), is(false));
- final ResultSet resultSet = connection.getMetaData().getSchemas();
- assertFalse(resultSet.next());
- final ResultSetMetaData metaData = resultSet.getMetaData();
- assertEquals(2, metaData.getColumnCount());
- assertEquals("TABLE_SCHEM", metaData.getColumnName(1));
- assertEquals("TABLE_CATALOG", metaData.getColumnName(2));
- resultSet.close();
- connection.close();
- assertThat(connection.isClosed(), is(true));
- }
-
- @Test public void testStatementExecuteQueryLocal() throws Exception {
- checkStatementExecuteQuery(ljs(), false);
- }
-
- @Ignore
- @Test public void testStatementExecuteQueryMock() throws Exception {
- checkStatementExecuteQuery(mjs(), false);
- }
-
- @Ignore
- @Test public void testPrepareExecuteQueryLocal() throws Exception {
- checkStatementExecuteQuery(ljs(), true);
- }
-
- @Ignore
- @Test public void testPrepareExecuteQueryMock() throws Exception {
- checkStatementExecuteQuery(mjs(), true);
- }
-
- private void checkStatementExecuteQuery(Connection connection,
- boolean prepare) throws SQLException {
- final String sql = "select * from (\n"
- + " values (1, 'a'), (null, 'b'), (3, 'c')) as t (c1, c2)";
- final Statement statement;
- final ResultSet resultSet;
- final ParameterMetaData parameterMetaData;
- if (prepare) {
- final PreparedStatement ps = connection.prepareStatement(sql);
- statement = ps;
- parameterMetaData = ps.getParameterMetaData();
- resultSet = ps.executeQuery();
- } else {
- statement = connection.createStatement();
- parameterMetaData = null;
- resultSet = statement.executeQuery(sql);
- }
- if (parameterMetaData != null) {
- assertThat(parameterMetaData.getParameterCount(), equalTo(2));
- }
- final ResultSetMetaData metaData = resultSet.getMetaData();
- assertEquals(2, metaData.getColumnCount());
- assertEquals("C1", metaData.getColumnName(1));
- assertEquals("C2", metaData.getColumnName(2));
- assertTrue(resultSet.next());
- assertTrue(resultSet.next());
- assertTrue(resultSet.next());
- assertFalse(resultSet.next());
- resultSet.close();
- statement.close();
- connection.close();
- }
-
- @Test public void testStatementLifecycle() throws Exception {
- try (AvaticaConnection connection = (AvaticaConnection) ljs()) {
- Map<Integer, AvaticaStatement> clientMap = connection.statementMap;
- Cache<Integer, Object> serverMap =
- QuasiRemoteJdbcServiceFactory.getRemoteStatementMap(connection);
- assertEquals(0, clientMap.size());
- assertEquals(0, serverMap.size());
- Statement stmt = connection.createStatement();
- assertEquals(1, clientMap.size());
- assertEquals(1, serverMap.size());
- stmt.close();
- assertEquals(0, clientMap.size());
- assertEquals(0, serverMap.size());
- }
- }
-
- @Test public void testConnectionIsolation() throws Exception {
- final String sql = "select * from (values (1, 'a'))";
- Connection conn1 = ljs();
- Connection conn2 = ljs();
- Cache<String, Connection> connectionMap =
- QuasiRemoteJdbcServiceFactory.getRemoteConnectionMap(
- (AvaticaConnection) conn1);
- assertEquals("connection cache should start empty",
- 0, connectionMap.size());
- PreparedStatement conn1stmt1 = conn1.prepareStatement(sql);
- assertEquals(
- "statement creation implicitly creates a connection server-side",
- 1, connectionMap.size());
- PreparedStatement conn2stmt1 = conn2.prepareStatement(sql);
- assertEquals(
- "statement creation implicitly creates a connection server-side",
- 2, connectionMap.size());
- AvaticaPreparedStatement s1 = (AvaticaPreparedStatement) conn1stmt1;
- AvaticaPreparedStatement s2 = (AvaticaPreparedStatement) conn2stmt1;
- assertFalse("connection id's should be unique",
- s1.handle.connectionId.equalsIgnoreCase(s2.handle.connectionId));
- conn2.close();
- assertEquals("closing a connection closes the server-side connection",
- 1, connectionMap.size());
- conn1.close();
- assertEquals("closing a connection closes the server-side connection",
- 0, connectionMap.size());
- }
-
- private void checkStatementExecuteQuery(Connection connection)
- throws SQLException {
- final Statement statement = connection.createStatement();
- final ResultSet resultSet =
- statement.executeQuery("select * from (\n"
- + " values (1, 'a'), (null, 'b'), (3, 'c')) as t (c1, c2)");
- final ResultSetMetaData metaData = resultSet.getMetaData();
- assertEquals(2, metaData.getColumnCount());
- assertEquals("C1", metaData.getColumnName(1));
- assertEquals("C2", metaData.getColumnName(2));
- assertTrue(resultSet.next());
- assertTrue(resultSet.next());
- assertTrue(resultSet.next());
- assertFalse(resultSet.next());
- resultSet.close();
- statement.close();
- connection.close();
- }
-
- @Test public void testPrepareBindExecuteFetch() throws Exception {
- checkPrepareBindExecuteFetch(ljs());
- }
-
- private void checkPrepareBindExecuteFetch(Connection connection)
- throws SQLException {
- final String sql = "select cast(? as integer) * 3 as c, 'x' as x\n"
- + "from (values (1, 'a'))";
- final PreparedStatement ps =
- connection.prepareStatement(sql);
- final ResultSetMetaData metaData = ps.getMetaData();
- assertEquals(2, metaData.getColumnCount());
- assertEquals("C", metaData.getColumnName(1));
- assertEquals("X", metaData.getColumnName(2));
- try {
- final ResultSet resultSet = ps.executeQuery();
- fail("expected error, got " + resultSet);
- } catch (SQLException e) {
- assertThat(e.getMessage(),
- equalTo("exception while executing query: unbound parameter"));
- }
-
- final ParameterMetaData parameterMetaData = ps.getParameterMetaData();
- assertThat(parameterMetaData.getParameterCount(), equalTo(1));
-
- ps.setInt(1, 10);
- final ResultSet resultSet = ps.executeQuery();
- assertTrue(resultSet.next());
- assertThat(resultSet.getInt(1), equalTo(30));
- assertFalse(resultSet.next());
- resultSet.close();
-
- ps.setInt(1, 20);
- final ResultSet resultSet2 = ps.executeQuery();
- assertFalse(resultSet2.isClosed());
- assertTrue(resultSet2.next());
- assertThat(resultSet2.getInt(1), equalTo(60));
- assertThat(resultSet2.wasNull(), is(false));
- assertFalse(resultSet2.next());
- resultSet2.close();
-
- ps.setObject(1, null);
- final ResultSet resultSet3 = ps.executeQuery();
- assertTrue(resultSet3.next());
- assertThat(resultSet3.getInt(1), equalTo(0));
- assertThat(resultSet3.wasNull(), is(true));
- assertFalse(resultSet3.next());
- resultSet3.close();
-
- ps.close();
- connection.close();
- }
-
- /**
- * Factory that creates a service based on a local JDBC connection.
- */
- public static class LocalJdbcServiceFactory implements Service.Factory {
- @Override public Service create(AvaticaConnection connection) {
- try {
- return new LocalService(
- new JdbcMeta(CONNECTION_SPEC.url, CONNECTION_SPEC.username,
- CONNECTION_SPEC.password));
- } catch (SQLException e) {
- throw new RuntimeException(e);
- }
- }
- }
-
- /**
- * Factory that creates a service based on a local JDBC connection.
- */
- public static class QuasiRemoteJdbcServiceFactory implements Service.Factory {
-
- /** a singleton instance that is recreated for each test */
- private static Service service;
-
- static void initService() {
- try {
- final JdbcMeta jdbcMeta = new JdbcMeta(CONNECTION_SPEC.url,
- CONNECTION_SPEC.username, CONNECTION_SPEC.password);
- final LocalService localService = new LocalService(jdbcMeta);
- service = new LocalJsonService(localService);
- } catch (SQLException e) {
- throw new RuntimeException(e);
- }
- }
-
- @Override public Service create(AvaticaConnection connection) {
- assert service != null;
- return service;
- }
-
- /**
- * Reach into the guts of a quasi-remote connection and pull out the
- * statement map from the other side.
- * TODO: refactor tests to replace reflection with package-local access
- */
- static Cache<Integer, Object>
- getRemoteStatementMap(AvaticaConnection connection) throws Exception {
- Field metaF = AvaticaConnection.class.getDeclaredField("meta");
- metaF.setAccessible(true);
- Meta clientMeta = (Meta) metaF.get(connection);
- Field remoteMetaServiceF = clientMeta.getClass().getDeclaredField("service");
- remoteMetaServiceF.setAccessible(true);
- LocalJsonService remoteMetaService = (LocalJsonService) remoteMetaServiceF.get(clientMeta);
- Field remoteMetaServiceServiceF = remoteMetaService.getClass().getDeclaredField("service");
- remoteMetaServiceServiceF.setAccessible(true);
- LocalService remoteMetaServiceService =
- (LocalService) remoteMetaServiceServiceF.get(remoteMetaService);
- Field remoteMetaServiceServiceMetaF =
- remoteMetaServiceService.getClass().getDeclaredField("meta");
- remoteMetaServiceServiceMetaF.setAccessible(true);
- JdbcMeta serverMeta = (JdbcMeta) remoteMetaServiceServiceMetaF.get(remoteMetaServiceService);
- Field jdbcMetaStatementMapF = JdbcMeta.class.getDeclaredField("statementCache");
- jdbcMetaStatementMapF.setAccessible(true);
- //noinspection unchecked
- return (Cache<Integer, Object>) jdbcMetaStatementMapF.get(serverMeta);
- }
-
- /**
- * Reach into the guts of a quasi-remote connection and pull out the
- * connection map from the other side.
- * TODO: refactor tests to replace reflection with package-local access
- */
- static Cache<String, Connection>
- getRemoteConnectionMap(AvaticaConnection connection) throws Exception {
- Field metaF = AvaticaConnection.class.getDeclaredField("meta");
- metaF.setAccessible(true);
- Meta clientMeta = (Meta) metaF.get(connection);
- Field remoteMetaServiceF = clientMeta.getClass().getDeclaredField("service");
- remoteMetaServiceF.setAccessible(true);
- LocalJsonService remoteMetaService = (LocalJsonService) remoteMetaServiceF.get(clientMeta);
- Field remoteMetaServiceServiceF = remoteMetaService.getClass().getDeclaredField("service");
- remoteMetaServiceServiceF.setAccessible(true);
- LocalService remoteMetaServiceService =
- (LocalService) remoteMetaServiceServiceF.get(remoteMetaService);
- Field remoteMetaServiceServiceMetaF =
- remoteMetaServiceService.getClass().getDeclaredField("meta");
- remoteMetaServiceServiceMetaF.setAccessible(true);
- JdbcMeta serverMeta = (JdbcMeta) remoteMetaServiceServiceMetaF.get(remoteMetaServiceService);
- Field jdbcMetaConnectionCacheF = JdbcMeta.class.getDeclaredField("connectionCache");
- jdbcMetaConnectionCacheF.setAccessible(true);
- //noinspection unchecked
- return (Cache<String, Connection>) jdbcMetaConnectionCacheF.get(serverMeta);
- }
- }
-
- /** Information necessary to create a JDBC connection. Specify one to run
- * tests against a different database. (hsqldb is the default.) */
- public static class ConnectionSpec {
- public final String url;
- public final String username;
- public final String password;
- public final String driver;
-
- public ConnectionSpec(String url, String username, String password,
- String driver) {
- this.url = url;
- this.username = username;
- this.password = password;
- this.driver = driver;
- }
-
- public static final ConnectionSpec HSQLDB =
- new ConnectionSpec(ScottHsqldb.URI, ScottHsqldb.USER,
- ScottHsqldb.PASSWORD, "org.hsqldb.jdbcDriver");
- }
-}
-
-// End RemoteDriverTest.java
http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/fa9bdc4a/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 7d26118..cb7217e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -92,6 +92,12 @@ limitations under the License.
</dependency>
<dependency>
<groupId>org.apache.calcite</groupId>
+ <artifactId>calcite-avatica</artifactId>
+ <version>1.2.0-incubating-SNAPSHOT</version>
+ <type>test-jar</type>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.calcite</groupId>
<artifactId>calcite-avatica-server</artifactId>
<version>1.2.0-incubating-SNAPSHOT</version>
</dependency>
@@ -119,6 +125,21 @@ limitations under the License.
<version>1.4</version>
</dependency>
<dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.1.3</version>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-core</artifactId>
+ <version>2.1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-annotations</artifactId>
+ <version>2.1.1</version>
+ </dependency>
+ <dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.1.1</version>
@@ -136,6 +157,11 @@ limitations under the License.
<version>14.0.1</version>
</dependency>
<dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>javax.servlet-api</artifactId>
+ <version>3.0.1</version>
+ </dependency>
+ <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
@@ -191,11 +217,6 @@ limitations under the License.
<version>3.2</version>
</dependency>
<dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- <version>1.1.3</version>
- </dependency>
- <dependency>
<groupId>org.codehaus.janino</groupId>
<artifactId>janino</artifactId>
<version>2.7.6</version>
@@ -206,6 +227,11 @@ limitations under the License.
<version>2.7.6</version>
</dependency>
<dependency>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>hamcrest-core</artifactId>
+ <version>1.3</version>
+ </dependency>
+ <dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>2.3.1</version>
@@ -231,6 +257,11 @@ limitations under the License.
<version>9.2.7.v20150116</version>
</dependency>
<dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-util</artifactId>
+ <version>9.2.7.v20150116</version>
+ </dependency>
+ <dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
<version>2.12.3</version>