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

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


     * Test the serialization of an entry with no attribute and no Dn
     */
    @Test
    public void testSerializeEntryWithNoDNNoAttribute() throws LdapException, IOException, ClassNotFoundException
    {
        Entry entry = new DefaultEntry();

        Entry entrySer = deserializeValue( serializeValue( entry ) );

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


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

        dn.apply( schemaManager );

        Entry entry = new DefaultEntry( dn );

        Entry entrySer = deserializeValue( serializeValue( entry ) );

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

     * Test method for userCertificate;binary AT
     */
    @Test
    public void testUserCertificateBinary() throws LdapException
    {
        Entry entry = new DefaultEntry( schemaManager );
        entry.add( "objectClass", "top", "person", "inetorgPerson" );
        entry.add( "cn", "test1", "test2" );
        entry.add( "sn", "Test1", "Test2" );
        entry.add( "userPassword", BYTES1, BYTES2 );

        entry.add( "userCertificate;binary", Strings.getBytesUtf8( "secret" ) );
        assertTrue( entry.containsAttribute( "userCertificate;binary" ) );
        assertTrue( entry.containsAttribute( "userCertificate" ) );

        entry.removeAttributes( "userCertificate;binary" );
        assertFalse( entry.containsAttribute( "userCertificate;binary" ) );
        assertFalse( entry.containsAttribute( "userCertificate" ) );

        entry.add( "userCertificate", Strings.getBytesUtf8( "secret" ) );
        assertTrue( entry.containsAttribute( "userCertificate;binary" ) );
        assertTrue( entry.containsAttribute( "userCertificate" ) );
    }
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

     * 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( String, byte[]... )
     */
    @Test
    public void testAddStringByteArrayArray() throws LdapException
    {
        Entry entry = new DefaultEntry();

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

        entry.add( "jpegPhoto", BYTES1, BYTES1, BYTES2 );
        assertEquals( 2, entry.size() );
        Attribute attributeJPG = entry.get( "jpegPhoto" );
        assertEquals( 2, attributeJPG.size() );
        assertNotNull( attributeJPG.get() );
        assertTrue( attributeJPG.contains( BYTES1 ) );
        assertTrue( attributeJPG.contains( BYTES2 ) );
    }
View Full Code Here

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

        entry.add( "cn", ( String ) null );
        assertEquals( 1, entry.size() );
        Attribute attributeCN = entry.get( "cn" );
        assertEquals( 1, attributeCN.size() );
        assertNotNull( attributeCN.get() );
        assertNull( attributeCN.get().getValue() );

        entry.add( "sn", "test", "test", "TEST" );
        assertEquals( 2, entry.size() );
        Attribute attributeSN = entry.get( "sn" );
        assertEquals( 2, attributeSN.size() );
        assertNotNull( attributeSN.get() );
        assertTrue( attributeSN.contains( "test" ) );
        assertTrue( attributeSN.contains( "TEST" ) );
    }
View Full Code Here

     * Test method for add( String, Value<?>... )
     */
    @Test
    public void testAddStringValueArray() throws LdapException
    {
        Entry entry = new DefaultEntry();

        Value<String> value = new StringValue( ( String ) null );

        entry.add( "cn", value );
        assertEquals( 1, entry.size() );
        Attribute attributeCN = entry.get( "cn" );
        assertEquals( 1, attributeCN.size() );
        assertNotNull( attributeCN.get() );
        assertNull( attributeCN.get().getValue() );

        Value<String> value1 = new StringValue( "test1" );
        Value<String> value2 = new StringValue( "test2" );
        Value<String> value3 = new StringValue( "test1" );

        entry.add( "sn", value1, value2, value3 );
        assertEquals( 2, entry.size() );
        Attribute attributeSN = entry.get( "sn" );
        assertEquals( 2, attributeSN.size() );
        assertNotNull( attributeSN.get() );
        assertTrue( attributeSN.contains( value1 ) );
        assertTrue( attributeSN.contains( value2 ) );

        Value<byte[]> value4 = new BinaryValue( BYTES1 );
        entry.add( "l", value1, value4 );
        assertEquals( 3, entry.size() );
        Attribute attributeL = entry.get( "l" );
        assertEquals( 2, attributeL.size() );
        assertNotNull( attributeL.get() );
        assertTrue( attributeL.contains( value1 ) );

        // The byte[] value must have been transformed to a String
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.