mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Valery Kharseko
12 hours ago d0ce1d7f63e37dc3dc2233b52ced614a2cb5d71b
opendj-server-legacy/src/test/java/org/opends/server/protocols/ldap/TestLDAPConnectionHandler.java
@@ -29,6 +29,7 @@
import org.opends.server.TestCaseUtils;
import org.forgerock.opendj.server.config.server.LDAPConnectionHandlerCfg;
import org.opends.server.api.ClientConnection;
import org.opends.server.api.ConnectionHandler;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.Attribute;
@@ -366,4 +367,38 @@
    LDAPConnHandler.applyConfigurationChange(config);
    LDAPConnHandler.finalizeConnectionHandler(reasonMsg);
  }
  /**
   * A handler created with {@code dsconfig create-connection-handler --type ldap} and no explicit
   * {@code java-class} must run on the same class as the shipped LDAP listeners, not on the legacy
   * {@link LDAPConnectionHandler} (issue #1116).
   */
  @Test
  public void testCreatedHandlerDefaultsToLDAPConnectionHandler2() throws Exception {
    final String handlerName = "Default Class LDAP Connection Handler";
    final DN handlerDN = DN.valueOf("cn=" + handlerName + ",cn=Connection Handlers,cn=config");
    TestCaseUtils.dsconfig(
        "create-connection-handler",
        "--type", "ldap",
        "--handler-name", handlerName,
        "--set", "enabled:true",
        "--set", "listen-address:127.0.0.1",
        "--set", "listen-port:" + TestCaseUtils.findFreePort());
    try {
      Entry handlerEntry = DirectoryServer.getEntry(handlerDN);
      assertEquals(handlerEntry.parseAttribute("ds-cfg-java-class").asString(),
          LDAPConnectionHandler2.class.getName());
      ConnectionHandler<?> running = null;
      for (ConnectionHandler<?> handler : DirectoryServer.getConnectionHandlers()) {
        if (handlerDN.equals(handler.getComponentEntryDN())) {
          running = handler;
        }
      }
      assertNotNull(running, "the created handler is not registered");
      assertEquals(running.getClass(), LDAPConnectionHandler2.class);
    } finally {
      TestCaseUtils.dsconfig("delete-connection-handler", "--handler-name", handlerName);
    }
  }
}