You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by se...@apache.org on 2010/01/30 18:23:04 UTC
svn commit: r904816 - in /directory/apacheds/trunk:
core-annotations/src/main/java/org/apache/directory/server/core/factory/DSAnnotationProcessor.java
test-framework/src/main/java/org/apache/directory/server/core/integ/FrameworkSuite.java
Author: seelmann
Date: Sat Jan 30 17:23:03 2010
New Revision: 904816
URL: http://svn.apache.org/viewvc?rev=904816&view=rev
Log:
o let the test fail if creation or start of of directory service or LDAP server fails
o replaced 'instanceof JdbmPartiton' check by 'instanceof BTreePartition'
Modified:
directory/apacheds/trunk/core-annotations/src/main/java/org/apache/directory/server/core/factory/DSAnnotationProcessor.java
directory/apacheds/trunk/test-framework/src/main/java/org/apache/directory/server/core/integ/FrameworkSuite.java
Modified: directory/apacheds/trunk/core-annotations/src/main/java/org/apache/directory/server/core/factory/DSAnnotationProcessor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-annotations/src/main/java/org/apache/directory/server/core/factory/DSAnnotationProcessor.java?rev=904816&r1=904815&r2=904816&view=diff
==============================================================================
--- directory/apacheds/trunk/core-annotations/src/main/java/org/apache/directory/server/core/factory/DSAnnotationProcessor.java (original)
+++ directory/apacheds/trunk/core-annotations/src/main/java/org/apache/directory/server/core/factory/DSAnnotationProcessor.java Sat Jan 30 17:23:03 2010
@@ -38,8 +38,8 @@
import org.apache.directory.server.core.entry.ServerEntry;
import org.apache.directory.server.core.interceptor.Interceptor;
import org.apache.directory.server.core.partition.Partition;
+import org.apache.directory.server.core.partition.impl.btree.BTreePartition;
import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmIndex;
-import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmPartition;
import org.apache.directory.server.i18n.I18n;
import org.apache.directory.server.xdbm.Index;
import org.apache.directory.shared.ldap.ldif.LdifEntry;
@@ -64,76 +64,70 @@
/**
* Create the DirectoryService
*/
- private static DirectoryService createDS( CreateDS dsBuilder )
+ private static DirectoryService createDS( CreateDS dsBuilder ) throws Exception
{
- try
+ LOG.debug( "Starting DS {}...", dsBuilder.name() );
+ Class<?> factory = dsBuilder.factory();
+ DirectoryServiceFactory dsf = ( DirectoryServiceFactory ) factory.newInstance();
+
+ DirectoryService service = dsf.getDirectoryService();
+ service.setAccessControlEnabled( dsBuilder.enableAccessControl() );
+ service.setAllowAnonymousAccess( dsBuilder.allowAnonAccess() );
+ service.getChangeLog().setEnabled( dsBuilder.enableChangeLog() );
+
+ List<Interceptor> interceptorList = service.getInterceptors();
+ for ( Class<?> interceptorClass : dsBuilder.additionalInterceptors() )
{
- LOG.debug( "Starting DS {}...", dsBuilder.name() );
- Class<?> factory = dsBuilder.factory();
- DirectoryServiceFactory dsf = ( DirectoryServiceFactory ) factory.newInstance();
-
- DirectoryService service = dsf.getDirectoryService();
- service.setAccessControlEnabled( dsBuilder.enableAccessControl() );
- service.setAllowAnonymousAccess( dsBuilder.allowAnonAccess() );
- service.getChangeLog().setEnabled( dsBuilder.enableChangeLog() );
+ interceptorList.add( ( Interceptor ) interceptorClass.newInstance() );
+ }
- List<Interceptor> interceptorList = service.getInterceptors();
- for ( Class<?> interceptorClass : dsBuilder.additionalInterceptors() )
- {
- interceptorList.add( ( Interceptor ) interceptorClass.newInstance() );
- }
+ service.setInterceptors( interceptorList );
- service.setInterceptors( interceptorList );
+ dsf.init( dsBuilder.name() );
- dsf.init( dsBuilder.name() );
+ // Process the Partition, if any.
+ for ( CreatePartition createPartition : dsBuilder.partitions() )
+ {
+ // Create the partition
+ Partition partition = createPartition.type().newInstance();
+ partition.setId( createPartition.name() );
+ partition.setSuffix( createPartition.suffix() );
+ partition.setSchemaManager( service.getSchemaManager() );
- // Process the Partition, if any.
- for ( CreatePartition createPartition : dsBuilder.partitions() )
+ if ( partition instanceof BTreePartition )
{
- // Create the partition
- Partition partition = createPartition.type().newInstance();
- partition.setId( createPartition.name() );
- partition.setSuffix( createPartition.suffix() );
- partition.setSchemaManager( service.getSchemaManager() );
-
- if ( partition instanceof JdbmPartition )
- {
- JdbmPartition jdbmPartition = ( JdbmPartition ) partition;
- jdbmPartition.setCacheSize( createPartition.cacheSize() );
- jdbmPartition.setPartitionDir( new File( service.getWorkingDirectory(), createPartition.name() ) );
+ BTreePartition btreePartition = ( BTreePartition ) partition;
+ btreePartition.setCacheSize( createPartition.cacheSize() );
+ btreePartition.setPartitionDir( new File( service.getWorkingDirectory(), createPartition.name() ) );
- // Process the indexes if any
- CreateIndex[] indexes = createPartition.indexes();
+ // Process the indexes if any
+ CreateIndex[] indexes = createPartition.indexes();
- for ( CreateIndex createIndex : indexes )
- {
- Index<String, ServerEntry> index = new JdbmIndex<String, ServerEntry>( createIndex.attribute() );
- index.setCacheSize( createIndex.cacheSize() );
+ // TODO: use index factory
+ for ( CreateIndex createIndex : indexes )
+ {
+ Index<String, ServerEntry> index = new JdbmIndex<String, ServerEntry>( createIndex.attribute() );
+ index.setCacheSize( createIndex.cacheSize() );
- jdbmPartition.addIndexedAttributes( index );
- }
+ btreePartition.addIndexedAttributes( index );
}
+ }
- partition.setSchemaManager( service.getSchemaManager() );
+ partition.setSchemaManager( service.getSchemaManager() );
- // Inject the partition into the DirectoryService
- service.addPartition( partition );
+ // Inject the partition into the DirectoryService
+ service.addPartition( partition );
- // Last, process the context entry
- ContextEntry contextEntry = createPartition.contextEntry();
+ // Last, process the context entry
+ ContextEntry contextEntry = createPartition.contextEntry();
- if ( contextEntry != null )
- {
- injectEntries( service, contextEntry.entryLdif() );
- }
+ if ( contextEntry != null )
+ {
+ injectEntries( service, contextEntry.entryLdif() );
}
-
- return service;
- }
- catch ( Exception e )
- {
- return null;
}
+
+ return service;
}
@@ -143,24 +137,17 @@
* @param description The annotations containing the info from which we will create the DS
* @return A valid DS
*/
- public static DirectoryService getDirectoryService( Description description )
+ public static DirectoryService getDirectoryService( Description description ) throws Exception
{
- try
- {
- CreateDS dsBuilder = description.getAnnotation( CreateDS.class );
+ CreateDS dsBuilder = description.getAnnotation( CreateDS.class );
- if ( dsBuilder != null )
- {
- return createDS( dsBuilder );
- }
- else
- {
- LOG.debug( "No {} DS.", description.getDisplayName() );
- return null;
- }
+ if ( dsBuilder != null )
+ {
+ return createDS( dsBuilder );
}
- catch ( Exception e )
+ else
{
+ LOG.debug( "No {} DS.", description.getDisplayName() );
return null;
}
}
Modified: directory/apacheds/trunk/test-framework/src/main/java/org/apache/directory/server/core/integ/FrameworkSuite.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/test-framework/src/main/java/org/apache/directory/server/core/integ/FrameworkSuite.java?rev=904816&r1=904815&r2=904816&view=diff
==============================================================================
--- directory/apacheds/trunk/test-framework/src/main/java/org/apache/directory/server/core/integ/FrameworkSuite.java (original)
+++ directory/apacheds/trunk/test-framework/src/main/java/org/apache/directory/server/core/integ/FrameworkSuite.java Sat Jan 30 17:23:03 2010
@@ -28,6 +28,7 @@
import org.apache.directory.server.ldap.LdapServer;
import org.junit.runner.Description;
import org.junit.runner.Runner;
+import org.junit.runner.notification.Failure;
import org.junit.runner.notification.RunNotifier;
import org.junit.runners.Suite;
import org.junit.runners.model.InitializationError;
@@ -69,7 +70,7 @@
/**
* Start and initialize the DS
*/
- private void startDS( Description description )
+ private void startDS( Description description ) throws Exception
{
// Initialize and start the DS before running any test, if we have a DS annotation
directoryService = DSAnnotationProcessor.getDirectoryService( description );
@@ -77,14 +78,7 @@
// and inject LDIFs if needed
if ( directoryService != null )
{
- try
- {
- DSAnnotationProcessor.applyLdifs( description, directoryService );
- }
- catch ( Exception e )
- {
- return;
- }
+ DSAnnotationProcessor.applyLdifs( description, directoryService );
}
}
@@ -121,16 +115,9 @@
}
- private void startLdapServer( Description description )
+ private void startLdapServer( Description description ) throws Exception
{
- try
- {
- ldapServer = ServerAnnotationProcessor.getLdapServer( description, directoryService, 1024 );
- }
- catch ( Exception e )
- {
- e.printStackTrace();
- }
+ ldapServer = ServerAnnotationProcessor.getLdapServer( description, directoryService, 1024 );
}
@@ -149,23 +136,30 @@
@Override
public void run( final RunNotifier notifier )
{
- // Create and initialize the Suite DS
- startDS( getDescription() );
-
- // Add the partitions to this DS
- addPartitions( getDescription() );
-
- // create and initialize the suite LdapServer
- startLdapServer( getDescription() );
-
- // Run the suite
- super.run( notifier );
-
- // Stop the LdapServer
- stopLdapServer();
-
- // last, stop the DS if we have one
- stopDS();
+ try
+ {
+ // Create and initialize the Suite DS
+ startDS( getDescription() );
+
+ // Add the partitions to this DS
+ addPartitions( getDescription() );
+
+ // create and initialize the suite LdapServer
+ startLdapServer( getDescription() );
+
+ // Run the suite
+ super.run( notifier );
+
+ // Stop the LdapServer
+ stopLdapServer();
+
+ // last, stop the DS if we have one
+ stopDS();
+ }
+ catch ( Exception e )
+ {
+ notifier.fireTestFailure(new Failure(getDescription(), e));
+ }
}
/**