Skip to content

Commit d979c38

Browse files
committed
Bump test dependencies
Don't use JUnit's assertThat anymore, as it's deprecated in 4.13. Use assertj instead. Get rid of Awaitility (created a waitUntil test utility instead) and Hamcrest (not used anymore).
1 parent ac8b6f0 commit d979c38

19 files changed

+331
-373
lines changed

pom.xml

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,10 @@
5959
<micrometer.version>1.3.2</micrometer.version>
6060
<jackson.version>2.10.1</jackson.version>
6161
<logback.version>1.2.3</logback.version>
62-
<junit.version>4.12</junit.version>
63-
<awaitility.version>4.0.1</awaitility.version>
64-
<mockito.version>3.2.0</mockito.version>
65-
<assertj.version>3.14.0</assertj.version>
66-
<jetty.version>9.4.24.v20191120</jetty.version>
62+
<junit.version>4.13</junit.version>
63+
<mockito.version>3.3.3</mockito.version>
64+
<assertj.version>3.15.0</assertj.version>
65+
<jetty.version>9.4.27.v20200227</jetty.version>
6766
<bouncycastle.version>1.64</bouncycastle.version>
6867

6968
<maven.javadoc.plugin.version>3.1.1</maven.javadoc.plugin.version>
@@ -722,12 +721,6 @@
722721
<version>${logback.version}</version>
723722
<scope>test</scope>
724723
</dependency>
725-
<dependency>
726-
<groupId>org.awaitility</groupId>
727-
<artifactId>awaitility</artifactId>
728-
<version>${awaitility.version}</version>
729-
<scope>test</scope>
730-
</dependency>
731724
<dependency>
732725
<groupId>org.mockito</groupId>
733726
<artifactId>mockito-core</artifactId>
@@ -740,12 +733,6 @@
740733
<version>${assertj.version}</version>
741734
<scope>test</scope>
742735
</dependency>
743-
<dependency>
744-
<groupId>org.hamcrest</groupId>
745-
<artifactId>hamcrest-library</artifactId>
746-
<version>1.3</version>
747-
<scope>test</scope>
748-
</dependency>
749736
<dependency>
750737
<groupId>org.eclipse.jetty</groupId>
751738
<artifactId>jetty-servlet</artifactId>

src/test/java/com/rabbitmq/client/test/AMQChannelTest.java

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
import java.util.concurrent.ScheduledExecutorService;
3434
import java.util.concurrent.TimeUnit;
3535

36-
import static org.hamcrest.Matchers.*;
37-
import static org.junit.Assert.*;
36+
import static org.assertj.core.api.Assertions.assertThat;
37+
import static org.assertj.core.api.Assertions.fail;
3838
import static org.mockito.Mockito.*;
3939

4040
public class AMQChannelTest {
@@ -69,10 +69,10 @@ public class AMQChannelTest {
6969
fail("Should time out and throw an exception");
7070
} catch(ChannelContinuationTimeoutException e) {
7171
// OK
72-
assertThat((DummyAmqChannel) e.getChannel(), is(channel));
73-
assertThat(e.getChannelNumber(), is(channel.getChannelNumber()));
74-
assertThat(e.getMethod(), is(method));
75-
assertNull("outstanding RPC should have been cleaned", channel.nextOutstandingRpc());
72+
assertThat((DummyAmqChannel) e.getChannel()).isEqualTo(channel);
73+
assertThat(e.getChannelNumber()).isEqualTo(channel.getChannelNumber());
74+
assertThat(e.getMethod()).isEqualTo(method);
75+
assertThat(channel.nextOutstandingRpc()).as("outstanding RPC should have been cleaned").isNull();
7676
}
7777
}
7878

@@ -105,7 +105,7 @@ public Void call() throws Exception {
105105
}, (long) (rpcTimeout / 2.0), TimeUnit.MILLISECONDS);
106106

107107
AMQCommand rpcResponse = channel.rpc(method);
108-
assertThat(rpcResponse.getMethod(), is(response));
108+
assertThat(rpcResponse.getMethod()).isEqualTo(response);
109109
}
110110

111111
@Test
@@ -130,10 +130,10 @@ public void testRpcTimeoutReplyComesDuringNexRpc() throws Exception {
130130
fail("Should time out and throw an exception");
131131
} catch(final ChannelContinuationTimeoutException e) {
132132
// OK
133-
assertThat((DummyAmqChannel) e.getChannel(), is(channel));
134-
assertThat(e.getChannelNumber(), is(channel.getChannelNumber()));
135-
assertThat(e.getMethod(), is(method));
136-
assertNull("outstanding RPC should have been cleaned", channel.nextOutstandingRpc());
133+
assertThat((DummyAmqChannel) e.getChannel()).isEqualTo(channel);
134+
assertThat(e.getChannelNumber()).isEqualTo(channel.getChannelNumber());
135+
assertThat(e.getMethod()).isEqualTo(method);
136+
assertThat(channel.nextOutstandingRpc()).as("outstanding RPC should have been cleaned").isNull();
137137
}
138138

139139
// now do a basic.consume request and have the queue.declareok returned instead
@@ -151,18 +151,15 @@ public void testRpcTimeoutReplyComesDuringNexRpc() throws Exception {
151151
final Method response2 = new AMQImpl.Basic.ConsumeOk.Builder()
152152
.consumerTag("456").build();
153153

154-
scheduler.schedule(new Callable<Void>() {
155-
@Override
156-
public Void call() throws Exception {
157-
channel.handleCompleteInboundCommand(new AMQCommand(response1));
158-
Thread.sleep(10);
159-
channel.handleCompleteInboundCommand(new AMQCommand(response2));
160-
return null;
161-
}
154+
scheduler.schedule((Callable<Void>) () -> {
155+
channel.handleCompleteInboundCommand(new AMQCommand(response1));
156+
Thread.sleep(10);
157+
channel.handleCompleteInboundCommand(new AMQCommand(response2));
158+
return null;
162159
}, (long) (rpcTimeout / 2.0), TimeUnit.MILLISECONDS);
163160

164161
AMQCommand rpcResponse = channel.rpc(method);
165-
assertThat(rpcResponse.getMethod(), is(response2));
162+
assertThat(rpcResponse.getMethod()).isEqualTo(response2);
166163
}
167164

168165
static class DummyAmqChannel extends AMQChannel {

src/test/java/com/rabbitmq/client/test/ChannelRpcTimeoutIntegrationTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
import java.util.concurrent.ThreadFactory;
2828
import java.util.concurrent.TimeoutException;
2929

30-
import static org.hamcrest.Matchers.*;
31-
import static org.junit.Assert.*;
30+
import static org.assertj.core.api.Assertions.assertThat;
31+
import static org.assertj.core.api.Assertions.fail;
3232

3333
public class ChannelRpcTimeoutIntegrationTest {
3434

@@ -73,9 +73,9 @@ public void tearDown() {
7373
fail("Should time out and throw an exception");
7474
} catch(ChannelContinuationTimeoutException e) {
7575
// OK
76-
assertThat((Channel) e.getChannel(), is(channel));
77-
assertThat(e.getChannelNumber(), is(channel.getChannelNumber()));
78-
assertThat(e.getMethod(), instanceOf(AMQP.Queue.Declare.class));
76+
assertThat((Channel) e.getChannel()).isEqualTo(channel);
77+
assertThat(e.getChannelNumber()).isEqualTo(channel.getChannelNumber());
78+
assertThat(e.getMethod()).isInstanceOf(AMQP.Queue.Declare.class);
7979
}
8080
} finally {
8181
connection.close();

src/test/java/com/rabbitmq/client/test/ClientVersionTest.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,13 @@
1818
import com.rabbitmq.client.impl.ClientVersion;
1919
import org.junit.Test;
2020

21-
import static org.hamcrest.Matchers.not;
22-
import static org.hamcrest.Matchers.notNullValue;
23-
import static org.junit.Assert.assertThat;
21+
import static org.assertj.core.api.Assertions.assertThat;
2422

2523
public class ClientVersionTest {
2624

2725
@Test
2826
public void clientVersion() {
29-
assertThat(ClientVersion.VERSION, notNullValue());
30-
assertThat(ClientVersion.VERSION, not("0.0.0"));
27+
assertThat(ClientVersion.VERSION).isNotNull();
28+
assertThat(ClientVersion.VERSION).isNotEqualTo("0.0.0");
3129
}
3230
}

src/test/java/com/rabbitmq/client/test/DnsSrvRecordAddressResolverTest.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@
2323
import java.util.Arrays;
2424
import java.util.List;
2525

26-
import static org.hamcrest.CoreMatchers.is;
27-
import static org.junit.Assert.assertThat;
26+
import static org.assertj.core.api.Assertions.assertThat;
2827

2928
/**
3029
*
@@ -46,12 +45,12 @@ protected List<SrvRecord> lookupSrvRecords(String service, String dnsUrls) throw
4645
};
4746

4847
List<Address> addresses = resolver.getAddresses();
49-
assertThat(addresses.size(), is(5));
50-
assertThat(addresses.get(0).getHost(), is("alt1.xmpp-server.l.google.com"));
51-
assertThat(addresses.get(1).getHost(), is("alt2.xmpp-server.l.google.com"));
52-
assertThat(addresses.get(2).getHost(), is("alt3.xmpp-server.l.google.com"));
53-
assertThat(addresses.get(3).getHost(), is("alt4.xmpp-server.l.google.com"));
54-
assertThat(addresses.get(4).getHost(), is("alt5.xmpp-server.l.google.com"));
48+
assertThat(addresses.size()).isEqualTo(5);
49+
assertThat(addresses.get(0).getHost()).isEqualTo("alt1.xmpp-server.l.google.com");
50+
assertThat(addresses.get(1).getHost()).isEqualTo("alt2.xmpp-server.l.google.com");
51+
assertThat(addresses.get(2).getHost()).isEqualTo("alt3.xmpp-server.l.google.com");
52+
assertThat(addresses.get(3).getHost()).isEqualTo("alt4.xmpp-server.l.google.com");
53+
assertThat(addresses.get(4).getHost()).isEqualTo("alt5.xmpp-server.l.google.com");
5554
}
5655

5756
}

src/test/java/com/rabbitmq/client/test/FrameBuilderTest.java

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,8 @@
2828
import java.nio.ByteBuffer;
2929
import java.nio.channels.ReadableByteChannel;
3030

31-
import static org.hamcrest.Matchers.is;
32-
import static org.hamcrest.Matchers.notNullValue;
33-
import static org.hamcrest.Matchers.nullValue;
34-
import static org.junit.Assert.assertThat;
35-
import static org.junit.Assert.fail;
31+
import static org.assertj.core.api.Assertions.assertThat;
32+
import static org.assertj.core.api.Assertions.fail;
3633

3734
/**
3835
*
@@ -52,10 +49,10 @@ public void buildFrameInOneGo() throws IOException {
5249
buffer = ByteBuffer.wrap(new byte[] { 1, 0, 0, 0, 0, 0, 3, 1, 2, 3, end() });
5350
builder = new FrameBuilder(channel, buffer);
5451
Frame frame = builder.readFrame();
55-
assertThat(frame, notNullValue());
56-
assertThat(frame.getType(), is(1));
57-
assertThat(frame.getChannel(), is(0));
58-
assertThat(frame.getPayload().length, is(3));
52+
assertThat(frame).isNotNull();
53+
assertThat(frame.getType()).isEqualTo(1);
54+
assertThat(frame.getChannel()).isEqualTo(0);
55+
assertThat(frame.getPayload()).hasSize(3);
5956
}
6057

6158
@Test
@@ -73,31 +70,31 @@ public void buildFramesInOneGo() throws IOException {
7370
int frameCount = 0;
7471
Frame frame;
7572
while ((frame = builder.readFrame()) != null) {
76-
assertThat(frame, notNullValue());
77-
assertThat(frame.getType(), is(1));
78-
assertThat(frame.getChannel(), is(0));
79-
assertThat(frame.getPayload().length, is(3));
73+
assertThat(frame).isNotNull();
74+
assertThat(frame.getType()).isEqualTo(1);
75+
assertThat(frame.getChannel()).isEqualTo(0);
76+
assertThat(frame.getPayload()).hasSize(3);
8077
frameCount++;
8178
}
82-
assertThat(frameCount, is(nbFrames));
79+
assertThat(frameCount).isEqualTo(nbFrames);
8380
}
8481

8582
@Test
8683
public void buildFrameInSeveralCalls() throws IOException {
8784
buffer = ByteBuffer.wrap(new byte[] { 1, 0, 0, 0, 0, 0, 3, 1, 2 });
8885
builder = new FrameBuilder(channel, buffer);
8986
Frame frame = builder.readFrame();
90-
assertThat(frame, nullValue());
87+
assertThat(frame).isNull();
9188

9289
buffer.clear();
9390
buffer.put(b(3)).put(end());
9491
buffer.flip();
9592

9693
frame = builder.readFrame();
97-
assertThat(frame, notNullValue());
98-
assertThat(frame.getType(), is(1));
99-
assertThat(frame.getChannel(), is(0));
100-
assertThat(frame.getPayload().length, is(3));
94+
assertThat(frame).isNotNull();
95+
assertThat(frame.getType()).isEqualTo(1);
96+
assertThat(frame.getChannel()).isEqualTo(0);
97+
assertThat(frame.getPayload()).hasSize(3);
10198
}
10299

103100
@Test
@@ -127,7 +124,7 @@ public void protocolMismatchHeader() throws IOException {
127124
builder.readFrame();
128125
fail("protocol header not correct, exception should have been thrown");
129126
} catch (MalformedFrameException e) {
130-
assertThat(e.getMessage(), is(messages[i]));
127+
assertThat(e.getMessage()).isEqualTo(messages[i]);
131128
}
132129
}
133130
}

src/test/java/com/rabbitmq/client/test/FrameTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@
1717
import java.util.List;
1818
import java.util.Random;
1919

20-
import static org.hamcrest.Matchers.equalTo;
21-
import static org.junit.Assert.assertThat;
20+
import static org.assertj.core.api.Assertions.assertThat;
2221

2322
/**
2423
*
@@ -72,7 +71,7 @@ private void checkWrittenChunks(int totalFrameSize, AccumulatorWritableByteChann
7271
for (byte[] chunk : channel.chunks) {
7372
totalWritten += chunk.length;
7473
}
75-
assertThat(totalWritten, equalTo(totalFrameSize));
74+
assertThat(totalWritten).isEqualTo(totalFrameSize);
7675
}
7776

7877
private static class AccumulatorWritableByteChannel implements WritableByteChannel {

0 commit comments

Comments
 (0)