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

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


     * Test method for hashcode()
     */
    @Test
    public void testHashCode() throws LdapException, LdapException
    {
        Entry entry1 = new DefaultEntry( EXAMPLE_DN );
        Entry entry2 = new DefaultEntry( EXAMPLE_DN );

        assertEquals( entry1.hashCode(), entry2.hashCode() );

        entry2.setDn( new Dn( "ou=system,dc=com" ) );
        assertNotSame( entry1.hashCode(), entry2.hashCode() );

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

        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.add( attrOC, attrCN, attrSN, attrPWD );
        entry2.add( attrOC, attrCN, attrSN, attrPWD );

        assertEquals( entry1.hashCode(), entry2.hashCode() );

        Entry entry3 = new DefaultEntry( EXAMPLE_DN );
        entry3.add( attrOC, attrSN, attrCN, attrPWD );

        assertEquals( entry1.hashCode(), entry3.hashCode() );
    }
View Full Code Here


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

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

        entry.add( new DefaultAttribute( "objectClass", "top", "person" ) );

        assertTrue( entry.hasObjectClass( "top" ) );
        assertTrue( entry.hasObjectClass( "person" ) );
        assertFalse( entry.hasObjectClass( "inetorgperson" ) );
        assertFalse( entry.hasObjectClass( ( String ) null ) );
        assertFalse( entry.hasObjectClass( "" ) );
    }
View Full Code Here

     * Test method for Iterator()
     */
    @Test
    public void testIterator() throws LdapException
    {
        Entry entry = createEntry();

        Iterator<Attribute> iterator = entry.iterator();

        assertTrue( iterator.hasNext() );

        Set<String> expectedIds = new HashSet<String>();
        expectedIds.add( "objectclass" );
View Full Code Here

     * Test method for put( EntryAttribute... )
     */
    @Test
    public void testPutEntryAttributeArray() 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 );

        List<Attribute> removed = entry.put( attrOC, attrCN, attrSN, attrPWD );

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

        Attribute attrCN2 = new DefaultAttribute( "cn", "test3", "test4" );
        removed = entry.put( attrCN2 );
        assertEquals( 4, entry.size() );
        assertEquals( 1, removed.size() );
        assertTrue( entry.containsAttribute( "CN" ) );
        assertTrue( entry.contains( "cn", "test3", "test4" ) );
    }
View Full Code Here

     */
    private Entry createEntry()
    {
        try
        {
            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 );

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

            return entry;
        }
        catch ( LdapException ne )
        {
View Full Code Here

        try
        {
            oIn = new ObjectInputStream( in );

            Entry value = ( Entry ) oIn.readObject();

            return value;
        }
        catch ( IOException ioe )
        {
View Full Code Here

     * Test method for DefaultEntry()
     */
    @Test
    public void testDefaultClientEntry()
    {
        Entry entry = new DefaultEntry();

        assertNotNull( entry );
        assertEquals( Dn.EMPTY_DN, entry.getDn() );
        assertEquals( 0, entry.size() );
    }
View Full Code Here

     * Test method for DefaultEntry()
     */
    @Test
    public void testDefaultClientEntryLdif() throws Exception
    {
        Entry entry = new DefaultEntry(
            "ou=example, dc=com",
            "ObjectClass: top",
            "ObjectClass: person",
            "cn: test",
            "sn: test" );

        assertNotNull( entry );
        assertEquals( "ou=example, dc=com", entry.getDn().toString() );
        assertEquals( 3, entry.size() );
        assertTrue( entry.contains( "objectClass", "top", "person" ) );
        assertTrue( entry.contains( "cn", "test" ) );
        assertTrue( entry.contains( "sn", "test" ) );
    }
View Full Code Here

     * Test method for DefaultEntry( Dn )
     */
    @Test
    public void testDefaultClientEntryLdapDN()
    {
        Entry entry = new DefaultEntry( EXAMPLE_DN );

        assertNotNull( entry );
        assertNotNull( entry.getDn() );
        assertEquals( EXAMPLE_DN, entry.getDn() );
        assertEquals( 0, entry.size() );
    }
View Full Code Here

     * Test method for add( EntryAttribute... )
     */
    @Test
    public void testAddEntryAttributeArray() throws LdapException
    {
        Entry entry = createEntry();

        assertEquals( 4, entry.size() );
        assertTrue( entry.containsAttribute( "ObjectClass" ) );
        assertTrue( entry.containsAttribute( "CN" ) );
        assertTrue( entry.containsAttribute( "  sn  " ) );
        assertTrue( entry.containsAttribute( "userPassword" ) );

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

        Attribute attrCN2 = new DefaultAttribute( "cn", "test1", "test3" );
        entry.add( attrCN2 );
        assertEquals( 4, entry.size() );
        attr = entry.get( "cn" );
        assertEquals( 3, attr.size() );
        assertTrue( attr.contains( "test1", "test2", "test3" ) );

        // Check adding some byte[] values (they will not be transformed to Strings)
        attrCN2.clear();
        attrCN2.add( BYTES1, BYTES2 );
        entry.add( attrCN2 );
        assertEquals( 4, entry.size() );
        attr = entry.get( "cn" );
        assertEquals( 3, attr.size() );
        assertTrue( attr.contains( "test1", "test2", "test3" ) );
        assertFalse( attr.contains( "ab", "b" ) );
    }
View Full Code Here

TOP

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

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.