Skip to content
Permalink
Browse files
Switching to junit5 and fixing threaded test issue
  • Loading branch information
effrafax committed Oct 8, 2019
1 parent adf374e commit 9587936f89635fb36682bf2d26d3c86321ebeb5e
Showing 4 changed files with 20 additions and 21 deletions.
@@ -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,17 +57,12 @@
</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>
@@ -118,7 +118,7 @@ public void run()
}
catch ( TaskExecutionException e )
{
logger.error( "Error executing task", e );
logger.error( "Error executing task: {}", e.getMessage(), e );
}
}
} );
@@ -129,7 +129,7 @@ public void run()
}
catch ( ExecutionException e )
{
logger.error( "Error executing task", e );
logger.error( "Error executing task: {}", e.getMessage(), e );
}
}

@@ -19,8 +19,6 @@
* under the License.
*/

import org.apache.archiva.redback.components.taskqueue.Task;

/**
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
*
@@ -42,11 +40,13 @@

private long executionTime;

private boolean cancelled;
private volatile boolean cancelled;

private volatile boolean done;

private boolean done;
private volatile boolean started;

private boolean started;
private volatile boolean wasStarted = false;

private boolean ignoreInterrupts;

@@ -142,6 +142,7 @@ public boolean isStarted()
public void start()
{
this.started = true;
this.wasStarted = true;
}

public void setIgnoreInterrupts( boolean ignore )
@@ -154,4 +155,7 @@ public boolean ignoreInterrupts()
return ignoreInterrupts;
}

public boolean wasStarted() {
return wasStarted;
}
}
@@ -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 @@ public void testTimeoutWithInterrupts()

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 @@ private static void waitForExpectedTaskEnd( BuildProjectTask task )
// is actually running before starting to count the timeout.
for ( int i = 0; i < 500; i++ )
{
if ( task.isStarted() )
if ( task.wasStarted() )
{
break;
}

0 comments on commit 9587936

Please sign in to comment.