Search in sources :

Example 1 with TestRequestHandler

use of com.unboundid.ldap.listener.TestRequestHandler in project ldapsdk by pingidentity.

the class LDAPDebuggerTestCase method setUp.

/**
 * Create the listener that will be used for this class.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@BeforeClass()
public void setUp() throws Exception {
    final File debuggerLogFile = createTempFile();
    debuggerLogFile.delete();
    final File codeLogFile = createTempFile();
    codeLogFile.delete();
    final File listenerLogFile = createTempFile();
    listenerLogFile.delete();
    final AccessLogRequestHandler requestHandler = new AccessLogRequestHandler(new FileHandler(listenerLogFile.getAbsolutePath()), new TestRequestHandler());
    final LDAPListenerConfig config = new LDAPListenerConfig(0, requestHandler);
    listener = new LDAPListener(config);
    listener.startListening();
    final int listenerPort = listener.getListenPort();
    debugger = new LDAPDebugger(null, null);
    assertEquals(debugger.runTool("--hostname", "localhost", "--port", String.valueOf(listenerPort), "--outputFile", debuggerLogFile.getAbsolutePath(), "--codeLogFile", codeLogFile.getAbsolutePath()), ResultCode.SUCCESS);
    conn = new LDAPConnection("localhost", debugger.getListener().getListenPort());
    TestRequestHandler.setControls(new Control("4.3.2.1", true, new ASN1OctetString("x")), new Control("4.3.2.2", false, new ASN1OctetString("y")));
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) LDAPListenerConfig(com.unboundid.ldap.listener.LDAPListenerConfig) AuthorizationIdentityRequestControl(com.unboundid.ldap.sdk.controls.AuthorizationIdentityRequestControl) Control(com.unboundid.ldap.sdk.Control) ManageDsaITRequestControl(com.unboundid.ldap.sdk.controls.ManageDsaITRequestControl) LDAPListener(com.unboundid.ldap.listener.LDAPListener) TestRequestHandler(com.unboundid.ldap.listener.TestRequestHandler) LDAPConnection(com.unboundid.ldap.sdk.LDAPConnection) File(java.io.File) AccessLogRequestHandler(com.unboundid.ldap.listener.AccessLogRequestHandler) FileHandler(java.util.logging.FileHandler) BeforeClass(org.testng.annotations.BeforeClass)

Aggregations

ASN1OctetString (com.unboundid.asn1.ASN1OctetString)1 AccessLogRequestHandler (com.unboundid.ldap.listener.AccessLogRequestHandler)1 LDAPListener (com.unboundid.ldap.listener.LDAPListener)1 LDAPListenerConfig (com.unboundid.ldap.listener.LDAPListenerConfig)1 TestRequestHandler (com.unboundid.ldap.listener.TestRequestHandler)1 Control (com.unboundid.ldap.sdk.Control)1 LDAPConnection (com.unboundid.ldap.sdk.LDAPConnection)1 AuthorizationIdentityRequestControl (com.unboundid.ldap.sdk.controls.AuthorizationIdentityRequestControl)1 ManageDsaITRequestControl (com.unboundid.ldap.sdk.controls.ManageDsaITRequestControl)1 File (java.io.File)1 FileHandler (java.util.logging.FileHandler)1 BeforeClass (org.testng.annotations.BeforeClass)1