@Test(timeout = 5000)
public void testAddInvalidlabel() throws IOException {

  boolean caught = false;
  try {
    Set<String> set = new HashSet<String>();
    set.add(null);
    mgr.addToCluserNodeLabelsWithDefaultExclusivity(set);
  } catch (IOException e) {
    caught = true;
  }
  Assert.assertTrue("null label should not add to repo", caught);
  caught = false;
  try {
    mgr.addToCluserNodeLabelsWithDefaultExclusivity(ImmutableSet.of(CommonNodeLabelsManager.NO_LABEL));
  } catch (IOException e) {
    caught = true;
  }
  Assert.assertTrue("empty label should not add to repo", caught);
  caught = false;
  try {
    mgr.addToCluserNodeLabelsWithDefaultExclusivity(ImmutableSet.of("-?"));
  } catch (IOException e) {
    caught = true;
  }
  Assert.assertTrue("invalid label character should not add to repo", caught);
  caught = false;
  try {
    mgr.addToCluserNodeLabelsWithDefaultExclusivity(ImmutableSet.of(StringUtils.repeat("c", 257)));
  } catch (IOException e) {
    caught = true;
  }
  Assert.assertTrue("too long label should not add to repo", caught);
  caught = false;
  try {
    mgr.addToCluserNodeLabelsWithDefaultExclusivity(ImmutableSet.of("-aaabbb"));
  } catch (IOException e) {
    caught = true;
  }
  Assert.assertTrue("label cannot start with \"-\"", caught);
  caught = false;
  try {
    mgr.addToCluserNodeLabelsWithDefaultExclusivity(ImmutableSet.of("_aaabbb"));
  } catch (IOException e) {
    caught = true;
  }
  Assert.assertTrue("label cannot start with \"_\"", caught);
  
  caught = false;
  try {
    mgr.addToCluserNodeLabelsWithDefaultExclusivity(ImmutableSet.of("a^aabbb"));
  } catch (IOException e) {
    caught = true;
  }
  Assert.assertTrue("label cannot contains other chars like ^[] ...", caught);
  
  caught = false;
  try {
    mgr.addToCluserNodeLabelsWithDefaultExclusivity(ImmutableSet.of("aa[a]bbb"));
  } catch (IOException e) {
    caught = true;
  }
  Assert.assertTrue("label cannot contains other chars like ^[] ...", caught);
}