@Test(expected = MetaException.class) public void testCommitInsertIntoWithNonExtendableSegment()
      throws MetaException, IOException {
    DerbyConnectorTestUtility connector = derbyConnectorRule.getConnector();
    MetadataStorageTablesConfig metadataStorageTablesConfig = derbyConnectorRule.metadataTablesConfigSupplier().get();
    druidStorageHandler.preCreateTable(tableMock);
    LocalFileSystem localFileSystem = FileSystem.getLocal(config);
    Path taskDirPath = new Path(tableWorkingPath, druidStorageHandler.makeStagingName());
    List<DataSegment>
        existingSegments =
        Arrays.asList(createSegment(new Path(taskDirPath, "index_old_1.zip").toString(),
            new Interval(100, 150, DateTimeZone.UTC),
            "v0",
            NoneShardSpec.instance()),
            createSegment(new Path(taskDirPath, "index_old_2.zip").toString(),
                new Interval(200, 250, DateTimeZone.UTC),
                "v0",
                new LinearShardSpec(0)),
            createSegment(new Path(taskDirPath, "index_old_3.zip").toString(),
                new Interval(250, 300, DateTimeZone.UTC),
                "v0",
                new LinearShardSpec(0)));
    HdfsDataSegmentPusherConfig pusherConfig = new HdfsDataSegmentPusherConfig();
    pusherConfig.setStorageDirectory(taskDirPath.toString());
    DataSegmentPusher
        dataSegmentPusher =
        new HdfsDataSegmentPusher(pusherConfig, config, DruidStorageHandlerUtils.JSON_MAPPER);
    DruidStorageHandlerUtils.publishSegmentsAndCommit(connector,
        metadataStorageTablesConfig,
        DATA_SOURCE_NAME,
        existingSegments,
        true,
        config,
        dataSegmentPusher);

    // Try appending to non extendable shard spec
    DataSegment
        conflictingSegment =
        createSegment(new Path(taskDirPath, DruidStorageHandlerUtils.INDEX_ZIP).toString(),
            new Interval(100, 150, DateTimeZone.UTC),
            "v1",
            new LinearShardSpec(0));
    Path
        descriptorPath =
        DruidStorageHandlerUtils.makeSegmentDescriptorOutputPath(conflictingSegment,
            new Path(taskDirPath, DruidStorageHandler.SEGMENTS_DESCRIPTOR_DIR_NAME));
    DruidStorageHandlerUtils.writeSegmentDescriptor(localFileSystem, conflictingSegment, descriptorPath);

    druidStorageHandler.commitInsertTable(tableMock, false);

  }
Test class for Druid Storage handler.
druid-handler/src/test/org/apache/hadoop/hive/druid/TestDruidStorageHandler.java