use of org.apache.directory.api.dsmlv2.Dsmlv2ResponseParser in project directory-ldap-api by apache.
the class CompareResponseTest 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(CompareResponseTest.class.getResource("response_with_empty_error_message.xml").openStream(), "UTF-8");
parser.parse();
} catch (Exception e) {
fail(e.getMessage());
}
CompareResponse compareResponse = (CompareResponse) parser.getBatchResponse().getCurrentResponse();
LdapResult ldapResult = compareResponse.getLdapResult();
assertNull(ldapResult.getDiagnosticMessage());
}
use of org.apache.directory.api.dsmlv2.Dsmlv2ResponseParser in project directory-ldap-api by apache.
the class DelResponseTest method testResponseWithErrorMessage.
/**
* Test parsing of a response with Error Message
*/
@Test
public void testResponseWithErrorMessage() {
Dsmlv2ResponseParser parser = null;
try {
parser = new Dsmlv2ResponseParser(getCodec());
parser.setInput(DelResponseTest.class.getResource("response_with_error_message.xml").openStream(), "UTF-8");
parser.parse();
} catch (Exception e) {
fail(e.getMessage());
}
DeleteResponse delResponse = (DeleteResponse) parser.getBatchResponse().getCurrentResponse();
LdapResult ldapResult = delResponse.getLdapResult();
assertEquals("Unrecognized extended operation EXTENSION_OID: 1.2.6.1.4.1.18060.1.1.1.100.2", ldapResult.getDiagnosticMessage());
}
use of org.apache.directory.api.dsmlv2.Dsmlv2ResponseParser in project directory-ldap-api by apache.
the class DelResponseTest method testResponseWithRequestId.
/**
* Test parsing of a Response with the (optional) requestID attribute
*/
@Test
public void testResponseWithRequestId() {
Dsmlv2ResponseParser parser = null;
try {
parser = new Dsmlv2ResponseParser(getCodec());
parser.setInput(DelResponseTest.class.getResource("response_with_requestID_attribute.xml").openStream(), "UTF-8");
parser.parse();
} catch (Exception e) {
fail(e.getMessage());
}
DeleteResponse delResponse = (DeleteResponse) parser.getBatchResponse().getCurrentResponse();
assertEquals(456, delResponse.getMessageId());
}
use of org.apache.directory.api.dsmlv2.Dsmlv2ResponseParser in project directory-ldap-api by apache.
the class DelResponseTest method testResponseWith3ControlsWithoutValue.
/**
* Test parsing of a response with 3 (optional) Control elements without value
*/
@Test
public void testResponseWith3ControlsWithoutValue() {
Dsmlv2ResponseParser parser = null;
try {
parser = new Dsmlv2ResponseParser(getCodec());
parser.setInput(DelResponseTest.class.getResource("response_with_3_controls_without_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(3, delResponse.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());
}
use of org.apache.directory.api.dsmlv2.Dsmlv2ResponseParser in project directory-ldap-api by apache.
the class DelResponseTest method testResponseWith1EmptyReferral.
/**
* Test parsing of a response with an empty Referral
*/
@Test
public void testResponseWith1EmptyReferral() {
Dsmlv2ResponseParser parser = null;
try {
parser = new Dsmlv2ResponseParser(getCodec());
parser.setInput(DelResponseTest.class.getResource("response_with_1_empty_referral.xml").openStream(), "UTF-8");
parser.parse();
} catch (Exception e) {
fail(e.getMessage());
}
DeleteResponse delResponse = (DeleteResponse) parser.getBatchResponse().getCurrentResponse();
LdapResult ldapResult = delResponse.getLdapResult();
Collection<String> referrals = ldapResult.getReferral().getLdapUrls();
assertEquals(0, referrals.size());
}
Aggregations