private static void populatePartitions(HiveMetaStoreClient hmsc, Table table, List<String> blurbs) throws Exception {
    for (int i=0; i< nDates; ++i) {
      for (String blurb : blurbs) {
        StorageDescriptor sd = new StorageDescriptor(table.getSd());
        // Add partitions located in the table-directory (i.e. default).
        List<String> values = Arrays.asList(datePrefix + i, blurb);
        sd.setLocation(getPartitionPath(table, values));
        hmsc.add_partition(new Partition(values, dbName, tableName, 0, 0, sd, null));
      }
    }
  }
Test to check PartitionSpec support in HiveMetaStore.
standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestHiveMetaStorePartitionSpecs.java