use of org.apache.flink.shaded.guava30.com.google.common.cache.Cache in project calcite-avatica by apache.
the class ConnectionPropertiesTest method getConnection.
private static Connection getConnection(JdbcMeta m, String id) throws Exception {
Field f = JdbcMeta.class.getDeclaredField("connectionCache");
f.setAccessible(true);
// noinspection unchecked
Cache<String, Connection> connectionCache = (Cache<String, Connection>) f.get(m);
return connectionCache.getIfPresent(id);
}
use of org.apache.flink.shaded.guava30.com.google.common.cache.Cache in project calcite-avatica by apache.
the class RemoteMetaTest method getConnection.
private static Connection getConnection(JdbcMeta m, String id) throws Exception {
Field f = JdbcMeta.class.getDeclaredField("connectionCache");
f.setAccessible(true);
// noinspection unchecked
Cache<String, Connection> connectionCache = (Cache<String, Connection>) f.get(m);
return connectionCache.getIfPresent(id);
}
use of org.apache.flink.shaded.guava30.com.google.common.cache.Cache in project calcite-avatica by apache.
the class JdbcMetaTest method testPrepareAndExecuteSetsMaxRows.
@Test
public void testPrepareAndExecuteSetsMaxRows() throws Exception {
final String id = UUID.randomUUID().toString();
final int statementId = 12345;
final String sql = "SELECT * FROM FOO";
final int maxRows = 500;
JdbcMeta meta = Mockito.mock(JdbcMeta.class);
PreparedStatement statement = Mockito.mock(PreparedStatement.class);
@SuppressWarnings("unchecked") Cache<Integer, StatementInfo> statementCache = (Cache<Integer, StatementInfo>) Mockito.mock(Cache.class);
Signature signature = Mockito.mock(Signature.class);
final StatementInfo statementInfo = new StatementInfo(statement);
final StatementHandle statementHandle = new StatementHandle(id, statementId, signature);
Mockito.when(meta.getStatementCache()).thenReturn(statementCache);
Mockito.when(statementCache.getIfPresent(statementId)).thenReturn(statementInfo);
Mockito.when(statement.getResultSet()).thenReturn(null);
// The real methods
Mockito.when(meta.prepareAndExecute(statementHandle, sql, maxRows, 50, null)).thenCallRealMethod();
Mockito.doCallRealMethod().when(meta).setMaxRows(statement, maxRows);
// Call our method
meta.prepareAndExecute(statementHandle, sql, maxRows, 50, null);
// Verify we called setMaxRows with the right value
Mockito.verify(statement).setMaxRows(maxRows);
}
Aggregations