Switching to junit5 and fixing threaded test issue
diff --git a/pom.xml b/pom.xml
index 93ab51c..1d6e6ec 100644
--- a/pom.xml
+++ b/pom.xml
@@ -30,7 +30,7 @@
<version>2.2-SNAPSHOT</version>
<artifactId>spring-taskqueue</artifactId>
- <name>Spring Task Queue</name>
+ <name>Redback Components :: Spring Task Queue</name>
<properties>
<scmBrowseUrl>https://gitbox.apache.org/repos/asf?a=tree;p=archiva-redback-components-spring-taskqueue.git</scmBrowseUrl>
@@ -57,18 +57,13 @@
</dependency>
<dependency>
<groupId>javax.annotation</groupId>
- <artifactId>jsr250-api</artifactId>
+ <artifactId>javax.annotation-api</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<scope>test</scope>
diff --git a/src/main/java/org/apache/archiva/redback/components/taskqueue/execution/ThreadedTaskQueueExecutor.java b/src/main/java/org/apache/archiva/redback/components/taskqueue/execution/ThreadedTaskQueueExecutor.java
index c79dc43..175ad5d 100644
--- a/src/main/java/org/apache/archiva/redback/components/taskqueue/execution/ThreadedTaskQueueExecutor.java
+++ b/src/main/java/org/apache/archiva/redback/components/taskqueue/execution/ThreadedTaskQueueExecutor.java
@@ -118,7 +118,7 @@
}
catch ( TaskExecutionException e )
{
- logger.error( "Error executing task", e );
+ logger.error( "Error executing task: {}", e.getMessage(), e );
}
}
} );
@@ -129,7 +129,7 @@
}
catch ( ExecutionException e )
{
- logger.error( "Error executing task", e );
+ logger.error( "Error executing task: {}", e.getMessage(), e );
}
}
diff --git a/src/test/java/org/apache/archiva/redback/components/taskqueue/BuildProjectTask.java b/src/test/java/org/apache/archiva/redback/components/taskqueue/BuildProjectTask.java
index 4b5e953..af33fe5 100644
--- a/src/test/java/org/apache/archiva/redback/components/taskqueue/BuildProjectTask.java
+++ b/src/test/java/org/apache/archiva/redback/components/taskqueue/BuildProjectTask.java
@@ -19,8 +19,6 @@
* under the License.
*/
-import org.apache.archiva.redback.components.taskqueue.Task;
-
/**
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a>
*
@@ -42,11 +40,13 @@
private long executionTime;
- private boolean cancelled;
+ private volatile boolean cancelled;
- private boolean done;
+ private volatile boolean done;
- private boolean started;
+ private volatile boolean started;
+
+ private volatile boolean wasStarted = false;
private boolean ignoreInterrupts;
@@ -142,6 +142,7 @@
public void start()
{
this.started = true;
+ this.wasStarted = true;
}
public void setIgnoreInterrupts( boolean ignore )
@@ -154,4 +155,7 @@
return ignoreInterrupts;
}
+ public boolean wasStarted() {
+ return wasStarted;
+ }
}
diff --git a/src/test/java/org/apache/archiva/redback/components/taskqueue/execution/TaskQueueExecutorTest.java b/src/test/java/org/apache/archiva/redback/components/taskqueue/execution/TaskQueueExecutorTest.java
index 3f97c13..2b372a1 100644
--- a/src/test/java/org/apache/archiva/redback/components/taskqueue/execution/TaskQueueExecutorTest.java
+++ b/src/test/java/org/apache/archiva/redback/components/taskqueue/execution/TaskQueueExecutorTest.java
@@ -49,6 +49,10 @@
private TaskQueueExecutor taskQueueExecutor;
+ /**
+ * We run both tests in one test method, to avoid the shutdown of the executor
+ *
+ */
@Test
public void testTimeoutWithInterrupts()
throws TaskQueueException, InterruptedException
@@ -59,13 +63,9 @@
assertTrue( task.isCancelled() );
assertFalse( task.isDone() );
- }
- @Test
- public void testTimeoutWithoutInterrupts()
- throws TaskQueueException, InterruptedException
- {
- BuildProjectTask task = putTask( 2 * 1000, true );
+
+ task = putTask( 2 * 1000, true );
waitForExpectedTaskEnd( task );
@@ -93,7 +93,7 @@
// is actually running before starting to count the timeout.
for ( int i = 0; i < 500; i++ )
{
- if ( task.isStarted() )
+ if ( task.wasStarted() )
{
break;
}