[jira] Created: (DIRSERVER-915) Hot Partitions Throw Exceptions for
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Web Servers reviews > Apache Server configuration support > Apache Directory Project > [jira] Created: (DIRSERVER-915) Hot Partitions Throw Exceptions for




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    [jira] Created: (DIRSERVER-915) Hot Partitions Throw Exceptions for  
Ole Ersoy (JIRA)


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
04-24-07 06:11 PM

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


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.MutablePartitionConfig
uration;
import org.apache.directory.server.core.configuration.MutableStartupConfigur
ation;
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 "s
ecret"
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.currentTimeMi
llis() - 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", jennyAttrib
utes );
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  testHotPartitionConnectWithApacheContext
Factory()
throws NamingException
{
DirContext directoryContext = null;
try
{
directoryContext = connectWithApacheContextFactory();
}
catch (Exception e)
{

}
assertNull(directoryContext);
}

public void  testHotPartitionConnectWithSunContextFac
tory()
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.







[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 06:20 PM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register