@Test
public void testAddToClusterNodeLabels() throws Exception {

  // successfully add labels
  String[] args =
      { "-addToClusterNodeLabels", "x", "-directlyAccessNodeLabelStore" };
  assertEquals(0, rmAdminCLI.run(args));
  assertTrue(dummyNodeLabelsManager.getClusterNodeLabelNames().containsAll(
      ImmutableSet.of("x")));
  
  // no labels, should fail
  args = new String[] { "-addToClusterNodeLabels" };
  assertTrue(0 != rmAdminCLI.run(args));
  
  // no labels, should fail
  args =
      new String[] { "-addToClusterNodeLabels",
          "-directlyAccessNodeLabelStore" };
  assertTrue(0 != rmAdminCLI.run(args));
  // no labels, should fail at client validation
  args = new String[] { "-addToClusterNodeLabels", " " };
  assertTrue(0 != rmAdminCLI.run(args));
  // no labels, should fail at client validation
  args = new String[] { "-addToClusterNodeLabels", " , " };
  assertTrue(0 != rmAdminCLI.run(args));
  // successfully add labels
  args =
      new String[] { "-addToClusterNodeLabels", ",x,,",
          "-directlyAccessNodeLabelStore" };
  assertEquals(0, rmAdminCLI.run(args));
  assertTrue(dummyNodeLabelsManager.getClusterNodeLabelNames().containsAll(
      ImmutableSet.of("x")));
}