@AfterClass
  public static void cleanupSuite() throws Exception {
    ldap.stop(true);

    // FileUtils.deleteQuietly( new File( config.getGatewayHomeDir() ) );
    // NoOpAppender.tearDown( appenders );
  }
 /**
  * Starts an embedded LDAP server of the specified port.
  *
  * @param port The desired port the LDAP server should listen on.
  * @return The actual port the LDAP server is listening on.
  * @throws Exception Thrown if a failure occurs.
  */
 public int setupLdap(int port) throws Exception {
   URL usersUrl = getResourceUrl("users.ldif");
   ldapTransport = new TcpTransport(port);
   ldap =
       new SimpleLdapDirectoryServer(
           "dc=hadoop,dc=apache,dc=org", new File(usersUrl.toURI()), ldapTransport);
   ldap.start();
   log.info("LDAP port = " + port);
   return port;
 }
 public static void setupLdap() throws Exception {
   URL usersUrl = getResourceUrl("users.ldif");
   int port = findFreePort();
   ldapTransport = new TcpTransport(port);
   ldap =
       new SimpleLdapDirectoryServer(
           "dc=hadoop,dc=apache,dc=org", new File(usersUrl.toURI()), ldapTransport);
   ldap.start();
   LOG.info("LDAP port = " + ldapTransport.getPort());
 }
  public void cleanup() throws Exception {
    gateway.stop();
    FileUtils.deleteQuietly(new File(config.getGatewayTopologyDir()));
    FileUtils.deleteQuietly(new File(config.getGatewayConfDir()));
    FileUtils.deleteQuietly(new File(config.getGatewaySecurityDir()));
    FileUtils.deleteQuietly(new File(config.getGatewayDeploymentDir()));
    FileUtils.deleteQuietly(new File(config.getGatewayDataDir()));
    FileUtils.deleteQuietly(new File(config.getGatewayServicesDir()));

    for (Service service : services.values()) {
      service.server.stop();
    }
    services.clear();

    ldap.stop(true);
  }