Search in sources :

Example 1 with MySQLConnectorDriverConfig

use of org.apache.druid.metadata.storage.mysql.MySQLConnectorDriverConfig in project druid by druid-io.

the class MySQLFirehoseDatabaseConnectorTest method testSerde.

@Test
public void testSerde() throws JsonProcessingException {
    ObjectMapper mapper = new DefaultObjectMapper();
    mapper.registerModules(new MySQLMetadataStorageModule().getJacksonModules());
    mapper.setInjectableValues(new InjectableValues.Std().addValue(JdbcAccessSecurityConfig.class, INJECTED_CONF).addValue(MySQLConnectorDriverConfig.class, mySQLConnectorDriverConfig));
    MetadataStorageConnectorConfig connectorConfig = new MetadataStorageConnectorConfig() {

        @Override
        public String getConnectURI() {
            return "jdbc:mysql://localhost:3306/test";
        }
    };
    MySQLFirehoseDatabaseConnector connector = new MySQLFirehoseDatabaseConnector(connectorConfig, null, INJECTED_CONF, mySQLConnectorDriverConfig);
    MySQLFirehoseDatabaseConnector andBack = mapper.readValue(mapper.writeValueAsString(connector), MySQLFirehoseDatabaseConnector.class);
    Assert.assertEquals(connector, andBack);
    // test again with classname
    connector = new MySQLFirehoseDatabaseConnector(connectorConfig, "some.class.name.Driver", INJECTED_CONF, mySQLConnectorDriverConfig);
    andBack = mapper.readValue(mapper.writeValueAsString(connector), MySQLFirehoseDatabaseConnector.class);
    Assert.assertEquals(connector, andBack);
}
Also used : MetadataStorageConnectorConfig(org.apache.druid.metadata.MetadataStorageConnectorConfig) MySQLConnectorDriverConfig(org.apache.druid.metadata.storage.mysql.MySQLConnectorDriverConfig) DefaultObjectMapper(org.apache.druid.jackson.DefaultObjectMapper) InjectableValues(com.fasterxml.jackson.databind.InjectableValues) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) DefaultObjectMapper(org.apache.druid.jackson.DefaultObjectMapper) MySQLMetadataStorageModule(org.apache.druid.metadata.storage.mysql.MySQLMetadataStorageModule) Test(org.junit.Test)

Example 2 with MySQLConnectorDriverConfig

use of org.apache.druid.metadata.storage.mysql.MySQLConnectorDriverConfig in project druid by apache.

the class MySQLFirehoseDatabaseConnectorTest method testSerde.

@Test
public void testSerde() throws JsonProcessingException {
    ObjectMapper mapper = new DefaultObjectMapper();
    mapper.registerModules(new MySQLMetadataStorageModule().getJacksonModules());
    mapper.setInjectableValues(new InjectableValues.Std().addValue(JdbcAccessSecurityConfig.class, INJECTED_CONF).addValue(MySQLConnectorDriverConfig.class, mySQLConnectorDriverConfig));
    MetadataStorageConnectorConfig connectorConfig = new MetadataStorageConnectorConfig() {

        @Override
        public String getConnectURI() {
            return "jdbc:mysql://localhost:3306/test";
        }
    };
    MySQLFirehoseDatabaseConnector connector = new MySQLFirehoseDatabaseConnector(connectorConfig, null, INJECTED_CONF, mySQLConnectorDriverConfig);
    MySQLFirehoseDatabaseConnector andBack = mapper.readValue(mapper.writeValueAsString(connector), MySQLFirehoseDatabaseConnector.class);
    Assert.assertEquals(connector, andBack);
    // test again with classname
    connector = new MySQLFirehoseDatabaseConnector(connectorConfig, "some.class.name.Driver", INJECTED_CONF, mySQLConnectorDriverConfig);
    andBack = mapper.readValue(mapper.writeValueAsString(connector), MySQLFirehoseDatabaseConnector.class);
    Assert.assertEquals(connector, andBack);
}
Also used : MetadataStorageConnectorConfig(org.apache.druid.metadata.MetadataStorageConnectorConfig) MySQLConnectorDriverConfig(org.apache.druid.metadata.storage.mysql.MySQLConnectorDriverConfig) DefaultObjectMapper(org.apache.druid.jackson.DefaultObjectMapper) InjectableValues(com.fasterxml.jackson.databind.InjectableValues) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) DefaultObjectMapper(org.apache.druid.jackson.DefaultObjectMapper) MySQLMetadataStorageModule(org.apache.druid.metadata.storage.mysql.MySQLMetadataStorageModule) Test(org.junit.Test)

Aggregations

InjectableValues (com.fasterxml.jackson.databind.InjectableValues)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 DefaultObjectMapper (org.apache.druid.jackson.DefaultObjectMapper)2 MetadataStorageConnectorConfig (org.apache.druid.metadata.MetadataStorageConnectorConfig)2 MySQLConnectorDriverConfig (org.apache.druid.metadata.storage.mysql.MySQLConnectorDriverConfig)2 MySQLMetadataStorageModule (org.apache.druid.metadata.storage.mysql.MySQLMetadataStorageModule)2 Test (org.junit.Test)2