@Test
public void testValidAuxServiceName() throws IOException {

  Configuration conf = getABConf("Asrv1", "Bsrv_2", ServiceA.class,
      ServiceB.class);
  final AuxServices aux = new AuxServices(MOCK_AUX_PATH_HANDLER,
      MOCK_CONTEXT, MOCK_DEL_SERVICE);
  try {
    aux.init(conf);
  } catch (Exception ex) {
    Assert.fail("Should not receive the exception.");
  }
  //Test bad auxService Name
  final AuxServices aux1 = new AuxServices(MOCK_AUX_PATH_HANDLER,
      MOCK_CONTEXT, MOCK_DEL_SERVICE);
  if (useManifest) {
    AuxServiceRecord serviceA =
        AuxServices.newAuxService("1Asrv1", ServiceA.class.getName());
    writeManifestFile(new AuxServiceRecords().serviceList(serviceA), conf);
  } else {
    conf.setStrings(YarnConfiguration.NM_AUX_SERVICES, new String[]
        {"1Asrv1"});
    conf.setClass(String.format(YarnConfiguration.NM_AUX_SERVICE_FMT,
        "1Asrv1"), ServiceA.class, Service.class);
  }
  try {
    aux1.init(conf);
    Assert.fail("Should receive the exception.");
  } catch (Exception ex) {
    assertTrue("Wrong message: " + ex.getMessage(),
        ex.getMessage().contains("The auxiliary service name: 1Asrv1 is " +
            "invalid. The valid service name should only contain a-zA-Z0-9_" +
            " and cannot start with numbers."));
  }
}