Skip to content

Commit

Permalink
Throw an error if the verifier did not complete in time
Browse files Browse the repository at this point in the history
  • Loading branch information
trickl committed Oct 3, 2020
1 parent 32c3278 commit 7972930
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
11 changes: 7 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.trickl</groupId>
<artifactId>flux-mock-websocket</artifactId>
<version>0.0.3-SNAPSHOT</version>
<version>0.0.5-SNAPSHOT</version>
<packaging>jar</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
Expand Down Expand Up @@ -97,8 +97,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<source>8</source>
<target>8</target>
<debug>true</debug>
</configuration>
</plugin>
Expand Down Expand Up @@ -130,6 +130,9 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.3</version>
<configuration>
<source>8</source>
</configuration>
<executions>
<execution>
<id>attach-javadocs</id>
Expand Down Expand Up @@ -208,7 +211,7 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.1</version>
<version>0.8.5</version>
<executions>
<execution>
<id>prepare-agent</id>
Expand Down
9 changes: 7 additions & 2 deletions src/main/java/com/trickl/flux/websocket/VerifierComplete.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.trickl.flux.websocket;

import com.trickl.exceptions.StepVerifierException;
import java.time.Duration;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
Expand All @@ -17,17 +18,21 @@ public class VerifierComplete {
* @param duration how long to wait
*/
public void waitComplete(Duration duration) {
boolean didComplete = false;
try {
completeSignal.await(duration.toMillis(), TimeUnit.MILLISECONDS);
didComplete = completeSignal.await(duration.toMillis(), TimeUnit.MILLISECONDS);
} catch (InterruptedException ex) {
log.warning("Verifier interrupted");
}
if (!didComplete) {
throw new StepVerifierException("Verifier did not complete within " + duration.toString());
}
}

/**
* Block until complete.
*/
public void waitComplete() {
public void waitComplete() {
try {
completeSignal.await();
} catch (InterruptedException ex) {
Expand Down

0 comments on commit 7972930

Please sign in to comment.