Skip to content
Permalink
Browse files
Merge pull request #31 from apache/awaitility
use awaitility library when possible
  • Loading branch information
olamy committed Aug 6, 2022
2 parents 6fde270 + 296e1d5 commit 469cb7146698728f9b3b3b0e16ca96b9f6b97d78
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 32 deletions.
30 pom.xml
@@ -271,7 +271,11 @@
<artifactId>swagger-annotations</artifactId>
<version>${io.swagger.version}</version>
</dependency>

<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
<version>4.2.0</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
@@ -282,6 +286,12 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
<scope>test</scope>
</dependency>

<!-- JUNIT 5 -->
<dependency>
<groupId>org.junit.platform</groupId>
@@ -447,15 +457,15 @@
<outputEncoding>UTF-8</outputEncoding>
<skipDeploy>true</skipDeploy>
<stagingDirectory>${site.staging.base}/target/staging${scmPublishPath}</stagingDirectory>
<asciidoc>
<!-- optional site-wide AsciiDoc attributes -->
<attributes>
<icons>font</icons>
<source-highlighter>coderay</source-highlighter>
<coderay-css>style</coderay-css>
<toclevels>2</toclevels>
</attributes>
</asciidoc>
<!-- <asciidoc>-->
<!-- &lt;!&ndash; optional site-wide AsciiDoc attributes &ndash;&gt;-->
<!-- <attributes>-->
<!-- <icons>font</icons>-->
<!-- <source-highlighter>coderay</source-highlighter>-->
<!-- <coderay-css>style</coderay-css>-->
<!-- <toclevels>2</toclevels>-->
<!-- </attributes>-->
<!-- </asciidoc>-->
</configuration>
<dependencies>
<dependency>
@@ -47,14 +47,6 @@
public abstract class AbstractCacheTestCase
extends TestCase
{
// static
// {
// Logger logger = Logger.getLogger( "org.codehaus.plexus.cache" );
// logger.setLevel( Level.ALL );
// ConsoleHandler handler = new ConsoleHandler( );
// handler.setLevel( Level.ALL );
// logger.addHandler( handler );
// }

private static final Logger log = LoggerFactory.getLogger( AbstractCacheTestCase.class );

@@ -20,6 +20,7 @@
*/

import junit.framework.TestCase;
import org.awaitility.Awaitility;
import org.junit.After;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -37,6 +38,7 @@
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import javax.inject.Inject;
import java.util.concurrent.TimeUnit;

@RunWith ( SpringJUnit4ClassRunner.class )
@ContextConfiguration ( locations = { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context.xml" } )
@@ -81,10 +83,8 @@ public void testCreation()

scheduler.scheduleJob( jobDetail, trigger );

while ( !triggerFired )
{
Thread.sleep( 10 );
}
Awaitility.await().atLeast( 100, TimeUnit.MILLISECONDS ).until( () -> triggerFired );

logger.info( "ok triggerFired" );
}

@@ -23,13 +23,15 @@
import org.apache.archiva.components.taskqueue.BuildProjectTask;
import org.apache.archiva.components.taskqueue.TaskQueue;
import org.apache.archiva.components.taskqueue.TaskQueueException;
import org.awaitility.Awaitility;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import javax.inject.Inject;
import javax.inject.Named;
import java.util.concurrent.TimeUnit;

/**
* @author <a href="mailto:kenney@apache.org">Kenney Westerhof</a>
@@ -90,16 +92,7 @@ private static void waitForExpectedTaskEnd( BuildProjectTask task )
{
// thread scheduling may take some time, so we want to wait until the task
// is actually running before starting to count the timeout.
for ( int i = 0; i < 500; i++ )
{
if ( task.wasStarted( ) )
{
break;
}
Thread.sleep( 10 );
}

assertTrue( "Task not started in 5 seconds - heavy load?", task.isStarted( ) );
Awaitility.await().atMost( 5, TimeUnit.SECONDS ).until( () -> task.isStarted() );

Thread.sleep( task.getMaxExecutionTime( ) );
}

0 comments on commit 469cb71

Please sign in to comment.