static Table createTableAndWriteDataWithLabels(TableName tableName, String... labelExps)
    throws Exception {
    List<Put> puts = new ArrayList<>(labelExps.length);
    for (int i = 0; i < labelExps.length; i++) {
      Put put = new Put(Bytes.toBytes("row" + (i + 1)));
      put.addColumn(fam, qual, HConstants.LATEST_TIMESTAMP, value);
      put.setCellVisibility(new CellVisibility(labelExps[i]));
      puts.add(put);
    }
    Table table = TEST_UTIL.createTable(tableName, fam);
    table.put(puts);
    return table;
  }
Base test class for visibility labels basic features
hbase-server/src/test/java/org/apache/hadoop/hbase/security/visibility/TestVisibilityLabels.java