@Test(expected = MetaException.class) public void testPreCreateTableWhenDataSourceExists()
      throws MetaException, IOException {
    derbyConnectorRule.getConnector().createSegmentTable();
    SQLMetadataStorageUpdaterJobHandler
        sqlMetadataStorageUpdaterJobHandler =
        new SQLMetadataStorageUpdaterJobHandler(derbyConnectorRule.getConnector());
    Path taskDirPath = new Path(tableWorkingPath, druidStorageHandler.makeStagingName());
    DataSegment dataSegment = createSegment(new Path(taskDirPath, "intermediatePath").toString());

    sqlMetadataStorageUpdaterJobHandler.publishSegments(segmentsTable,
        Collections.singletonList(dataSegment),
        DruidStorageHandlerUtils.JSON_MAPPER);

    druidStorageHandler.preCreateTable(tableMock);
  }
Test class for Druid Storage handler.
druid-handler/src/test/org/apache/hadoop/hive/druid/TestDruidStorageHandler.java