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 2010/07/26 18:34:50 UTC
svn commit: r979348 -
/directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/configuration/PartitionConfigurationIT.java
Author: elecharny
Date: Mon Jul 26 16:34:50 2010
New Revision: 979348
URL: http://svn.apache.org/viewvc?rev=979348&view=rev
Log:
Migrated the test to use the API instead of JNDI
Modified:
directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/configuration/PartitionConfigurationIT.java
Modified: directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/configuration/PartitionConfigurationIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/configuration/PartitionConfigurationIT.java?rev=979348&r1=979347&r2=979348&view=diff
==============================================================================
--- directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/configuration/PartitionConfigurationIT.java (original)
+++ directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/configuration/PartitionConfigurationIT.java Mon Jul 26 16:34:50 2010
@@ -6,40 +6,36 @@
* 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.
- *
+ * under the License.
+ *
*/
package org.apache.directory.server.core.configuration;
-import java.util.Hashtable;
-import java.util.UUID;
-
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NameNotFoundException;
+import static junit.framework.Assert.assertNotNull;
+import static junit.framework.Assert.assertNull;
-import junit.framework.Assert;
+import java.util.UUID;
-import org.apache.directory.server.core.DirectoryService;
+import org.apache.directory.ldap.client.api.LdapConnection;
import org.apache.directory.server.core.factory.DefaultDirectoryServiceFactory;
import org.apache.directory.server.core.factory.PartitionFactory;
import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
import org.apache.directory.server.core.integ.FrameworkRunner;
+import org.apache.directory.server.core.integ.IntegrationUtils;
import org.apache.directory.server.core.interceptor.context.AddOperationContext;
-import org.apache.directory.server.core.jndi.CoreContextFactory;
import org.apache.directory.server.core.partition.Partition;
import org.apache.directory.shared.ldap.csn.CsnFactory;
-import org.apache.directory.shared.ldap.entry.DefaultEntry;
import org.apache.directory.shared.ldap.entry.Entry;
+import org.apache.directory.shared.ldap.ldif.LdifUtils;
import org.apache.directory.shared.ldap.name.DN;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -65,34 +61,23 @@ public class PartitionConfigurationIT ex
service.addPartition( partition );
DN suffixDn = new DN( "ou=removable", service.getSchemaManager() );
- Entry ctxEntry = new DefaultEntry( service.getSchemaManager(), suffixDn );
- ctxEntry.put( "objectClass", "top" );
- ctxEntry.get( "objectClass" ).add( "organizationalUnit" );
- ctxEntry.put( "ou", "removable" );
- ctxEntry.put( "entryCSN", new CsnFactory( 1 ).newInstance().toString() );
- ctxEntry.put( "entryUUID", UUID.randomUUID().toString() );
+
+ Entry ctxEntry = LdifUtils.createEntry( service.getSchemaManager(), suffixDn,
+ "objectClass: top",
+ "objectClass: organizationalUnit",
+ "ou: removable",
+ "entryCSN", new CsnFactory( 1 ).newInstance().toString(),
+ "entryUUID", UUID.randomUUID().toString() );
+
partition.add( new AddOperationContext( service.getAdminSession(), ctxEntry ) );
- Hashtable<String, Object> env = new Hashtable<String, Object>();
- env.put( Context.INITIAL_CONTEXT_FACTORY, CoreContextFactory.class.getName() );
- env.put( DirectoryService.JNDI_KEY, service );
- env.put( Context.SECURITY_CREDENTIALS, "secret" );
- env.put( Context.SECURITY_AUTHENTICATION, "simple" );
- env.put( Context.SECURITY_PRINCIPAL, "uid=admin,ou=system" );
- Context ctx = new InitialContext( env );
- Assert.assertNotNull( ctx.lookup( "ou=removable" ) );
+ LdapConnection connection = IntegrationUtils.getAdminConnection( service );
+
+ assertNotNull( connection.lookup( "ou=removable" ) );
// Test removeContextPartition
service.removePartition( partition );
- ctx = new InitialContext( env );
- try
- {
- ctx.lookup( "ou=removable" );
- Assert.fail( "NameNotFoundException should be thrown." );
- }
- catch ( NameNotFoundException e )
- {
- // Partition is removed.
- }
+
+ assertNull( connection.lookup( "ou=removable" ) );
}
}