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

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


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

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

        Iterator<Attribute> attributeIterator = entry.iterator();
        Attribute attribute = attributeIterator.next();
        assertEquals( "dc", attribute.getUpId() );
        assertEquals( 1, attribute.size() );

        Iterator<Value<?>> valueIterator = attribute.iterator();
View Full Code Here


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

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

        Iterator<Attribute> attributeIterator = entry.iterator();
        Attribute attribute = attributeIterator.next();
        assertEquals( "objectclass", attribute.getUpId() );
        assertEquals( 2, attribute.size() );

        Iterator<Value<?>> valueIterator = attribute.iterator();
View Full Code Here

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

        Entry entry = searchResultEntry.getEntry();
        assertEquals( 2, entry.size() );

        Attribute objectClassAttribute = entry.get( "objectclass" );
        assertEquals( 1, objectClassAttribute.size() );

        Iterator<Value<?>> valueIterator = objectClassAttribute.iterator();
        assertTrue( valueIterator.hasNext() );
        Value<?> value = valueIterator.next();
        assertEquals( "top", value.getString() );
        assertFalse( valueIterator.hasNext() );

        Attribute dcAttribute = entry.get( "dc" );
        assertEquals( 1, objectClassAttribute.size() );

        valueIterator = dcAttribute.iterator();
        assertTrue( valueIterator.hasNext() );
        value = valueIterator.next();
View Full Code Here

     *
     * @return
     */
    private Entry getEntry()
    {
        Entry entry = new DefaultEntry();

        try
        {
            entry.put( getAttribute( "attr0" ) );
            entry.put( getAttribute( "attr1" ) );
            entry.put( getAttribute( "attr2" ) );
        }
        catch ( LdapException ne )
        {
            // Do nothing
        }
View Full Code Here

    @Test
    public void testNotEqualDiffAttributes() throws LdapException
    {
        AddRequestImpl req0 = new AddRequestImpl();
        req0.setMessageId( 5 );
        Entry entry0 = getEntry();
        entry0.setDn( new Dn( "cn=admin,dc=apache,dc=org" ) );
        req0.setEntry( entry0 );

        AddRequestImpl req1 = new AddRequestImpl();
        req1.setMessageId( 5 );
        req1.setEntryDn( new Dn( "cn=admin,dc=apache,dc=org" ) );

        assertTrue( req0.equals( req1 ) );
        assertTrue( req1.equals( req0 ) );

        Entry entry1 = getEntry();
        entry1.setDn( new Dn( "cn=admin,dc=apache,dc=org" ) );
        req1.setEntry( entry1 );

        assertTrue( req0.equals( req1 ) );
        assertTrue( req1.equals( req0 ) );
View Full Code Here

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

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

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

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

        assertEquals( 0, entry.size() );
        entry.add( "ObjectClass", "top", "person" );
        entry.add( "cn", "test" );
        entry.add( "sn", "Test" );

        assertEquals( 3, entry.size() );

        entry.clear();
        assertEquals( 0, entry.size() );
    }
View Full Code Here

     * Test method for for {@link org.apache.directory.shared.ldap.model.entry.DefaultEntry#toString()}.
     */
    @Test
    public void testToString()
    {
        Entry entry = new DefaultEntry( EXAMPLE_DN );

        assertEquals( "Entry\n    dn: dc=example,dc=com\n", entry.toString() );

        Value<String> strValueTop = new StringValue( "top" );
        Value<String> strValuePerson = new StringValue( "person" );
        Value<String> strNullValue = new StringValue( ( String ) null );

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

        entry.put( "ObjectClass", strValueTop, strValuePerson, strNullValue );
        entry.put( "UserPassword", binValue1, binValue2, binNullValue );

        String expected =
            "Entry\n" +
                "    dn: dc=example,dc=com\n" +
                "    ObjectClass: top\n" +
                "    ObjectClass: person\n" +
                "    ObjectClass: ''\n" +
                "    UserPassword: '0x61 0x62 '\n" +
                "    UserPassword: '0x62 '\n" +
                "    UserPassword: ''\n";

        assertEquals( expected, entry.toString() );
    }
View Full Code Here

        Dn dn = new Dn( "ou=system" );

        dn.apply( schemaManager );

        byte[] password = Strings.getBytesUtf8( "secret" );
        Entry entry = new DefaultEntry( dn );
        entry.add( "ObjectClass", "top", "person" );
        entry.add( "cn", "test1" );
        entry.add( "userPassword", password );

        Entry entrySer = deserializeValue( serializeValue( entry ) );

        assertEquals( entry, entrySer );
    }
View Full Code Here

     */
    @Test
    public void testSerializeEntryWithNoDN() throws LdapException, IOException, ClassNotFoundException
    {
        byte[] password = Strings.getBytesUtf8( "secret" );
        Entry entry = new DefaultEntry();
        entry.add( "ObjectClass", "top", "person" );
        entry.add( "cn", "test1" );
        entry.add( "userPassword", password );

        Entry entrySer = deserializeValue( serializeValue( entry ) );

        assertEquals( entry, entrySer );
    }
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.