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

Examples of org.apache.directory.shared.ldap.model.entry.DefaultEntry


     * Test method for clear()
     */
    @Test
    public void testClear() throws LdapException
    {
        Entry entry = new DefaultEntry( EXAMPLE_DN );

        assertEquals( 0, entry.size() );
        assertNull( entry.get( "ObjectClass" ) );
        entry.clear();
        assertEquals( 0, entry.size() );
        assertNull( entry.get( "ObjectClass" ) );

        entry.add( "ObjectClass", "top", "person" );
        assertEquals( 1, entry.size() );
        assertNotNull( entry.get( "ObjectClass" ) );

        entry.clear();
        assertEquals( 0, entry.size() );
        assertNull( entry.get( "ObjectClass" ) );
    }
View Full Code Here


     * Test method for clone()
     */
    @Test
    public void testClone() throws LdapException
    {
        Entry entry1 = new DefaultEntry();

        Entry entry2 = entry1.clone();

        assertEquals( entry1, entry2 );
        entry2.setDn( EXAMPLE_DN );

        assertEquals( Dn.EMPTY_DN, entry1.getDn() );

        entry1.setDn( EXAMPLE_DN );
        entry2 = entry1.clone();
        assertEquals( entry1, entry2 );

        entry1.add( "objectClass", "top", "person" );
        entry1.add( "cn", "test1", "test2" );

        entry2 = entry1.clone();
        assertEquals( entry1, entry2 );

        entry1.add( "cn", "test3" );
        assertEquals( 2, entry2.get( "cn" ).size() );
        assertFalse( entry2.contains( "cn", "test3" ) );

        entry1.add( "sn", ( String ) null );
        assertFalse( entry2.containsAttribute( "sn" ) );
    }
View Full Code Here

     * Test method for contains( EntryAttribute... )
     */
    @Test
    public void testContainsEntryAttributeArray() throws LdapException
    {
        Entry entry = new DefaultEntry( EXAMPLE_DN );

        Attribute attrOC = new DefaultAttribute( "objectClass", "top", "person" );
        Attribute attrCN = new DefaultAttribute( "cn", "test1", "test2" );
        Attribute attrSN = new DefaultAttribute( "sn", "Test1", "Test2" );
        Attribute attrPWD = new DefaultAttribute( "userPassword", BYTES1, BYTES2 );

        assertFalse( entry.contains( attrOC, attrCN ) );

        entry.add( attrOC, attrCN );

        assertTrue( entry.contains( attrOC, attrCN ) );
        assertFalse( entry.contains( attrOC, attrCN, attrSN ) );

        entry.add( attrSN, attrPWD );

        assertTrue( entry.contains( attrSN, attrPWD ) );
    }
View Full Code Here

     * Test method for contains( String, byte[]... )
     */
    @Test
    public void testContainsStringByteArray() throws LdapException
    {
        Entry entry = new DefaultEntry( EXAMPLE_DN );

        assertFalse( entry.containsAttribute( "objectClass" ) );

        Attribute attrPWD = new DefaultAttribute( "userPassword", BYTES1, ( byte[] ) null, BYTES2 );

        entry.add( attrPWD );

        assertTrue( entry.contains( "  userPASSWORD  ", BYTES1, BYTES2 ) );
        assertTrue( entry.contains( "  userPASSWORD  ", ( byte[] ) null ) );

        // We can search for byte[] using Strings. the strings will be converted to byte[]
        assertTrue( entry.contains( "  userPASSWORD  ", "ab", "b" ) );

        assertFalse( entry.contains( "  userPASSWORD  ", "ab", "b", "d" ) );
    }
View Full Code Here

     * Test method for contains( String, String... )
     */
    @Test
    public void testContainsStringStringArray() throws LdapException
    {
        Entry entry = new DefaultEntry( EXAMPLE_DN );

        assertFalse( entry.containsAttribute( "objectClass" ) );

        Attribute attrOC = new DefaultAttribute( "objectClass", "top", "person" );
        Attribute attrCN = new DefaultAttribute( "cn", "test1", "test2" );
        Attribute attrSN = new DefaultAttribute( "sn", "Test1", "Test2", ( String ) null );
        Attribute attrPWD = new DefaultAttribute( "userPassword", BYTES1, BYTES2 );

        entry.add( attrOC, attrCN, attrSN, attrPWD );

        assertTrue( entry.contains( "OBJECTCLASS", "top", "person" ) );
        assertTrue( entry.contains( " cn ", "test1", "test2" ) );
        assertTrue( entry.contains( "Sn", "Test1", "Test2", ( String ) null ) );
        assertTrue( entry.contains( "  userPASSWORD  ", "ab", "b" ) );

        assertFalse( entry.contains( "OBJECTCLASS", "PERSON" ) );
        assertFalse( entry.contains( " cn ", "test1", "test3" ) );
        assertFalse( entry.contains( "Sn", "Test" ) );
        assertFalse( entry.contains( "  userPASSWORD  ", ( String ) null ) );
    }
View Full Code Here

     * Test method for contains( Sring, Value<?>... )
     */
    @Test
    public void testContainsStringValueArray() throws LdapException
    {
        Entry entry = new DefaultEntry( EXAMPLE_DN );

        assertFalse( entry.containsAttribute( "objectClass" ) );

        Attribute attrCN = new DefaultAttribute( "cn", "test1", "test2", ( String ) null );
        Attribute attrPWD = new DefaultAttribute( "userPassword", BYTES1, BYTES2, ( byte[] ) null );

        entry.add( attrCN, attrPWD );

        Value<String> strValue1 = new StringValue( "test1" );
        Value<String> strValue2 = new StringValue( "test2" );
        Value<String> strValue3 = new StringValue( "test3" );
        Value<String> strNullValue = new StringValue( ( String ) null );

        Value<byte[]> binValue1 = new BinaryValue( BYTES1 );
        Value<byte[]> binValue2 = new BinaryValue( BYTES2 );
        Value<byte[]> binValue3 = new BinaryValue( BYTES3 );
        Value<byte[]> binNullValue = new BinaryValue( ( byte[] ) null );

        assertTrue( entry.contains( "CN", strValue1, strValue2, strNullValue ) );
        assertTrue( entry.contains( "userpassword", binValue1, binValue2, binNullValue ) );

        assertFalse( entry.contains( "cn", strValue3 ) );
        assertFalse( entry.contains( "UserPassword", binValue3 ) );
    }
View Full Code Here

     * Test method for containsAttribute( String )
     */
    @Test
    public void testContainsAttribute() throws LdapException
    {
        Entry entry = new DefaultEntry( EXAMPLE_DN );

        assertFalse( entry.containsAttribute( "objectClass" ) );

        Attribute attrOC = new DefaultAttribute( "objectClass", "top", "person" );
        Attribute attrCN = new DefaultAttribute( "cn", "test1", "test2" );
        Attribute attrSN = new DefaultAttribute( "sn", "Test1", "Test2" );
        Attribute attrPWD = new DefaultAttribute( "userPassword", BYTES1, BYTES2 );

        entry.add( attrOC, attrCN, attrSN, attrPWD );

        assertTrue( entry.containsAttribute( "OBJECTCLASS" ) );
        assertTrue( entry.containsAttribute( " cn " ) );
        assertTrue( entry.containsAttribute( "Sn" ) );
        assertTrue( entry.containsAttribute( "  userPASSWORD  " ) );

        entry.clear();

        assertFalse( entry.containsAttribute( "OBJECTCLASS" ) );
        assertFalse( entry.containsAttribute( " cn " ) );
        assertFalse( entry.containsAttribute( "Sn" ) );
        assertFalse( entry.containsAttribute( "  userPASSWORD  " ) );
    }
View Full Code Here

     * Test method for equals()
     */
    @Test
    public void testEqualsObject() throws LdapException
    {
        Entry entry1 = new DefaultEntry();
        Entry entry2 = new DefaultEntry();

        assertEquals( entry1, entry2 );

        entry1.setDn( EXAMPLE_DN );
        assertNotSame( entry1, entry2 );

        entry2.setDn( EXAMPLE_DN );
        assertEquals( entry1, entry2 );

        Attribute attrOC = new DefaultAttribute( "objectClass", "top", "person" );
        Attribute attrCN = new DefaultAttribute( "cn", "test1", "test2" );
        Attribute attrSN = new DefaultAttribute( "sn", "Test1", "Test2" );
        Attribute attrPWD = new DefaultAttribute( "userPassword", BYTES1, BYTES2 );

        entry1.put( attrOC, attrCN, attrSN, attrPWD );
        entry2.put( attrOC, attrCN, attrSN );
        assertNotSame( entry1, entry2 );

        entry2.put( attrPWD );
        assertEquals( entry1, entry2 );

        Attribute attrL1 = new DefaultAttribute( "l", "Paris", "New-York" );
        Attribute attrL2 = new DefaultAttribute( "l", "Paris", "Tokyo" );

        entry1.put( attrL1 );
        entry2.put( attrL1 );
        assertEquals( entry1, entry2 );

        entry1.add( "l", "London" );
        assertNotSame( entry1, entry2 );

        entry2.add( attrL2 );
        assertNotSame( entry1, entry2 );

        entry1.clear();
        entry2.clear();
        assertEquals( entry1, entry2 );
    }
View Full Code Here

     * Test method for get( String )
     */
    @Test
    public void testGet() throws LdapException
    {
        Entry entry = new DefaultEntry( EXAMPLE_DN );

        assertNull( entry.get( "objectClass" ) );

        Attribute attrOC = new DefaultAttribute( "objectClass", "top", "person" );
        Attribute attrCN = new DefaultAttribute( "cn", "test1", "test2" );
        Attribute attrSN = new DefaultAttribute( "sn", "Test1", "Test2" );
        Attribute attrPWD = new DefaultAttribute( "userPassword", BYTES1, BYTES2 );

        entry.add( attrOC, attrCN, attrSN, attrPWD );

        assertNotNull( entry.get( "  CN  " ) );
        Attribute attribute = entry.get( "cN" );

        assertEquals( attribute, attrCN );

        assertNull( entry.get( ( String ) null ) );
        assertNull( entry.get( "  " ) );
        assertNull( entry.get( "l" ) );
    }
View Full Code Here

     * Test method for getDN()
     */
    @Test
    public void testGetDn() throws LdapException
    {
        Entry entry = new DefaultEntry( EXAMPLE_DN );

        assertEquals( EXAMPLE_DN, entry.getDn() );

        Dn testDn = new Dn( "cn=test" );
        entry.setDn( testDn );

        assertEquals( testDn, entry.getDn() );
    }
View Full Code Here

TOP

Related Classes of org.apache.directory.shared.ldap.model.entry.DefaultEntry

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.