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

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


    @Test
    public void testReverseModifyReplaceExistingOuValues() throws LdapException
    {
        Entry modifiedEntry = buildEntry();
       
        EntryAttribute ou = new DefaultEntryAttribute( "ou" );
        ou.add( "apache", "acme corp" );
        modifiedEntry.put( ou );

        Dn dn = new Dn( "cn=test, ou=system" );

        EntryAttribute ouModified = new DefaultEntryAttribute( "ou" );
        ouModified.add( "directory" );
        ouModified.add( "BigCompany inc." );
       
        Modification mod = new DefaultModification(
            ModificationOperation.REPLACE_ATTRIBUTE, ouModified );

        LdifEntry reversed = LdifRevertor.reverseModify( dn,
                Collections.<Modification>singletonList( mod ), modifiedEntry );



        assertNotNull( reversed );
        assertEquals( dn.getName(), reversed.getDn().getName() );
        assertEquals( ChangeType.Modify, reversed.getChangeType() );
        assertNull( reversed.getEntry() );
       
        List<Modification> mods = reversed.getModificationItems();
       
        assertNotNull( mods );
        assertEquals( 1, mods.size() );
       
        Modification modif = mods.get( 0 );
       
        assertEquals( ModificationOperation.REPLACE_ATTRIBUTE, modif.getOperation() );

        EntryAttribute attr = modif.getAttribute();
       
        assertNotNull( attr );
        assertEquals( ou, attr );
    }
View Full Code Here


    {
        Entry modifiedEntry = buildEntry();
       
        Dn dn = new Dn( "cn=test, ou=system" );
       
        EntryAttribute newOu = new DefaultEntryAttribute( "ou" );
        newOu.add( "apache" );
        newOu.add( "acme corp" );

       
        Modification mod = new DefaultModification(
            ModificationOperation.REPLACE_ATTRIBUTE, newOu );

        LdifEntry reversed = LdifRevertor.reverseModify( dn,
                Collections.<Modification>singletonList( mod ), modifiedEntry );

        assertNotNull( reversed );
        assertEquals( dn.getName(), reversed.getDn().getName() );
        assertEquals( ChangeType.Modify, reversed.getChangeType() );
        assertNull( reversed.getEntry() );
       
        List<Modification> mods = reversed.getModificationItems();
       
        assertNotNull( mods );
        assertEquals( 1, mods.size() );
       
        Modification modif = mods.get( 0 );
       
        assertEquals( ModificationOperation.REPLACE_ATTRIBUTE, modif.getOperation() );

        EntryAttribute attr = modif.getAttribute();
       
        assertNotNull( attr );
        assertEquals( "ou", attr.getId() );
       
        assertNull( attr.get() );
    }
View Full Code Here

    @Test
    public void testReverseModifyReplaceExistingOuWithNothing() throws LdapException
    {
        Entry modifiedEntry = buildEntry();

        EntryAttribute ou = new DefaultEntryAttribute( "ou" );
        ou.add( "apache" );
        ou.add( "acme corp" );
        modifiedEntry.put( ou );
       
        Dn dn = new Dn( "cn=test, ou=system" );
       
        Modification mod = new DefaultModification(
            ModificationOperation.REPLACE_ATTRIBUTE, new DefaultEntryAttribute( "ou" ) );

        LdifEntry reversed = LdifRevertor.reverseModify( dn,
                Collections.<Modification>singletonList( mod ), modifiedEntry );

        assertNotNull( reversed );
        assertEquals( dn.getName(), reversed.getDn().getName() );
        assertEquals( ChangeType.Modify, reversed.getChangeType() );
        assertNull( reversed.getEntry() );
       
        List<Modification> mods = reversed.getModificationItems();
       
        assertNotNull( mods );
        assertEquals( 1, mods.size() );
       
        Modification modif = mods.get( 0 );
       
        assertEquals( ModificationOperation.REPLACE_ATTRIBUTE, modif.getOperation() );

        EntryAttribute attr = modif.getAttribute();
       
        assertNotNull( attr );
        assertEquals( "ou", attr.getId() );
       
        assertEquals( ou, attr );
    }
View Full Code Here

    @Test
    public void testReverseModifyAddNewOuValue() throws LdapException
    {
        Entry modifiedEntry = buildEntry();

        EntryAttribute ou = new DefaultEntryAttribute( "ou" );
        ou.add( "apache" );
        ou.add( "acme corp" );
        modifiedEntry.put( ou );
       
        Dn dn = new Dn( "cn=test, ou=system" );
        Modification mod = new DefaultModification(
            ModificationOperation.ADD_ATTRIBUTE,
            new DefaultEntryAttribute( "ou", "BigCompany inc." ) );

        LdifEntry reversed = LdifRevertor.reverseModify( dn,
                Collections.<Modification>singletonList( mod ), modifiedEntry );

        assertNotNull( reversed );
        assertEquals( dn.getName(), reversed.getDn().getName() );
        assertEquals( ChangeType.Modify, reversed.getChangeType() );
        assertNull( reversed.getEntry() );
        List<Modification> mods = reversed.getModificationItems();
       
        assertNotNull( mods );
        assertEquals( 1, mods.size() );
       
        Modification modif = mods.get( 0 );
       
        assertEquals( ModificationOperation.REMOVE_ATTRIBUTE, modif.getOperation() );

        EntryAttribute attr = modif.getAttribute();
       
        assertNotNull( attr );
        assertEquals( "ou", attr.getId() );
        assertEquals( "BigCompany inc.", attr.getString() );
    }
View Full Code Here

       
        Modification modif = mods.get( 0 );

        assertEquals( ModificationOperation.REMOVE_ATTRIBUTE, modif.getOperation() );

        EntryAttribute attr = modif.getAttribute();
       
        assertNotNull( attr );
        assertEquals( "ou", attr.getId() );
        assertEquals( "BigCompany inc.", attr.getString() );
    }
View Full Code Here

        Entry entry = reader.parseEntry( ldif );

        assertEquals( 1, reader.getVersion() );
        assertNotNull( entry );

        EntryAttribute attr = entry.get( "displayname" );
        assertTrue( attr.contains( "app1" ) );
    }
View Full Code Here

        LdifAttributesReader reader = new LdifAttributesReader();

        Entry entry = reader.parseEntry( ldif );
        assertNotNull( entry );

        EntryAttribute attr = entry.get( "displayname" );
        assertTrue( attr.contains( "app1" ) );

    }
View Full Code Here

        LdifAttributesReader reader = new LdifAttributesReader();
        Entry entry = reader.parseEntry( ldif );

        assertNotNull( entry );

        EntryAttribute attr = entry.get( "cn" );
        assertTrue( attr.contains( "app1" ) );

        attr = entry.get( "objectclass" );
        assertTrue( attr.contains( "top" ) );
        assertTrue( attr.contains( "apApplication" ) );

        attr = entry.get( "displayname" );
        assertTrue( attr.contains( "app1" ) );

        attr = entry.get( "dependencies" );
        assertNull( attr.get().get() );

        attr = entry.get( "envvars" );
        assertNull( attr.get().get() );
    }
View Full Code Here

        LdifAttributesReader reader = new LdifAttributesReader();
        Entry entry = reader.parseEntry( ldif );

        assertNotNull( entry );

        EntryAttribute attr = entry.get( "cn" );
        assertTrue( attr.contains( "app1#another comment" ) );

        attr = entry.get( "objectclass" );
        assertTrue( attr.contains( "top" ) );
        assertTrue( attr.contains( "apApplication" ) );

        attr = entry.get( "displayname" );
        assertTrue( attr.contains( "app1" ) );

        attr = entry.get( "dependencies" );
        assertNull( attr.get().get() );

        attr = entry.get( "envvars" );
        assertNull( attr.get().get() );
    }
View Full Code Here

        LdifAttributesReader reader = new LdifAttributesReader();
        Entry entry = reader.parseEntry( ldif );

        assertNotNull( entry );

        EntryAttribute attr = entry.get( "cn" );
        assertTrue( attr.contains( "app1#another comment" ) );

        attr = entry.get( "objectclass" );
        assertTrue( attr.contains( "top" ) );
        assertTrue( attr.contains( "apApplication" ) );

        attr = entry.get( "displayname" );
        assertTrue( attr.contains( "app1" ) );

        attr = entry.get( "dependencies" );
        assertNull( attr.get().get() );

        attr = entry.get( "envvars" );
        assertNull( attr.get().get() );
    }
View Full Code Here

TOP

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

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.