Search in sources :

Example 16 with AbandonRequest

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

the class AbandonRequestTest method testRequestWithRequestId.

/**
 * Test parsing of a request with the (optional) requestID attribute
 */
@Test
public void testRequestWithRequestId() {
    Dsmlv2Parser parser = null;
    try {
        parser = newParser();
        parser.setInput(AbandonRequestTest.class.getResource("request_with_requestID_attribute.xml").openStream(), "UTF-8");
        parser.parse();
    } catch (Exception e) {
        fail(e.getMessage());
    }
    AbandonRequest abandonRequest = (AbandonRequest) parser.getBatchRequest().getCurrentRequest();
    assertEquals(456, abandonRequest.getMessageId());
}
Also used : AbandonRequest(org.apache.directory.api.ldap.model.message.AbandonRequest) Dsmlv2Parser(org.apache.directory.api.dsmlv2.Dsmlv2Parser) Test(org.junit.Test) AbstractTest(org.apache.directory.api.dsmlv2.AbstractTest)

Example 17 with AbandonRequest

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

the class AbandonRequestTest method testRequestWith2Controls.

/**
 * Test parsing of a request with 2 (optional) Control elements
 */
@Test
public void testRequestWith2Controls() {
    Dsmlv2Parser parser = null;
    try {
        parser = newParser();
        parser.setInput(AbandonRequestTest.class.getResource("request_with_2_controls.xml").openStream(), "UTF-8");
        parser.parse();
    } catch (Exception e) {
        fail(e.getMessage());
    }
    AbandonRequest abandonRequest = (AbandonRequest) parser.getBatchRequest().getCurrentRequest();
    Map<String, Control> controls = abandonRequest.getControls();
    assertEquals(2, abandonRequest.getControls().size());
    Control control = controls.get("1.2.840.113556.1.4.789");
    assertNotNull(control);
    assertFalse(control.isCritical());
    assertEquals("1.2.840.113556.1.4.789", control.getOid());
    assertEquals("Some other text", Strings.utf8ToString(((DsmlControl<?>) control).getValue()));
}
Also used : DsmlControl(org.apache.directory.api.dsmlv2.DsmlControl) DsmlControl(org.apache.directory.api.dsmlv2.DsmlControl) Control(org.apache.directory.api.ldap.model.message.Control) AbandonRequest(org.apache.directory.api.ldap.model.message.AbandonRequest) Dsmlv2Parser(org.apache.directory.api.dsmlv2.Dsmlv2Parser) Test(org.junit.Test) AbstractTest(org.apache.directory.api.dsmlv2.AbstractTest)

Aggregations

AbandonRequest (org.apache.directory.api.ldap.model.message.AbandonRequest)17 Test (org.junit.Test)13 AbstractTest (org.apache.directory.api.dsmlv2.AbstractTest)9 Dsmlv2Parser (org.apache.directory.api.dsmlv2.Dsmlv2Parser)9 Control (org.apache.directory.api.ldap.model.message.Control)9 AbandonRequestDecorator (org.apache.directory.api.ldap.codec.decorators.AbandonRequestDecorator)6 AbandonRequestImpl (org.apache.directory.api.ldap.model.message.AbandonRequestImpl)6 DecoderException (org.apache.directory.api.asn1.DecoderException)5 DsmlControl (org.apache.directory.api.dsmlv2.DsmlControl)5 ByteBuffer (java.nio.ByteBuffer)4 EncoderException (org.apache.directory.api.asn1.EncoderException)4 Asn1Decoder (org.apache.directory.api.asn1.ber.Asn1Decoder)4 LdapMessageContainer (org.apache.directory.api.ldap.codec.api.LdapMessageContainer)4 AbstractCodecServiceTest (org.apache.directory.api.ldap.codec.osgi.AbstractCodecServiceTest)4 CodecControl (org.apache.directory.api.ldap.codec.api.CodecControl)3 BatchRequestDsml (org.apache.directory.api.dsmlv2.request.BatchRequestDsml)2 AddRequest (org.apache.directory.api.ldap.model.message.AddRequest)2 BindRequest (org.apache.directory.api.ldap.model.message.BindRequest)2 CompareRequest (org.apache.directory.api.ldap.model.message.CompareRequest)2 DeleteRequest (org.apache.directory.api.ldap.model.message.DeleteRequest)2