Search in sources :

Example 11 with BindRequestImpl

use of org.apache.directory.api.ldap.model.message.BindRequestImpl in project directory-ldap-api by apache.

the class BindRequestPerfTest method testEncodeBindRequestPerf.

/**
 * Test the decoding of a BindRequest with Simple authentication and no
 * controls
 */
@Test
@Ignore
public void testEncodeBindRequestPerf() throws Exception {
    Dn dn = new Dn("uid=akarasulu,dc=example,dc=com");
    int nbLoops = 1000000;
    long t0 = System.currentTimeMillis();
    for (int i = 0; i < nbLoops; i++) {
        // Check the decoded BindRequest
        BindRequest bindRequest = new BindRequestImpl();
        bindRequest.setMessageId(1);
        bindRequest.setSimple(true);
        bindRequest.setDn(dn);
        bindRequest.setCredentials(Strings.getBytesUtf8("password"));
        Control control = new OpaqueControl("2.16.840.1.113730.3.4.2");
        bindRequest.addControl(control);
        // Check the encoding
        try {
            encoder.encodeMessage(bindRequest);
        } catch (EncoderException ee) {
            ee.printStackTrace();
            fail(ee.getMessage());
        }
    }
    long t1 = System.currentTimeMillis();
    System.out.println("BindRequest testEncodeBindRequestPerf, " + nbLoops + " loops, Delta = " + (t1 - t0));
}
Also used : EncoderException(org.apache.directory.api.asn1.EncoderException) Control(org.apache.directory.api.ldap.model.message.Control) CodecControl(org.apache.directory.api.ldap.codec.api.CodecControl) OpaqueControl(org.apache.directory.api.ldap.model.message.controls.OpaqueControl) BindRequest(org.apache.directory.api.ldap.model.message.BindRequest) Dn(org.apache.directory.api.ldap.model.name.Dn) OpaqueControl(org.apache.directory.api.ldap.model.message.controls.OpaqueControl) BindRequestImpl(org.apache.directory.api.ldap.model.message.BindRequestImpl) Ignore(org.junit.Ignore) Test(org.junit.Test) AbstractCodecServiceTest(org.apache.directory.api.ldap.codec.osgi.AbstractCodecServiceTest)

Aggregations

BindRequestImpl (org.apache.directory.api.ldap.model.message.BindRequestImpl)11 BindRequest (org.apache.directory.api.ldap.model.message.BindRequest)9 BindResponse (org.apache.directory.api.ldap.model.message.BindResponse)5 Dn (org.apache.directory.api.ldap.model.name.Dn)4 IOException (java.io.IOException)2 DecoderException (org.apache.directory.api.asn1.DecoderException)2 LdapException (org.apache.directory.api.ldap.model.exception.LdapException)2 Control (org.apache.directory.api.ldap.model.message.Control)2 OpaqueControl (org.apache.directory.api.ldap.model.message.controls.OpaqueControl)2 Test (org.junit.Test)2 ConnectException (java.net.ConnectException)1 UnresolvedAddressException (java.nio.channels.UnresolvedAddressException)1 HashMap (java.util.HashMap)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 SaslClient (javax.security.sasl.SaslClient)1 EncoderException (org.apache.directory.api.asn1.EncoderException)1 TLV (org.apache.directory.api.asn1.ber.tlv.TLV)1 CodecControl (org.apache.directory.api.ldap.codec.api.CodecControl)1 MessageEncoderException (org.apache.directory.api.ldap.codec.api.MessageEncoderException)1 BindRequestDecorator (org.apache.directory.api.ldap.codec.decorators.BindRequestDecorator)1