Search in sources :

Example 6 with DsmlDecorator

use of org.apache.directory.api.dsmlv2.DsmlDecorator in project directory-ldap-api by apache.

the class BatchResponseTest method testResponseWith1AuthResponse.

/**
 * Test parsing of a Response with the 1 AuthResponse
 */
@Test
public void testResponseWith1AuthResponse() {
    Dsmlv2ResponseParser parser = null;
    try {
        parser = new Dsmlv2ResponseParser(getCodec());
        parser.setInput(BatchResponseTest.class.getResource("response_with_1_AuthResponse.xml").openStream(), "UTF-8");
        parser.parse();
    } catch (Exception e) {
        fail(e.getMessage());
    }
    BatchResponseDsml batchResponse = parser.getBatchResponse();
    assertEquals(1, batchResponse.getResponses().size());
    DsmlDecorator<? extends Response> response = batchResponse.getCurrentResponse();
    if (response instanceof BindResponse) {
        assertTrue(true);
    } else {
        fail();
    }
}
Also used : BatchResponseDsml(org.apache.directory.api.dsmlv2.response.BatchResponseDsml) Dsmlv2ResponseParser(org.apache.directory.api.dsmlv2.Dsmlv2ResponseParser) BindResponse(org.apache.directory.api.ldap.model.message.BindResponse) Test(org.junit.Test) AbstractResponseTest(org.apache.directory.api.dsmlv2.AbstractResponseTest)

Example 7 with DsmlDecorator

use of org.apache.directory.api.dsmlv2.DsmlDecorator in project directory-ldap-api by apache.

the class BatchResponseTest method testResponseWith2ModifyResponse.

/**
 * Test parsing of a Response with the 2 ModifyResponse
 */
@Test
public void testResponseWith2ModifyResponse() {
    Dsmlv2ResponseParser parser = null;
    try {
        parser = new Dsmlv2ResponseParser(getCodec());
        parser.setInput(BatchResponseTest.class.getResource("response_with_2_ModifyResponse.xml").openStream(), "UTF-8");
        parser.parse();
    } catch (Exception e) {
        fail(e.getMessage());
    }
    BatchResponseDsml batchResponse = parser.getBatchResponse();
    assertEquals(2, batchResponse.getResponses().size());
    DsmlDecorator<? extends Response> response = batchResponse.getCurrentResponse();
    if (response instanceof ModifyResponse) {
        assertTrue(true);
    } else {
        fail();
    }
}
Also used : BatchResponseDsml(org.apache.directory.api.dsmlv2.response.BatchResponseDsml) Dsmlv2ResponseParser(org.apache.directory.api.dsmlv2.Dsmlv2ResponseParser) ModifyResponse(org.apache.directory.api.ldap.model.message.ModifyResponse) Test(org.junit.Test) AbstractResponseTest(org.apache.directory.api.dsmlv2.AbstractResponseTest)

Example 8 with DsmlDecorator

use of org.apache.directory.api.dsmlv2.DsmlDecorator in project directory-ldap-api by apache.

the class BatchResponseTest method testResponseWith1DelResponse.

/**
 * Test parsing of a Response with the 1 DelResponse
 */
@Test
public void testResponseWith1DelResponse() {
    Dsmlv2ResponseParser parser = null;
    try {
        parser = new Dsmlv2ResponseParser(getCodec());
        parser.setInput(BatchResponseTest.class.getResource("response_with_1_DelResponse.xml").openStream(), "UTF-8");
        parser.parse();
    } catch (Exception e) {
        fail(e.getMessage());
    }
    BatchResponseDsml batchResponse = parser.getBatchResponse();
    assertEquals(1, batchResponse.getResponses().size());
    DsmlDecorator<? extends Response> response = batchResponse.getCurrentResponse();
    if (response instanceof DeleteResponse) {
        assertTrue(true);
    } else {
        fail();
    }
}
Also used : BatchResponseDsml(org.apache.directory.api.dsmlv2.response.BatchResponseDsml) Dsmlv2ResponseParser(org.apache.directory.api.dsmlv2.Dsmlv2ResponseParser) DeleteResponse(org.apache.directory.api.ldap.model.message.DeleteResponse) Test(org.junit.Test) AbstractResponseTest(org.apache.directory.api.dsmlv2.AbstractResponseTest)

Example 9 with DsmlDecorator

use of org.apache.directory.api.dsmlv2.DsmlDecorator in project directory-ldap-api by apache.

the class BatchResponseTest method testResponseWith2ModDNResponse.

/**
 * Test parsing of a Response with the 2 ModDNResponse
 */
@Test
public void testResponseWith2ModDNResponse() {
    Dsmlv2ResponseParser parser = null;
    try {
        parser = new Dsmlv2ResponseParser(getCodec());
        parser.setInput(BatchResponseTest.class.getResource("response_with_2_ModDNResponse.xml").openStream(), "UTF-8");
        parser.parse();
    } catch (Exception e) {
        fail(e.getMessage());
    }
    BatchResponseDsml batchResponse = parser.getBatchResponse();
    assertEquals(2, batchResponse.getResponses().size());
    DsmlDecorator<? extends Response> response = batchResponse.getCurrentResponse();
    if (response instanceof ModifyDnResponse) {
        assertTrue(true);
    } else {
        fail();
    }
}
Also used : BatchResponseDsml(org.apache.directory.api.dsmlv2.response.BatchResponseDsml) Dsmlv2ResponseParser(org.apache.directory.api.dsmlv2.Dsmlv2ResponseParser) ModifyDnResponse(org.apache.directory.api.ldap.model.message.ModifyDnResponse) Test(org.junit.Test) AbstractResponseTest(org.apache.directory.api.dsmlv2.AbstractResponseTest)

Example 10 with DsmlDecorator

use of org.apache.directory.api.dsmlv2.DsmlDecorator in project directory-ldap-api by apache.

the class BatchResponseTest method testResponseWith2CompareResponse.

/**
 * Test parsing of a Response with the 2 CompareResponse
 */
@Test
public void testResponseWith2CompareResponse() {
    Dsmlv2ResponseParser parser = null;
    try {
        parser = new Dsmlv2ResponseParser(getCodec());
        parser.setInput(BatchResponseTest.class.getResource("response_with_2_CompareResponse.xml").openStream(), "UTF-8");
        parser.parse();
    } catch (Exception e) {
        fail(e.getMessage());
    }
    BatchResponseDsml batchResponse = parser.getBatchResponse();
    assertEquals(2, batchResponse.getResponses().size());
    DsmlDecorator<? extends Response> response = batchResponse.getCurrentResponse();
    if (response instanceof CompareResponse) {
        assertTrue(true);
    } else {
        fail();
    }
}
Also used : BatchResponseDsml(org.apache.directory.api.dsmlv2.response.BatchResponseDsml) CompareResponse(org.apache.directory.api.ldap.model.message.CompareResponse) Dsmlv2ResponseParser(org.apache.directory.api.dsmlv2.Dsmlv2ResponseParser) Test(org.junit.Test) AbstractResponseTest(org.apache.directory.api.dsmlv2.AbstractResponseTest)

Aggregations

Test (org.junit.Test)19 AbstractResponseTest (org.apache.directory.api.dsmlv2.AbstractResponseTest)18 Dsmlv2ResponseParser (org.apache.directory.api.dsmlv2.Dsmlv2ResponseParser)18 BatchResponseDsml (org.apache.directory.api.dsmlv2.response.BatchResponseDsml)18 ErrorResponse (org.apache.directory.api.dsmlv2.response.ErrorResponse)4 AddResponse (org.apache.directory.api.ldap.model.message.AddResponse)3 BindResponse (org.apache.directory.api.ldap.model.message.BindResponse)3 CompareResponse (org.apache.directory.api.ldap.model.message.CompareResponse)3 DeleteResponse (org.apache.directory.api.ldap.model.message.DeleteResponse)3 ExtendedResponse (org.apache.directory.api.ldap.model.message.ExtendedResponse)3 ModifyDnResponse (org.apache.directory.api.ldap.model.message.ModifyDnResponse)3 ModifyResponse (org.apache.directory.api.ldap.model.message.ModifyResponse)3 SearchResponse (org.apache.directory.api.dsmlv2.response.SearchResponse)2 BufferedWriter (java.io.BufferedWriter)1 IOException (java.io.IOException)1 OutputStreamWriter (java.io.OutputStreamWriter)1 DecoderException (org.apache.directory.api.asn1.DecoderException)1 EncoderException (org.apache.directory.api.asn1.EncoderException)1 AbstractTest (org.apache.directory.api.dsmlv2.AbstractTest)1 DsmlDecorator (org.apache.directory.api.dsmlv2.DsmlDecorator)1