Package org.apache.directory.api.ldap.model.entry

Examples of org.apache.directory.api.ldap.model.entry.Attribute


        entry.put( atPwd, ( byte[] ) null );
        assertEquals( 1, entry.size() );
        assertTrue( entry.containsAttribute( atPwd ) );
        assertTrue( entry.contains( atPwd, ( byte[] ) null ) );

        Attribute replaced = entry.put( atPwd, BYTES1, BYTES2, BYTES1 );
        assertNotNull( replaced );
        assertEquals( atPwd, replaced.getAttributeType() );
        assertTrue( replaced.contains( ( byte[] ) null ) );
        assertEquals( 1, entry.size() );
        assertTrue( entry.contains( atPwd, BYTES1, BYTES2 ) );
        assertFalse( entry.contains( atPwd, BYTES3 ) );
        assertEquals( 2, entry.get( atPwd ).size() );

        replaced = entry.put( atPwd, "test" );
        assertNotNull( replaced );
        assertTrue( replaced.contains( BYTES1, BYTES2 ) );

        Attribute attribute = entry.get( atPwd );
        assertEquals( 1, attribute.size() );
        assertTrue( attribute.contains( "test".getBytes() ) );
    }
View Full Code Here


        entry.put( atEMail, ( String ) null );
        assertEquals( 1, entry.size() );
        assertTrue( entry.containsAttribute( atEMail ) );
        assertTrue( entry.contains( atEMail, ( String ) null ) );

        Attribute replaced = entry.put( atEMail, "test1", "test2", "test1" );
        assertNotNull( replaced );
        assertEquals( atEMail, replaced.getAttributeType() );
        assertTrue( replaced.contains( ( String ) null ) );
        assertEquals( 1, entry.size() );
        assertTrue( entry.contains( atEMail, "test1", "test2" ) );
        assertFalse( entry.contains( atEMail, "test3" ) );
        assertEquals( 2, entry.get( atEMail ).size() );

        replaced = entry.put( atEMail, BYTES1 );
        assertNotNull( replaced );
        assertTrue( replaced.contains( "test1", "test2" ) );

        Attribute attribute = entry.get( atEMail );
        assertEquals( 0, attribute.size() );
    }
View Full Code Here

        entry.put( atDC, strNullValue );
        assertEquals( 1, entry.size() );
        assertTrue( entry.containsAttribute( atDC ) );
        assertTrue( entry.contains( atDC, ( String ) null ) );

        Attribute replaced = entry.put( atDC, strValue1, strValue2, strValue1 );
        assertNotNull( replaced );
        assertEquals( atDC, replaced.getAttributeType() );
        assertTrue( replaced.contains( ( String ) null ) );
        assertEquals( 1, entry.size() );
        assertTrue( entry.contains( atDC, strValue1, strValue2 ) );
        assertFalse( entry.contains( atDC, strValue3 ) );
        assertEquals( 2, entry.get( atDC ).size() );

        replaced = entry.put( atDC, binValue1 );
        assertNotNull( replaced );
        assertTrue( replaced.contains( strValue1, strValue2 ) );

        Attribute attribute = entry.get( atDC );
        assertEquals( 0, attribute.size() );
    }
View Full Code Here

    @Test
    public void testPutEntryAttribute() throws Exception
    {
        Entry entry = new DefaultEntry( schemaManager, EXAMPLE_DN );

        Attribute oc = new DefaultAttribute( atObjectClass, "top", "person" );
        Attribute cn = new DefaultAttribute( atCN, "test1", "test2" );
        Attribute sn = new DefaultAttribute( atSN, "Test1", "Test2" );
        Attribute up = new DefaultAttribute( atPwd, BYTES1, BYTES2 );
        Attribute c = new DefaultAttribute( atEMail, "FR", "US" );

        List<Attribute> removed = entry.put( oc, cn, sn, c );

        assertEquals( 4, entry.size() );
        assertEquals( 0, removed.size() );
        assertTrue( entry.containsAttribute( "ObjectClass" ) );
        assertTrue( entry.containsAttribute( "CN" ) );
        assertTrue( entry.containsAttribute( "  sn  " ) );
        assertTrue( entry.containsAttribute( " email  " ) );

        Attribute attr = entry.get( "objectclass" );
        assertEquals( 2, attr.size() );

        Attribute c2 = new DefaultAttribute( atEMail, "UK", "DE" );
        removed = entry.put( c2, up );
        assertEquals( 1, removed.size() );
        assertEquals( c, removed.get( 0 ) );
        assertTrue( removed.get( 0 ).contains( "FR" ) );
        assertTrue( removed.get( 0 ).contains( "US" ) );

        assertEquals( 5, entry.size() );

        assertTrue( entry.containsAttribute( "userPassword" ) );
        assertTrue( entry.containsAttribute( " email " ) );

        Attribute attrC = entry.get( "email" );
        assertEquals( 2, attrC.size() );
        assertTrue( attrC.contains( "UK", "DE" ) );

        c2.clear();
        entry.put( c2 );
        assertEquals( 5, entry.size() );
        attrC = entry.get( "email" );
        assertEquals( 0, attrC.size() );
    }
View Full Code Here

        assertTrue( entry.containsAttribute( atPwd ) );
        assertTrue( entry.contains( atPwd, ( byte[] ) null ) );

        assertEquals( "UserPassword", entry.get( atPwd ).getUpId() );

        Attribute replaced = entry.put( "USERpassword ", atPwd, BYTES1, BYTES2, BYTES1 );
        assertNotNull( replaced );
        assertEquals( atPwd, replaced.getAttributeType() );
        assertTrue( replaced.contains( ( byte[] ) null ) );
        assertEquals( 1, entry.size() );
        assertTrue( entry.contains( atPwd, BYTES1, BYTES2 ) );
        assertFalse( entry.contains( atPwd, BYTES3 ) );
        assertEquals( 2, entry.get( atPwd ).size() );
        assertEquals( "USERpassword ", entry.get( atPwd ).getUpId() );

        replaced = entry.put( "userpassword", atPwd, "test" );
        assertNotNull( replaced );
        assertTrue( replaced.contains( BYTES1, BYTES2 ) );
        assertEquals( "userpassword", entry.get( atPwd ).getUpId() );

        Attribute attribute = entry.get( atPwd );
        assertEquals( 1, attribute.size() );
    }
View Full Code Here

        assertEquals( 1, entry.size() );
        assertTrue( entry.containsAttribute( atEMail ) );
        assertTrue( entry.contains( atEMail, ( String ) null ) );
        assertEquals( "EMail", entry.get( atEMail ).getUpId() );

        Attribute replaced = entry.put( "eMail", atEMail, "test1", "test2", "test1" );
        assertNotNull( replaced );
        assertEquals( atEMail, replaced.getAttributeType() );
        assertEquals( "eMail", entry.get( atEMail ).getUpId() );
        assertTrue( replaced.contains( ( String ) null ) );
        assertEquals( 1, entry.size() );
        assertTrue( entry.contains( atEMail, "test1", "test2" ) );
        assertFalse( entry.contains( atEMail, "test3" ) );
        assertEquals( 2, entry.get( atEMail ).size() );

        replaced = entry.put( "1.2.840.113549.1.9.1", atEMail, BYTES1 );
        assertNotNull( replaced );
        assertTrue( replaced.contains( "test1", "test2" ) );
        assertEquals( "1.2.840.113549.1.9.1", entry.get( atEMail ).getUpId() );

        Attribute attribute = entry.get( atEMail );
        assertEquals( 0, attribute.size() );
    }
View Full Code Here

        assertEquals( 1, entry.size() );
        assertTrue( entry.containsAttribute( atDC ) );
        assertTrue( entry.contains( atDC, ( String ) null ) );
        assertEquals( "Dc", entry.get( atDC ).getUpId() );

        Attribute replaced = entry.put( "domainComponent", atDC, strValue1, strValue2, strValue1 );
        assertNotNull( replaced );
        assertEquals( atDC, replaced.getAttributeType() );
        assertTrue( replaced.contains( ( String ) null ) );
        assertEquals( 1, entry.size() );
        assertTrue( entry.contains( atDC, strValue1, strValue2 ) );
        assertFalse( entry.contains( atDC, strValue3 ) );
        assertEquals( 2, entry.get( atDC ).size() );
        assertEquals( "domainComponent", entry.get( atDC ).getUpId() );

        replaced = entry.put( "0.9.2342.19200300.100.1.25", atDC, binValue1 );
        assertNotNull( replaced );
        assertTrue( replaced.contains( strValue1, strValue2 ) );

        Attribute attribute = entry.get( atDC );
        assertEquals( 0, attribute.size() );
        assertEquals( "0.9.2342.19200300.100.1.25", entry.get( atDC ).getUpId() );
    }
View Full Code Here

        catch ( IllegalArgumentException iae )
        {
            assertTrue( true );
        }

        Attribute replaced = entry.put( "userPassword", ( byte[] ) null );
        assertNull( replaced );
        assertEquals( 1, entry.size() );
        assertNotNull( entry.get( "userPassword" ) );
        assertEquals( 1, entry.get( "userPassword" ).size() );
        assertNull( entry.get( "userPassword" ).get().getValue() );

        replaced = entry.put( "UserPassword", BYTES1 );
        assertNotNull( replaced );
        assertEquals( atPwd, replaced.getAttributeType() );
        assertTrue( replaced.contains( ( byte[] ) null ) );
        assertEquals( 1, entry.size() );
        assertNotNull( entry.get( "userPassword" ) );
        assertEquals( 1, entry.get( "userPassword" ).size() );
        assertNotNull( entry.get( "userPassword" ).get().getValue() );
        assertTrue( entry.get( "userPassword" ).contains( BYTES1 ) );

        replaced = entry.put( "userPassword", BYTES1, BYTES2, BYTES1 );
        assertNotNull( replaced );
        assertEquals( 1, entry.size() );
        assertNotNull( entry.get( "userPassword" ) );
        assertEquals( 2, entry.get( "USERPassword" ).size() );
        Attribute attribute = entry.get( "userPassword" );
        assertTrue( attribute.contains( BYTES1 ) );
        assertTrue( attribute.contains( BYTES2 ) );
        assertEquals( "2.5.4.35", attribute.getId() );
        assertEquals( "userPassword", attribute.getUpId() );
    }
View Full Code Here

        catch ( IllegalArgumentException iae )
        {
            assertTrue( true );
        }

        Attribute replaced = entry.put( "dc", ( String ) null );
        assertNull( replaced );
        assertEquals( 1, entry.size() );
        assertNotNull( entry.get( "dc" ) );
        assertEquals( 1, entry.get( "dc" ).size() );
        assertNotNull( entry.get( "dc" ).get() );

        replaced = entry.put( "CN", "test" );
        assertNull( replaced );
        assertEquals( 2, entry.size() );
        assertNotNull( entry.get( "cn" ) );
        assertEquals( 1, entry.get( "cn" ).size() );
        assertNotNull( entry.get( "cn" ).get().getValue() );
        assertTrue( entry.get( "cn" ).contains( "test" ) );

        replaced = entry.put( "cN", "test1", "test2", "test1" );
        assertNotNull( replaced );
        assertEquals( "test", replaced.get().getString() );

        assertEquals( 2, entry.size() );
        assertNotNull( entry.get( "cn" ) );
        assertEquals( 2, entry.get( "CN" ).size() );

        Attribute attribute = entry.get( "cn" );
        assertTrue( attribute.contains( "test1" ) );
        assertTrue( attribute.contains( "test2" ) );
        assertEquals( "2.5.4.3", attribute.getId() );
        assertEquals( "cN", attribute.getUpId() );
    }
View Full Code Here

        catch ( IllegalArgumentException iae )
        {
            assertTrue( true );
        }

        Attribute replaced = entry.put( "domainComponent", strNullValue );
        assertNull( replaced );
        assertEquals( 1, entry.size() );
        assertNotNull( entry.get( "domainComponent" ) );
        assertEquals( 1, entry.get( "domainComponent" ).size() );
        assertNotNull( entry.get( "domainComponent" ).get() );
        assertNull( entry.get( "domainComponent" ).get().getValue() );
        entry.removeAttributes( "dc" );

        replaced = entry.put( "DC", strValue3 );
        assertNull( replaced );
        assertEquals( 1, entry.size() );
        assertNotNull( entry.get( "dc" ) );
        assertEquals( 1, entry.get( "dc" ).size() );
        assertNotNull( entry.get( "dc" ).get().getValue() );
        assertTrue( entry.get( "dc" ).contains( strValue3 ) );

        replaced = entry.put( "dC", strValue1, strValue2, strValue1 );
        assertNotNull( replaced );
        assertEquals( strValue3, replaced.get() );

        assertEquals( 1, entry.size() );
        assertNotNull( entry.get( "dc" ) );
        assertEquals( 2, entry.get( "DC" ).size() );

        Attribute attribute = entry.get( "dc" );
        assertTrue( attribute.contains( strValue1 ) );
        assertTrue( attribute.contains( strValue2 ) );
        assertEquals( "0.9.2342.19200300.100.1.25", attribute.getId() );
        assertEquals( "dC", attribute.getUpId() );

        // Bin values are not allowed, so the new CN will be empty
        entry.put( "dc", binValue1 );
        assertNull( entry.get( "dc" ).get() );
    }
View Full Code Here

TOP

Related Classes of org.apache.directory.api.ldap.model.entry.Attribute

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.