@Test
  public void testAddPartitionSpecWithSharedSD() throws Exception {

    Table table = createTable();
    PartitionWithoutSD partition1 = buildPartitionWithoutSD(Lists.newArrayList("2013"), 1);
    PartitionWithoutSD partition2 = buildPartitionWithoutSD(Lists.newArrayList("2014"), 2);
    PartitionWithoutSD partition3 = buildPartitionWithoutSD(Lists.newArrayList("2012"), 3);
    List<PartitionWithoutSD> partitions = Lists.newArrayList(partition1, partition2, partition3);

    String location = table.getSd().getLocation() + "/sharedSDTest/";
    PartitionSpecProxy partitionSpecProxy =
        buildPartitionSpecWithSharedSD(partitions, buildSD(location));
    client.add_partitions_pspec(partitionSpecProxy);

    verifyPartitionSharedSD(table, "year=2013", Lists.newArrayList("2013"), 1);
    verifyPartitionSharedSD(table, "year=2014", Lists.newArrayList("2014"), 2);
    verifyPartitionSharedSD(table, "year=2012", Lists.newArrayList("2012"), 3);
  }
Tests for creating partitions from partition spec.
standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/client/TestAddPartitionsFromPartSpec.java