Skip to content

Commit

Permalink
[4.x]: Use Hamcrest assertions instead of JUnit in tests/integration/…
Browse files Browse the repository at this point in the history
…jms (#1749) (#6643)
  • Loading branch information
Captain1653 authored Apr 19, 2023
1 parent bf38bbf commit 9f2156f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import org.hamcrest.Matchers;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.hamcrest.Matchers.is;

public abstract class AbstractMPTest extends AbstractJmsTest {

Expand All @@ -52,8 +52,8 @@ protected void produceAndCheck(final AbstractSampleBean consumingBean,
if (expected.size() > 0) {
// Wait till records are delivered
boolean done = consumingBean.await();
assertTrue(done, String.format("Timeout waiting for results.\nExpected: %s \nBut was: %s",
expected.toString(), consumingBean.consumed().toString()));
assertThat(String.format("Timeout waiting for results.\nExpected: %s \nBut was: %s",
expected.toString(), consumingBean.consumed().toString()), done, is(true));
}
if (!expected.isEmpty()) {
assertThat(consumingBean.consumed(), Matchers.containsInAnyOrder(expected.toArray()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertTrue;

/**
* This class contains the outputs of the tests. In order to avoid that one test mess up in the results
Expand Down Expand Up @@ -249,7 +248,7 @@ public static class ChannelBytes extends AbstractSampleBean {

public void await(long timeout) {
try {
assertTrue(countDownLatch.await(timeout, TimeUnit.MILLISECONDS));
assertThat(countDownLatch.await(timeout, TimeUnit.MILLISECONDS), is(true));
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
Expand Down Expand Up @@ -286,7 +285,7 @@ public static class ChannelProperties extends AbstractSampleBean {

public void await(long timeout) {
try {
assertTrue(countDownLatch.await(timeout, TimeUnit.MILLISECONDS));
assertThat(countDownLatch.await(timeout, TimeUnit.MILLISECONDS), is(true));
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
Expand Down Expand Up @@ -331,7 +330,7 @@ public static class ChannelCustomMapper extends AbstractSampleBean {

public void await(long timeout) {
try {
assertTrue(countDownLatch.await(timeout, TimeUnit.MILLISECONDS));
assertThat(countDownLatch.await(timeout, TimeUnit.MILLISECONDS), is(true));
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
Expand Down Expand Up @@ -375,7 +374,7 @@ public static class ChannelDerivedMessage extends AbstractSampleBean {

public void await(long timeout) {
try {
assertTrue(countDownLatch.await(timeout, TimeUnit.MILLISECONDS));
assertThat(countDownLatch.await(timeout, TimeUnit.MILLISECONDS), is(true));
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
import org.junit.jupiter.api.Test;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.startsWith;
import static org.junit.jupiter.api.Assertions.assertTrue;

public class JmsSeTest extends AbstractJmsTest {

Expand Down Expand Up @@ -81,7 +81,7 @@ void customFactoryTest() throws InterruptedException {
.build()
.start();

assertTrue(cdl.await(2, TimeUnit.SECONDS));
assertThat(cdl.await(2, TimeUnit.SECONDS), is(true));
assertThat(result, containsInAnyOrder("1", "2", "3", "4"));
}

Expand Down

0 comments on commit 9f2156f

Please sign in to comment.