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());
}
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());
}
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());
}
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());
}
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());
}
Aggregations