Search in sources :

Example 11 with BatchRequestDsml

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);
    }
}
Also used : BatchRequestDsml(org.apache.directory.api.dsmlv2.request.BatchRequestDsml) XmlPullParser(org.xmlpull.v1.XmlPullParser) XmlPullParserException(org.xmlpull.v1.XmlPullParserException) IOException(java.io.IOException)

Example 12 with BatchRequestDsml

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());
}
Also used : BatchRequestDsml(org.apache.directory.api.dsmlv2.request.BatchRequestDsml) SearchRequest(org.apache.directory.api.ldap.model.message.SearchRequest) Dsmlv2Parser(org.apache.directory.api.dsmlv2.Dsmlv2Parser) Test(org.junit.Test)

Example 13 with BatchRequestDsml

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();
    }
}
Also used : BatchRequestDsml(org.apache.directory.api.dsmlv2.request.BatchRequestDsml) CompareRequest(org.apache.directory.api.ldap.model.message.CompareRequest) Dsmlv2Parser(org.apache.directory.api.dsmlv2.Dsmlv2Parser) Test(org.junit.Test) AbstractTest(org.apache.directory.api.dsmlv2.AbstractTest)

Example 14 with BatchRequestDsml

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();
    }
}
Also used : BatchRequestDsml(org.apache.directory.api.dsmlv2.request.BatchRequestDsml) Dsmlv2Parser(org.apache.directory.api.dsmlv2.Dsmlv2Parser) ModifyDnRequest(org.apache.directory.api.ldap.model.message.ModifyDnRequest) Test(org.junit.Test) AbstractTest(org.apache.directory.api.dsmlv2.AbstractTest)

Example 15 with BatchRequestDsml

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();
    }
}
Also used : BatchRequestDsml(org.apache.directory.api.dsmlv2.request.BatchRequestDsml) Dsmlv2Parser(org.apache.directory.api.dsmlv2.Dsmlv2Parser) ModifyRequest(org.apache.directory.api.ldap.model.message.ModifyRequest) Test(org.junit.Test) AbstractTest(org.apache.directory.api.dsmlv2.AbstractTest)

Aggregations

BatchRequestDsml (org.apache.directory.api.dsmlv2.request.BatchRequestDsml)24 Test (org.junit.Test)23 Dsmlv2Parser (org.apache.directory.api.dsmlv2.Dsmlv2Parser)22 AbstractTest (org.apache.directory.api.dsmlv2.AbstractTest)21 SearchRequest (org.apache.directory.api.ldap.model.message.SearchRequest)4 AbandonRequest (org.apache.directory.api.ldap.model.message.AbandonRequest)3 AddRequest (org.apache.directory.api.ldap.model.message.AddRequest)3 CompareRequest (org.apache.directory.api.ldap.model.message.CompareRequest)3 DeleteRequest (org.apache.directory.api.ldap.model.message.DeleteRequest)3 ExtendedRequest (org.apache.directory.api.ldap.model.message.ExtendedRequest)3 ModifyDnRequest (org.apache.directory.api.ldap.model.message.ModifyDnRequest)3 ModifyRequest (org.apache.directory.api.ldap.model.message.ModifyRequest)3 BindRequest (org.apache.directory.api.ldap.model.message.BindRequest)2 IOException (java.io.IOException)1 DsmlDecorator (org.apache.directory.api.dsmlv2.DsmlDecorator)1 BatchRequestTest (org.apache.directory.api.dsmlv2.batchRequest.BatchRequestTest)1 BatchResponseTest (org.apache.directory.api.dsmlv2.batchResponse.BatchResponseTest)1 Request (org.apache.directory.api.ldap.model.message.Request)1 XmlPullParser (org.xmlpull.v1.XmlPullParser)1 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)1