use of org.apache.directory.api.dsmlv2.request.BatchRequestDsml in project directory-ldap-api by apache.
the class BatchRequestTest method testResponseWith1AuthRequestAnd1AddRequest.
/**
* Test parsing of a Request with 1 AuthRequest and 1 AddRequest
*/
@Test
public void testResponseWith1AuthRequestAnd1AddRequest() {
Dsmlv2Parser parser = null;
try {
parser = newParser();
parser.setInput(BatchRequestTest.class.getResource("request_with_1_AuthRequest_1_AddRequest.xml").openStream(), "UTF-8");
parser.parse();
} catch (Exception e) {
fail(e.getMessage());
}
BatchRequestDsml batchRequest = parser.getBatchRequest();
List<DsmlDecorator<? extends Request>> requests = batchRequest.getRequests();
assertEquals(2, requests.size());
if (requests.get(0) instanceof BindRequest) {
assertTrue(true);
} else {
fail();
}
if (requests.get(1) instanceof AddRequest) {
assertTrue(true);
} else {
fail();
}
}
use of org.apache.directory.api.dsmlv2.request.BatchRequestDsml in project directory-ldap-api by apache.
the class BatchRequestTest method testResponseWith2ModDNRequest.
/**
* Test parsing of a Request with 2 ModDNRequest
*/
@Test
public void testResponseWith2ModDNRequest() {
Dsmlv2Parser parser = null;
try {
parser = newParser();
parser.setInput(BatchRequestTest.class.getResource("request_with_2_ModDNRequest.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 ModifyDnRequest) {
assertTrue(true);
} else {
fail();
}
}
use of org.apache.directory.api.dsmlv2.request.BatchRequestDsml in project directory-ldap-api by apache.
the class ParserUtilsTest method testStyleDocumentWithBatchRequest.
/**
* Test for DIRAPI-238: DSML pretty print does not work, prints error.
*
* Indirect test of ParserUtils.styleDocument() via BatchRequestDsml.toDsml().
*/
@Test
public void testStyleDocumentWithBatchRequest() throws Exception {
Dsmlv2Parser parser = newParser();
parser.setInput(BatchRequestTest.class.getResource("request_with_2_AddRequest.xml").openStream(), "UTF-8");
parser.parse();
BatchRequestDsml batchRequest = parser.getBatchRequest();
String dsml = batchRequest.toDsml();
assertNotNull(dsml);
assertEquals("Pretty printed DSML should contain newlines", 20, countNewlines(dsml));
assertEquals("Pretty printed DSML should contain indention", 38, countIndention(dsml));
}
use of org.apache.directory.api.dsmlv2.request.BatchRequestDsml in project directory-ldap-api by apache.
the class AbandonRequestTest method testRequestWithoutAbandonId0.
/**
* Test parsing of a request without the abandonID attribute with a value of 0
*/
@Test
public void testRequestWithoutAbandonId0() {
Dsmlv2Parser parser = null;
try {
parser = newParser();
parser.setInput(AbandonRequestTest.class.getResource("request_with_0_abandonID_attribute.xml").openStream(), "UTF-8");
parser.parse();
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
BatchRequestDsml batchRequest = parser.getBatchRequest();
assertEquals(0, batchRequest.getRequestID());
}
Aggregations