Search in sources :

Example 1 with JdbcCatalog

use of org.apache.flink.connector.jdbc.catalog.JdbcCatalog in project flink by apache.

the class JdbcCatalogFactoryTest method setup.

@BeforeClass
public static void setup() throws SQLException {
    // jdbc:postgresql://localhost:50807/postgres?user=postgres
    String embeddedJdbcUrl = pg.getEmbeddedPostgres().getJdbcUrl(TEST_USERNAME, TEST_PWD);
    // jdbc:postgresql://localhost:50807/
    baseUrl = embeddedJdbcUrl.substring(0, embeddedJdbcUrl.lastIndexOf("/") + 1);
    catalog = new JdbcCatalog(TEST_CATALOG_NAME, PostgresCatalog.DEFAULT_DATABASE, TEST_USERNAME, TEST_PWD, baseUrl);
}
Also used : JdbcCatalog(org.apache.flink.connector.jdbc.catalog.JdbcCatalog) BeforeClass(org.junit.BeforeClass)

Example 2 with JdbcCatalog

use of org.apache.flink.connector.jdbc.catalog.JdbcCatalog in project flink by apache.

the class JdbcCatalogFactoryTest method test.

@Test
public void test() {
    final Map<String, String> options = new HashMap<>();
    options.put(CommonCatalogOptions.CATALOG_TYPE.key(), JdbcCatalogFactoryOptions.IDENTIFIER);
    options.put(JdbcCatalogFactoryOptions.DEFAULT_DATABASE.key(), PostgresCatalog.DEFAULT_DATABASE);
    options.put(JdbcCatalogFactoryOptions.USERNAME.key(), TEST_USERNAME);
    options.put(JdbcCatalogFactoryOptions.PASSWORD.key(), TEST_PWD);
    options.put(JdbcCatalogFactoryOptions.BASE_URL.key(), baseUrl);
    final Catalog actualCatalog = FactoryUtil.createCatalog(TEST_CATALOG_NAME, options, null, Thread.currentThread().getContextClassLoader());
    checkEquals(catalog, (JdbcCatalog) actualCatalog);
    assertTrue(((JdbcCatalog) actualCatalog).getInternal() instanceof PostgresCatalog);
}
Also used : JdbcCatalog(org.apache.flink.connector.jdbc.catalog.JdbcCatalog) HashMap(java.util.HashMap) PostgresCatalog(org.apache.flink.connector.jdbc.catalog.PostgresCatalog) JdbcCatalog(org.apache.flink.connector.jdbc.catalog.JdbcCatalog) PostgresCatalog(org.apache.flink.connector.jdbc.catalog.PostgresCatalog) Catalog(org.apache.flink.table.catalog.Catalog) Test(org.junit.Test)

Aggregations

JdbcCatalog (org.apache.flink.connector.jdbc.catalog.JdbcCatalog)2 HashMap (java.util.HashMap)1 PostgresCatalog (org.apache.flink.connector.jdbc.catalog.PostgresCatalog)1 Catalog (org.apache.flink.table.catalog.Catalog)1 BeforeClass (org.junit.BeforeClass)1 Test (org.junit.Test)1