Package org.apache.directory.api.dsmlv2

Examples of org.apache.directory.api.dsmlv2.Dsmlv2ResponseParser


     * Test parsing of a response with MatchedDN attribute
     */
    @Test
    public void testResponseWithMatchedDNAttribute()
    {
        Dsmlv2ResponseParser parser = null;
        try
        {
            parser = new Dsmlv2ResponseParser( getCodec() );

            parser.setInput( DelResponseTest.class.getResource( "response_with_matchedDN_attribute.xml" ).openStream(),
                "UTF-8" );

            parser.parse();
        }
        catch ( Exception e )
        {
            fail( e.getMessage() );
        }

        DeleteResponse delResponse = ( DeleteResponse ) parser.getBatchResponse().getCurrentResponse();

        LdapResult ldapResult = delResponse.getLdapResult();

        assertEquals( "cn=Bob Rush,ou=Dev,dc=Example,dc=COM", ldapResult.getMatchedDn().getNormName() );
    }
View Full Code Here


     * Test parsing of a response with a (optional) Control element
     */
    @Test
    public void testResponseWith1Control()
    {
        Dsmlv2ResponseParser parser = null;
        try
        {
            parser = new Dsmlv2ResponseParser( getCodec() );

            parser.setInput( SearchResultReferenceTest.class.getResource( "response_with_1_control.xml" ).openStream(),
                "UTF-8" );

            parser.parse();
        }
        catch ( Exception e )
        {
            fail( e.getMessage() );
        }

        SearchResultReference searchResultReference = ( ( SearchResponse ) parser.getBatchResponse()
            .getCurrentResponse().getDecorated() ).getCurrentSearchResultReference();
        Map<String, Control> controls = searchResultReference.getControls();

        assertEquals( 1, searchResultReference.getControls().size() );

View Full Code Here

     * Test parsing of a response with a (optional) Control element with empty value
     */
    @Test
    public void testResponseWith1ControlEmptyValue()
    {
        Dsmlv2ResponseParser parser = null;
        try
        {
            parser = new Dsmlv2ResponseParser( getCodec() );

            parser.setInput( SearchResultReferenceTest.class.getResource( "response_with_1_control_empty_value.xml" )
                .openStream(), "UTF-8" );

            parser.parse();
        }
        catch ( Exception e )
        {
            fail( e.getMessage() );
        }

        SearchResultReference searchResultReference = ( ( SearchResponse ) parser.getBatchResponse()
            .getCurrentResponse().getDecorated() ).getCurrentSearchResultReference();
        Map<String, Control> controls = searchResultReference.getControls();

        assertEquals( 1, searchResultReference.getControls().size() );

View Full Code Here

     * Test parsing of a response with 2 (optional) Control elements
     */
    @Test
    public void testResponseWith2Controls()
    {
        Dsmlv2ResponseParser parser = null;
        try
        {
            parser = new Dsmlv2ResponseParser( getCodec() );

            parser.setInput(
                SearchResultReferenceTest.class.getResource( "response_with_2_controls.xml" ).openStream(), "UTF-8" );

            parser.parse();
        }
        catch ( Exception e )
        {
            fail( e.getMessage() );
        }

        SearchResultReference searchResultReference = ( ( SearchResponse ) parser.getBatchResponse()
            .getCurrentResponse().getDecorated() ).getCurrentSearchResultReference();
        Map<String, Control> controls = searchResultReference.getControls();

        assertEquals( 2, searchResultReference.getControls().size() );

View Full Code Here

     * Test parsing of a response with 3 (optional) Control elements without value
     */
    @Test
    public void testResponseWith3ControlsWithoutValue()
    {
        Dsmlv2ResponseParser parser = null;
        try
        {
            parser = new Dsmlv2ResponseParser( getCodec() );

            parser.setInput( SearchResultReferenceTest.class.getResource( "response_with_3_controls_without_value.xml" )
                .openStream(), "UTF-8" );

            parser.parse();
        }
        catch ( Exception e )
        {
            fail( e.getMessage() );
        }

        SearchResultReference searchResultReference = ( ( SearchResponse ) parser.getBatchResponse()
            .getCurrentResponse().getDecorated() ).getCurrentSearchResultReference();
        Map<String, Control> controls = searchResultReference.getControls();

        assertEquals( 3, searchResultReference.getControls().size() );

View Full Code Here

     * Test parsing of a Response with the (optional) requestID attribute
     */
    @Test
    public void testResponseWithRequestId()
    {
        Dsmlv2ResponseParser parser = null;
        try
        {
            parser = new Dsmlv2ResponseParser( getCodec() );

            parser.setInput( SearchResultReferenceTest.class.getResource( "response_with_requestID_attribute.xml" )
                .openStream(), "UTF-8" );

            parser.parse();
        }
        catch ( Exception e )
        {
            fail( e.getMessage() );
        }

        SearchResultReference searchResultReference = ( ( SearchResponse ) parser.getBatchResponse()
            .getCurrentResponse().getDecorated() ).getCurrentSearchResultReference();

        assertEquals( 456, searchResultReference.getMessageId() );
    }
View Full Code Here

     * Test parsing of a Response with 1 Ref
     */
    @Test
    public void testResponseWith1Ref()
    {
        Dsmlv2ResponseParser parser = null;
        try
        {
            parser = new Dsmlv2ResponseParser( getCodec() );

            parser.setInput( SearchResultReferenceTest.class.getResource( "response_with_1_ref.xml" ).openStream(),
                "UTF-8" );

            parser.parse();
        }
        catch ( Exception e )
        {
            fail( e.getMessage() );
        }

        SearchResultReference searchResultReference = ( ( SearchResponse ) parser.getBatchResponse()
            .getCurrentResponse().getDecorated() ).getCurrentSearchResultReference();

        Collection<String> references = searchResultReference.getReferral().getLdapUrls();

        assertEquals( 1, references.size() );
View Full Code Here

     * Test parsing of a Response with 1 Ref
     */
    @Test
    public void testResponseWith1EmptyRef()
    {
        Dsmlv2ResponseParser parser = null;
        try
        {
            parser = new Dsmlv2ResponseParser( getCodec() );

            parser.setInput( SearchResultReferenceTest.class.getResource( "response_with_1_empty_ref.xml" )
                .openStream(), "UTF-8" );

            parser.parse();
        }
        catch ( Exception e )
        {
            fail( e.getMessage() );
        }

        SearchResultReference searchResultReference = ( ( SearchResponse ) parser.getBatchResponse()
            .getCurrentResponse().getDecorated() ).getCurrentSearchResultReference();

        Collection<String> references = searchResultReference.getReferral().getLdapUrls();

        assertEquals( 0, references.size() );
View Full Code Here

     * Test parsing of a Response with 2 Ref
     */
    @Test
    public void testResponseWith2Ref()
    {
        Dsmlv2ResponseParser parser = null;
        try
        {
            parser = new Dsmlv2ResponseParser( getCodec() );

            parser.setInput( SearchResultReferenceTest.class.getResource( "response_with_2_ref.xml" ).openStream(),
                "UTF-8" );

            parser.parse();
        }
        catch ( Exception e )
        {
            fail( e.getMessage() );
        }

        SearchResultReference searchResultReference = ( ( SearchResponse ) parser.getBatchResponse()
            .getCurrentResponse().getDecorated() ).getCurrentSearchResultReference();

        Collection<String> references = searchResultReference.getReferral().getLdapUrls();

        assertEquals( 2, references.size() );
View Full Code Here

     * Test parsing of a Response with the (optional) requestID attribute
     */
    @Test
    public void testResponseWithRequestId()
    {
        Dsmlv2ResponseParser parser = null;
        try
        {
            parser = new Dsmlv2ResponseParser( getCodec() );

            parser.setInput( ExtendedResponseTest.class.getResource( "response_with_requestID_attribute.xml" )
                .openStream(), "UTF-8" );

            parser.parse();
        }
        catch ( Exception e )
        {
            fail( e.getMessage() );
        }

        ExtendedResponse extendedResponse = ( ExtendedResponse ) parser.getBatchResponse().getCurrentResponse();

        assertEquals( 456, extendedResponse.getMessageId() );
    }
View Full Code Here

TOP

Related Classes of org.apache.directory.api.dsmlv2.Dsmlv2ResponseParser

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.