@Test
public void testReplaceLabelsOnNode() throws Exception {

  // Successfully replace labels
  dummyNodeLabelsManager
      .addToCluserNodeLabelsWithDefaultExclusivity(ImmutableSet.of("x", "y", "Y"));
  String[] args =
      { "-replaceLabelsOnNode",
          "node1:8000,x node2:8000=y node3,x node4=Y",
          "-directlyAccessNodeLabelStore" };
  assertEquals(0, rmAdminCLI.run(args));
  assertTrue(dummyNodeLabelsManager.getNodeLabels().containsKey(
      NodeId.newInstance("node1", 8000)));
  assertTrue(dummyNodeLabelsManager.getNodeLabels().containsKey(
      NodeId.newInstance("node2", 8000)));
  assertTrue(dummyNodeLabelsManager.getNodeLabels().containsKey(
      NodeId.newInstance("node3", 0)));
  assertTrue(dummyNodeLabelsManager.getNodeLabels().containsKey(
      NodeId.newInstance("node4", 0)));
  // no labels, should fail
  args = new String[] { "-replaceLabelsOnNode" };
  assertTrue(0 != rmAdminCLI.run(args));
  // no labels, should fail
  args = new String[] { "-replaceLabelsOnNode", "-failOnUnknownNodes" };
  assertTrue(0 != rmAdminCLI.run(args));
  // no labels, should fail
  args =
      new String[] { "-replaceLabelsOnNode", "-directlyAccessNodeLabelStore" };
  assertTrue(0 != rmAdminCLI.run(args));
  // no labels, should fail
  args = new String[] { "-replaceLabelsOnNode", " " };
  assertTrue(0 != rmAdminCLI.run(args));
  args = new String[] { "-replaceLabelsOnNode", ", " };
  assertTrue(0 != rmAdminCLI.run(args));
}