Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 76627 invoked from network); 30 Jan 2010 17:23:28 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 30 Jan 2010 17:23:28 -0000 Received: (qmail 51838 invoked by uid 500); 30 Jan 2010 17:23:28 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 51770 invoked by uid 500); 30 Jan 2010 17:23:28 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 51761 invoked by uid 99); 30 Jan 2010 17:23:28 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 30 Jan 2010 17:23:28 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 30 Jan 2010 17:23:25 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 0E0792388980; Sat, 30 Jan 2010 17:23:04 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: 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 Date: Sat, 30 Jan 2010 17:23:04 -0000 To: commits@directory.apache.org From: seelmann@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100130172304.0E0792388980@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 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 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 index = new JdbmIndex( createIndex.attribute() ); - index.setCacheSize( createIndex.cacheSize() ); + // TODO: use index factory + for ( CreateIndex createIndex : indexes ) + { + Index index = new JdbmIndex( 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)); + } } /**