Search in sources :

Example 1 with MySQLMetadataStorageModule

use of org.apache.druid.metadata.storage.mysql.MySQLMetadataStorageModule 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)

Aggregations

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