Package org.apache.directory.shared.ldap.model.message

Examples of org.apache.directory.shared.ldap.model.message.AddRequest


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

        AddRequest addRequest = ( AddRequest ) parser.getBatchRequest().getCurrentRequest();

        Entry entry = addRequest.getEntry();
        assertEquals( 1, entry.size() );

        // Getting the Attribute 
        Iterator<Attribute> attributeIterator = entry.iterator();
        Attribute attribute = attributeIterator.next();
View Full Code Here


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

        AddRequest addRequest = ( AddRequest ) parser.getBatchRequest().getCurrentRequest();

        Entry entry = addRequest.getEntry();
        assertEquals( 1, entry.size() );

        // Getting the Attribute      
        Iterator<Attribute> attributeIterator = entry.iterator();
        Attribute attribute = attributeIterator.next();
View Full Code Here

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

        AddRequest addRequest = ( AddRequest ) parser.getBatchRequest().getCurrentRequest();

        Entry entry = addRequest.getEntry();
        assertEquals( 1, entry.size() );

        // Getting the Attribute      
        Iterator<Attribute> attributeIterator = entry.iterator();
        Attribute attribute = attributeIterator.next();
View Full Code Here

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

        AddRequest addRequest = ( AddRequest ) parser.getBatchRequest().getCurrentRequest();

        Entry entry = addRequest.getEntry();
        assertEquals( 1, entry.size() );

        // Getting the Attribute      
        Iterator<Attribute> attributeIterator = entry.iterator();
        Attribute attribute = attributeIterator.next();
View Full Code Here

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

        AddRequest addRequest = ( AddRequest ) parser.getBatchRequest().getCurrentRequest();

        Entry entry = addRequest.getEntry();
        assertEquals( 1, entry.size() );

        // Getting the Attribute      
        Iterator<Attribute> attributeIterator = entry.iterator();
        Attribute attribute = attributeIterator.next();
View Full Code Here

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

        AddRequest addRequest = ( AddRequest ) parser.getBatchRequest().getCurrentRequest();

        Entry entry = addRequest.getEntry();
        assertEquals( 1, entry.size() );

        // Getting the Attribute      
        Iterator<Attribute> attributeIterator = entry.iterator();
        Attribute attribute = attributeIterator.next();
View Full Code Here

        {
            de.printStackTrace();
            fail( de.getMessage() );
        }

        AddRequest addRequest = container.getMessage();

        // Check the decoded message
        assertEquals( 1, addRequest.getMessageId() );
        assertEquals( "cn=testModify,ou=users,ou=system", addRequest.getEntryDn().toString() );

        Entry entry = addRequest.getEntry();

        assertEquals( 2, entry.size() );

        Set<String> expectedTypes = new HashSet<String>();

        expectedTypes.add( "l" );
        expectedTypes.add( "attrs" );

        Map<String, Set<String>> typesVals = new HashMap<String, Set<String>>();

        Set<String> lVal1 = new HashSet<String>();
        lVal1.add( "Paris" );
        typesVals.put( "l", lVal1 );

        Set<String> lVal2 = new HashSet<String>();
        lVal2.add( "test1" );
        lVal2.add( "test2" );
        lVal2.add( "test3" );
        typesVals.put( "attrs", lVal2 );

        Attribute attribute = entry.get( "l" );

        assertTrue( expectedTypes.contains( Strings.toLowerCase( attribute.getId() ) ) );

        Set<String> vals = ( Set<String> ) typesVals.get( Strings.toLowerCase( attribute.getId() ) );

        for ( Value<?> value : attribute )
        {
            assertTrue( vals.contains( value.getValue() ) );

            vals.remove( value.getValue() );
        }

        attribute = entry.get( "attrs" );

        assertTrue( expectedTypes.contains( Strings.toLowerCase( attribute.getId() ) ) );

        vals = ( Set<String> ) typesVals.get( Strings.toLowerCase( attribute.getId() ) );

        for ( Value<?> value : attribute )
        {
            assertTrue( vals.contains( value.getValue() ) );

            vals.remove( value.getValue() );
        }

        // Check the encoding
        try
        {
            ByteBuffer bb = encoder.encodeMessage( addRequest );

            // Check the length
            assertEquals( 0x59, bb.limit() );

            // We cannot compare the PDU, as the attributes order is not
            // kept. Let's decode again and compare the resulting AddRequest
            try
            {
                ldapDecoder.decode( bb, container );
            }
            catch ( DecoderException de )
            {
                de.printStackTrace();
                fail( de.getMessage() );
            }

            AddRequest addRequest2 = container.getMessage();
            assertEquals( addRequest, addRequest2 );
        }
        catch ( EncoderException ee )
        {
            ee.printStackTrace();
View Full Code Here

        {
            de.printStackTrace();
            fail( de.getMessage() );
        }

        AddRequest addRequest = container.getMessage();

        // Check the decoded message
        assertEquals( 1, addRequest.getMessageId() );
        assertEquals( "cn=testModify,ou=users,ou=system", addRequest.getEntryDn().toString() );

        Entry entry = addRequest.getEntry();

        assertEquals( 1, entry.size() );

        Attribute attribute = entry.get( "l" );
View Full Code Here

        {
            de.printStackTrace();
            fail( de.getMessage() );
        }

        AddRequest addRequest = container.getMessage();

        // Check the decoded message
        assertEquals( 1, addRequest.getMessageId() );
        assertEquals( "cn=testModify,ou=users,ou=system", addRequest.getEntryDn().toString() );

        Entry entry = addRequest.getEntry();

        assertEquals( 1, entry.size() );

        Attribute attribute = entry.get( "l" );

        assertEquals( "l", Strings.toLowerCase( attribute.getId() ) );

        for ( Value<?> value : attribute )
        {
            assertEquals( "", value.getString() );
        }

        // Check the Control
        Map<String, Control> controls = addRequest.getControls();

        assertEquals( 1, controls.size() );

        assertTrue( addRequest.hasControl( "2.16.840.1.113730.3.4.2" ) );

        @SuppressWarnings("unchecked")
        CodecControl<Control> control = (org.apache.directory.shared.ldap.codec.api.CodecControl<Control> ) controls.get( "2.16.840.1.113730.3.4.2" );
        assertEquals( "2.16.840.1.113730.3.4.2", control.getOid() );
        assertEquals( "", Strings.dumpBytes( ( byte[] ) control.getValue() ) );
View Full Code Here

     *                    +--> ...
     *                    +--> 0x04 L7-m-n value
     */
    public int computeLength()
    {
        AddRequest addRequest = getDecorated();
        Entry entry = addRequest.getEntry();

        if ( entry == null )
        {
            throw new IllegalArgumentException( I18n.err( I18n.ERR_04481_ENTRY_NULL_VALUE ) );
        }
View Full Code Here

TOP

Related Classes of org.apache.directory.shared.ldap.model.message.AddRequest

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.