Search in sources :

Example 21 with DeleteResponse

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

the class DelResponseTest method testResponseWithEmptyErrorMessage.

/**
 * Test parsing of a response with empty Error Message
 */
@Test
public void testResponseWithEmptyErrorMessage() {
    Dsmlv2ResponseParser parser = null;
    try {
        parser = new Dsmlv2ResponseParser(getCodec());
        parser.setInput(DelResponseTest.class.getResource("response_with_empty_error_message.xml").openStream(), "UTF-8");
        parser.parse();
    } catch (Exception e) {
        fail(e.getMessage());
    }
    DeleteResponse delResponse = (DeleteResponse) parser.getBatchResponse().getCurrentResponse();
    LdapResult ldapResult = delResponse.getLdapResult();
    assertNull(ldapResult.getDiagnosticMessage());
}
Also used : Dsmlv2ResponseParser(org.apache.directory.api.dsmlv2.Dsmlv2ResponseParser) DeleteResponse(org.apache.directory.api.ldap.model.message.DeleteResponse) LdapResult(org.apache.directory.api.ldap.model.message.LdapResult) LdapURLEncodingException(org.apache.directory.api.ldap.model.exception.LdapURLEncodingException) Test(org.junit.Test) AbstractResponseTest(org.apache.directory.api.dsmlv2.AbstractResponseTest)

Example 22 with DeleteResponse

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

the class DelResponseTest method testResponseWith1Control.

/**
 * Test parsing of a response with a (optional) Control element
 */
@Test
public void testResponseWith1Control() {
    Dsmlv2ResponseParser parser = null;
    try {
        parser = new Dsmlv2ResponseParser(getCodec());
        parser.setInput(DelResponseTest.class.getResource("response_with_1_control.xml").openStream(), "UTF-8");
        parser.parse();
    } catch (Exception e) {
        fail(e.getMessage());
    }
    DeleteResponse delResponse = (DeleteResponse) parser.getBatchResponse().getCurrentResponse();
    Map<String, Control> controls = delResponse.getControls();
    assertEquals(1, delResponse.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) Dsmlv2ResponseParser(org.apache.directory.api.dsmlv2.Dsmlv2ResponseParser) DsmlControl(org.apache.directory.api.dsmlv2.DsmlControl) Control(org.apache.directory.api.ldap.model.message.Control) DeleteResponse(org.apache.directory.api.ldap.model.message.DeleteResponse) LdapURLEncodingException(org.apache.directory.api.ldap.model.exception.LdapURLEncodingException) Test(org.junit.Test) AbstractResponseTest(org.apache.directory.api.dsmlv2.AbstractResponseTest)

Example 23 with DeleteResponse

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

the class DelResponseTest method testResponseWithMatchedDNAttribute.

/**
 * Test parsing of a response with MatchedDN attribute
 */
@Test
public void testResponseWithMatchedDNAttribute() {
    Dsmlv2ResponseParser parser = null;
    try {
        parser = new Dsmlv2ResponseParser(getCodec());
        parser.setInput(DelResponseTest.class.getResource("response_with_matchedDN_attribute.xml").openStream(), "UTF-8");
        parser.parse();
    } catch (Exception e) {
        fail(e.getMessage());
    }
    DeleteResponse delResponse = (DeleteResponse) parser.getBatchResponse().getCurrentResponse();
    LdapResult ldapResult = delResponse.getLdapResult();
    assertTrue(ldapResult.getMatchedDn().equals("cn=Bob Rush,ou=Dev,dc=Example,dc=COM"));
}
Also used : Dsmlv2ResponseParser(org.apache.directory.api.dsmlv2.Dsmlv2ResponseParser) DeleteResponse(org.apache.directory.api.ldap.model.message.DeleteResponse) LdapResult(org.apache.directory.api.ldap.model.message.LdapResult) LdapURLEncodingException(org.apache.directory.api.ldap.model.exception.LdapURLEncodingException) Test(org.junit.Test) AbstractResponseTest(org.apache.directory.api.dsmlv2.AbstractResponseTest)

Example 24 with DeleteResponse

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

the class DelResponseTest method testResponseWith2Controls.

/**
 * Test parsing of a response with 2 (optional) Control elements
 */
@Test
public void testResponseWith2Controls() {
    Dsmlv2ResponseParser parser = null;
    try {
        parser = new Dsmlv2ResponseParser(getCodec());
        parser.setInput(DelResponseTest.class.getResource("response_with_2_controls.xml").openStream(), "UTF-8");
        parser.parse();
    } catch (Exception e) {
        fail(e.getMessage());
    }
    DeleteResponse delResponse = (DeleteResponse) parser.getBatchResponse().getCurrentResponse();
    Map<String, Control> controls = delResponse.getControls();
    assertEquals(2, delResponse.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) Dsmlv2ResponseParser(org.apache.directory.api.dsmlv2.Dsmlv2ResponseParser) DsmlControl(org.apache.directory.api.dsmlv2.DsmlControl) Control(org.apache.directory.api.ldap.model.message.Control) DeleteResponse(org.apache.directory.api.ldap.model.message.DeleteResponse) LdapURLEncodingException(org.apache.directory.api.ldap.model.exception.LdapURLEncodingException) Test(org.junit.Test) AbstractResponseTest(org.apache.directory.api.dsmlv2.AbstractResponseTest)

Example 25 with DeleteResponse

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

the class DelResponseTest method testResponseWith1ControlemptyValue.

/**
 * Test parsing of a response with a (optional) Control element with empty value
 */
@Test
public void testResponseWith1ControlemptyValue() {
    Dsmlv2ResponseParser parser = null;
    try {
        parser = new Dsmlv2ResponseParser(getCodec());
        parser.setInput(DelResponseTest.class.getResource("response_with_1_control_empty_value.xml").openStream(), "UTF-8");
        parser.parse();
    } catch (Exception e) {
        fail(e.getMessage());
    }
    DeleteResponse delResponse = (DeleteResponse) parser.getBatchResponse().getCurrentResponse();
    Map<String, Control> controls = delResponse.getControls();
    assertEquals(1, delResponse.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());
    assertFalse(((DsmlControl<?>) control).hasValue());
}
Also used : Dsmlv2ResponseParser(org.apache.directory.api.dsmlv2.Dsmlv2ResponseParser) DsmlControl(org.apache.directory.api.dsmlv2.DsmlControl) Control(org.apache.directory.api.ldap.model.message.Control) DeleteResponse(org.apache.directory.api.ldap.model.message.DeleteResponse) LdapURLEncodingException(org.apache.directory.api.ldap.model.exception.LdapURLEncodingException) Test(org.junit.Test) AbstractResponseTest(org.apache.directory.api.dsmlv2.AbstractResponseTest)

Aggregations

DeleteResponse (org.apache.directory.api.ldap.model.message.DeleteResponse)25 Test (org.junit.Test)17 AbstractResponseTest (org.apache.directory.api.dsmlv2.AbstractResponseTest)15 Dsmlv2ResponseParser (org.apache.directory.api.dsmlv2.Dsmlv2ResponseParser)15 LdapURLEncodingException (org.apache.directory.api.ldap.model.exception.LdapURLEncodingException)13 LdapResult (org.apache.directory.api.ldap.model.message.LdapResult)8 Control (org.apache.directory.api.ldap.model.message.Control)6 DeleteRequest (org.apache.directory.api.ldap.model.message.DeleteRequest)5 DsmlControl (org.apache.directory.api.dsmlv2.DsmlControl)4 DeleteRequestImpl (org.apache.directory.api.ldap.model.message.DeleteRequestImpl)4 DecoderException (org.apache.directory.api.asn1.DecoderException)3 DeleteResponseDecorator (org.apache.directory.api.ldap.codec.decorators.DeleteResponseDecorator)3 LdapException (org.apache.directory.api.ldap.model.exception.LdapException)3 AddResponse (org.apache.directory.api.ldap.model.message.AddResponse)3 BindResponse (org.apache.directory.api.ldap.model.message.BindResponse)3 ByteBuffer (java.nio.ByteBuffer)2 EncoderException (org.apache.directory.api.asn1.EncoderException)2 Asn1Decoder (org.apache.directory.api.asn1.ber.Asn1Decoder)2 BatchResponseDsml (org.apache.directory.api.dsmlv2.response.BatchResponseDsml)2 LdapMessageContainer (org.apache.directory.api.ldap.codec.api.LdapMessageContainer)2