Search in sources :

Example 6 with Dsmlv2Parser

use of org.apache.directory.api.dsmlv2.Dsmlv2Parser in project directory-ldap-api by apache.

the class ModifyDNRequestTest method testRequestWithDnAndNewRdnAttributes.

/**
 * Test parsing of a request without dn and newrdn attributes
 */
@Test
public void testRequestWithDnAndNewRdnAttributes() {
    Dsmlv2Parser parser = null;
    try {
        parser = newParser();
        parser.setInput(ModifyDNRequestTest.class.getResource("request_with_dn_and_newrdn_attributes.xml").openStream(), "UTF-8");
        parser.parse();
    } catch (Exception e) {
        fail(e.getMessage());
    }
    ModifyDnRequest modifyDNRequest = (ModifyDnRequest) parser.getBatchRequest().getCurrentRequest();
    assertTrue(modifyDNRequest.getName().equals("cn=Bob Rush,ou=Dev,dc=Example,dc=COM"));
    assertEquals("CN=Steve Jobs", modifyDNRequest.getNewRdn().getName());
}
Also used : Dsmlv2Parser(org.apache.directory.api.dsmlv2.Dsmlv2Parser) ModifyDnRequest(org.apache.directory.api.ldap.model.message.ModifyDnRequest) Test(org.junit.Test) AbstractTest(org.apache.directory.api.dsmlv2.AbstractTest)

Example 7 with Dsmlv2Parser

use of org.apache.directory.api.dsmlv2.Dsmlv2Parser in project directory-ldap-api by apache.

the class ModifyDNRequestTest method testRequestWithDeleteOldRdnTrue.

/**
 * Test parsing of a request with deleteoldrdn to true
 */
@Test
public void testRequestWithDeleteOldRdnTrue() {
    Dsmlv2Parser parser = null;
    try {
        parser = newParser();
        parser.setInput(ModifyDNRequestTest.class.getResource("request_with_deleteoldrdn_true.xml").openStream(), "UTF-8");
        parser.parse();
    } catch (Exception e) {
        fail(e.getMessage());
    }
    ModifyDnRequest modifyDNRequest = (ModifyDnRequest) parser.getBatchRequest().getCurrentRequest();
    assertTrue(modifyDNRequest.getDeleteOldRdn());
}
Also used : Dsmlv2Parser(org.apache.directory.api.dsmlv2.Dsmlv2Parser) ModifyDnRequest(org.apache.directory.api.ldap.model.message.ModifyDnRequest) Test(org.junit.Test) AbstractTest(org.apache.directory.api.dsmlv2.AbstractTest)

Example 8 with Dsmlv2Parser

use of org.apache.directory.api.dsmlv2.Dsmlv2Parser in project directory-ldap-api by apache.

the class ModifyDNRequestTest method testRequestWithRequestId.

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

Example 9 with Dsmlv2Parser

use of org.apache.directory.api.dsmlv2.Dsmlv2Parser in project directory-ldap-api by apache.

the class ModifyDNRequestTest method testRequestWithDeleteOldRdnFalse.

/**
 * Test parsing of a request with deleteoldrdn to false
 */
@Test
public void testRequestWithDeleteOldRdnFalse() {
    Dsmlv2Parser parser = null;
    try {
        parser = newParser();
        parser.setInput(ModifyDNRequestTest.class.getResource("request_with_deleteoldrdn_false.xml").openStream(), "UTF-8");
        parser.parse();
    } catch (Exception e) {
        fail(e.getMessage());
    }
    ModifyDnRequest modifyDNRequest = (ModifyDnRequest) parser.getBatchRequest().getCurrentRequest();
    assertFalse(modifyDNRequest.getDeleteOldRdn());
}
Also used : Dsmlv2Parser(org.apache.directory.api.dsmlv2.Dsmlv2Parser) ModifyDnRequest(org.apache.directory.api.ldap.model.message.ModifyDnRequest) Test(org.junit.Test) AbstractTest(org.apache.directory.api.dsmlv2.AbstractTest)

Example 10 with Dsmlv2Parser

use of org.apache.directory.api.dsmlv2.Dsmlv2Parser in project directory-ldap-api by apache.

the class ModifyRequestTest method testRequestWith1ModificationBase64Value.

/**
 * Test parsing of a request with a Modification element with Base64 Value
 * @throws NamingException
 */
@Test
public void testRequestWith1ModificationBase64Value() throws LdapException {
    Dsmlv2Parser parser = null;
    try {
        parser = newParser();
        parser.setInput(ModifyRequestTest.class.getResource("request_with_1_modification_base64_value.xml").openStream(), "UTF-8");
        parser.parse();
    } catch (Exception e) {
        fail(e.getMessage());
    }
    ModifyRequest modifyRequest = (ModifyRequest) parser.getBatchRequest().getCurrentRequest();
    Collection<Modification> modifications = modifyRequest.getModifications();
    assertEquals(1, modifications.size());
    Modification modification = modifications.iterator().next();
    Attribute attribute = modification.getAttribute();
    assertEquals(ModificationOperation.ADD_ATTRIBUTE, modification.getOperation());
    assertEquals("directreport", attribute.getId());
    String expected = new String(new byte[] { 'c', 'n', '=', 'E', 'm', 'm', 'a', 'n', 'u', 'e', 'l', ' ', 'L', (byte) 0xc3, (byte) 0xa9, 'c', 'h', 'a', 'r', 'n', 'y', ',', ' ', 'o', 'u', '=', 'p', 'e', 'o', 'p', 'l', 'e', ',', ' ', 'd', 'c', '=', 'e', 'x', 'a', 'm', 'p', 'l', 'e', ',', ' ', 'd', 'c', '=', 'c', 'o', 'm' }, StandardCharsets.UTF_8);
    assertEquals(expected, attribute.get().getValue());
}
Also used : Modification(org.apache.directory.api.ldap.model.entry.Modification) Attribute(org.apache.directory.api.ldap.model.entry.Attribute) Dsmlv2Parser(org.apache.directory.api.dsmlv2.Dsmlv2Parser) ModifyRequest(org.apache.directory.api.ldap.model.message.ModifyRequest) LdapException(org.apache.directory.api.ldap.model.exception.LdapException) Test(org.junit.Test) AbstractTest(org.apache.directory.api.dsmlv2.AbstractTest)

Aggregations

Dsmlv2Parser (org.apache.directory.api.dsmlv2.Dsmlv2Parser)171 Test (org.junit.Test)168 AbstractTest (org.apache.directory.api.dsmlv2.AbstractTest)164 LdapException (org.apache.directory.api.ldap.model.exception.LdapException)78 SearchRequest (org.apache.directory.api.ldap.model.message.SearchRequest)67 DsmlControl (org.apache.directory.api.dsmlv2.DsmlControl)45 Control (org.apache.directory.api.ldap.model.message.Control)45 ExprNode (org.apache.directory.api.ldap.model.filter.ExprNode)40 BatchRequestDsml (org.apache.directory.api.dsmlv2.request.BatchRequestDsml)23 ModifyRequest (org.apache.directory.api.ldap.model.message.ModifyRequest)18 AddRequest (org.apache.directory.api.ldap.model.message.AddRequest)16 ModifyDnRequest (org.apache.directory.api.ldap.model.message.ModifyDnRequest)15 SubstringNode (org.apache.directory.api.ldap.model.filter.SubstringNode)14 CompareRequest (org.apache.directory.api.ldap.model.message.CompareRequest)13 Attribute (org.apache.directory.api.ldap.model.entry.Attribute)12 AbandonRequest (org.apache.directory.api.ldap.model.message.AbandonRequest)10 DeleteRequest (org.apache.directory.api.ldap.model.message.DeleteRequest)10 ExtendedRequestDsml (org.apache.directory.api.dsmlv2.request.ExtendedRequestDsml)9 Modification (org.apache.directory.api.ldap.model.entry.Modification)9 ExtensibleNode (org.apache.directory.api.ldap.model.filter.ExtensibleNode)9