use of com.amazonaws.athena.connectors.jdbc.connection.DatabaseConnectionConfig in project aws-athena-query-federation by awslabs.
the class TeradataCompositeHandlerTest method teradataCompositeHandlerTest.
@Test
public void teradataCompositeHandlerTest() {
Exception ex = null;
try {
DatabaseConnectionConfig databaseConnectionConfig = new DatabaseConnectionConfig("testCatalog", TeradataConstants.TERADATA_NAME, "teradata://jdbc:teradata://hostname/user=dbc&password=dbc");
PowerMockito.mockStatic(JDBCUtil.class);
JDBCUtil tested = PowerMockito.mock(JDBCUtil.class);
PowerMockito.when(tested.getSingleDatabaseConfigFromEnv(TeradataConstants.TERADATA_NAME)).thenReturn(databaseConnectionConfig);
teradataCompositeHandler = new TeradataCompositeHandler();
assertEquals(teradataCompositeHandler.getClass(), TeradataCompositeHandler.class);
} catch (Exception e) {
ex = e;
}
assertEquals(null, ex);
}
use of com.amazonaws.athena.connectors.jdbc.connection.DatabaseConnectionConfig in project aws-athena-query-federation by awslabs.
the class HiveMuxMetadataHandlerTest method setup.
@Before
public void setup() {
this.allocator = new BlockAllocatorImpl();
this.hiveMetadataHandler = Mockito.mock(HiveMetadataHandler.class);
this.metadataHandlerMap = Collections.singletonMap("metaHive", this.hiveMetadataHandler);
this.secretsManager = Mockito.mock(AWSSecretsManager.class);
this.athena = Mockito.mock(AmazonAthena.class);
this.queryStatusChecker = Mockito.mock(QueryStatusChecker.class);
this.jdbcConnectionFactory = Mockito.mock(JdbcConnectionFactory.class);
DatabaseConnectionConfig databaseConnectionConfig = new DatabaseConnectionConfig("testCatalog", HiveConstants.HIVE_NAME, "hive2://jdbc:hive2://54.89.6.2:10000/authena;AuthMech=3;${testSecret}", "testSecret");
this.jdbcMetadataHandler = new HiveMuxMetadataHandler(this.secretsManager, this.athena, this.jdbcConnectionFactory, this.metadataHandlerMap, databaseConnectionConfig);
}
use of com.amazonaws.athena.connectors.jdbc.connection.DatabaseConnectionConfig in project aws-athena-query-federation by awslabs.
the class ImpalaMuxRecordHandlerTest method maxCatalogTest.
@Test
public void maxCatalogTest() {
Map<String, JdbcRecordHandler> recorddataHandlersMap = new HashMap<String, JdbcRecordHandler>();
for (int jdbcHandlerCount = 0; jdbcHandlerCount <= 100; jdbcHandlerCount++) {
recorddataHandlersMap.put("recordImpala" + jdbcHandlerCount, this.impalaRecordHandler);
}
DatabaseConnectionConfig databaseConnectionConfig = new DatabaseConnectionConfig("testCatalog1", ImpalaConstants.IMPALA_NAME, "impala://jdbc:impala://54.89.6.2:10000/authena;AuthMech=3;${testSecret}", "testSecret");
try {
new ImpalaMuxRecordHandler(this.amazonS3, this.secretsManager, this.athena, this.jdbcConnectionFactory, databaseConnectionConfig, recorddataHandlersMap);
} catch (Exception e) {
e.getMessage();
Assert.assertTrue(e.getMessage().contains("Max 100 catalogs supported in multiplexer."));
}
}
use of com.amazonaws.athena.connectors.jdbc.connection.DatabaseConnectionConfig in project aws-athena-query-federation by awslabs.
the class ImpalaRecordHandlerTest method setup.
@Before
public void setup() {
this.amazonS3 = Mockito.mock(AmazonS3.class);
this.secretsManager = Mockito.mock(AWSSecretsManager.class);
this.athena = Mockito.mock(AmazonAthena.class);
Mockito.when(this.secretsManager.getSecretValue(Mockito.eq(new GetSecretValueRequest().withSecretId("testSecret")))).thenReturn(new GetSecretValueResult().withSecretString("{\"username\": \"testUser\", \"password\": \"testPassword\"}"));
this.connection = Mockito.mock(Connection.class);
this.jdbcConnectionFactory = Mockito.mock(JdbcConnectionFactory.class);
Mockito.when(this.jdbcConnectionFactory.getConnection(Mockito.mock(JdbcCredentialProvider.class))).thenReturn(this.connection);
jdbcSplitQueryBuilder = new ImpalaQueryStringBuilder("`");
final DatabaseConnectionConfig databaseConnectionConfig = new DatabaseConnectionConfig("testCatalog", ImpalaConstants.IMPALA_NAME, "impala://jdbc:impala://54.89.6.2:10000/authena;{testSecret}", "testSecret");
this.impalaRecordHandler = new ImpalaRecordHandler(databaseConnectionConfig, amazonS3, secretsManager, athena, jdbcConnectionFactory, jdbcSplitQueryBuilder);
}
use of com.amazonaws.athena.connectors.jdbc.connection.DatabaseConnectionConfig in project aws-athena-query-federation by awslabs.
the class DataLakeCompositeHandlerTest method dataLakeCompositeHandlerTest.
@Test
public void dataLakeCompositeHandlerTest() {
Exception ex = null;
try {
DatabaseConnectionConfig databaseConnectionConfig = new DatabaseConnectionConfig("testCatalog1", DataLakeGen2Constants.NAME, "datalakegentwo://jdbc:sqlserver://hostname;databaseName=fakedatabase;");
PowerMockito.mockStatic(JDBCUtil.class);
JDBCUtil tested = PowerMockito.mock(JDBCUtil.class);
PowerMockito.when(tested.getSingleDatabaseConfigFromEnv(DataLakeGen2Constants.NAME)).thenReturn(databaseConnectionConfig);
dataLakeGen2CompositeHandler = new DataLakeGen2CompositeHandler();
logger.info("dataLakeGen2CompositeHandler: {}", dataLakeGen2CompositeHandler);
} catch (Exception e) {
ex = e;
}
Assert.assertEquals(null, ex);
}
Aggregations