You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2009/08/05 19:55:16 UTC
svn commit: r801340 [7/13] - in /directory/apacheds/trunk:
core-entry/src/main/java/org/apache/directory/server/core/entry/
core-entry/src/test/java/org/apache/directory/server/core/entry/
core-integ/src/main/java/org/apache/directory/server/core/integ...
Modified: directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/changelog/DefaultChangeLogIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/changelog/DefaultChangeLogIT.java?rev=801340&r1=801339&r2=801340&view=diff
==============================================================================
--- directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/changelog/DefaultChangeLogIT.java (original)
+++ directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/changelog/DefaultChangeLogIT.java Wed Aug 5 17:55:15 2009
@@ -1,409 +1,409 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.directory.server.core.changelog;
-
-
-import org.apache.directory.server.core.DirectoryService;
-import org.apache.directory.server.core.integ.CiRunner;
-import static org.apache.directory.server.core.integ.state.TestServiceContext.shutdown;
-import static org.apache.directory.server.core.integ.state.TestServiceContext.startup;
-import static org.apache.directory.server.core.integ.IntegrationUtils.getSystemContext;
-import org.apache.directory.shared.ldap.exception.LdapNameNotFoundException;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.naming.NamingException;
-import javax.naming.directory.Attribute;
-import javax.naming.directory.Attributes;
-import javax.naming.directory.BasicAttribute;
-import javax.naming.directory.BasicAttributes;
-import javax.naming.directory.DirContext;
-import javax.naming.directory.ModificationItem;
-import javax.naming.ldap.LdapContext;
-import java.util.Arrays;
-
-
-/**
- * Used to test the default change log implementation with an in memory
- * change log store. Note that this will probably be removed since this
- * functionality will be used and tested anyway in all other test cases.
- *
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- * @version $Rev$, $Date$
- */
-@RunWith ( CiRunner.class )
-public class DefaultChangeLogIT
-{
- public static final Logger LOG = LoggerFactory.getLogger( DefaultChangeLogIT.class );
-
- public static DirectoryService service;
-
-
-// service.setShutdownHookEnabled( false );
-
- @Test
- public void testManyTagsPersistenceAcrossRestarts() throws Exception, InterruptedException
- {
- LdapContext sysRoot = getSystemContext( service );
- long revision = service.getChangeLog().getCurrentRevision();
-
- // add new test entry
- Attributes attrs = new BasicAttributes( "objectClass", "organizationalUnit", true );
- attrs.put( "ou", "test0" );
- sysRoot.createSubcontext( "ou=test0", attrs );
- assertEquals( revision + 1, service.getChangeLog().getCurrentRevision() );
-
- Tag t0 = service.getChangeLog().tag();
- assertEquals( t0, service.getChangeLog().getLatest() );
- assertEquals( revision + 1, service.getChangeLog().getCurrentRevision() );
- assertEquals( revision + 1, t0.getRevision() );
-
- // add another test entry
- attrs = new BasicAttributes( "objectClass", "organizationalUnit", true );
- attrs.put( "ou", "test1" );
- sysRoot.createSubcontext( "ou=test1", attrs );
- assertEquals( revision + 2, service.getChangeLog().getCurrentRevision() );
-
- Tag t1 = service.getChangeLog().tag();
- assertEquals( t1, service.getChangeLog().getLatest() );
- assertEquals( revision + 2, service.getChangeLog().getCurrentRevision() );
- assertEquals( revision + 2, t1.getRevision() );
-
- shutdown();
- startup();
-
- assertEquals( revision + 2, service.getChangeLog().getCurrentRevision() );
- assertEquals( t1, service.getChangeLog().getLatest() );
- assertEquals( revision + 2, t1.getRevision() );
-
- // add third test entry
- attrs = new BasicAttributes( "objectClass", "organizationalUnit", true );
- attrs.put( "ou", "test2" );
- sysRoot.createSubcontext( "ou=test2", attrs );
- assertEquals( revision + 3, service.getChangeLog().getCurrentRevision() );
-
- service.revert();
- sysRoot.getAttributes( "ou=test0" ); // test present
- sysRoot.getAttributes( "ou=test1" ); // test present
- assertNotPresent( sysRoot, "ou=test2" );
- assertEquals( revision + 4, service.getChangeLog().getCurrentRevision() );
- assertEquals( t1, service.getChangeLog().getLatest() );
-
- service.revert( t0.getRevision() );
- sysRoot.getAttributes( "ou=test0" ); // test present
- assertNotPresent( sysRoot, "ou=test1" );
- assertNotPresent( sysRoot, "ou=test2" );
- assertEquals( revision + 7, service.getChangeLog().getCurrentRevision() );
- assertEquals( t1, service.getChangeLog().getLatest() );
-
- // no sync this time but should happen automatically
- shutdown();
- startup();
- assertEquals( revision + 7, service.getChangeLog().getCurrentRevision() );
- assertEquals( t1, service.getChangeLog().getLatest() );
- assertEquals( revision + 2, t1.getRevision() );
-
- service.revert( revision );
- assertNotPresent( sysRoot, "ou=test0" );
- assertNotPresent( sysRoot, "ou=test1" );
- assertNotPresent( sysRoot, "ou=test2" );
- assertEquals( revision + 14, service.getChangeLog().getCurrentRevision() );
- assertEquals( t1, service.getChangeLog().getLatest() );
- }
-
-
- @Test
- public void testTagPersistenceAcrossRestarts() throws Exception, InterruptedException
- {
- LdapContext sysRoot = getSystemContext( service );
- long revision = service.getChangeLog().getCurrentRevision();
-
- Tag t0 = service.getChangeLog().tag();
- assertEquals( t0, service.getChangeLog().getLatest() );
- assertEquals( revision, service.getChangeLog().getCurrentRevision() );
-
- // add new test entry
- Attributes attrs = new BasicAttributes( "objectClass", "organizationalUnit", true );
- attrs.put( "ou", "test" );
- sysRoot.createSubcontext( "ou=test", attrs );
- assertEquals( revision + 1, service.getChangeLog().getCurrentRevision() );
-
- shutdown();
- startup();
-
- assertEquals( revision + 1, service.getChangeLog().getCurrentRevision() );
- assertEquals( t0, service.getChangeLog().getLatest() );
-
- service.revert();
- assertNotPresent( sysRoot, "ou=test" );
- assertEquals( revision + 2, service.getChangeLog().getCurrentRevision() );
- assertEquals( t0, service.getChangeLog().getLatest() );
- }
-
-
- @Test
- public void testRevertAddOperations() throws Exception
- {
- LdapContext sysRoot = getSystemContext( service );
- Tag t0 = service.getChangeLog().tag();
- Attributes attrs = new BasicAttributes( "objectClass", "organizationalUnit", true );
- attrs.put( "ou", "test" );
- sysRoot.createSubcontext( "ou=test", attrs );
-
- assertNotNull( sysRoot.getAttributes( "ou=test" ) );
- service.revert( t0.getRevision() );
-
- try
- {
- sysRoot.getAttributes( "ou=test" );
- fail( "Should not be able to find the entry!" );
- }
- catch ( NamingException ne )
- {
- assertTrue( ne instanceof LdapNameNotFoundException );
- }
- }
-
-
- @Test
- public void testRevertAddAndDeleteOperations() throws Exception
- {
- LdapContext sysRoot = getSystemContext( service );
- Tag t0 = service.getChangeLog().tag();
-
- // add new test entry
- Attributes attrs = new BasicAttributes( "objectClass", "organizationalUnit", true );
- attrs.put( "ou", "test" );
- sysRoot.createSubcontext( "ou=test", attrs );
-
- // assert presence
- assertNotNull( sysRoot.getAttributes( "ou=test" ) );
-
- // delete the test entry and test that it is gone
- sysRoot.destroySubcontext( "ou=test" );
- assertNotPresent( sysRoot, "ou=test" );
-
- // now revert back to begining the added entry is still gone
- service.revert( t0.getRevision() );
- assertNotPresent( sysRoot, "ou=test" );
- }
-
-
- @Test
- public void testRevertDeleteOperations() throws Exception
- {
- LdapContext sysRoot = getSystemContext( service );
- Attributes attrs = new BasicAttributes( "objectClass", "organizationalUnit", true );
- attrs.put( "ou", "test" );
- sysRoot.createSubcontext( "ou=test", attrs );
-
- // tag after the addition before deletion
- Tag t0 = service.getChangeLog().tag();
- assertNotNull( sysRoot.getAttributes( "ou=test" ) );
-
- // delete the test entry and test that it is gone
- sysRoot.destroySubcontext( "ou=test" );
- assertNotPresent( sysRoot, "ou=test" );
-
- // now revert and assert that the added entry re-appears
- service.revert( t0.getRevision() );
- assertNotNull( sysRoot.getAttributes( "ou=test" ) );
- }
-
-
- @Test
- public void testRevertRenameOperations() throws Exception
- {
- LdapContext sysRoot = getSystemContext( service );
- Attributes attrs = new BasicAttributes( "objectClass", "organizationalUnit", true );
- attrs.put( "ou", "oldname" );
- sysRoot.createSubcontext( "ou=oldname", attrs );
-
- // tag after the addition before rename
- Tag t0 = service.getChangeLog().tag();
- assertNotNull( sysRoot.getAttributes( "ou=oldname" ) );
-
- // rename the test entry and test that the rename occurred
- sysRoot.rename( "ou=oldname", "ou=newname" );
- assertNotPresent( sysRoot, "ou=oldname" );
- assertNotNull( sysRoot.getAttributes( "ou=newname" ) );
-
- // now revert and assert that the rename was reversed
- service.revert( t0.getRevision() );
- assertNotPresent( sysRoot, "ou=newname" );
- assertNotNull( sysRoot.getAttributes( "ou=oldname" ) );
- }
-
-
- @Test
- public void testRevertModifyOperations() throws Exception
- {
- LdapContext sysRoot = getSystemContext( service );
- Attributes attrs = new BasicAttributes( "objectClass", "organizationalUnit", true );
- attrs.put( "ou", "test5" );
- sysRoot.createSubcontext( "ou=test5", attrs );
-
- // -------------------------------------------------------------------
- // Modify ADD Test
- // -------------------------------------------------------------------
-
- // tag after the addition before modify ADD
- Tag t0 = service.getChangeLog().tag();
- assertNotNull( sysRoot.getAttributes( "ou=test5" ) );
-
- // modify the test entry to add description and test new attr appears
- sysRoot.modifyAttributes( "ou=test5", DirContext.ADD_ATTRIBUTE,
- new BasicAttributes( "description", "a desc value", true ) );
- Attributes resusitated = sysRoot.getAttributes( "ou=test5" );
- assertNotNull( resusitated );
- Attribute description = resusitated.get( "description" );
- assertNotNull( description );
- assertEquals( "a desc value", description.get() );
-
- // now revert and assert that the added entry re-appears
- service.revert( t0.getRevision() );
- resusitated = sysRoot.getAttributes( "ou=test5" );
- assertNotNull( resusitated );
- assertNull( resusitated.get( "description" ) );
-
- // -------------------------------------------------------------------
- // Modify REPLACE Test
- // -------------------------------------------------------------------
-
- // add the attribute again and make sure it is old value
- sysRoot.modifyAttributes( "ou=test5", DirContext.ADD_ATTRIBUTE,
- new BasicAttributes( "description", "old value", true ) );
- resusitated = sysRoot.getAttributes( "ou=test5" );
- assertNotNull( resusitated );
- description = resusitated.get( "description" );
- assertNotNull( description );
- assertEquals( description.get(), "old value" );
-
- // now tag then replace the value to "new value" and confirm
- Tag t1 = service.getChangeLog().tag();
- sysRoot.modifyAttributes( "ou=test5", DirContext.REPLACE_ATTRIBUTE,
- new BasicAttributes( "description", "new value", true ) );
- resusitated = sysRoot.getAttributes( "ou=test5" );
- assertNotNull( resusitated );
- description = resusitated.get( "description" );
- assertNotNull( description );
- assertEquals( description.get(), "new value" );
-
- // now revert and assert the old value is now reverted
- service.revert( t1.getRevision() );
- resusitated = sysRoot.getAttributes( "ou=test5" );
- assertNotNull( resusitated );
- description = resusitated.get( "description" );
- assertNotNull( description );
- assertEquals( description.get(), "old value" );
-
-
- // -------------------------------------------------------------------
- // Modify REMOVE Test
- // -------------------------------------------------------------------
-
- Tag t2 = service.getChangeLog().tag();
- sysRoot.modifyAttributes( "ou=test5", DirContext.REMOVE_ATTRIBUTE,
- new BasicAttributes( "description", "old value", true ) );
- resusitated = sysRoot.getAttributes( "ou=test5" );
- assertNotNull( resusitated );
- description = resusitated.get( "description" );
- assertNull( description );
-
- // now revert and assert the old value is now reverted
- service.revert( t2.getRevision() );
- resusitated = sysRoot.getAttributes( "ou=test5" );
- assertNotNull( resusitated );
- description = resusitated.get( "description" );
- assertNotNull( description );
- assertEquals( description.get(), "old value" );
-
- // -------------------------------------------------------------------
- // Modify Multi Operation Test
- // -------------------------------------------------------------------
-
- // add a userPassword attribute so we can test replacing it
- sysRoot.modifyAttributes( "ou=test5", DirContext.ADD_ATTRIBUTE,
- new BasicAttributes( "userPassword", "to be replaced", true ) );
- assertPassword( sysRoot.getAttributes( "ou=test5" ), "to be replaced" );
-
- ModificationItem[] mods = new ModificationItem[]
- {
- new ModificationItem( DirContext.REMOVE_ATTRIBUTE,
- new BasicAttribute( "description", "old value" ) ),
- new ModificationItem( DirContext.ADD_ATTRIBUTE,
- new BasicAttribute( "seeAlso", "ou=added" ) ),
- new ModificationItem( DirContext.REPLACE_ATTRIBUTE,
- new BasicAttribute( "userPassword", "a replaced value" ) )
- };
- Tag t3 = service.getChangeLog().tag();
-
- // now make the modification and check that description is gone,
- // seeAlso is added, and that the userPassword has been replaced
- sysRoot.modifyAttributes( "ou=test5", mods );
- resusitated = sysRoot.getAttributes( "ou=test5" );
- assertNotNull( resusitated );
- description = resusitated.get( "description" );
- assertNull( description );
- assertPassword( resusitated, "a replaced value" );
- Attribute seeAlso = resusitated.get( "seeAlso" );
- assertNotNull( seeAlso );
- assertEquals( seeAlso.get(), "ou=added" );
-
- // now we revert and make sure the old values are as they were
- service.revert( t3.getRevision() );
- resusitated = sysRoot.getAttributes( "ou=test5" );
- assertNotNull( resusitated );
- description = resusitated.get( "description" );
- assertNotNull( description );
- assertEquals( description.get(), "old value" );
- assertPassword( resusitated, "to be replaced" );
- seeAlso = resusitated.get( "seeAlso" );
- assertNull( seeAlso );
- }
-
-
- private void assertPassword( Attributes entry, String password ) throws NamingException
- {
- Attribute userPassword = entry.get( "userPassword" );
- assertNotNull( userPassword );
- Arrays.equals( password.getBytes(), ( byte[] ) userPassword.get() );
- }
-
-
- private void assertNotPresent( DirContext ctx, String dn ) throws NamingException
- {
- try
- {
- ctx.getAttributes( dn );
- fail( "Should not be able to find the entry " + dn + " but it is still there." );
- }
- catch ( NamingException ne )
- {
- assertTrue( ne instanceof LdapNameNotFoundException );
- }
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.directory.server.core.changelog;
+
+
+import org.apache.directory.server.core.DirectoryService;
+import org.apache.directory.server.core.integ.CiRunner;
+import static org.apache.directory.server.core.integ.state.TestServiceContext.shutdown;
+import static org.apache.directory.server.core.integ.state.TestServiceContext.startup;
+import static org.apache.directory.server.core.integ.IntegrationUtils.getSystemContext;
+import org.apache.directory.shared.ldap.exception.LdapNameNotFoundException;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.BasicAttribute;
+import javax.naming.directory.BasicAttributes;
+import javax.naming.directory.DirContext;
+import javax.naming.directory.ModificationItem;
+import javax.naming.ldap.LdapContext;
+import java.util.Arrays;
+
+
+/**
+ * Used to test the default change log implementation with an in memory
+ * change log store. Note that this will probably be removed since this
+ * functionality will be used and tested anyway in all other test cases.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+@RunWith ( CiRunner.class )
+public class DefaultChangeLogIT
+{
+ public static final Logger LOG = LoggerFactory.getLogger( DefaultChangeLogIT.class );
+
+ public static DirectoryService service;
+
+
+// service.setShutdownHookEnabled( false );
+
+ @Test
+ public void testManyTagsPersistenceAcrossRestarts() throws Exception, InterruptedException
+ {
+ LdapContext sysRoot = getSystemContext( service );
+ long revision = service.getChangeLog().getCurrentRevision();
+
+ // add new test entry
+ Attributes attrs = new BasicAttributes( "objectClass", "organizationalUnit", true );
+ attrs.put( "ou", "test0" );
+ sysRoot.createSubcontext( "ou=test0", attrs );
+ assertEquals( revision + 1, service.getChangeLog().getCurrentRevision() );
+
+ Tag t0 = service.getChangeLog().tag();
+ assertEquals( t0, service.getChangeLog().getLatest() );
+ assertEquals( revision + 1, service.getChangeLog().getCurrentRevision() );
+ assertEquals( revision + 1, t0.getRevision() );
+
+ // add another test entry
+ attrs = new BasicAttributes( "objectClass", "organizationalUnit", true );
+ attrs.put( "ou", "test1" );
+ sysRoot.createSubcontext( "ou=test1", attrs );
+ assertEquals( revision + 2, service.getChangeLog().getCurrentRevision() );
+
+ Tag t1 = service.getChangeLog().tag();
+ assertEquals( t1, service.getChangeLog().getLatest() );
+ assertEquals( revision + 2, service.getChangeLog().getCurrentRevision() );
+ assertEquals( revision + 2, t1.getRevision() );
+
+ shutdown();
+ startup();
+
+ assertEquals( revision + 2, service.getChangeLog().getCurrentRevision() );
+ assertEquals( t1, service.getChangeLog().getLatest() );
+ assertEquals( revision + 2, t1.getRevision() );
+
+ // add third test entry
+ attrs = new BasicAttributes( "objectClass", "organizationalUnit", true );
+ attrs.put( "ou", "test2" );
+ sysRoot.createSubcontext( "ou=test2", attrs );
+ assertEquals( revision + 3, service.getChangeLog().getCurrentRevision() );
+
+ service.revert();
+ sysRoot.getAttributes( "ou=test0" ); // test present
+ sysRoot.getAttributes( "ou=test1" ); // test present
+ assertNotPresent( sysRoot, "ou=test2" );
+ assertEquals( revision + 4, service.getChangeLog().getCurrentRevision() );
+ assertEquals( t1, service.getChangeLog().getLatest() );
+
+ service.revert( t0.getRevision() );
+ sysRoot.getAttributes( "ou=test0" ); // test present
+ assertNotPresent( sysRoot, "ou=test1" );
+ assertNotPresent( sysRoot, "ou=test2" );
+ assertEquals( revision + 7, service.getChangeLog().getCurrentRevision() );
+ assertEquals( t1, service.getChangeLog().getLatest() );
+
+ // no sync this time but should happen automatically
+ shutdown();
+ startup();
+ assertEquals( revision + 7, service.getChangeLog().getCurrentRevision() );
+ assertEquals( t1, service.getChangeLog().getLatest() );
+ assertEquals( revision + 2, t1.getRevision() );
+
+ service.revert( revision );
+ assertNotPresent( sysRoot, "ou=test0" );
+ assertNotPresent( sysRoot, "ou=test1" );
+ assertNotPresent( sysRoot, "ou=test2" );
+ assertEquals( revision + 14, service.getChangeLog().getCurrentRevision() );
+ assertEquals( t1, service.getChangeLog().getLatest() );
+ }
+
+
+ @Test
+ public void testTagPersistenceAcrossRestarts() throws Exception, InterruptedException
+ {
+ LdapContext sysRoot = getSystemContext( service );
+ long revision = service.getChangeLog().getCurrentRevision();
+
+ Tag t0 = service.getChangeLog().tag();
+ assertEquals( t0, service.getChangeLog().getLatest() );
+ assertEquals( revision, service.getChangeLog().getCurrentRevision() );
+
+ // add new test entry
+ Attributes attrs = new BasicAttributes( "objectClass", "organizationalUnit", true );
+ attrs.put( "ou", "test" );
+ sysRoot.createSubcontext( "ou=test", attrs );
+ assertEquals( revision + 1, service.getChangeLog().getCurrentRevision() );
+
+ shutdown();
+ startup();
+
+ assertEquals( revision + 1, service.getChangeLog().getCurrentRevision() );
+ assertEquals( t0, service.getChangeLog().getLatest() );
+
+ service.revert();
+ assertNotPresent( sysRoot, "ou=test" );
+ assertEquals( revision + 2, service.getChangeLog().getCurrentRevision() );
+ assertEquals( t0, service.getChangeLog().getLatest() );
+ }
+
+
+ @Test
+ public void testRevertAddOperations() throws Exception
+ {
+ LdapContext sysRoot = getSystemContext( service );
+ Tag t0 = service.getChangeLog().tag();
+ Attributes attrs = new BasicAttributes( "objectClass", "organizationalUnit", true );
+ attrs.put( "ou", "test" );
+ sysRoot.createSubcontext( "ou=test", attrs );
+
+ assertNotNull( sysRoot.getAttributes( "ou=test" ) );
+ service.revert( t0.getRevision() );
+
+ try
+ {
+ sysRoot.getAttributes( "ou=test" );
+ fail( "Should not be able to find the entry!" );
+ }
+ catch ( NamingException ne )
+ {
+ assertTrue( ne instanceof LdapNameNotFoundException );
+ }
+ }
+
+
+ @Test
+ public void testRevertAddAndDeleteOperations() throws Exception
+ {
+ LdapContext sysRoot = getSystemContext( service );
+ Tag t0 = service.getChangeLog().tag();
+
+ // add new test entry
+ Attributes attrs = new BasicAttributes( "objectClass", "organizationalUnit", true );
+ attrs.put( "ou", "test" );
+ sysRoot.createSubcontext( "ou=test", attrs );
+
+ // assert presence
+ assertNotNull( sysRoot.getAttributes( "ou=test" ) );
+
+ // delete the test entry and test that it is gone
+ sysRoot.destroySubcontext( "ou=test" );
+ assertNotPresent( sysRoot, "ou=test" );
+
+ // now revert back to begining the added entry is still gone
+ service.revert( t0.getRevision() );
+ assertNotPresent( sysRoot, "ou=test" );
+ }
+
+
+ @Test
+ public void testRevertDeleteOperations() throws Exception
+ {
+ LdapContext sysRoot = getSystemContext( service );
+ Attributes attrs = new BasicAttributes( "objectClass", "organizationalUnit", true );
+ attrs.put( "ou", "test" );
+ sysRoot.createSubcontext( "ou=test", attrs );
+
+ // tag after the addition before deletion
+ Tag t0 = service.getChangeLog().tag();
+ assertNotNull( sysRoot.getAttributes( "ou=test" ) );
+
+ // delete the test entry and test that it is gone
+ sysRoot.destroySubcontext( "ou=test" );
+ assertNotPresent( sysRoot, "ou=test" );
+
+ // now revert and assert that the added entry re-appears
+ service.revert( t0.getRevision() );
+ assertNotNull( sysRoot.getAttributes( "ou=test" ) );
+ }
+
+
+ @Test
+ public void testRevertRenameOperations() throws Exception
+ {
+ LdapContext sysRoot = getSystemContext( service );
+ Attributes attrs = new BasicAttributes( "objectClass", "organizationalUnit", true );
+ attrs.put( "ou", "oldname" );
+ sysRoot.createSubcontext( "ou=oldname", attrs );
+
+ // tag after the addition before rename
+ Tag t0 = service.getChangeLog().tag();
+ assertNotNull( sysRoot.getAttributes( "ou=oldname" ) );
+
+ // rename the test entry and test that the rename occurred
+ sysRoot.rename( "ou=oldname", "ou=newname" );
+ assertNotPresent( sysRoot, "ou=oldname" );
+ assertNotNull( sysRoot.getAttributes( "ou=newname" ) );
+
+ // now revert and assert that the rename was reversed
+ service.revert( t0.getRevision() );
+ assertNotPresent( sysRoot, "ou=newname" );
+ assertNotNull( sysRoot.getAttributes( "ou=oldname" ) );
+ }
+
+
+ @Test
+ public void testRevertModifyOperations() throws Exception
+ {
+ LdapContext sysRoot = getSystemContext( service );
+ Attributes attrs = new BasicAttributes( "objectClass", "organizationalUnit", true );
+ attrs.put( "ou", "test5" );
+ sysRoot.createSubcontext( "ou=test5", attrs );
+
+ // -------------------------------------------------------------------
+ // Modify ADD Test
+ // -------------------------------------------------------------------
+
+ // tag after the addition before modify ADD
+ Tag t0 = service.getChangeLog().tag();
+ assertNotNull( sysRoot.getAttributes( "ou=test5" ) );
+
+ // modify the test entry to add description and test new attr appears
+ sysRoot.modifyAttributes( "ou=test5", DirContext.ADD_ATTRIBUTE,
+ new BasicAttributes( "description", "a desc value", true ) );
+ Attributes resusitated = sysRoot.getAttributes( "ou=test5" );
+ assertNotNull( resusitated );
+ Attribute description = resusitated.get( "description" );
+ assertNotNull( description );
+ assertEquals( "a desc value", description.get() );
+
+ // now revert and assert that the added entry re-appears
+ service.revert( t0.getRevision() );
+ resusitated = sysRoot.getAttributes( "ou=test5" );
+ assertNotNull( resusitated );
+ assertNull( resusitated.get( "description" ) );
+
+ // -------------------------------------------------------------------
+ // Modify REPLACE Test
+ // -------------------------------------------------------------------
+
+ // add the attribute again and make sure it is old value
+ sysRoot.modifyAttributes( "ou=test5", DirContext.ADD_ATTRIBUTE,
+ new BasicAttributes( "description", "old value", true ) );
+ resusitated = sysRoot.getAttributes( "ou=test5" );
+ assertNotNull( resusitated );
+ description = resusitated.get( "description" );
+ assertNotNull( description );
+ assertEquals( description.get(), "old value" );
+
+ // now tag then replace the value to "new value" and confirm
+ Tag t1 = service.getChangeLog().tag();
+ sysRoot.modifyAttributes( "ou=test5", DirContext.REPLACE_ATTRIBUTE,
+ new BasicAttributes( "description", "new value", true ) );
+ resusitated = sysRoot.getAttributes( "ou=test5" );
+ assertNotNull( resusitated );
+ description = resusitated.get( "description" );
+ assertNotNull( description );
+ assertEquals( description.get(), "new value" );
+
+ // now revert and assert the old value is now reverted
+ service.revert( t1.getRevision() );
+ resusitated = sysRoot.getAttributes( "ou=test5" );
+ assertNotNull( resusitated );
+ description = resusitated.get( "description" );
+ assertNotNull( description );
+ assertEquals( description.get(), "old value" );
+
+
+ // -------------------------------------------------------------------
+ // Modify REMOVE Test
+ // -------------------------------------------------------------------
+
+ Tag t2 = service.getChangeLog().tag();
+ sysRoot.modifyAttributes( "ou=test5", DirContext.REMOVE_ATTRIBUTE,
+ new BasicAttributes( "description", "old value", true ) );
+ resusitated = sysRoot.getAttributes( "ou=test5" );
+ assertNotNull( resusitated );
+ description = resusitated.get( "description" );
+ assertNull( description );
+
+ // now revert and assert the old value is now reverted
+ service.revert( t2.getRevision() );
+ resusitated = sysRoot.getAttributes( "ou=test5" );
+ assertNotNull( resusitated );
+ description = resusitated.get( "description" );
+ assertNotNull( description );
+ assertEquals( description.get(), "old value" );
+
+ // -------------------------------------------------------------------
+ // Modify Multi Operation Test
+ // -------------------------------------------------------------------
+
+ // add a userPassword attribute so we can test replacing it
+ sysRoot.modifyAttributes( "ou=test5", DirContext.ADD_ATTRIBUTE,
+ new BasicAttributes( "userPassword", "to be replaced", true ) );
+ assertPassword( sysRoot.getAttributes( "ou=test5" ), "to be replaced" );
+
+ ModificationItem[] mods = new ModificationItem[]
+ {
+ new ModificationItem( DirContext.REMOVE_ATTRIBUTE,
+ new BasicAttribute( "description", "old value" ) ),
+ new ModificationItem( DirContext.ADD_ATTRIBUTE,
+ new BasicAttribute( "seeAlso", "ou=added" ) ),
+ new ModificationItem( DirContext.REPLACE_ATTRIBUTE,
+ new BasicAttribute( "userPassword", "a replaced value" ) )
+ };
+ Tag t3 = service.getChangeLog().tag();
+
+ // now make the modification and check that description is gone,
+ // seeAlso is added, and that the userPassword has been replaced
+ sysRoot.modifyAttributes( "ou=test5", mods );
+ resusitated = sysRoot.getAttributes( "ou=test5" );
+ assertNotNull( resusitated );
+ description = resusitated.get( "description" );
+ assertNull( description );
+ assertPassword( resusitated, "a replaced value" );
+ Attribute seeAlso = resusitated.get( "seeAlso" );
+ assertNotNull( seeAlso );
+ assertEquals( seeAlso.get(), "ou=added" );
+
+ // now we revert and make sure the old values are as they were
+ service.revert( t3.getRevision() );
+ resusitated = sysRoot.getAttributes( "ou=test5" );
+ assertNotNull( resusitated );
+ description = resusitated.get( "description" );
+ assertNotNull( description );
+ assertEquals( description.get(), "old value" );
+ assertPassword( resusitated, "to be replaced" );
+ seeAlso = resusitated.get( "seeAlso" );
+ assertNull( seeAlso );
+ }
+
+
+ private void assertPassword( Attributes entry, String password ) throws NamingException
+ {
+ Attribute userPassword = entry.get( "userPassword" );
+ assertNotNull( userPassword );
+ Arrays.equals( password.getBytes(), ( byte[] ) userPassword.get() );
+ }
+
+
+ private void assertNotPresent( DirContext ctx, String dn ) throws NamingException
+ {
+ try
+ {
+ ctx.getAttributes( dn );
+ fail( "Should not be able to find the entry " + dn + " but it is still there." );
+ }
+ catch ( NamingException ne )
+ {
+ assertTrue( ne instanceof LdapNameNotFoundException );
+ }
+ }
+}
Modified: directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/suites/AuthzISuite.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/suites/AuthzISuite.java?rev=801340&r1=801339&r2=801340&view=diff
==============================================================================
--- directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/suites/AuthzISuite.java (original)
+++ directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/suites/AuthzISuite.java Wed Aug 5 17:55:15 2009
@@ -1,65 +1,65 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.directory.server.core.suites;
-
-
-import org.apache.directory.server.core.authz.AddAuthorizationIT;
-import org.apache.directory.server.core.authz.AdministratorsGroupIT;
-import org.apache.directory.server.core.authz.AuthorizationServiceAsAdminIT;
-import org.apache.directory.server.core.authz.AuthorizationServiceAsNonAdminIT;
-import org.apache.directory.server.core.authz.AuthzAuthnIT;
-import org.apache.directory.server.core.authz.CompareAuthorizationIT;
-import org.apache.directory.server.core.authz.DeleteAuthorizationIT;
-import org.apache.directory.server.core.authz.GeneralAuthorizationIT;
-import org.apache.directory.server.core.authz.ModifyAuthorizationIT;
-import org.apache.directory.server.core.authz.MoveRenameAuthorizationIT;
-import org.apache.directory.server.core.authz.SearchAuthorizationIT;
-import org.apache.directory.server.core.integ.CiSuite;
-import org.apache.directory.server.core.integ.Level;
-import org.apache.directory.server.core.integ.annotations.*;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-
-/**
- * Document me!
- *
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- * @version $Rev$, $Date$
- */
-@RunWith ( CiSuite.class )
-@Suite.SuiteClasses ( {
- AddAuthorizationIT.class,
- AuthorizationServiceAsAdminIT.class,
- AuthorizationServiceAsNonAdminIT.class,
- AuthzAuthnIT.class,
- CompareAuthorizationIT.class,
- DeleteAuthorizationIT.class,
- GeneralAuthorizationIT.class,
- ModifyAuthorizationIT.class,
- MoveRenameAuthorizationIT.class,
- SearchAuthorizationIT.class,
- AdministratorsGroupIT.class // make sure this always runs last since it leaves
- // the default factory service running instead of
- // one with
- } )
-@CleanupLevel ( Level.SUITE )
-public class AuthzISuite
-{
-}
\ No newline at end of file
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.directory.server.core.suites;
+
+
+import org.apache.directory.server.core.authz.AddAuthorizationIT;
+import org.apache.directory.server.core.authz.AdministratorsGroupIT;
+import org.apache.directory.server.core.authz.AuthorizationServiceAsAdminIT;
+import org.apache.directory.server.core.authz.AuthorizationServiceAsNonAdminIT;
+import org.apache.directory.server.core.authz.AuthzAuthnIT;
+import org.apache.directory.server.core.authz.CompareAuthorizationIT;
+import org.apache.directory.server.core.authz.DeleteAuthorizationIT;
+import org.apache.directory.server.core.authz.GeneralAuthorizationIT;
+import org.apache.directory.server.core.authz.ModifyAuthorizationIT;
+import org.apache.directory.server.core.authz.MoveRenameAuthorizationIT;
+import org.apache.directory.server.core.authz.SearchAuthorizationIT;
+import org.apache.directory.server.core.integ.CiSuite;
+import org.apache.directory.server.core.integ.Level;
+import org.apache.directory.server.core.integ.annotations.*;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+
+/**
+ * Document me!
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+@RunWith ( CiSuite.class )
+@Suite.SuiteClasses ( {
+ AddAuthorizationIT.class,
+ AuthorizationServiceAsAdminIT.class,
+ AuthorizationServiceAsNonAdminIT.class,
+ AuthzAuthnIT.class,
+ CompareAuthorizationIT.class,
+ DeleteAuthorizationIT.class,
+ GeneralAuthorizationIT.class,
+ ModifyAuthorizationIT.class,
+ MoveRenameAuthorizationIT.class,
+ SearchAuthorizationIT.class,
+ AdministratorsGroupIT.class // make sure this always runs last since it leaves
+ // the default factory service running instead of
+ // one with
+ } )
+@CleanupLevel ( Level.SUITE )
+public class AuthzISuite
+{
+}
Modified: directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/suites/SchemaISuite.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/suites/SchemaISuite.java?rev=801340&r1=801339&r2=801340&view=diff
==============================================================================
--- directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/suites/SchemaISuite.java (original)
+++ directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/suites/SchemaISuite.java Wed Aug 5 17:55:15 2009
@@ -1,65 +1,65 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.directory.server.core.suites;
-
-
-import org.apache.directory.server.core.integ.CiSuite;
-import org.apache.directory.server.core.integ.Level;
-import org.apache.directory.server.core.integ.annotations.*;
-import org.apache.directory.server.core.schema.MetaAttributeTypeHandlerIT;
-import org.apache.directory.server.core.schema.MetaComparatorHandlerIT;
-import org.apache.directory.server.core.schema.MetaMatchingRuleHandlerIT;
-import org.apache.directory.server.core.schema.MetaNormalizerHandlerIT;
-import org.apache.directory.server.core.schema.MetaObjectClassHandlerIT;
-import org.apache.directory.server.core.schema.MetaSchemaHandlerIT;
-import org.apache.directory.server.core.schema.MetaSyntaxCheckerHandlerIT;
-import org.apache.directory.server.core.schema.MetaSyntaxHandlerIT;
-import org.apache.directory.server.core.schema.ObjectClassCreateIT;
-import org.apache.directory.server.core.schema.SchemaPersistenceIT;
-import org.apache.directory.server.core.schema.SchemaServiceIT;
-import org.apache.directory.server.core.schema.SubschemaSubentryIT;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-
-/**
- * Document me!
- *
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- * @version $Rev$, $Date$
- */
-@RunWith ( CiSuite.class )
-@Suite.SuiteClasses ( {
- MetaAttributeTypeHandlerIT.class,
- MetaComparatorHandlerIT.class,
- MetaMatchingRuleHandlerIT.class,
- MetaNormalizerHandlerIT.class,
- MetaObjectClassHandlerIT.class,
- MetaSchemaHandlerIT.class,
- MetaSyntaxCheckerHandlerIT.class,
- MetaSyntaxHandlerIT.class,
- ObjectClassCreateIT.class,
- SchemaPersistenceIT.class,
- SubschemaSubentryIT.class,
- SchemaServiceIT.class
- } )
-@CleanupLevel ( Level.SUITE )
-public class SchemaISuite
-{
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.directory.server.core.suites;
+
+
+import org.apache.directory.server.core.integ.CiSuite;
+import org.apache.directory.server.core.integ.Level;
+import org.apache.directory.server.core.integ.annotations.*;
+import org.apache.directory.server.core.schema.MetaAttributeTypeHandlerIT;
+import org.apache.directory.server.core.schema.MetaComparatorHandlerIT;
+import org.apache.directory.server.core.schema.MetaMatchingRuleHandlerIT;
+import org.apache.directory.server.core.schema.MetaNormalizerHandlerIT;
+import org.apache.directory.server.core.schema.MetaObjectClassHandlerIT;
+import org.apache.directory.server.core.schema.MetaSchemaHandlerIT;
+import org.apache.directory.server.core.schema.MetaSyntaxCheckerHandlerIT;
+import org.apache.directory.server.core.schema.MetaSyntaxHandlerIT;
+import org.apache.directory.server.core.schema.ObjectClassCreateIT;
+import org.apache.directory.server.core.schema.SchemaPersistenceIT;
+import org.apache.directory.server.core.schema.SchemaServiceIT;
+import org.apache.directory.server.core.schema.SubschemaSubentryIT;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+
+/**
+ * Document me!
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+@RunWith ( CiSuite.class )
+@Suite.SuiteClasses ( {
+ MetaAttributeTypeHandlerIT.class,
+ MetaComparatorHandlerIT.class,
+ MetaMatchingRuleHandlerIT.class,
+ MetaNormalizerHandlerIT.class,
+ MetaObjectClassHandlerIT.class,
+ MetaSchemaHandlerIT.class,
+ MetaSyntaxCheckerHandlerIT.class,
+ MetaSyntaxHandlerIT.class,
+ ObjectClassCreateIT.class,
+ SchemaPersistenceIT.class,
+ SubschemaSubentryIT.class,
+ SchemaServiceIT.class
+ } )
+@CleanupLevel ( Level.SUITE )
+public class SchemaISuite
+{
+}
Modified: directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/suites/StockCoreISuite.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/suites/StockCoreISuite.java?rev=801340&r1=801339&r2=801340&view=diff
==============================================================================
--- directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/suites/StockCoreISuite.java (original)
+++ directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/suites/StockCoreISuite.java Wed Aug 5 17:55:15 2009
@@ -1,104 +1,104 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.directory.server.core.suites;
-
-import org.apache.directory.server.core.authn.SimpleAuthenticationIT;
-import org.apache.directory.server.core.changelog.DefaultChangeLogIT;
-import org.apache.directory.server.core.collective.CollectiveAttributeServiceIT;
-import org.apache.directory.server.core.configuration.PartitionConfigurationIT;
-import org.apache.directory.server.core.event.EventServiceIT;
-import org.apache.directory.server.core.exception.ExceptionServiceIT;
-import org.apache.directory.server.core.integ.CiSuite;
-import org.apache.directory.server.core.integ.Level;
-import org.apache.directory.server.core.integ.SetupMode;
-import org.apache.directory.server.core.integ.annotations.*;
-import org.apache.directory.server.core.jndi.AddIT;
-import org.apache.directory.server.core.jndi.CreateContextIT;
-import org.apache.directory.server.core.jndi.DIRSERVER169IT;
-import org.apache.directory.server.core.jndi.DIRSERVER783IT;
-import org.apache.directory.server.core.jndi.DIRSERVER791IT;
-import org.apache.directory.server.core.jndi.DestroyContextIT;
-import org.apache.directory.server.core.jndi.ExtensibleObjectIT;
-import org.apache.directory.server.core.jndi.ListIT;
-import org.apache.directory.server.core.jndi.ModifyContextIT;
-import org.apache.directory.server.core.jndi.ObjStateFactoryIT;
-import org.apache.directory.server.core.jndi.RFC2713IT;
-import org.apache.directory.server.core.jndi.RootDSEIT;
-import org.apache.directory.server.core.jndi.UniqueMemberIT;
-import org.apache.directory.server.core.normalization.NormalizationServiceIT;
-import org.apache.directory.server.core.operational.OperationalAttributeServiceIT;
-import org.apache.directory.server.core.operations.search.DIRSERVER759IT;
-import org.apache.directory.server.core.operations.search.SearchIT;
-import org.apache.directory.server.core.prefs.PreferencesIT;
-import org.apache.directory.server.core.sp.LdapClassLoaderIT;
-import org.apache.directory.server.core.subtree.BadSubentryServiceIT;
-import org.apache.directory.server.core.subtree.SubentryServiceEntryModificationHandlingIT;
-import org.apache.directory.server.core.subtree.SubentryServiceIT;
-import org.apache.directory.server.core.subtree.SubentryServiceObjectClassChangeHandlingIT;
-import org.apache.directory.server.core.trigger.SubentryServiceForTriggersIT;
-import org.apache.directory.server.core.trigger.TriggerInterceptorIT;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-
-/**
- * Document me!
- *
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- * @version $Rev$, $Date$
- */
-@RunWith ( CiSuite.class )
-@Suite.SuiteClasses ( {
- SimpleAuthenticationIT.class,
- CollectiveAttributeServiceIT.class,
- ExceptionServiceIT.class,
- EventServiceIT.class,
- AddIT.class,
- CreateContextIT.class,
- DestroyContextIT.class,
- PartitionConfigurationIT.class,
- DIRSERVER169IT.class,
- DIRSERVER759IT.class,
- DIRSERVER783IT.class,
- DIRSERVER791IT.class,
- ListIT.class,
- ObjStateFactoryIT.class,
- ExtensibleObjectIT.class,
- ModifyContextIT.class,
- RFC2713IT.class,
- RootDSEIT.class,
- SearchIT.class,
- UniqueMemberIT.class,
- OperationalAttributeServiceIT.class,
- PreferencesIT.class,
- TriggerInterceptorIT.class,
- SubentryServiceForTriggersIT.class,
- BadSubentryServiceIT.class,
- SubentryServiceEntryModificationHandlingIT.class,
- SubentryServiceObjectClassChangeHandlingIT.class,
- SubentryServiceIT.class,
- LdapClassLoaderIT.class,
- NormalizationServiceIT.class,
- DefaultChangeLogIT.class
- } )
-@CleanupLevel ( Level.SUITE )
-@Mode ( SetupMode.ROLLBACK )
-public class StockCoreISuite
-{
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.directory.server.core.suites;
+
+import org.apache.directory.server.core.authn.SimpleAuthenticationIT;
+import org.apache.directory.server.core.changelog.DefaultChangeLogIT;
+import org.apache.directory.server.core.collective.CollectiveAttributeServiceIT;
+import org.apache.directory.server.core.configuration.PartitionConfigurationIT;
+import org.apache.directory.server.core.event.EventServiceIT;
+import org.apache.directory.server.core.exception.ExceptionServiceIT;
+import org.apache.directory.server.core.integ.CiSuite;
+import org.apache.directory.server.core.integ.Level;
+import org.apache.directory.server.core.integ.SetupMode;
+import org.apache.directory.server.core.integ.annotations.*;
+import org.apache.directory.server.core.jndi.AddIT;
+import org.apache.directory.server.core.jndi.CreateContextIT;
+import org.apache.directory.server.core.jndi.DIRSERVER169IT;
+import org.apache.directory.server.core.jndi.DIRSERVER783IT;
+import org.apache.directory.server.core.jndi.DIRSERVER791IT;
+import org.apache.directory.server.core.jndi.DestroyContextIT;
+import org.apache.directory.server.core.jndi.ExtensibleObjectIT;
+import org.apache.directory.server.core.jndi.ListIT;
+import org.apache.directory.server.core.jndi.ModifyContextIT;
+import org.apache.directory.server.core.jndi.ObjStateFactoryIT;
+import org.apache.directory.server.core.jndi.RFC2713IT;
+import org.apache.directory.server.core.jndi.RootDSEIT;
+import org.apache.directory.server.core.jndi.UniqueMemberIT;
+import org.apache.directory.server.core.normalization.NormalizationServiceIT;
+import org.apache.directory.server.core.operational.OperationalAttributeServiceIT;
+import org.apache.directory.server.core.operations.search.DIRSERVER759IT;
+import org.apache.directory.server.core.operations.search.SearchIT;
+import org.apache.directory.server.core.prefs.PreferencesIT;
+import org.apache.directory.server.core.sp.LdapClassLoaderIT;
+import org.apache.directory.server.core.subtree.BadSubentryServiceIT;
+import org.apache.directory.server.core.subtree.SubentryServiceEntryModificationHandlingIT;
+import org.apache.directory.server.core.subtree.SubentryServiceIT;
+import org.apache.directory.server.core.subtree.SubentryServiceObjectClassChangeHandlingIT;
+import org.apache.directory.server.core.trigger.SubentryServiceForTriggersIT;
+import org.apache.directory.server.core.trigger.TriggerInterceptorIT;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+
+/**
+ * Document me!
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+@RunWith ( CiSuite.class )
+@Suite.SuiteClasses ( {
+ SimpleAuthenticationIT.class,
+ CollectiveAttributeServiceIT.class,
+ ExceptionServiceIT.class,
+ EventServiceIT.class,
+ AddIT.class,
+ CreateContextIT.class,
+ DestroyContextIT.class,
+ PartitionConfigurationIT.class,
+ DIRSERVER169IT.class,
+ DIRSERVER759IT.class,
+ DIRSERVER783IT.class,
+ DIRSERVER791IT.class,
+ ListIT.class,
+ ObjStateFactoryIT.class,
+ ExtensibleObjectIT.class,
+ ModifyContextIT.class,
+ RFC2713IT.class,
+ RootDSEIT.class,
+ SearchIT.class,
+ UniqueMemberIT.class,
+ OperationalAttributeServiceIT.class,
+ PreferencesIT.class,
+ TriggerInterceptorIT.class,
+ SubentryServiceForTriggersIT.class,
+ BadSubentryServiceIT.class,
+ SubentryServiceEntryModificationHandlingIT.class,
+ SubentryServiceObjectClassChangeHandlingIT.class,
+ SubentryServiceIT.class,
+ LdapClassLoaderIT.class,
+ NormalizationServiceIT.class,
+ DefaultChangeLogIT.class
+ } )
+@CleanupLevel ( Level.SUITE )
+@Mode ( SetupMode.ROLLBACK )
+public class StockCoreISuite
+{
+}
Modified: directory/apacheds/trunk/core-unit/src/main/java/org/apache/directory/server/core/unit/IntegrationUtils.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-unit/src/main/java/org/apache/directory/server/core/unit/IntegrationUtils.java?rev=801340&r1=801339&r2=801340&view=diff
==============================================================================
--- directory/apacheds/trunk/core-unit/src/main/java/org/apache/directory/server/core/unit/IntegrationUtils.java (original)
+++ directory/apacheds/trunk/core-unit/src/main/java/org/apache/directory/server/core/unit/IntegrationUtils.java Wed Aug 5 17:55:15 2009
@@ -1,176 +1,176 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.directory.server.core.unit;
-
-
-import org.apache.commons.io.FileUtils;
-import org.apache.directory.server.core.CoreSession;
-import org.apache.directory.server.core.entry.DefaultServerEntry;
-import org.apache.directory.shared.ldap.entry.EntryAttribute;
-import org.apache.directory.shared.ldap.entry.client.DefaultClientAttribute;
-import org.apache.directory.shared.ldap.ldif.ChangeType;
-import org.apache.directory.shared.ldap.ldif.LdifEntry;
-import org.apache.directory.shared.ldap.name.LdapDN;
-import org.apache.directory.shared.ldap.name.Rdn;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.naming.InvalidNameException;
-import javax.naming.NamingException;
-import java.io.File;
-import java.io.IOException;
-
-
-/**
- * Integration test utility methods.
- *
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- * @version $Rev$, $Date$
- */
-public class IntegrationUtils
-{
- private static final Logger LOG = LoggerFactory.getLogger( IntegrationUtils.class );
-
-
- /**
- * Deletes the working directory.
- *
- * @param wkdir the working directory to delete
- * @throws IOException if the working directory cannot be deleted
- */
- public static void doDelete( File wkdir ) throws IOException
- {
- if ( wkdir.exists() )
- {
- try
- {
- FileUtils.deleteDirectory( wkdir );
- }
- catch ( IOException e )
- {
- LOG.error( "Failed to delete the working directory.", e );
- }
- }
- if ( wkdir.exists() )
- {
- throw new IOException( "Failed to delete: " + wkdir );
- }
- }
-
-
- public static LdifEntry getUserAddLdif() throws InvalidNameException, NamingException
- {
- return getUserAddLdif( "uid=akarasulu,ou=users,ou=system", "test".getBytes(), "Alex Karasulu", "Karasulu" );
- }
-
-
-
- public static void apply( CoreSession root, LdifEntry entry ) throws Exception
- {
- LdapDN dn = new LdapDN( entry.getDn() );
-
- switch( entry.getChangeType().getChangeType() )
- {
- case( ChangeType.ADD_ORDINAL ):
- root.add(
- new DefaultServerEntry(
- root.getDirectoryService().getRegistries(), entry.getEntry() ) );
- break;
-
- case( ChangeType.DELETE_ORDINAL ):
- root.delete( entry.getDn() );
- break;
-
- case( ChangeType.MODDN_ORDINAL ):
- case( ChangeType.MODRDN_ORDINAL ):
- Rdn newRdn = new Rdn( entry.getNewRdn() );
-
- if ( entry.getNewSuperior() != null )
- {
- // It's a move. The superior have changed
- // Let's see if it's a rename too
- Rdn oldRdn = dn.getRdn();
- LdapDN newSuperior = new LdapDN( entry.getNewSuperior() );
-
- if ( dn.size() == 0 )
- {
- throw new IllegalStateException( "can't move the root DSE" );
- }
- else if ( oldRdn.equals( newRdn ) )
- {
- // Same rdn : it's a move
- root.move( dn, newSuperior );
- }
- else
- {
- // it's a move and rename
- root.moveAndRename( dn, newSuperior, newRdn, entry.isDeleteOldRdn() );
- }
- }
- else
- {
- // it's a rename
- root.rename( dn, newRdn, entry.isDeleteOldRdn() );
- }
-
- break;
-
- case( ChangeType.MODIFY_ORDINAL ):
- root.modify( dn, entry.getModificationItems() );
- break;
-
- default:
- throw new IllegalStateException( "Unidentified change type value: " + entry.getChangeType() );
- }
- }
-
-
- public static LdifEntry getUserAddLdif( String dnstr, byte[] password, String cn, String sn )
- throws InvalidNameException, NamingException
- {
- LdapDN dn = new LdapDN( dnstr );
- LdifEntry ldif = new LdifEntry();
- ldif.setDn( dnstr );
- ldif.setChangeType( ChangeType.Add );
-
- EntryAttribute attr = new DefaultClientAttribute( "objectClass",
- "top", "person", "organizationalPerson", "inetOrgPerson" );
-
- ldif.addAttribute( attr );
-
- attr = new DefaultClientAttribute( "ou", "Engineering", "People" );
- ldif.addAttribute( attr );
-
- String uid = ( String ) dn.getRdn().getValue();
- ldif.putAttribute( "uid", uid );
-
- ldif.putAttribute( "l", "Bogusville" );
- ldif.putAttribute( "cn", cn );
- ldif.putAttribute( "sn", sn );
- ldif.putAttribute( "mail", uid + "@apache.org" );
- ldif.putAttribute( "telephoneNumber", "+1 408 555 4798" );
- ldif.putAttribute( "facsimileTelephoneNumber", "+1 408 555 9751" );
- ldif.putAttribute( "roomnumber", "4612" );
- ldif.putAttribute( "userPassword", password );
-
- String givenName = cn.split( " " )[0];
- ldif.putAttribute( "givenName", givenName );
- return ldif;
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.directory.server.core.unit;
+
+
+import org.apache.commons.io.FileUtils;
+import org.apache.directory.server.core.CoreSession;
+import org.apache.directory.server.core.entry.DefaultServerEntry;
+import org.apache.directory.shared.ldap.entry.EntryAttribute;
+import org.apache.directory.shared.ldap.entry.client.DefaultClientAttribute;
+import org.apache.directory.shared.ldap.ldif.ChangeType;
+import org.apache.directory.shared.ldap.ldif.LdifEntry;
+import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.shared.ldap.name.Rdn;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.naming.InvalidNameException;
+import javax.naming.NamingException;
+import java.io.File;
+import java.io.IOException;
+
+
+/**
+ * Integration test utility methods.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class IntegrationUtils
+{
+ private static final Logger LOG = LoggerFactory.getLogger( IntegrationUtils.class );
+
+
+ /**
+ * Deletes the working directory.
+ *
+ * @param wkdir the working directory to delete
+ * @throws IOException if the working directory cannot be deleted
+ */
+ public static void doDelete( File wkdir ) throws IOException
+ {
+ if ( wkdir.exists() )
+ {
+ try
+ {
+ FileUtils.deleteDirectory( wkdir );
+ }
+ catch ( IOException e )
+ {
+ LOG.error( "Failed to delete the working directory.", e );
+ }
+ }
+ if ( wkdir.exists() )
+ {
+ throw new IOException( "Failed to delete: " + wkdir );
+ }
+ }
+
+
+ public static LdifEntry getUserAddLdif() throws InvalidNameException, NamingException
+ {
+ return getUserAddLdif( "uid=akarasulu,ou=users,ou=system", "test".getBytes(), "Alex Karasulu", "Karasulu" );
+ }
+
+
+
+ public static void apply( CoreSession root, LdifEntry entry ) throws Exception
+ {
+ LdapDN dn = new LdapDN( entry.getDn() );
+
+ switch( entry.getChangeType().getChangeType() )
+ {
+ case( ChangeType.ADD_ORDINAL ):
+ root.add(
+ new DefaultServerEntry(
+ root.getDirectoryService().getRegistries(), entry.getEntry() ) );
+ break;
+
+ case( ChangeType.DELETE_ORDINAL ):
+ root.delete( entry.getDn() );
+ break;
+
+ case( ChangeType.MODDN_ORDINAL ):
+ case( ChangeType.MODRDN_ORDINAL ):
+ Rdn newRdn = new Rdn( entry.getNewRdn() );
+
+ if ( entry.getNewSuperior() != null )
+ {
+ // It's a move. The superior have changed
+ // Let's see if it's a rename too
+ Rdn oldRdn = dn.getRdn();
+ LdapDN newSuperior = new LdapDN( entry.getNewSuperior() );
+
+ if ( dn.size() == 0 )
+ {
+ throw new IllegalStateException( "can't move the root DSE" );
+ }
+ else if ( oldRdn.equals( newRdn ) )
+ {
+ // Same rdn : it's a move
+ root.move( dn, newSuperior );
+ }
+ else
+ {
+ // it's a move and rename
+ root.moveAndRename( dn, newSuperior, newRdn, entry.isDeleteOldRdn() );
+ }
+ }
+ else
+ {
+ // it's a rename
+ root.rename( dn, newRdn, entry.isDeleteOldRdn() );
+ }
+
+ break;
+
+ case( ChangeType.MODIFY_ORDINAL ):
+ root.modify( dn, entry.getModificationItems() );
+ break;
+
+ default:
+ throw new IllegalStateException( "Unidentified change type value: " + entry.getChangeType() );
+ }
+ }
+
+
+ public static LdifEntry getUserAddLdif( String dnstr, byte[] password, String cn, String sn )
+ throws InvalidNameException, NamingException
+ {
+ LdapDN dn = new LdapDN( dnstr );
+ LdifEntry ldif = new LdifEntry();
+ ldif.setDn( dnstr );
+ ldif.setChangeType( ChangeType.Add );
+
+ EntryAttribute attr = new DefaultClientAttribute( "objectClass",
+ "top", "person", "organizationalPerson", "inetOrgPerson" );
+
+ ldif.addAttribute( attr );
+
+ attr = new DefaultClientAttribute( "ou", "Engineering", "People" );
+ ldif.addAttribute( attr );
+
+ String uid = ( String ) dn.getRdn().getValue();
+ ldif.putAttribute( "uid", uid );
+
+ ldif.putAttribute( "l", "Bogusville" );
+ ldif.putAttribute( "cn", cn );
+ ldif.putAttribute( "sn", sn );
+ ldif.putAttribute( "mail", uid + "@apache.org" );
+ ldif.putAttribute( "telephoneNumber", "+1 408 555 4798" );
+ ldif.putAttribute( "facsimileTelephoneNumber", "+1 408 555 9751" );
+ ldif.putAttribute( "roomnumber", "4612" );
+ ldif.putAttribute( "userPassword", password );
+
+ String givenName = cn.split( " " )[0];
+ ldif.putAttribute( "givenName", givenName );
+ return ldif;
+ }
+}