use of org.apache.directory.api.dsmlv2.request.BatchRequestDsml in project directory-ldap-api by apache.
the class Dsmlv2Parser method parseBatchRequest.
/**
* Launches the parsing of the Batch Request only
*
* @throws XmlPullParserException if an error occurs in the parser
*/
public void parseBatchRequest() throws XmlPullParserException {
XmlPullParser xpp = container.getParser();
int eventType = xpp.getEventType();
do {
switch(eventType) {
case XmlPullParser.START_DOCUMENT:
container.setState(Dsmlv2StatesEnum.INIT_GRAMMAR_STATE);
break;
case XmlPullParser.END_DOCUMENT:
container.setState(Dsmlv2StatesEnum.GRAMMAR_END);
break;
case XmlPullParser.START_TAG:
processTag(container, Tag.START);
break;
case XmlPullParser.END_TAG:
processTag(container, Tag.END);
break;
default:
break;
}
try {
eventType = xpp.next();
} catch (IOException ioe) {
throw new XmlPullParserException(I18n.err(I18n.ERR_03037, ioe.getLocalizedMessage()), xpp, ioe);
}
} while (container.getState() != Dsmlv2StatesEnum.BATCHREQUEST_START_TAG);
BatchRequestDsml br = container.getBatchRequest();
if (br != null) {
br.setStoreReq(storeMsgInBatchReq);
}
}
use of org.apache.directory.api.dsmlv2.request.BatchRequestDsml in project directory-ldap-api by apache.
the class SoapDsmlParsingTest method testParsingRequestsOneByOne.
@Test
public void testParsingRequestsOneByOne() throws Exception {
Dsmlv2Parser parser = new Dsmlv2Parser(false);
parser.setInput(SoapDsmlParsingTest.class.getResource("soap-dsml-multiple-operation-requests.xml").openStream(), "UTF-8");
parser.parseBatchRequest();
BatchRequestDsml batchReq = parser.getBatchRequest();
assertNotNull(batchReq);
assertFalse(batchReq.isStoringRequests());
assertTrue(batchReq.getRequests().isEmpty());
SearchRequest searchRequest = (SearchRequest) parser.getNextRequest();
assertTrue(searchRequest.getTypesOnly());
// assert again that the batch request object is not storing requests
assertTrue(batchReq.getRequests().isEmpty());
searchRequest = (SearchRequest) parser.getNextRequest();
assertFalse(searchRequest.getTypesOnly());
assertNull(parser.getNextRequest());
// assert again that the batch request object is not storing requests
assertTrue(batchReq.getRequests().isEmpty());
assertNotNull(batchReq.getCurrentRequest());
}
use of org.apache.directory.api.dsmlv2.request.BatchRequestDsml 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.dsmlv2.request.BatchRequestDsml in project directory-ldap-api by apache.
the class BatchRequestTest method testResponseWith1ModDNRequest.
/**
* Test parsing of a Request with 1 ModDNRequest
*/
@Test
public void testResponseWith1ModDNRequest() {
Dsmlv2Parser parser = null;
try {
parser = newParser();
parser.setInput(BatchRequestTest.class.getResource("request_with_1_ModDNRequest.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 ModifyDnRequest) {
assertTrue(true);
} else {
fail();
}
}
use of org.apache.directory.api.dsmlv2.request.BatchRequestDsml in project directory-ldap-api by apache.
the class BatchRequestTest method testResponseWith1ModifyRequest.
/**
* Test parsing of a Request with 1 ModifyRequest
*/
@Test
public void testResponseWith1ModifyRequest() {
Dsmlv2Parser parser = null;
try {
parser = newParser();
parser.setInput(BatchRequestTest.class.getResource("request_with_1_ModifyRequest.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 ModifyRequest) {
assertTrue(true);
} else {
fail();
}
}
Aggregations