private void doBadFactoryClassTest(String configKey) throws Exception {
    Properties properties = new Properties();
    setMandatoryValues(properties);

    // Non existent class.
    properties.setProperty(configKey, "non.existent.factory");
    VerifiableProperties verifiableProperties = new VerifiableProperties(properties);
    try {
      new RestServer(verifiableProperties, new MockClusterMap(), new LoggingNotificationSystem(), SSL_FACTORY);
      fail("Properties file contained non existent " + configKey + ", yet no exception was thrown");
    } catch (ClassNotFoundException e) {
      // nothing to do. expected.
    }

    // invalid factory class.
    properties.setProperty(configKey, RestServerTest.class.getCanonicalName());
    verifiableProperties = new VerifiableProperties(properties);
    try {
      new RestServer(verifiableProperties, new MockClusterMap(), new LoggingNotificationSystem(), SSL_FACTORY);
      fail("Properties file contained invalid " + configKey + " class, yet no exception was thrown");
    } catch (NoSuchMethodException e) {
      // nothing to do. expected.
    }

    // faulty factory class
    properties.setProperty(configKey, FaultyFactory.class.getCanonicalName());
    verifiableProperties = new VerifiableProperties(properties);
    try {
      RestServer restServer =
          new RestServer(verifiableProperties, new MockClusterMap(), new LoggingNotificationSystem(), SSL_FACTORY);
      restServer.start();
      fail("Properties file contained faulty " + configKey + " class, yet no exception was thrown");
    } catch (InstantiationException e) {
      // nothing to do. expected.
    }
  }
Tests for bad factory class name for {@code configKey} in {@link RestServer}.
@param configKey the property whose value is the bad factory class
@throws Exception
ambry-rest/src/test/java/com/github/ambry/rest/RestServerTest.java