Search in sources :

Example 16 with CompareRequest

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

the class BatchRequestTest method testResponseWith1CompareRequest.

/**
 * Test parsing of a Request with 1 CompareRequest
 */
@Test
public void testResponseWith1CompareRequest() {
    Dsmlv2Parser parser = null;
    try {
        parser = newParser();
        parser.setInput(BatchRequestTest.class.getResource("request_with_1_CompareRequest.xml").openStream(), "UTF-8");
        parser.parse();
    } catch (Exception e) {
        fail(e.getMessage());
    }
    BatchRequestDsml batchRequest = parser.getBatchRequest();
    assertEquals(1, batchRequest.getRequests().size());
    if (batchRequest.getCurrentRequest() instanceof CompareRequest) {
        assertTrue(true);
    } else {
        fail();
    }
}
Also used : BatchRequestDsml(org.apache.directory.api.dsmlv2.request.BatchRequestDsml) CompareRequest(org.apache.directory.api.ldap.model.message.CompareRequest) Dsmlv2Parser(org.apache.directory.api.dsmlv2.Dsmlv2Parser) Test(org.junit.Test) AbstractTest(org.apache.directory.api.dsmlv2.AbstractTest)

Example 17 with CompareRequest

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

the class BatchRequestTest method testResponseWith2CompareRequest.

/**
 * Test parsing of a Request with 2 CompareRequest
 */
@Test
public void testResponseWith2CompareRequest() {
    Dsmlv2Parser parser = null;
    try {
        parser = newParser();
        parser.setInput(BatchRequestTest.class.getResource("request_with_2_CompareRequest.xml").openStream(), "UTF-8");
        parser.parse();
    } catch (Exception e) {
        fail(e.getMessage());
    }
    BatchRequestDsml batchRequest = parser.getBatchRequest();
    assertEquals(2, batchRequest.getRequests().size());
    if (batchRequest.getCurrentRequest() instanceof CompareRequest) {
        assertTrue(true);
    } else {
        fail();
    }
}
Also used : BatchRequestDsml(org.apache.directory.api.dsmlv2.request.BatchRequestDsml) CompareRequest(org.apache.directory.api.ldap.model.message.CompareRequest) Dsmlv2Parser(org.apache.directory.api.dsmlv2.Dsmlv2Parser) Test(org.junit.Test) AbstractTest(org.apache.directory.api.dsmlv2.AbstractTest)

Example 18 with CompareRequest

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

the class CompareRequestTest method testRequestWith1CompleteAssertion.

/**
 * Test parsing of a request with an Attr elements with value
 */
@Test
public void testRequestWith1CompleteAssertion() {
    Dsmlv2Parser parser = null;
    try {
        parser = newParser();
        parser.setInput(CompareRequestTest.class.getResource("request_with_1_complete_assertion.xml").openStream(), "UTF-8");
        parser.parse();
    } catch (Exception e) {
        fail(e.getMessage());
    }
    CompareRequest compareRequest = (CompareRequest) parser.getBatchRequest().getCurrentRequest();
    assertTrue(compareRequest.getName().equals("cn=Bob Rush,ou=Dev,dc=Example,dc=COM"));
    assertEquals("sn", compareRequest.getAttributeId());
    assertEquals("Johnson", compareRequest.getAssertionValue().getValue());
}
Also used : CompareRequest(org.apache.directory.api.ldap.model.message.CompareRequest) Dsmlv2Parser(org.apache.directory.api.dsmlv2.Dsmlv2Parser) Test(org.junit.Test) AbstractTest(org.apache.directory.api.dsmlv2.AbstractTest)

Example 19 with CompareRequest

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

the class CompareRequestTest method testRequestWith1Control.

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

Example 20 with CompareRequest

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

the class CompareRequestTest method testRequestWith3ControlsWithoutValue.

/**
 * Test parsing of a request with 3 (optional) Control elements without value
 */
@Test
public void testRequestWith3ControlsWithoutValue() {
    Dsmlv2Parser parser = null;
    try {
        parser = newParser();
        parser.setInput(CompareRequestTest.class.getResource("request_with_3_controls_without_value.xml").openStream(), "UTF-8");
        parser.parse();
    } catch (Exception e) {
        fail(e.getMessage());
    }
    CompareRequest compareRequest = (CompareRequest) parser.getBatchRequest().getCurrentRequest();
    Map<String, Control> controls = compareRequest.getControls();
    assertEquals(3, compareRequest.getControls().size());
    Control control = controls.get("1.2.840.113556.1.4.456");
    assertNotNull(control);
    assertTrue(control.isCritical());
    assertEquals("1.2.840.113556.1.4.456", control.getOid());
    assertFalse(((DsmlControl<?>) control).hasValue());
}
Also used : CompareRequest(org.apache.directory.api.ldap.model.message.CompareRequest) DsmlControl(org.apache.directory.api.dsmlv2.DsmlControl) Control(org.apache.directory.api.ldap.model.message.Control) Dsmlv2Parser(org.apache.directory.api.dsmlv2.Dsmlv2Parser) Test(org.junit.Test) AbstractTest(org.apache.directory.api.dsmlv2.AbstractTest)

Aggregations

CompareRequest (org.apache.directory.api.ldap.model.message.CompareRequest)26 Test (org.junit.Test)15 AbstractTest (org.apache.directory.api.dsmlv2.AbstractTest)12 Dsmlv2Parser (org.apache.directory.api.dsmlv2.Dsmlv2Parser)12 Control (org.apache.directory.api.ldap.model.message.Control)7 DsmlControl (org.apache.directory.api.dsmlv2.DsmlControl)5 CompareRequestDecorator (org.apache.directory.api.ldap.codec.decorators.CompareRequestDecorator)5 CompareRequestImpl (org.apache.directory.api.ldap.model.message.CompareRequestImpl)5 CompareResponse (org.apache.directory.api.ldap.model.message.CompareResponse)5 DecoderException (org.apache.directory.api.asn1.DecoderException)4 ByteBuffer (java.nio.ByteBuffer)3 EncoderException (org.apache.directory.api.asn1.EncoderException)3 Asn1Decoder (org.apache.directory.api.asn1.ber.Asn1Decoder)3 TLV (org.apache.directory.api.asn1.ber.tlv.TLV)3 LdapMessageContainer (org.apache.directory.api.ldap.codec.api.LdapMessageContainer)3 AbstractCodecServiceTest (org.apache.directory.api.ldap.codec.osgi.AbstractCodecServiceTest)3 Dn (org.apache.directory.api.ldap.model.name.Dn)3 BatchRequestDsml (org.apache.directory.api.dsmlv2.request.BatchRequestDsml)2 ResponseCarryingException (org.apache.directory.api.ldap.codec.api.ResponseCarryingException)2 AbandonRequest (org.apache.directory.api.ldap.model.message.AbandonRequest)2