You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@directory.apache.org by "Emmanuel Lecharny (JIRA)" <ji...@apache.org> on 2007/07/01 14:56:04 UTC
[jira] Updated: (DIRSERVER-915) Hot Partitions Throw Exceptions for
Normal JNDI Operations
[ https://issues.apache.org/jira/browse/DIRSERVER-915?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Emmanuel Lecharny updated DIRSERVER-915:
----------------------------------------
Fix Version/s: 1.5.2
Postponed to the next version. No time to analyze it before 1.5.1 release, but it's not urgent too. The server works well when used in the standard way.
> Hot Partitions Throw Exceptions for Normal JNDI Operations
> ----------------------------------------------------------
>
> Key: DIRSERVER-915
> URL: https://issues.apache.org/jira/browse/DIRSERVER-915
> Project: Directory ApacheDS
> Issue Type: Bug
> Components: core
> Affects Versions: 1.5.1
> Environment: Linux
> Reporter: Ole Ersoy
> Priority: Blocker
> Fix For: 1.5.2
>
>
> package org.apache.tuscany.das.ldap.prototype.learning;
> import java.util.HashSet;
> import java.util.Hashtable;
> import java.util.Set;
> import javax.naming.Context;
> import javax.naming.NameNotFoundException;
> import javax.naming.NamingException;
> import javax.naming.directory.Attribute;
> import javax.naming.directory.Attributes;
> import javax.naming.directory.BasicAttributes;
> import javax.naming.directory.DirContext;
> import javax.naming.directory.InitialDirContext;
> import org.apache.directory.server.core.configuration.Configuration;
> import org.apache.directory.server.core.configuration.MutablePartitionConfiguration;
> import org.apache.directory.server.core.configuration.MutableStartupConfiguration;
> import org.slf4j.Logger;
> import org.slf4j.LoggerFactory;
> import junit.framework.TestCase;
> public class LearningTest extends TestCase
> {
> private static final Logger log = LoggerFactory.getLogger( "partition" );
> // Create the mutable configuration
> MutableStartupConfiguration configuration = new MutableStartupConfiguration();
>
> // Create the partition configuration to fill in
> MutablePartitionConfiguration partition = new MutablePartitionConfiguration();
>
> public void testDynamicPartitioning()
> throws NamingException
> {
> // Get the start time
> long startTime = System.currentTimeMillis();
> partition.setName( "das" );
>
> partition.setSuffix( "ou=das" );
> Attributes suffixAttributes = new BasicAttributes();
> suffixAttributes.put( "objectClass", "top");
> suffixAttributes.get( "objectClass" ).add( "organizationalUnit" );
> suffixAttributes.put( "ou", "das" );
>
> partition.setContextEntry( suffixAttributes );
>
> // Add the new partition configuration to the configuration bean
> Set partitions = new HashSet();
> partitions.add( partition );
> configuration.setContextPartitionConfigurations( partitions );
>
> // ------------------------------------------------------------
> // Setup environment using the configuration with extra partition
> // ------------------------------------------------------------
> Hashtable env = new Hashtable();
> // Notice that the provider URL is not really a URL but a DN
> // This time instead of ou=system we're accessing the apachecon partition
> env.put( Context.PROVIDER_URL, "ou=das" );
> // User the ApacheDS core InitialContextFactory implementation
> env.put( Context.INITIAL_CONTEXT_FACTORY, "org.apache.directory.server.core.jndi.CoreContextFactory" );
> // Fixed uber admin user is always present and initial password is set to "secret"
> env.put( Context.SECURITY_PRINCIPAL, "uid=admin,ou=system" );
> env.put( Context.SECURITY_CREDENTIALS, "secret" );
> env.put( Context.SECURITY_AUTHENTICATION, "simple" );
> // Put extended configuration into environment
> env.put( Configuration.JNDI_KEY, configuration );
>
> // Startup the server core by getting the first InitialDirContext.
> DirContext ictx = new InitialDirContext( env );
> ictx.destroySubcontext( "cn=test" );
> ictx.createSubcontext( "cn=test" );
> System.out.println( "Embedded ApacheDS started in " + ( System.currentTimeMillis() - startTime ) + " milliseconds" );
> DirContext jenny = null;
> try
> {
> // Get context on jenny if she exists.
> jenny = ( DirContext ) ictx.lookup( "cn=Jenny Tutone" );
> System.out.println( jenny.getNameInNamespace() + " already exists" );
> // jenny = ( DirContext ) ictx.lookup( "cn=Jenny Tutone" );
> }
> catch ( NameNotFoundException e2 )
> {
> // Create a new entry under ou=system since jenny does not
> // already exist.
> System.out.println( "jenny does not exist" );
> Attributes jennyAttributes = new BasicAttributes( "objectClass", "top", true );
> jennyAttributes.get( "objectClass" ).add( "person" );
> jennyAttributes.put( "sn", "Tutone" );
> jennyAttributes.put( "cn", "Jenny Tutone" );
> jennyAttributes.put( "telephoneNumber", "867-5309" );
> jenny = ( DirContext ) ictx.createSubcontext( "cn=Jenny Tutone", jennyAttributes );
> System.out.println( "created " + jenny.getNameInNamespace() );
> }
> Attribute number = jenny.getAttributes( "" ).get( "telephoneNumber" );
> System.out.println( "Jenny's phone number is " + number.get() );
> }
>
> private DirContext connectWithApacheContextFactory() throws NamingException
> {
> Hashtable<String,String> env = new Hashtable<String, String>();
>
> env.put(
> "java.naming.factory.initial",
> "org.apache.directory.server.core.jndi.CoreContextFactory" );
> env.put(
> "java.naming.provider.url",
> "ldap://localhost:10389/ou=das");
> env.put(
> "java.naming.security.authentication",
> "simple");
> env.put(
> "java.naming.security.principal",
> "uid=admin,ou=system" );
> env.put(
> "java.naming.security.credentials",
> "secret" );
>
> return new InitialDirContext(env);
> }
> private DirContext connectWithSunContextFactory() throws NamingException
> {
> Hashtable<String,String> env = new Hashtable<String, String>();
>
> env.put(
> "java.naming.factory.initial",
> "com.sun.jndi.ldap.LdapCtxFactory" );
> env.put(
> "java.naming.provider.url",
> "ldap://localhost:10389/ou=das");
> env.put(
> "java.naming.security.authentication",
> "simple");
> env.put(
> "java.naming.security.principal",
> "uid=admin,ou=system" );
> env.put(
> "java.naming.security.credentials",
> "secret" );
>
> return new InitialDirContext(env);
> }
>
> public void testHotPartitionConnectWithApacheContextFactory()
> throws NamingException
> {
> DirContext directoryContext = null;
> try
> {
> directoryContext = connectWithApacheContextFactory();
> }
> catch (Exception e)
> {
>
> }
> assertNull(directoryContext);
> }
>
> public void testHotPartitionConnectWithSunContextFactory()
> throws NamingException
> {
> DirContext directoryContext = null;
> directoryContext = connectWithSunContextFactory();
> assertNotNull(directoryContext);
> directoryContext.close();
> }
>
> public void testHotPartitionEntryCreation()
> throws NamingException
> {
> DirContext directoryContext = null;
> directoryContext = connectWithSunContextFactory();
> boolean exceptionOccured = false;
> try
> {
> directoryContext.createSubcontext( "cn=test" );
> }
> catch (Exception e)
> {
> exceptionOccured = true;
> }
> assertTrue(exceptionOccured);
> directoryContext.close();
> }
> }
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.