You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by gn...@apache.org on 2020/07/22 16:59:10 UTC
[camel] 04/18: [CAMEL-11807] Upgrade camel-lra to junit5
This is an automated email from the ASF dual-hosted git repository.
gnodet pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 9554125a185d3a4ef1003db843e0164e24fbaa09
Author: Guillaume Nodet <gn...@gmail.com>
AuthorDate: Wed Jul 22 13:49:46 2020 +0200
[CAMEL-11807] Upgrade camel-lra to junit5
---
components/camel-lra/pom.xml | 6 +++---
.../camel/service/lra/AbstractLRATestSupport.java | 14 +++++++-------
.../java/org/apache/camel/service/lra/LRACreditIT.java | 3 ++-
.../org/apache/camel/service/lra/LRAFailuresIT.java | 2 +-
.../java/org/apache/camel/service/lra/LRAManualIT.java | 2 +-
.../org/apache/camel/service/lra/LRAOptionsIT.java | 18 ++++++++----------
.../org/apache/camel/service/lra/LRATimeoutIT.java | 2 +-
7 files changed, 23 insertions(+), 24 deletions(-)
diff --git a/components/camel-lra/pom.xml b/components/camel-lra/pom.xml
index c6b1f0f..b1de5f6 100644
--- a/components/camel-lra/pom.xml
+++ b/components/camel-lra/pom.xml
@@ -69,12 +69,12 @@
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
- <artifactId>camel-test</artifactId>
+ <artifactId>camel-test-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
diff --git a/components/camel-lra/src/test/java/org/apache/camel/service/lra/AbstractLRATestSupport.java b/components/camel-lra/src/test/java/org/apache/camel/service/lra/AbstractLRATestSupport.java
index c39f0ac..492387a 100644
--- a/components/camel-lra/src/test/java/org/apache/camel/service/lra/AbstractLRATestSupport.java
+++ b/components/camel-lra/src/test/java/org/apache/camel/service/lra/AbstractLRATestSupport.java
@@ -28,14 +28,14 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.camel.CamelContext;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.test.AvailablePortFinder;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.awaitility.Awaitility.await;
import static org.hamcrest.Matchers.equalTo;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Base class for LRA based tests.
@@ -46,15 +46,15 @@ public abstract class AbstractLRATestSupport extends CamelTestSupport {
private int activeLRAs;
- @Before
+ @BeforeEach
public void getActiveLRAs() throws IOException {
this.activeLRAs = getNumberOfActiveLRAs();
}
- @After
+ @AfterEach
public void checkActiveLRAs() throws IOException {
await().atMost(2, SECONDS).until(() -> getNumberOfActiveLRAs(), equalTo(activeLRAs));
- Assert.assertEquals("Some LRA have been left pending", activeLRAs, getNumberOfActiveLRAs());
+ assertEquals(activeLRAs, getNumberOfActiveLRAs(), "Some LRA have been left pending");
}
@Override
diff --git a/components/camel-lra/src/test/java/org/apache/camel/service/lra/LRACreditIT.java b/components/camel-lra/src/test/java/org/apache/camel/service/lra/LRACreditIT.java
index 4485c74..50ed72c 100644
--- a/components/camel-lra/src/test/java/org/apache/camel/service/lra/LRACreditIT.java
+++ b/components/camel-lra/src/test/java/org/apache/camel/service/lra/LRACreditIT.java
@@ -26,10 +26,11 @@ import org.apache.camel.Exchange;
import org.apache.camel.Header;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.model.SagaPropagation;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import static org.awaitility.Awaitility.await;
import static org.hamcrest.Matchers.equalTo;
+import static org.junit.jupiter.api.Assertions.fail;
public class LRACreditIT extends AbstractLRATestSupport {
diff --git a/components/camel-lra/src/test/java/org/apache/camel/service/lra/LRAFailuresIT.java b/components/camel-lra/src/test/java/org/apache/camel/service/lra/LRAFailuresIT.java
index ad4f9d0..752c4da 100644
--- a/components/camel-lra/src/test/java/org/apache/camel/service/lra/LRAFailuresIT.java
+++ b/components/camel-lra/src/test/java/org/apache/camel/service/lra/LRAFailuresIT.java
@@ -20,7 +20,7 @@ import java.util.concurrent.atomic.AtomicInteger;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class LRAFailuresIT extends AbstractLRATestSupport {
diff --git a/components/camel-lra/src/test/java/org/apache/camel/service/lra/LRAManualIT.java b/components/camel-lra/src/test/java/org/apache/camel/service/lra/LRAManualIT.java
index 7cc6ec5..ea43586 100644
--- a/components/camel-lra/src/test/java/org/apache/camel/service/lra/LRAManualIT.java
+++ b/components/camel-lra/src/test/java/org/apache/camel/service/lra/LRAManualIT.java
@@ -23,7 +23,7 @@ import org.apache.camel.RoutesBuilder;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.model.SagaCompletionMode;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class LRAManualIT extends AbstractLRATestSupport {
diff --git a/components/camel-lra/src/test/java/org/apache/camel/service/lra/LRAOptionsIT.java b/components/camel-lra/src/test/java/org/apache/camel/service/lra/LRAOptionsIT.java
index f5b884e..c2a0557 100644
--- a/components/camel-lra/src/test/java/org/apache/camel/service/lra/LRAOptionsIT.java
+++ b/components/camel-lra/src/test/java/org/apache/camel/service/lra/LRAOptionsIT.java
@@ -20,8 +20,9 @@ import org.apache.camel.Exchange;
import org.apache.camel.RuntimeCamelException;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertThrows;
public class LRAOptionsIT extends AbstractLRATestSupport {
@@ -48,19 +49,16 @@ public class LRAOptionsIT extends AbstractLRATestSupport {
compensate.expectedHeaderReceived("name", "Nicola");
compensate.expectedMessagesMatches(ex -> ex.getIn().getHeader(Exchange.SAGA_LONG_RUNNING_ACTION) != null);
- try {
- template.sendBodyAndHeader("direct:workflow", "compensate", "myname", "Nicola");
- Assert.fail("Should throw an exception");
- } catch (Exception ex) {
- // OK
- }
+ assertThrows(Exception.class,
+ () -> template.sendBodyAndHeader("direct:workflow", "compensate", "myname", "Nicola"));
compensate.assertIsSatisfied();
}
- @Test(expected = RuntimeCamelException.class)
+ @Test
public void testRouteDoesNotHangOnOptionError() throws Exception {
- template.sendBody("direct:wrong-expression", "Hello");
+ assertThrows(RuntimeCamelException.class,
+ () -> template.sendBody("direct:wrong-expression", "Hello"));
}
@Override
diff --git a/components/camel-lra/src/test/java/org/apache/camel/service/lra/LRATimeoutIT.java b/components/camel-lra/src/test/java/org/apache/camel/service/lra/LRATimeoutIT.java
index 1a16a12..517e7ce 100644
--- a/components/camel-lra/src/test/java/org/apache/camel/service/lra/LRATimeoutIT.java
+++ b/components/camel-lra/src/test/java/org/apache/camel/service/lra/LRATimeoutIT.java
@@ -21,7 +21,7 @@ import java.util.concurrent.TimeUnit;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.model.SagaCompletionMode;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class LRATimeoutIT extends AbstractLRATestSupport {