Package org.apache.directory.studio.dsmlv2

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


                fout.close();
            }
           
            // Processing Reponse (Reading and displaying possible errors)
            int errorCount = 0;
            Dsmlv2ResponseParser responseParser = new Dsmlv2ResponseParser();
            responseParser.setInput( response );
            LdapResponse ldapResponse = responseParser.getNextResponse();
            while ( ldapResponse != null )
            {
                if ( ( ldapResponse instanceof ErrorResponse )
                     || ( ldapResponse.getLdapResult().getResultCode() != ResultCodeEnum.SUCCESS ) )
                {
                    errorCount++;
                }
                ldapResponse = responseParser.getNextResponse();
            }
           
            if ( errorCount > 0 )
            {
                monitor.reportError( BrowserCoreMessages.bind(
View Full Code Here


     */
    public void testParsingFail( Class testClass, String filename )
    {
        try
        {
            Dsmlv2ResponseParser parser = new Dsmlv2ResponseParser();

            parser.setInputFile( testClass.getResource( filename ).getFile() );

            parser.parse();
        }
        catch ( XmlPullParserException e )
        {
            assertTrue( e.getMessage(), true );
            return;
View Full Code Here

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

            parser.setInputFile( SearchResultEntryTest.class.getResource( "response_with_1_control.xml" ).getFile() );

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

        SearchResultEntry searchResultEntry = ( ( SearchResponse ) parser.getBatchResponse().getCurrentResponse() )
            .getCurrentSearchResultEntry();

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

        Control control = searchResultEntry.getCurrentControl();
View Full Code Here

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

            parser.setInputFile( SearchResultEntryTest.class.getResource( "response_with_1_control_empty_value.xml" )
                .getFile() );

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

        SearchResultEntry searchResultEntry = ( ( SearchResponse ) parser.getBatchResponse().getCurrentResponse() )
            .getCurrentSearchResultEntry();
        Control control = searchResultEntry.getCurrentControl();

        assertEquals( 1, searchResultEntry.getControls().size() );
        assertTrue( control.getCriticality() );
View Full Code Here

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

            parser.setInputFile( SearchResultEntryTest.class.getResource( "response_with_2_controls.xml" ).getFile() );

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

        SearchResultEntry searchResultEntry = ( ( SearchResponse ) parser.getBatchResponse().getCurrentResponse() )
            .getCurrentSearchResultEntry();

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

        Control control = searchResultEntry.getCurrentControl();
View Full Code Here

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

            parser.setInputFile( SearchResultEntryTest.class.getResource( "response_with_3_controls_without_value.xml" )
                .getFile() );

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

        SearchResultEntry searchResultEntry = ( ( SearchResponse ) parser.getBatchResponse().getCurrentResponse() )
            .getCurrentSearchResultEntry();

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

        Control control = searchResultEntry.getCurrentControl();
View Full Code Here

    /**
     * Test parsing of a response with dn Attribute
     */
    public void testResponseWithDnAttribute()
    {
        Dsmlv2ResponseParser parser = null;
        try
        {
            parser = new Dsmlv2ResponseParser();

            parser.setInputFile( SearchResultEntryTest.class.getResource( "response_with_dn_attribute.xml" ).getFile() );

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

        SearchResultEntry searchResultEntry = ( ( SearchResponse ) parser.getBatchResponse().getCurrentResponse() )
            .getCurrentSearchResultEntry();

        assertEquals( "dc=example,dc=com", searchResultEntry.getObjectName().toString() );
    }
View Full Code Here

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

            parser.setInputFile( SearchResultEntryTest.class.getResource( "response_with_requestID_attribute.xml" )
                .getFile() );

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

        SearchResultEntry searchResultEntry = ( ( SearchResponse ) parser.getBatchResponse().getCurrentResponse() )
            .getCurrentSearchResultEntry();

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

                fout.close();
            }
           
            // Processing Reponse (Reading and displaying possible errors)
            int errorCount = 0;
            Dsmlv2ResponseParser responseParser = new Dsmlv2ResponseParser();
            responseParser.setInput( response );
            LdapResponse ldapResponse = responseParser.getNextResponse();
            while ( ldapResponse != null )
            {
                if ( ( ldapResponse instanceof ErrorResponse )
                     || ( ldapResponse.getLdapResult().getResultCode() != ResultCodeEnum.SUCCESS ) )
                {
                    errorCount++;
                }
                ldapResponse = responseParser.getNextResponse();
            }
           
            if ( errorCount > 0 )
            {
                monitor.reportError( BrowserCoreMessages.bind(
View Full Code Here

    /**
     * Test parsing of a response with 0 Attr
     */
    public void testResponseWith0Attr()
    {
        Dsmlv2ResponseParser parser = null;
        try
        {
            parser = new Dsmlv2ResponseParser();

            parser.setInputFile( SearchResultEntryTest.class.getResource( "response_with_0_attr.xml" ).getFile() );

            parser.parse();
        }
        catch ( Exception e )
        {
            fail( e.getMessage() );
        }
View Full Code Here

TOP

Related Classes of org.apache.directory.studio.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.