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 2009/06/05 17:02:21 UTC
svn commit: r782036 - in /directory: apacheds/trunk/
apacheds/trunk/core-integ/src/main/java/org/apache/directory/server/core/integ/
apacheds/trunk/core-integ/src/main/java/org/apache/directory/server/core/integ/state/
apacheds/trunk/server-integ/src/m...
Author: seelmann
Date: Fri Jun 5 15:02:20 2009
New Revision: 782036
URL: http://svn.apache.org/viewvc?rev=782036&view=rev
Log:
DIRSERVER-1374:
o Update to JUnit 4.5 (needed for Studio UI tests)
o Refactorings of testing frameworks server-integ and core-integ, due to changes in JUnit API
o Removed all deprecated warnings
o Only one constructor per test class allowed
Modified:
directory/apacheds/trunk/core-integ/src/main/java/org/apache/directory/server/core/integ/CiRunner.java
directory/apacheds/trunk/core-integ/src/main/java/org/apache/directory/server/core/integ/CiSuite.java
directory/apacheds/trunk/core-integ/src/main/java/org/apache/directory/server/core/integ/state/AbstractState.java
directory/apacheds/trunk/core-integ/src/main/java/org/apache/directory/server/core/integ/state/NonExistentState.java
directory/apacheds/trunk/core-integ/src/main/java/org/apache/directory/server/core/integ/state/StartedNormalState.java
directory/apacheds/trunk/core-integ/src/main/java/org/apache/directory/server/core/integ/state/StartedPristineState.java
directory/apacheds/trunk/core-integ/src/main/java/org/apache/directory/server/core/integ/state/TestServiceContext.java
directory/apacheds/trunk/core-integ/src/main/java/org/apache/directory/server/core/integ/state/TestServiceState.java
directory/apacheds/trunk/pom.xml
directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/SiRunner.java
directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/SiSuite.java
directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/state/AbstractState.java
directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/state/NonExistentState.java
directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/state/StartedNormalState.java
directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/state/StartedPristineState.java
directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/state/TestServerContext.java
directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/state/TestServerState.java
directory/daemon/trunk/pom.xml
directory/installers/trunk/pom.xml
directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ACIItemChekerTest.java
directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ACIItemParserTest.java
directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/subtree/SubtreeSpecificationParserTest.java
directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/trigger/TriggerSpecificationParserTest.java
directory/shared/trunk/pom.xml
Modified: directory/apacheds/trunk/core-integ/src/main/java/org/apache/directory/server/core/integ/CiRunner.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/main/java/org/apache/directory/server/core/integ/CiRunner.java?rev=782036&r1=782035&r2=782036&view=diff
==============================================================================
--- directory/apacheds/trunk/core-integ/src/main/java/org/apache/directory/server/core/integ/CiRunner.java (original)
+++ directory/apacheds/trunk/core-integ/src/main/java/org/apache/directory/server/core/integ/CiRunner.java Fri Jun 5 15:02:20 2009
@@ -19,17 +19,19 @@
package org.apache.directory.server.core.integ;
-import java.lang.reflect.Method;
-
import static org.apache.directory.server.core.integ.state.TestServiceContext.cleanup;
import static org.apache.directory.server.core.integ.state.TestServiceContext.destroy;
import static org.apache.directory.server.core.integ.state.TestServiceContext.shutdown;
import static org.apache.directory.server.core.integ.state.TestServiceContext.test;
-import org.junit.internal.runners.InitializationError;
-import org.junit.internal.runners.JUnit4ClassRunner;
+
+import org.junit.Ignore;
import org.junit.runner.Description;
import org.junit.runner.notification.Failure;
import org.junit.runner.notification.RunNotifier;
+import org.junit.runners.BlockJUnit4ClassRunner;
+import org.junit.runners.model.FrameworkMethod;
+import org.junit.runners.model.InitializationError;
+import org.junit.runners.model.Statement;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -40,7 +42,7 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$, $Date$
*/
-public class CiRunner extends JUnit4ClassRunner
+public class CiRunner extends BlockJUnit4ClassRunner
{
private static final Logger LOG = LoggerFactory.getLogger( CiRunner.class );
private CiSuite suite;
@@ -74,7 +76,7 @@
{
super.run( notifier );
Level cleanupLevel = getSettings().getCleanupLevel();
-
+
if ( cleanupLevel == Level.CLASS )
{
try
@@ -86,7 +88,7 @@
catch ( Exception e )
{
LOG.error( "Encountered exception while trying to cleanup after test class: "
- + this.getDescription().getDisplayName(), e );
+ + this.getDescription().getDisplayName(), e );
notifier.fireTestFailure( new Failure( getDescription(), e ) );
}
}
@@ -94,14 +96,22 @@
@Override
- protected void invokeTestMethod( Method method, final RunNotifier notifier )
+ protected void runChild( FrameworkMethod method, RunNotifier notifier )
{
LOG.debug( "About to invoke test method {}", method.getName() );
- Description description = methodDescription( method );
- test( getTestClass(), wrapMethod( method ), notifier, new InheritableSettings( description, getSettings() ) );
+
+ Description description = describeChild( method );
+ if ( method.getAnnotation( Ignore.class ) != null )
+ {
+ notifier.fireTestIgnored( description );
+ return;
+ }
+
+ Statement statement = methodBlock( method );
+ test( getTestClass(), statement, notifier, new InheritableSettings( description, getSettings() ) );
Level cleanupLevel = getSettings().getCleanupLevel();
-
+
if ( cleanupLevel == Level.METHOD )
{
try
@@ -113,7 +123,7 @@
catch ( Exception e )
{
LOG.error( "Encountered exception while trying to cleanup after test class: "
- + this.getDescription().getDisplayName(), e );
+ + this.getDescription().getDisplayName(), e );
notifier.fireTestFailure( new Failure( getDescription(), e ) );
}
}
Modified: directory/apacheds/trunk/core-integ/src/main/java/org/apache/directory/server/core/integ/CiSuite.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/main/java/org/apache/directory/server/core/integ/CiSuite.java?rev=782036&r1=782035&r2=782036&view=diff
==============================================================================
--- directory/apacheds/trunk/core-integ/src/main/java/org/apache/directory/server/core/integ/CiSuite.java (original)
+++ directory/apacheds/trunk/core-integ/src/main/java/org/apache/directory/server/core/integ/CiSuite.java Fri Jun 5 15:02:20 2009
@@ -19,17 +19,15 @@
package org.apache.directory.server.core.integ;
-import java.util.List;
-
import static org.apache.directory.server.core.integ.state.TestServiceContext.cleanup;
import static org.apache.directory.server.core.integ.state.TestServiceContext.destroy;
import static org.apache.directory.server.core.integ.state.TestServiceContext.shutdown;
-import org.junit.internal.requests.IgnoredClassRunner;
-import org.junit.internal.runners.InitializationError;
-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;
+import org.junit.runners.model.RunnerBuilder;
/**
@@ -45,57 +43,13 @@
private InheritableSettings settings;
- public CiSuite( Class<?> clazz ) throws InitializationError
+ public CiSuite( Class<?> clazz, RunnerBuilder builder ) throws InitializationError
{
- super( clazz );
+ super( clazz, builder );
settings = new InheritableSettings( getDescription() );
}
- public void addAll( List<? extends Runner> runners )
- {
- for ( Runner runner : getRunners() )
- {
- if ( runner instanceof CiRunner )
- {
- CiRunner cir = ( CiRunner) runner;
- cir.setSuite( this );
- }
- else if ( runner instanceof IgnoredClassRunner )
- {
- // allow this one
- }
- else
- {
- throw new IllegalArgumentException( String.format( "Unexpected runner type \"%s\". " +
- "Test classes within CiSuites must use CiRunners.", runner ) );
- }
- }
-
- super.addAll( runners );
- }
-
-
- public void add( Runner runner )
- {
- if ( runner instanceof CiRunner )
- {
- CiRunner cir = ( CiRunner) runner;
- cir.setSuite( this );
- super.add( runner );
- }
- else if ( runner instanceof IgnoredClassRunner )
- {
- // allow this one
- }
- else
- {
- throw new IllegalArgumentException( String.format( "Unexpected runner type \"%s\". " +
- "Test classes within CiSuites must use CiRunners.", runner ) );
- }
- }
-
-
@Override
public void run( final RunNotifier notifier )
{
Modified: directory/apacheds/trunk/core-integ/src/main/java/org/apache/directory/server/core/integ/state/AbstractState.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/main/java/org/apache/directory/server/core/integ/state/AbstractState.java?rev=782036&r1=782035&r2=782036&view=diff
==============================================================================
--- directory/apacheds/trunk/core-integ/src/main/java/org/apache/directory/server/core/integ/state/AbstractState.java (original)
+++ directory/apacheds/trunk/core-integ/src/main/java/org/apache/directory/server/core/integ/state/AbstractState.java Fri Jun 5 15:02:20 2009
@@ -34,9 +34,11 @@
import org.apache.directory.server.core.integ.InheritableSettings;
import org.apache.directory.shared.ldap.ldif.LdifEntry;
import org.apache.directory.shared.ldap.ldif.LdifReader;
-import org.junit.internal.runners.TestClass;
-import org.junit.internal.runners.TestMethod;
+import org.junit.runner.Description;
+import org.junit.runner.notification.Failure;
import org.junit.runner.notification.RunNotifier;
+import org.junit.runners.model.Statement;
+import org.junit.runners.model.TestClass;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -147,12 +149,12 @@
* access to the method annotations below
*
* @param testClass the class whose test method is to be run
- * @param testMethod the test method which is to be run
+ * @param statement the test method which is to be run
* @param notifier a notifier to report failures to
* @param settings the inherited settings and annotations associated with
* the test method
*/
- public void test( TestClass testClass, TestMethod testMethod, RunNotifier notifier, InheritableSettings settings )
+ public void test( TestClass testClass, Statement statement, RunNotifier notifier, InheritableSettings settings )
{
}
@@ -237,4 +239,12 @@
}
}
}
+
+
+ protected void testAborted( RunNotifier notifier, Description description, Throwable cause )
+ {
+ notifier.fireTestStarted( description );
+ notifier.fireTestFailure( new Failure( description, cause ) );
+ notifier.fireTestFinished( description );
+ }
}
Modified: directory/apacheds/trunk/core-integ/src/main/java/org/apache/directory/server/core/integ/state/NonExistentState.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/main/java/org/apache/directory/server/core/integ/state/NonExistentState.java?rev=782036&r1=782035&r2=782036&view=diff
==============================================================================
--- directory/apacheds/trunk/core-integ/src/main/java/org/apache/directory/server/core/integ/state/NonExistentState.java (original)
+++ directory/apacheds/trunk/core-integ/src/main/java/org/apache/directory/server/core/integ/state/NonExistentState.java Fri Jun 5 15:02:20 2009
@@ -26,9 +26,9 @@
import org.apache.directory.server.core.integ.DirectoryServiceFactory;
import org.apache.directory.server.core.integ.InheritableSettings;
import static org.apache.directory.server.core.integ.IntegrationUtils.doDelete;
-import org.junit.internal.runners.TestClass;
-import org.junit.internal.runners.TestMethod;
import org.junit.runner.notification.RunNotifier;
+import org.junit.runners.model.Statement;
+import org.junit.runners.model.TestClass;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -130,16 +130,10 @@
*
* @see TestServiceState#test(TestClass, TestMethod, RunNotifier, InheritableSettings)
*/
- public void test( TestClass testClass, TestMethod testMethod, RunNotifier notifier, InheritableSettings settings )
+ public void test( TestClass testClass, Statement statement, RunNotifier notifier, InheritableSettings settings )
{
LOG.debug( "calling test(): {}, mode {}", settings.getDescription().getDisplayName(), settings.getMode() );
- if ( testMethod.isIgnored() )
- {
- // The test is ignored
- return;
- }
-
switch ( settings.getMode() )
{
case CUMULATIVE:
@@ -151,7 +145,7 @@
catch ( NamingException ne )
{
LOG.error( "Failed to create and start new server instance: " + ne );
- notifier.testAborted( settings.getDescription(), ne );
+ testAborted( notifier, settings.getDescription(), ne );
return;
}
@@ -162,13 +156,13 @@
catch ( Exception e )
{
LOG.error( "Failed to create and start new server instance: " + e );
- notifier.testAborted( settings.getDescription(), e );
+ testAborted( notifier, settings.getDescription(), e );
return;
}
context.setState( context.getStartedNormalState() );
- context.getState().test( testClass, testMethod, notifier, settings );
+ context.getState().test( testClass, statement, notifier, settings );
return;
@@ -181,7 +175,7 @@
catch ( NamingException ne )
{
LOG.error( "Failed to create and start new server instance: " + ne );
- notifier.testAborted( settings.getDescription(), ne );
+ testAborted( notifier, settings.getDescription(), ne );
return;
}
@@ -192,7 +186,7 @@
catch ( IOException ioe )
{
LOG.error( "Failed to create and start new server instance: " + ioe );
- notifier.testAborted( settings.getDescription(), ioe );
+ testAborted( notifier, settings.getDescription(), ioe );
return;
}
@@ -203,12 +197,12 @@
catch ( Exception e )
{
LOG.error( "Failed to create and start new server instance: " + e );
- notifier.testAborted( settings.getDescription(), e );
+ testAborted( notifier, settings.getDescription(), e );
return;
}
context.setState( context.getStartedPristineState() );
- context.getState().test( testClass, testMethod, notifier, settings );
+ context.getState().test( testClass, statement, notifier, settings );
return;
default:
Modified: directory/apacheds/trunk/core-integ/src/main/java/org/apache/directory/server/core/integ/state/StartedNormalState.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/main/java/org/apache/directory/server/core/integ/state/StartedNormalState.java?rev=782036&r1=782035&r2=782036&view=diff
==============================================================================
--- directory/apacheds/trunk/core-integ/src/main/java/org/apache/directory/server/core/integ/state/StartedNormalState.java (original)
+++ directory/apacheds/trunk/core-integ/src/main/java/org/apache/directory/server/core/integ/state/StartedNormalState.java Fri Jun 5 15:02:20 2009
@@ -23,9 +23,9 @@
import org.apache.directory.server.core.integ.InheritableSettings;
import static org.apache.directory.server.core.integ.IntegrationUtils.doDelete;
-import org.junit.internal.runners.TestClass;
-import org.junit.internal.runners.TestMethod;
import org.junit.runner.notification.RunNotifier;
+import org.junit.runners.model.Statement;
+import org.junit.runners.model.TestClass;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -132,21 +132,15 @@
* access to the method annotations below
*
* @param testClass the class whose test method is to be run
- * @param testMethod the test method which is to be run
+ * @param statement the test method which is to be run
* @param notifier a notifier to report failures to
* @param settings the inherited settings and annotations associated with
* the test method
*/
- public void test( TestClass testClass, TestMethod testMethod, RunNotifier notifier, InheritableSettings settings )
+ public void test( TestClass testClass, Statement statement, RunNotifier notifier, InheritableSettings settings )
{
LOG.debug( "calling test(): {}, mode {}", settings.getDescription().getDisplayName(), settings.getMode() );
- if ( testMethod.isIgnored() )
- {
- // The test is ignored
- return;
- }
-
switch ( settings.getMode() )
{
case ROLLBACK:
@@ -159,14 +153,14 @@
// @TODO - we might want to check the revision of the service before
// we presume that it has been soiled. Some tests may simply perform
// some read operations or checks on the service and may not alter it
- notifier.testAborted( settings.getDescription(), e );
+ testAborted( notifier, settings.getDescription(), e );
return;
}
// Inject the LDIFs, if any
injectLdifs( context.getService(), settings );
- TestServiceContext.invokeTest( testClass, testMethod, notifier, settings.getDescription() );
+ TestServiceContext.invokeTest( testClass, statement, notifier, settings.getDescription() );
try
{
@@ -177,7 +171,7 @@
// @TODO - we might want to check the revision of the service before
// we presume that it has been soiled. Some tests may simply perform
// some read operations or checks on the service and may not alter it
- notifier.testAborted( settings.getDescription(), e );
+ testAborted( notifier, settings.getDescription(), e );
return;
}
@@ -188,7 +182,7 @@
injectLdifs( context.getService(), settings );
- TestServiceContext.invokeTest( testClass, testMethod, notifier, settings.getDescription() );
+ TestServiceContext.invokeTest( testClass, statement, notifier, settings.getDescription() );
try
{
@@ -199,7 +193,7 @@
// @TODO - we might want to check the revision of the service before
// we presume that it has been soiled. Some tests may simply perform
// some read operations or checks on the service and may not alter it
- notifier.testAborted( settings.getDescription(), e );
+ testAborted( notifier, settings.getDescription(), e );
return;
}
@@ -210,7 +204,7 @@
catch ( Exception e )
{
LOG.error( "Failed to create and start new server instance: " + e );
- notifier.testAborted( settings.getDescription(), e );
+ testAborted( notifier, settings.getDescription(), e );
return;
}
Modified: directory/apacheds/trunk/core-integ/src/main/java/org/apache/directory/server/core/integ/state/StartedPristineState.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/main/java/org/apache/directory/server/core/integ/state/StartedPristineState.java?rev=782036&r1=782035&r2=782036&view=diff
==============================================================================
--- directory/apacheds/trunk/core-integ/src/main/java/org/apache/directory/server/core/integ/state/StartedPristineState.java (original)
+++ directory/apacheds/trunk/core-integ/src/main/java/org/apache/directory/server/core/integ/state/StartedPristineState.java Fri Jun 5 15:02:20 2009
@@ -23,9 +23,9 @@
import org.apache.directory.server.core.integ.InheritableSettings;
import static org.apache.directory.server.core.integ.IntegrationUtils.doDelete;
-import org.junit.internal.runners.TestClass;
-import org.junit.internal.runners.TestMethod;
import org.junit.runner.notification.RunNotifier;
+import org.junit.runners.model.Statement;
+import org.junit.runners.model.TestClass;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -115,28 +115,22 @@
* access to the method annotations below
*
* @param testClass the class whose test method is to be run
- * @param testMethod the test method which is to be run
+ * @param statement the test method which is to be run
* @param notifier a notifier to report failures to
* @param settings the inherited settings and annotations associated with
* the test method
*/
- public void test( TestClass testClass, TestMethod testMethod, RunNotifier notifier, InheritableSettings settings )
+ public void test( TestClass testClass, Statement statement, RunNotifier notifier, InheritableSettings settings )
{
LOG.debug( "calling test(): {}, mode {}", settings.getDescription().getDisplayName(), settings.getMode() );
- if ( testMethod.isIgnored() )
- {
- // The test is ignored
- return;
- }
-
switch ( settings.getMode() )
{
case PRISTINE:
// Inject the LDIFs, if any
injectLdifs( context.getService(), settings );
- TestServiceContext.invokeTest( testClass, testMethod, notifier, settings.getDescription() );
+ TestServiceContext.invokeTest( testClass, statement, notifier, settings.getDescription() );
try
{
@@ -147,7 +141,7 @@
// @TODO - we might want to check the revision of the service before
// we presume that it has been soiled. Some tests may simply perform
// some read operations or checks on the service and may not alter it
- notifier.testAborted( settings.getDescription(), e );
+ testAborted( notifier, settings.getDescription(), e );
return;
}
@@ -158,7 +152,7 @@
catch ( IOException ioe )
{
LOG.error( "Failed to cleanup new server instance: " + ioe );
- notifier.testAborted( settings.getDescription(), ioe );
+ testAborted( notifier, settings.getDescription(), ioe );
return;
}
@@ -176,14 +170,14 @@
// @TODO - we might want to check the revision of the service before
// we presume that it has been soiled. Some tests may simply perform
// some read operations or checks on the service and may not alter it
- notifier.testAborted( settings.getDescription(), e );
+ testAborted( notifier, settings.getDescription(), e );
return;
}
// Inject the LDIFs, if any
injectLdifs( context.getService(), settings );
- TestServiceContext.invokeTest( testClass, testMethod, notifier, settings.getDescription() );
+ TestServiceContext.invokeTest( testClass, statement, notifier, settings.getDescription() );
context.setState( context.getStartedNormalState() );
try
@@ -195,7 +189,7 @@
// @TODO - we might want to check the revision of the service before
// we presume that it has been soiled. Some tests may simply perform
// some read operations or checks on the service and may not alter it
- notifier.testAborted( settings.getDescription(), e );
+ testAborted( notifier, settings.getDescription(), e );
return;
}
return;
Modified: directory/apacheds/trunk/core-integ/src/main/java/org/apache/directory/server/core/integ/state/TestServiceContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/main/java/org/apache/directory/server/core/integ/state/TestServiceContext.java?rev=782036&r1=782035&r2=782036&view=diff
==============================================================================
--- directory/apacheds/trunk/core-integ/src/main/java/org/apache/directory/server/core/integ/state/TestServiceContext.java (original)
+++ directory/apacheds/trunk/core-integ/src/main/java/org/apache/directory/server/core/integ/state/TestServiceContext.java Fri Jun 5 15:02:20 2009
@@ -26,11 +26,11 @@
import org.apache.directory.server.core.DirectoryService;
import org.apache.directory.server.core.integ.InheritableSettings;
-import org.junit.internal.runners.MethodRoadie;
-import org.junit.internal.runners.TestClass;
-import org.junit.internal.runners.TestMethod;
import org.junit.runner.Description;
+import org.junit.runner.notification.Failure;
import org.junit.runner.notification.RunNotifier;
+import org.junit.runners.model.Statement;
+import org.junit.runners.model.TestClass;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -174,16 +174,16 @@
* Action where an attempt is made to run a test against the service.
*
* @param testClass the class whose test method is to be run
- * @param testMethod the test method which is to be run
+ * @param statement the test method which is to be run
* @param notifier a notifier to report failures to
* @param settings the inherited settings and annotations associated with
* the test method
*/
- public static void test( TestClass testClass, TestMethod testMethod, RunNotifier notifier,
+ public static void test( TestClass testClass, Statement statement, RunNotifier notifier,
InheritableSettings settings )
{
LOG.debug( "calling test(): {}", settings.getDescription().getDisplayName() );
- get().getState().test( testClass, testMethod, notifier, settings );
+ get().getState().test( testClass, statement, notifier, settings );
}
@@ -200,43 +200,51 @@
}
- static void invokeTest( TestClass testClass, TestMethod testMethod, RunNotifier notifier, Description description )
+ static void invokeTest( TestClass testClass, Statement statement, RunNotifier notifier, Description description )
{
try
{
- Object test = testClass.getConstructor().newInstance();
Field field = testClass.getJavaClass().getDeclaredField( "service" );
field.set( testClass.getJavaClass(), get().getService() );
- new MethodRoadie( test, testMethod, notifier, description ).run();
+
+ notifier.fireTestStarted( description );
+ statement.evaluate();
+ notifier.fireTestFinished( description );
}
catch ( InvocationTargetException e )
{
LOG.error( "Failed to invoke test method: " + description.getDisplayName(), e.getCause() );
- notifier.testAborted( description, e.getCause() );
+ testAborted( notifier, description, e.getCause() );
return;
}
catch ( InstantiationException ie )
{
LOG.error( "Failed to invoke test method: " + description.getDisplayName(), ie );
- notifier.testAborted( description, ie );
+ testAborted( notifier, description, ie );
return;
}
catch ( IllegalAccessException iae )
{
LOG.error( "Failed to invoke test method: " + description.getDisplayName(), iae );
- notifier.testAborted( description, iae );
+ testAborted( notifier, description, iae );
return;
}
catch ( NoSuchMethodException nsme )
{
LOG.error( "Failed to invoke test method: " + description.getDisplayName(), nsme );
- notifier.testAborted( description, nsme );
+ testAborted( notifier, description, nsme );
return;
}
catch ( NoSuchFieldException nsfe )
{
LOG.error( "Failed to invoke test method: " + description.getDisplayName(), nsfe );
- notifier.testAborted( description, nsfe );
+ testAborted( notifier, description, nsfe );
+ return;
+ }
+ catch ( Throwable t )
+ {
+ LOG.error( "Failed to invoke test method: " + description.getDisplayName(), t );
+ testAborted( notifier, description, t );
return;
}
}
@@ -287,4 +295,12 @@
{
this.service = service;
}
+
+
+ private static void testAborted( RunNotifier notifier, Description description, Throwable cause )
+ {
+ notifier.fireTestStarted( description );
+ notifier.fireTestFailure( new Failure( description, cause ) );
+ notifier.fireTestFinished( description );
+ }
}
Modified: directory/apacheds/trunk/core-integ/src/main/java/org/apache/directory/server/core/integ/state/TestServiceState.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/main/java/org/apache/directory/server/core/integ/state/TestServiceState.java?rev=782036&r1=782035&r2=782036&view=diff
==============================================================================
--- directory/apacheds/trunk/core-integ/src/main/java/org/apache/directory/server/core/integ/state/TestServiceState.java (original)
+++ directory/apacheds/trunk/core-integ/src/main/java/org/apache/directory/server/core/integ/state/TestServiceState.java Fri Jun 5 15:02:20 2009
@@ -19,12 +19,13 @@
package org.apache.directory.server.core.integ.state;
import java.io.IOException;
+
import javax.naming.NamingException;
import org.apache.directory.server.core.integ.InheritableSettings;
-import org.junit.internal.runners.TestClass;
-import org.junit.internal.runners.TestMethod;
import org.junit.runner.notification.RunNotifier;
+import org.junit.runners.model.Statement;
+import org.junit.runners.model.TestClass;
/**
@@ -90,12 +91,12 @@
* access to the method annotations below
*
* @param testClass the class whose test method is to be run
- * @param testMethod the test method which is to be run
+ * @param statement the test method which is to be run
* @param notifier a notifier to report failures to
* @param settings the inherited settings and annotations associated with
* the test method
*/
- void test( TestClass testClass, TestMethod testMethod, RunNotifier notifier, InheritableSettings settings );
+ void test( TestClass testClass, Statement statement, RunNotifier notifier, InheritableSettings settings );
/**
Modified: directory/apacheds/trunk/pom.xml
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/pom.xml?rev=782036&r1=782035&r2=782036&view=diff
==============================================================================
--- directory/apacheds/trunk/pom.xml (original)
+++ directory/apacheds/trunk/pom.xml Fri Jun 5 15:02:20 2009
@@ -171,7 +171,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
- <version>4.4</version>
+ <version>4.5</version>
</dependency>
<dependency>
Modified: directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/SiRunner.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/SiRunner.java?rev=782036&r1=782035&r2=782036&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/SiRunner.java (original)
+++ directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/SiRunner.java Fri Jun 5 15:02:20 2009
@@ -19,19 +19,20 @@
package org.apache.directory.server.integ;
-import java.lang.reflect.Method;
-
import static org.apache.directory.server.integ.state.TestServerContext.cleanup;
import static org.apache.directory.server.integ.state.TestServerContext.destroy;
import static org.apache.directory.server.integ.state.TestServerContext.shutdown;
import static org.apache.directory.server.integ.state.TestServerContext.test;
import org.apache.directory.server.core.integ.Level;
-import org.junit.internal.runners.InitializationError;
-import org.junit.internal.runners.JUnit4ClassRunner;
+import org.junit.Ignore;
import org.junit.runner.Description;
import org.junit.runner.notification.Failure;
import org.junit.runner.notification.RunNotifier;
+import org.junit.runners.BlockJUnit4ClassRunner;
+import org.junit.runners.model.FrameworkMethod;
+import org.junit.runners.model.InitializationError;
+import org.junit.runners.model.Statement;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -42,7 +43,7 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$, $Date$
*/
-public class SiRunner extends JUnit4ClassRunner
+public class SiRunner extends BlockJUnit4ClassRunner
{
private static final Logger LOG = LoggerFactory.getLogger( SiRunner.class );
private SiSuite suite;
@@ -76,7 +77,7 @@
{
super.run( notifier );
Level cleanupLevel = getSettings().getCleanupLevel();
-
+
if ( cleanupLevel == Level.CLASS )
{
try
@@ -88,7 +89,7 @@
catch ( Exception e )
{
LOG.error( "Encountered exception while trying to cleanup after test class: "
- + this.getDescription().getDisplayName(), e );
+ + this.getDescription().getDisplayName(), e );
notifier.fireTestFailure( new Failure( getDescription(), e ) );
}
}
@@ -96,14 +97,22 @@
@Override
- protected void invokeTestMethod( Method method, final RunNotifier notifier )
+ protected void runChild( FrameworkMethod method, RunNotifier notifier )
{
LOG.debug( "About to invoke test method {}", method.getName() );
- Description description = methodDescription( method );
- test( getTestClass(), wrapMethod( method ), notifier, new InheritableServerSettings( description, getSettings() ) );
+
+ Description description = describeChild( method );
+ if ( method.getAnnotation( Ignore.class ) != null )
+ {
+ notifier.fireTestIgnored( description );
+ return;
+ }
+
+ Statement statement = methodBlock( method );
+ test( getTestClass(), statement, notifier, new InheritableServerSettings( description, getSettings() ) );
Level cleanupLevel = getSettings().getCleanupLevel();
-
+
if ( cleanupLevel == Level.METHOD )
{
try
@@ -115,7 +124,7 @@
catch ( Exception e )
{
LOG.error( "Encountered exception while trying to cleanup after test class: "
- + this.getDescription().getDisplayName(), e );
+ + this.getDescription().getDisplayName(), e );
notifier.fireTestFailure( new Failure( getDescription(), e ) );
}
}
Modified: directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/SiSuite.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/SiSuite.java?rev=782036&r1=782035&r2=782036&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/SiSuite.java (original)
+++ directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/SiSuite.java Fri Jun 5 15:02:20 2009
@@ -19,19 +19,16 @@
package org.apache.directory.server.integ;
-import java.util.List;
-
import static org.apache.directory.server.integ.state.TestServerContext.cleanup;
import static org.apache.directory.server.integ.state.TestServerContext.destroy;
import static org.apache.directory.server.integ.state.TestServerContext.shutdown;
import org.apache.directory.server.core.integ.Level;
-import org.junit.internal.requests.IgnoredClassRunner;
-import org.junit.internal.runners.InitializationError;
-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;
+import org.junit.runners.model.RunnerBuilder;
/**
@@ -44,60 +41,16 @@
*/
public class SiSuite extends Suite
{
- private InheritableServerSettings settings;
+ private InheritableServerSettings settings = new InheritableServerSettings( getDescription() );
- public SiSuite( Class<?> clazz ) throws InitializationError
+ public SiSuite( Class<?> clazz, RunnerBuilder builder ) throws InitializationError
{
- super( clazz );
+ super( clazz, builder );
settings = new InheritableServerSettings( getDescription() );
}
- public void addAll( List<? extends Runner> runners )
- {
- for ( Runner runner : getRunners() )
- {
- if ( runner instanceof SiRunner )
- {
- SiRunner cir = ( SiRunner) runner;
- cir.setSuite( this );
- }
- else if ( runner instanceof IgnoredClassRunner )
- {
- // allow this one
- }
- else
- {
- throw new IllegalArgumentException( String.format( "Unexpected runner type \"%s\". " +
- "Test classes within CiSuites must use CiRunners.", runner ) );
- }
- }
-
- super.addAll( runners );
- }
-
-
- public void add( Runner runner )
- {
- if ( runner instanceof SiRunner )
- {
- SiRunner cir = ( SiRunner) runner;
- cir.setSuite( this );
- super.add( runner );
- }
- else if ( runner instanceof IgnoredClassRunner )
- {
- // allow this one
- }
- else
- {
- throw new IllegalArgumentException( String.format( "Unexpected runner type \"%s\". " +
- "Test classes within CiSuites must use CiRunners.", runner ) );
- }
- }
-
-
@Override
public void run( final RunNotifier notifier )
{
Modified: directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/state/AbstractState.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/state/AbstractState.java?rev=782036&r1=782035&r2=782036&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/state/AbstractState.java (original)
+++ directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/state/AbstractState.java Fri Jun 5 15:02:20 2009
@@ -33,9 +33,11 @@
import org.apache.directory.server.integ.InheritableServerSettings;
import org.apache.directory.shared.ldap.ldif.LdifEntry;
import org.apache.directory.shared.ldap.ldif.LdifReader;
-import org.junit.internal.runners.TestClass;
-import org.junit.internal.runners.TestMethod;
+import org.junit.runner.Description;
+import org.junit.runner.notification.Failure;
import org.junit.runner.notification.RunNotifier;
+import org.junit.runners.model.Statement;
+import org.junit.runners.model.TestClass;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -146,12 +148,12 @@
* access to the method annotations below
*
* @param testClass the class whose test method is to be run
- * @param testMethod the test method which is to be run
+ * @param statement the test method which is to be run
* @param notifier a notifier to report failures to
* @param settings the inherited settings and annotations associated with
* the test method
*/
- public void test( TestClass testClass, TestMethod testMethod, RunNotifier notifier, InheritableServerSettings settings )
+ public void test( TestClass testClass, Statement statement, RunNotifier notifier, InheritableServerSettings settings )
{
}
@@ -248,4 +250,12 @@
}
}
}
+
+
+ protected void testAborted( RunNotifier notifier, Description description, Throwable cause )
+ {
+ notifier.fireTestStarted( description );
+ notifier.fireTestFailure( new Failure( description, cause ) );
+ notifier.fireTestFinished( description );
+ }
}
Modified: directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/state/NonExistentState.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/state/NonExistentState.java?rev=782036&r1=782035&r2=782036&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/state/NonExistentState.java (original)
+++ directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/state/NonExistentState.java Fri Jun 5 15:02:20 2009
@@ -19,16 +19,17 @@
package org.apache.directory.server.integ.state;
+import static org.apache.directory.server.core.integ.IntegrationUtils.doDelete;
+
import java.io.IOException;
import javax.naming.NamingException;
-import org.apache.directory.server.integ.LdapServerFactory;
import org.apache.directory.server.integ.InheritableServerSettings;
-import static org.apache.directory.server.core.integ.IntegrationUtils.doDelete;
-import org.junit.internal.runners.TestClass;
-import org.junit.internal.runners.TestMethod;
+import org.apache.directory.server.integ.LdapServerFactory;
import org.junit.runner.notification.RunNotifier;
+import org.junit.runners.model.Statement;
+import org.junit.runners.model.TestClass;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -132,16 +133,10 @@
*
* @see TestServerState#test(TestClass, TestMethod, RunNotifier, InheritableServerSettings)
*/
- public void test( TestClass testClass, TestMethod testMethod, RunNotifier notifier, InheritableServerSettings settings )
+ public void test( TestClass testClass, Statement statement, RunNotifier notifier, InheritableServerSettings settings )
{
LOG.debug( "calling test(): {}, mode {}", settings.getDescription().getDisplayName(), settings.getMode() );
- if ( testMethod.isIgnored() )
- {
- // The test is ignored
- return;
- }
-
switch ( settings.getMode() )
{
case CUMULATIVE:
@@ -153,7 +148,7 @@
catch ( NamingException ne )
{
LOG.error( "Failed to create and start new server instance: " + ne );
- notifier.testAborted( settings.getDescription(), ne );
+ testAborted( notifier, settings.getDescription(), ne );
return;
}
@@ -164,13 +159,13 @@
catch ( Exception e )
{
LOG.error( "Failed to create and start new server instance: " + e );
- notifier.testAborted( settings.getDescription(), e );
+ testAborted( notifier, settings.getDescription(), e );
return;
}
context.setState( context.getStartedNormalState() );
- context.getState().test( testClass, testMethod, notifier, settings );
+ context.getState().test( testClass, statement, notifier, settings );
return;
@@ -183,7 +178,7 @@
catch ( NamingException ne )
{
LOG.error( "Failed to create and start new server instance: " + ne );
- notifier.testAborted( settings.getDescription(), ne );
+ testAborted( notifier, settings.getDescription(), ne );
return;
}
@@ -194,7 +189,7 @@
catch ( IOException ioe )
{
LOG.error( "Failed to create and start new server instance: " + ioe );
- notifier.testAborted( settings.getDescription(), ioe );
+ testAborted( notifier, settings.getDescription(), ioe );
return;
}
@@ -205,12 +200,12 @@
catch ( Exception e )
{
LOG.error( "Failed to create and start new server instance: " + e );
- notifier.testAborted( settings.getDescription(), e );
+ testAborted( notifier, settings.getDescription(), e );
return;
}
context.setState( context.getStartedPristineState() );
- context.getState().test( testClass, testMethod, notifier, settings );
+ context.getState().test( testClass, statement, notifier, settings );
return;
default:
Modified: directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/state/StartedNormalState.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/state/StartedNormalState.java?rev=782036&r1=782035&r2=782036&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/state/StartedNormalState.java (original)
+++ directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/state/StartedNormalState.java Fri Jun 5 15:02:20 2009
@@ -19,13 +19,14 @@
package org.apache.directory.server.integ.state;
+import static org.apache.directory.server.core.integ.IntegrationUtils.doDelete;
+
import java.io.IOException;
import org.apache.directory.server.integ.InheritableServerSettings;
-import static org.apache.directory.server.core.integ.IntegrationUtils.doDelete;
-import org.junit.internal.runners.TestClass;
-import org.junit.internal.runners.TestMethod;
import org.junit.runner.notification.RunNotifier;
+import org.junit.runners.model.Statement;
+import org.junit.runners.model.TestClass;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -135,21 +136,15 @@
* access to the method annotations below
*
* @param testClass the class whose test method is to be run
- * @param testMethod the test method which is to be run
+ * @param statement the test method which is to be run
* @param notifier a notifier to report failures to
* @param settings the inherited settings and annotations associated with
* the test method
*/
- public void test( TestClass testClass, TestMethod testMethod, RunNotifier notifier, InheritableServerSettings settings )
+ public void test( TestClass testClass, Statement statement, RunNotifier notifier, InheritableServerSettings settings )
{
LOG.debug( "calling test(): {}, mode {}", settings.getDescription().getDisplayName(), settings.getMode() );
- if ( testMethod.isIgnored() )
- {
- // The test is ignored
- return;
- }
-
switch ( settings.getMode() )
{
case ROLLBACK:
@@ -165,11 +160,11 @@
// @TODO - we might want to check the revision of the service before
// we presume that it has been soiled. Some tests may simply perform
// some read operations or checks on the service and may not alter it
- notifier.testAborted( settings.getDescription(), e );
+ testAborted( notifier, settings.getDescription(), e );
return;
}
- TestServerContext.invokeTest( testClass, testMethod, notifier, settings.getDescription() );
+ TestServerContext.invokeTest( testClass, statement, notifier, settings.getDescription() );
try
{
@@ -180,7 +175,7 @@
// @TODO - we might want to check the revision of the service before
// we presume that it has been soiled. Some tests may simply perform
// some read operations or checks on the service and may not alter it
- notifier.testAborted( settings.getDescription(), e );
+ testAborted( notifier, settings.getDescription(), e );
return;
}
@@ -197,11 +192,11 @@
// @TODO - we might want to check the revision of the service before
// we presume that it has been soiled. Some tests may simply perform
// some read operations or checks on the service and may not alter it
- notifier.testAborted( settings.getDescription(), e );
+ testAborted( notifier, settings.getDescription(), e );
return;
}
- TestServerContext.invokeTest( testClass, testMethod, notifier, settings.getDescription() );
+ TestServerContext.invokeTest( testClass, statement, notifier, settings.getDescription() );
try
{
@@ -212,7 +207,7 @@
// @TODO - we might want to check the revision of the service before
// we presume that it has been soiled. Some tests may simply perform
// some read operations or checks on the service and may not alter it
- notifier.testAborted( settings.getDescription(), e );
+ testAborted( notifier, settings.getDescription(), e );
return;
}
@@ -223,7 +218,7 @@
catch ( Exception e )
{
LOG.error( "Failed to create and start new server instance: " + e );
- notifier.testAborted( settings.getDescription(), e );
+ testAborted( notifier, settings.getDescription(), e );
return;
}
Modified: directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/state/StartedPristineState.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/state/StartedPristineState.java?rev=782036&r1=782035&r2=782036&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/state/StartedPristineState.java (original)
+++ directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/state/StartedPristineState.java Fri Jun 5 15:02:20 2009
@@ -19,15 +19,15 @@
package org.apache.directory.server.integ.state;
+import static org.apache.directory.server.core.integ.IntegrationUtils.doDelete;
+
import java.io.IOException;
import org.apache.directory.server.integ.InheritableServerSettings;
import org.apache.directory.server.ldap.LdapService;
-
-import static org.apache.directory.server.core.integ.IntegrationUtils.doDelete;
-import org.junit.internal.runners.TestClass;
-import org.junit.internal.runners.TestMethod;
import org.junit.runner.notification.RunNotifier;
+import org.junit.runners.model.Statement;
+import org.junit.runners.model.TestClass;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -121,21 +121,15 @@
* access to the method annotations below
*
* @param testClass the class whose test method is to be run
- * @param testMethod the test method which is to be run
+ * @param statement the test method which is to be run
* @param notifier a notifier to report failures to
* @param settings the inherited settings and annotations associated with
* the test method
*/
- public void test( TestClass testClass, TestMethod testMethod, RunNotifier notifier, InheritableServerSettings settings )
+ public void test( TestClass testClass, Statement statement, RunNotifier notifier, InheritableServerSettings settings )
{
LOG.debug( "calling test(): {}, mode {}", settings.getDescription().getDisplayName(), settings.getMode() );
- if ( testMethod.isIgnored() )
- {
- // The test is ignored
- return;
- }
-
switch ( settings.getMode() )
{
case PRISTINE:
@@ -149,11 +143,11 @@
// @TODO - we might want to check the revision of the service before
// we presume that it has been soiled. Some tests may simply perform
// some read operations or checks on the service and may not alter it
- notifier.testAborted( settings.getDescription(), e );
+ testAborted( notifier, settings.getDescription(), e );
return;
}
- TestServerContext.invokeTest( testClass, testMethod, notifier, settings.getDescription() );
+ TestServerContext.invokeTest( testClass, statement, notifier, settings.getDescription() );
try
{
@@ -164,7 +158,7 @@
// @TODO - we might want to check the revision of the service before
// we presume that it has been soiled. Some tests may simply perform
// some read operations or checks on the service and may not alter it
- notifier.testAborted( settings.getDescription(), e );
+ testAborted( notifier, settings.getDescription(), e );
return;
}
@@ -175,7 +169,7 @@
catch ( IOException ioe )
{
LOG.error( "Failed to cleanup new server instance: " + ioe );
- notifier.testAborted( settings.getDescription(), ioe );
+ testAborted( notifier, settings.getDescription(), ioe );
return;
}
@@ -196,11 +190,11 @@
// @TODO - we might want to check the revision of the service before
// we presume that it has been soiled. Some tests may simply perform
// some read operations or checks on the service and may not alter it
- notifier.testAborted( settings.getDescription(), e );
+ testAborted( notifier, settings.getDescription(), e );
return;
}
- TestServerContext.invokeTest( testClass, testMethod, notifier, settings.getDescription() );
+ TestServerContext.invokeTest( testClass, statement, notifier, settings.getDescription() );
context.setState( context.getStartedNormalState() );
try
@@ -212,7 +206,7 @@
// @TODO - we might want to check the revision of the service before
// we presume that it has been soiled. Some tests may simply perform
// some read operations or checks on the service and may not alter it
- notifier.testAborted( settings.getDescription(), e );
+ testAborted( notifier, settings.getDescription(), e );
return;
}
return;
Modified: directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/state/TestServerContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/state/TestServerContext.java?rev=782036&r1=782035&r2=782036&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/state/TestServerContext.java (original)
+++ directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/state/TestServerContext.java Fri Jun 5 15:02:20 2009
@@ -27,11 +27,11 @@
import org.apache.directory.server.integ.InheritableServerSettings;
import org.apache.directory.server.ldap.LdapService;
-import org.junit.internal.runners.MethodRoadie;
-import org.junit.internal.runners.TestClass;
-import org.junit.internal.runners.TestMethod;
import org.junit.runner.Description;
+import org.junit.runner.notification.Failure;
import org.junit.runner.notification.RunNotifier;
+import org.junit.runners.model.Statement;
+import org.junit.runners.model.TestClass;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -180,17 +180,17 @@
* Action where an attempt is made to run a test against the service.
*
* @param testClass the class whose test method is to be run
- * @param testMethod the test method which is to be run
+ * @param statement the test method which is to be run
* @param notifier a notifier to report failures to
* @param settings the inherited settings and annotations associated with
* the test method
*/
- public static void test( TestClass testClass, TestMethod testMethod, RunNotifier notifier,
+ public static void test( TestClass testClass, Statement statement, RunNotifier notifier,
InheritableServerSettings settings )
{
LOG.debug( "calling test(): {}", settings.getDescription().getDisplayName() );
TestServerState state = getServerContext().getState();
- state.test( testClass, testMethod, notifier, settings );
+ state.test( testClass, statement, notifier, settings );
}
@@ -208,43 +208,51 @@
}
- static void invokeTest( TestClass testClass, TestMethod testMethod, RunNotifier notifier, Description description )
+ static void invokeTest( TestClass testClass, Statement statement, RunNotifier notifier, Description description )
{
try
{
- Object test = testClass.getConstructor().newInstance();
Field field = testClass.getJavaClass().getDeclaredField( "ldapService" );
field.set( testClass.getJavaClass(), getServerContext().getLdapServer() );
- new MethodRoadie( test, testMethod, notifier, description ).run();
+
+ notifier.fireTestStarted( description );
+ statement.evaluate();
+ notifier.fireTestFinished( description );
}
catch ( InvocationTargetException e )
{
LOG.error( "Failed to invoke test method: " + description.getDisplayName(), e.getCause() );
- notifier.testAborted( description, e.getCause() );
+ testAborted( notifier, description, e.getCause() );
return;
}
catch ( InstantiationException ie )
{
LOG.error( "Failed to invoke test method: " + description.getDisplayName(), ie );
- notifier.testAborted( description, ie );
+ testAborted( notifier, description, ie );
return;
}
catch ( IllegalAccessException iae )
{
LOG.error( "Failed to invoke test method: " + description.getDisplayName(), iae );
- notifier.testAborted( description, iae );
+ testAborted( notifier, description, iae );
return;
}
catch ( NoSuchMethodException nsme )
{
LOG.error( "Failed to invoke test method: " + description.getDisplayName(), nsme );
- notifier.testAborted( description, nsme );
+ testAborted( notifier, description, nsme );
return;
}
catch ( NoSuchFieldException nsfe )
{
LOG.error( "Failed to invoke test method: " + description.getDisplayName(), nsfe );
- notifier.testAborted( description, nsfe );
+ testAborted( notifier, description, nsfe );
+ return;
+ }
+ catch ( Throwable t )
+ {
+ LOG.error( "Failed to invoke test method: " + description.getDisplayName(), t );
+ testAborted( notifier, description, t );
return;
}
}
@@ -295,4 +303,12 @@
{
this.ldapService = ldapService;
}
+
+
+ private static void testAborted( RunNotifier notifier, Description description, Throwable cause )
+ {
+ notifier.fireTestStarted( description );
+ notifier.fireTestFailure( new Failure( description, cause ) );
+ notifier.fireTestFinished( description );
+ }
}
Modified: directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/state/TestServerState.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/state/TestServerState.java?rev=782036&r1=782035&r2=782036&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/state/TestServerState.java (original)
+++ directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/state/TestServerState.java Fri Jun 5 15:02:20 2009
@@ -23,9 +23,9 @@
import javax.naming.NamingException;
import org.apache.directory.server.integ.InheritableServerSettings;
-import org.junit.internal.runners.TestClass;
-import org.junit.internal.runners.TestMethod;
import org.junit.runner.notification.RunNotifier;
+import org.junit.runners.model.Statement;
+import org.junit.runners.model.TestClass;
/**
@@ -91,12 +91,12 @@
* access to the method annotations below
*
* @param testClass the class whose test method is to be run
- * @param testMethod the test method which is to be run
+ * @param statement the test method which is to be run
* @param notifier a notifier to report failures to
* @param settings the inherited settings and annotations associated with
* the test method
*/
- void test( TestClass testClass, TestMethod testMethod, RunNotifier notifier, InheritableServerSettings settings );
+ void test( TestClass testClass, Statement statement, RunNotifier notifier, InheritableServerSettings settings );
/**
Modified: directory/daemon/trunk/pom.xml
URL: http://svn.apache.org/viewvc/directory/daemon/trunk/pom.xml?rev=782036&r1=782035&r2=782036&view=diff
==============================================================================
--- directory/daemon/trunk/pom.xml (original)
+++ directory/daemon/trunk/pom.xml Fri Jun 5 15:02:20 2009
@@ -73,7 +73,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
- <version>4.4</version>
+ <version>4.5</version>
</dependency>
<dependency>
Modified: directory/installers/trunk/pom.xml
URL: http://svn.apache.org/viewvc/directory/installers/trunk/pom.xml?rev=782036&r1=782035&r2=782036&view=diff
==============================================================================
--- directory/installers/trunk/pom.xml (original)
+++ directory/installers/trunk/pom.xml Fri Jun 5 15:02:20 2009
@@ -276,7 +276,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
- <version>4.4</version>
+ <version>4.5</version>
</dependency>
<dependency>
Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ACIItemChekerTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ACIItemChekerTest.java?rev=782036&r1=782035&r2=782036&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ACIItemChekerTest.java (original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ACIItemChekerTest.java Fri Jun 5 15:02:20 2009
@@ -55,15 +55,6 @@
/**
- * Creates a ACIItemParserTest instance.
- */
- public ACIItemChekerTest(String s)
- {
- checker = new ACIItemChecker();
- }
-
-
- /**
* Tests the checker with an ACIItem of ItemFirst main component.
*/
@Test
Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ACIItemParserTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ACIItemParserTest.java?rev=782036&r1=782035&r2=782036&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ACIItemParserTest.java (original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ACIItemParserTest.java Fri Jun 5 15:02:20 2009
@@ -51,15 +51,6 @@
}
- /**
- * Creates a ACIItemParserTest instance.
- */
- public ACIItemParserTest( String s )
- {
- parser = new ACIItemParser( null );
- }
-
-
private void checkItemToString( String spec, ACIItem item ) throws Exception
{
// try to parse the result of item.toString() again
Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/subtree/SubtreeSpecificationParserTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/subtree/SubtreeSpecificationParserTest.java?rev=782036&r1=782035&r2=782036&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/subtree/SubtreeSpecificationParserTest.java (original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/subtree/SubtreeSpecificationParserTest.java Fri Jun 5 15:02:20 2009
@@ -122,15 +122,6 @@
/**
- * Creates a SubtreeSpecificationParserTest instance.
- */
- public SubtreeSpecificationParserTest(String s)
- {
- parser = new SubtreeSpecificationParser( null );
- }
-
-
- /**
* Tests the parser with a valid empty specification.
*/
@Test
Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/trigger/TriggerSpecificationParserTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/trigger/TriggerSpecificationParserTest.java?rev=782036&r1=782035&r2=782036&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/trigger/TriggerSpecificationParserTest.java (original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/trigger/TriggerSpecificationParserTest.java Fri Jun 5 15:02:20 2009
@@ -55,14 +55,6 @@
}
- /**
- * Creates a TriggerSpecificationParserTest instance.
- */
- public TriggerSpecificationParserTest( String s )
- {
- parser = new TriggerSpecificationParser();
- }
-
@Test
public void testWithOperationParameters() throws Exception
{
Modified: directory/shared/trunk/pom.xml
URL: http://svn.apache.org/viewvc/directory/shared/trunk/pom.xml?rev=782036&r1=782035&r2=782036&view=diff
==============================================================================
--- directory/shared/trunk/pom.xml (original)
+++ directory/shared/trunk/pom.xml Fri Jun 5 15:02:20 2009
@@ -94,7 +94,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
- <version>4.4</version>
+ <version>4.5</version>
</dependency>
<dependency>