Search in sources :

Example 21 with BatchRequestDsml

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();
    }
}
Also used : BatchRequestDsml(org.apache.directory.api.dsmlv2.request.BatchRequestDsml) AddRequest(org.apache.directory.api.ldap.model.message.AddRequest) ModifyRequest(org.apache.directory.api.ldap.model.message.ModifyRequest) SearchRequest(org.apache.directory.api.ldap.model.message.SearchRequest) CompareRequest(org.apache.directory.api.ldap.model.message.CompareRequest) Request(org.apache.directory.api.ldap.model.message.Request) BindRequest(org.apache.directory.api.ldap.model.message.BindRequest) AddRequest(org.apache.directory.api.ldap.model.message.AddRequest) ModifyDnRequest(org.apache.directory.api.ldap.model.message.ModifyDnRequest) AbandonRequest(org.apache.directory.api.ldap.model.message.AbandonRequest) DeleteRequest(org.apache.directory.api.ldap.model.message.DeleteRequest) ExtendedRequest(org.apache.directory.api.ldap.model.message.ExtendedRequest) BindRequest(org.apache.directory.api.ldap.model.message.BindRequest) Dsmlv2Parser(org.apache.directory.api.dsmlv2.Dsmlv2Parser) DsmlDecorator(org.apache.directory.api.dsmlv2.DsmlDecorator) Test(org.junit.Test) AbstractTest(org.apache.directory.api.dsmlv2.AbstractTest)

Example 22 with BatchRequestDsml

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();
    }
}
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 23 with BatchRequestDsml

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));
}
Also used : BatchRequestDsml(org.apache.directory.api.dsmlv2.request.BatchRequestDsml) Test(org.junit.Test) BatchRequestTest(org.apache.directory.api.dsmlv2.batchRequest.BatchRequestTest) BatchResponseTest(org.apache.directory.api.dsmlv2.batchResponse.BatchResponseTest)

Example 24 with BatchRequestDsml

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