Package org.apache.directory.server.core.api.changelog

Examples of org.apache.directory.server.core.api.changelog.Tag


        if ( tags.containsKey( revision ) )
        {
            return tags.get( revision );
        }

        latest = new Tag( revision, descrition );
        tags.put( revision, latest );
        return latest;
    }
View Full Code Here


        if ( store instanceof TaggableChangeLogStore )
        {
            return latest = ( ( TaggableChangeLogStore ) store ).tag( revision );
        }

        return latest = new Tag( revision, description );
    }
View Full Code Here

     */
    @BeforeClass
    public static void initNames() throws Exception
    {

        tagA = new Tag( 1L, "aa", 1L, 1L );
        tagACopy = new Tag( 1L, "aa", 1L, 1L );
        tagB = new Tag( 1L, "aa", 2L, 2L );
        tagC = new Tag( 2L, "aa", 1L, 1L );
        tagD = new Tag( 1L, "bb", 1L, 1L );
        tagANull = new Tag( 1L, null, 1L, 1L );
    }
View Full Code Here

    public void testTagPersistenceAcrossRestarts() throws Exception, InterruptedException
    {
        LdapConnection sysRoot = getAdminConnection( getService() );
        long revision = getService().getChangeLog().getCurrentRevision();

        Tag t0 = getService().getChangeLog().tag();
        assertEquals( t0, getService().getChangeLog().getLatest() );
        assertEquals( revision, getService().getChangeLog().getCurrentRevision() );

        // add new test entry
        Entry entry = new DefaultEntry( "ou=test,ou=system",
View Full Code Here

    @Test
    public void testRevertAddOperations() throws Exception
    {
        LdapConnection sysRoot = getAdminConnection( getService() );
        Tag t0 = getService().getChangeLog().tag();
        Entry entry = new DefaultEntry( "ou=test,ou=system",
            "objectClass: organizationalUnit",
            "ou: test" );

        sysRoot.add( entry );

        assertPresent( sysRoot, "ou=test,ou=system" );
        getService().revert( t0.getRevision() );

        assertNotPresent( sysRoot, "ou=test,ou=system" );
    }
View Full Code Here

    @Test
    public void testRevertAddAndDeleteOperations() throws Exception
    {
        LdapConnection sysRoot = getAdminConnection( getService() );
        Tag t0 = getService().getChangeLog().tag();

        // add new test entry
        Entry entry = new DefaultEntry( "ou=test,ou=system",
            "objectClass: organizationalUnit",
            "ou: test" );

        sysRoot.add( entry );

        // assert presence
        assertPresent( sysRoot, "ou=test,ou=system" );

        // delete the test entry and test that it is gone
        sysRoot.delete( "ou=test,ou=system" );
        assertNotPresent( sysRoot, "ou=test,ou=system" );

        // now revert back to begining the added entry is still gone
        getService().revert( t0.getRevision() );
        assertNotPresent( sysRoot, "ou=test" );
    }
View Full Code Here

            "ou: test" );

        sysRoot.add( entry );

        // tag after the addition before deletion
        Tag t0 = getService().getChangeLog().tag();
        assertPresent( sysRoot, "ou=test,ou=system" );

        // delete the test entry and test that it is gone
        sysRoot.delete( "ou=test,ou=system" );
        assertNotPresent( sysRoot, "ou=test,ou=system" );

        // now revert and assert that the added entry re-appears
        getService().revert( t0.getRevision() );
        assertPresent( sysRoot, "ou=test,ou=system" );
    }
View Full Code Here

            "ou: oldname" );

        sysRoot.add( entry );

        // tag after the addition before rename
        Tag t0 = getService().getChangeLog().tag();
        assertPresent( sysRoot, "ou=oldname,ou=system" );

        // rename the test entry and test that the rename occurred
        sysRoot.rename( "ou=oldname,ou=system", "ou=newname" );
        assertNotPresent( sysRoot, "ou=oldname,ou=system" );
        assertPresent( sysRoot, "ou=newname,ou=system" );

        // now revert and assert that the rename was reversed
        getService().revert( t0.getRevision() );
        assertPresent( sysRoot, "ou=oldname,ou=system" );
        assertNotPresent( sysRoot, "ou=newname,ou=system" );

    }
View Full Code Here

        // -------------------------------------------------------------------
        // Modify ADD Test
        // -------------------------------------------------------------------

        // tag after the addition before modify ADD
        Tag t0 = getService().getChangeLog().tag();
        assertPresent( sysRoot, "ou=test5,ou=system" );

        // modify the test entry to add description and test new attr appears
        ModifyRequest modReq = new ModifyRequestImpl();
        modReq.setName( entry.getDn() );
        modReq.add( "description", "a desc value" );
        sysRoot.modify( modReq );

        Entry resusitated = sysRoot.lookup( "ou=test5,ou=system" );
        assertNotNull( resusitated );
        Attribute description = resusitated.get( "description" );
        assertNotNull( description );
        assertTrue( description.contains( "a desc value" ) );

        // now revert and assert that the added entry re-appears
        getService().revert( t0.getRevision() );
        resusitated = sysRoot.lookup( "ou=test5,ou=system" );
        assertNotNull( resusitated );
        assertNull( resusitated.get( "description" ) );

        // -------------------------------------------------------------------
        // Modify REPLACE Test
        // -------------------------------------------------------------------

        // add the attribute again and make sure it is old value
        modReq = new ModifyRequestImpl();
        modReq.setName( resusitated.getDn() );
        modReq.add( "description", "old value" );
        sysRoot.modify( modReq );
        resusitated = sysRoot.lookup( "ou=test5,ou=system" );
        assertNotNull( resusitated );
        description = resusitated.get( "description" );
        assertNotNull( description );
        assertTrue( description.contains( "old value" ) );

        // now tag then replace the value to "new value" and confirm
        Tag t1 = getService().getChangeLog().tag();
        modReq = new ModifyRequestImpl();
        modReq.setName( resusitated.getDn() );
        modReq.replace( "description", "new value" );
        sysRoot.modify( modReq );

        resusitated = sysRoot.lookup( "ou=test5,ou=system" );
        assertNotNull( resusitated );
        assertTrue( resusitated.containsAttribute( "description" ) );
        description = resusitated.get( "description" );
        assertNotNull( description );
        assertTrue( description.contains( "new value" ) );

        // now revert and assert the old value is now reverted
        getService().revert( t1.getRevision() );
        resusitated = sysRoot.lookup( "ou=test5,ou=system" );
        assertNotNull( resusitated );
        description = resusitated.get( "description" );
        assertNotNull( description );
        assertTrue( description.contains( "old value" ) );

        // -------------------------------------------------------------------
        // Modify REMOVE Test
        // -------------------------------------------------------------------

        Tag t2 = getService().getChangeLog().tag();
        modReq = new ModifyRequestImpl();
        modReq.setName( resusitated.getDn() );
        modReq.remove( "description", "old value" );
        sysRoot.modify( modReq );

        resusitated = sysRoot.lookup( "ou=test5,ou=system" );
        assertNotNull( resusitated );
        description = resusitated.get( "description" );
        assertNull( description );

        // now revert and assert the old value is now reverted
        getService().revert( t2.getRevision() );
        resusitated = sysRoot.lookup( "ou=test5,ou=system" );
        assertNotNull( resusitated );
        description = resusitated.get( "description" );
        assertNotNull( description );
        assertTrue( description.contains( "old value" ) );

        // -------------------------------------------------------------------
        // Modify Multi Operation Test
        // -------------------------------------------------------------------

        // add a userPassword attribute so we can test replacing it
        modReq = new ModifyRequestImpl();
        modReq.setName( resusitated.getDn() );
        modReq.add( "userPassword", "to be replaced" );
        sysRoot.modify( modReq );
        resusitated = sysRoot.lookup( "ou=test5,ou=system" );
        assertPassword( resusitated, "to be replaced" );

        modReq = new ModifyRequestImpl();
        modReq.setName( resusitated.getDn() );
        modReq.remove( "description", "old value" );
        modReq.add( "seeAlso", "ou=added" );
        modReq.replace( "userPassword", "a replaced value" );

        Tag t3 = getService().getChangeLog().tag();

        // now make the modification and check that description is gone,
        // seeAlso is added, and that the userPassword has been replaced
        sysRoot.modify( modReq );
        resusitated = sysRoot.lookup( "ou=test5,ou=system" );
        assertNotNull( resusitated );
        description = resusitated.get( "description" );
        assertNull( description );
        assertPassword( resusitated, "a replaced value" );
        Attribute seeAlso = resusitated.get( "seeAlso" );
        assertNotNull( seeAlso );
        assertTrue( seeAlso.contains( "ou=added" ) );

        // now we revert and make sure the old values are as they were
        getService().revert( t3.getRevision() );
        resusitated = sysRoot.lookup( "ou=test5,ou=system" );
        assertNotNull( resusitated );
        description = resusitated.get( "description" );
        assertNotNull( description );
        assertTrue( description.contains( "old value" ) );
View Full Code Here

        sysRoot.add( entry );

        assertEquals( revision + 1, getService().getChangeLog().getCurrentRevision() );

        Tag t0 = getService().getChangeLog().tag();
        assertEquals( t0, getService().getChangeLog().getLatest() );
        assertEquals( revision + 1, getService().getChangeLog().getCurrentRevision() );
        assertEquals( revision + 1, t0.getRevision() );

        // add another test entry
        entry = new DefaultEntry( "ou=test1,ou=system",
            "objectClass: organizationalUnit",
            "ou: test1" );
           
        sysRoot.add( entry );
        assertEquals( revision + 2, getService().getChangeLog().getCurrentRevision() );

        Tag t1 = getService().getChangeLog().tag();
        assertEquals( t1, getService().getChangeLog().getLatest() );
        assertEquals( revision + 2, getService().getChangeLog().getCurrentRevision() );
        assertEquals( revision + 2, t1.getRevision() );

        getService().shutdown();
        getService().startup();

        sysRoot = getAdminConnection( getService() );
        assertEquals( revision + 2, getService().getChangeLog().getCurrentRevision() );
        assertEquals( t1, getService().getChangeLog().getLatest() );
        assertEquals( revision + 2, t1.getRevision() );

        // add third test entry
        entry = new DefaultEntry( "ou=test2,ou=system",
            "objectClass: organizationalUnit",
            "ou: test2" );

        sysRoot.add( entry );
        assertEquals( revision + 3, getService().getChangeLog().getCurrentRevision() );

        getService().revert();

        assertPresent( sysRoot, "ou=test0,ou=system" ); // test present
        assertPresent( sysRoot, "ou=test1,ou=system" ); // test present

        assertNotPresent( sysRoot, "ou=test2,ou=system" );
        assertEquals( revision + 4, getService().getChangeLog().getCurrentRevision() );
        assertEquals( t1, getService().getChangeLog().getLatest() );

        getService().revert( t0.getRevision() );
        assertPresent( sysRoot, "ou=test0,ou=system" ); // test present
        assertNotPresent( sysRoot, "ou=test1,ou=system" );
        assertNotPresent( sysRoot, "ou=test2,ou=system" );
        assertEquals( revision + 7, getService().getChangeLog().getCurrentRevision() );
        assertEquals( t1, getService().getChangeLog().getLatest() );

        // no sync this time but should happen automatically
        getService().shutdown();
        getService().startup();

        sysRoot = getAdminConnection( getService() );
        assertEquals( revision + 7, getService().getChangeLog().getCurrentRevision() );
        assertEquals( t1, getService().getChangeLog().getLatest() );
        assertEquals( revision + 2, t1.getRevision() );

        getService().revert( revision );
        assertNotPresent( sysRoot, "ou=test0,ou=system" );
        assertNotPresent( sysRoot, "ou=test1,ou=system" );
        assertNotPresent( sysRoot, "ou=test2,ou=system" );
View Full Code Here

TOP

Related Classes of org.apache.directory.server.core.api.changelog.Tag

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.