update Hamcrest library for testing

This commit is contained in:
Stefan Kalscheuer 2019-10-20 11:51:34 +02:00
parent 8ce5ea3aef
commit 4bb7c595c2
3 changed files with 20 additions and 19 deletions

View File

@ -65,20 +65,20 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.hamcrest</groupId> <groupId>org.hamcrest</groupId>
<artifactId>hamcrest-junit</artifactId> <artifactId>hamcrest</artifactId>
<version>2.0.0.0</version> <version>2.2</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.bytebuddy</groupId> <groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId> <artifactId>byte-buddy</artifactId>
<version>1.10.1</version> <version>1.10.2</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.bytebuddy</groupId> <groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy-agent</artifactId> <artifactId>byte-buddy-agent</artifactId>
<version>1.10.1</version> <version>1.10.2</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@ -21,8 +21,8 @@ import de.stklcode.pubtrans.ura.model.Trip;
import net.bytebuddy.ByteBuddy; import net.bytebuddy.ByteBuddy;
import net.bytebuddy.agent.ByteBuddyAgent; import net.bytebuddy.agent.ByteBuddyAgent;
import net.bytebuddy.dynamic.loading.ClassReloadingStrategy; import net.bytebuddy.dynamic.loading.ClassReloadingStrategy;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;

View File

@ -27,7 +27,10 @@ import org.junit.jupiter.api.Test;
import java.io.*; import java.io.*;
import java.net.URL; import java.net.URL;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.*; import java.util.ArrayDeque;
import java.util.Collections;
import java.util.Deque;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedDeque; import java.util.concurrent.ConcurrentLinkedDeque;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
@ -35,10 +38,8 @@ import java.util.concurrent.atomic.AtomicInteger;
import static net.bytebuddy.implementation.MethodDelegation.to; import static net.bytebuddy.implementation.MethodDelegation.to;
import static net.bytebuddy.matcher.ElementMatchers.named; import static net.bytebuddy.matcher.ElementMatchers.named;
import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.empty;
import static org.hamcrest.core.Is.is; import static org.hamcrest.core.Is.is;
import static org.junit.Assume.assumeThat; import static org.junit.jupiter.api.Assumptions.assumeTrue;
import static org.junit.Assume.assumeTrue;
/** /**
* Unit test for the asynchronous URA Trip reader. * Unit test for the asynchronous URA Trip reader.
@ -95,11 +96,11 @@ public class AsyncUraTripReaderTest {
tr.open(); tr.open();
// Read for 1 second. // Read for 1 second.
TimeUnit.SECONDS.sleep(1); TimeUnit.SECONDS.sleep(1);
assumeThat("Trips should empty after 1s without reading", trips, is(empty())); assumeTrue(trips.isEmpty(), "Trips should empty after 1s without reading");
// Now write a single line to the stream pipe. // Now write a single line to the stream pipe.
assumeTrue("First line (version info) should be written", writeNextLine()); assumeTrue(writeNextLine(), "First line (version info) should be written");
assumeTrue("Second line (first record) should be written", writeNextLine()); assumeTrue(writeNextLine(), "Second line (first record) should be written");
// Wait up to 1s for the callback to be triggered. // Wait up to 1s for the callback to be triggered.
int i = 10; int i = 10;
@ -136,10 +137,10 @@ public class AsyncUraTripReaderTest {
tr.open(); tr.open();
// Read for 1 second. // Read for 1 second.
TimeUnit.SECONDS.sleep(1); TimeUnit.SECONDS.sleep(1);
assumeThat("Trips should empty after 1s without reading", trips, is(empty())); assumeTrue(trips.isEmpty(), "Trips should empty after 1s without reading");
assumeTrue("First line of v2 (version info) should be written", writeNextLine()); assumeTrue(writeNextLine(), "First line of v2 (version info) should be written");
assumeTrue("Second line of v2 (first record) should be written", writeNextLine()); assumeTrue(writeNextLine(), "Second line of v2 (first record) should be written");
i = 10; i = 10;
counter.set(0); counter.set(0);
@ -202,11 +203,11 @@ public class AsyncUraTripReaderTest {
// Read for 100ms. // Read for 100ms.
TimeUnit.MILLISECONDS.sleep(100); TimeUnit.MILLISECONDS.sleep(100);
assumeThat("Trips should empty after 100ms without reading", trips, is(empty())); assumeTrue(trips.isEmpty(), "Trips should empty after 100ms without reading");
// Now write a single line to the stream pipe. // Now write a single line to the stream pipe.
assumeTrue("First line (version info) should be written", writeNextLine()); assumeTrue(writeNextLine(), "First line (version info) should be written");
assumeTrue("Second line (first record) should be written", writeNextLine()); assumeTrue(writeNextLine(), "Second line (first record) should be written");
// Wait up to 1s for the callback to be triggered. // Wait up to 1s for the callback to be triggered.
int i = 10; int i = 10;
@ -214,7 +215,7 @@ public class AsyncUraTripReaderTest {
TimeUnit.MILLISECONDS.sleep(100); TimeUnit.MILLISECONDS.sleep(100);
} }
assumeThat("Unexpected number of trips after first entry", trips.size(), is(1)); assumeTrue(1 == trips.size(), "Unexpected number of trips after first entry");
// Close the stream. // Close the stream.
mockOutputStream.close(); mockOutputStream.close();