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