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/09 20:02:03 UTC
[camel] 12/19: [CAMEL-11807] Upgrade camel-mllp 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 1468ba6a767a49412c117e7ef059ea75f58dbb74
Author: Guillaume Nodet <gn...@gmail.com>
AuthorDate: Thu Jul 9 12:58:43 2020 +0200
[CAMEL-11807] Upgrade camel-mllp to junit5
---
components/camel-mllp/pom.xml | 12 ++-
.../MllpTcpServerConsumerLenientBindTest.java | 13 +++-
.../MllpAcknowledgementDeliveryExceptionTest.java | 8 +-
.../mllp/MllpAcknowledgementExceptionTest.java | 10 +--
.../MllpAcknowledgementReceiveExceptionTest.java | 10 +--
.../MllpAcknowledgementTimeoutExceptionTest.java | 10 +--
...plicationErrorAcknowledgementExceptionTest.java | 12 +--
...licationRejectAcknowledgementExceptionTest.java | 12 +--
...llpCommitErrorAcknowledgementExceptionTest.java | 12 +--
...lpCommitRejectAcknowledgementExceptionTest.java | 12 +--
.../camel/component/mllp/MllpComponentTest.java | 18 ++---
.../camel/component/mllp/MllpEndpointTest.java | 4 +-
.../camel/component/mllp/MllpExceptionTest.java | 12 +--
.../component/mllp/MllpExceptionTestSupport.java | 4 +-
.../MllpInvalidAcknowledgementExceptionTest.java | 10 +--
.../mllp/MllpInvalidMessageExceptionTest.java | 10 +--
.../mllp/MllpMaxConcurrentConsumersTest.java | 17 +++--
.../MllpNegativeAcknowledgementExceptionTest.java | 10 +--
.../mllp/MllpProducerConsumerLoopbackTest.java | 23 +++---
.../component/mllp/MllpReceiveExceptionTest.java | 10 +--
.../component/mllp/MllpSocketExceptionTest.java | 8 +-
.../MllpTcpClientProducerConnectionErrorTest.java | 34 +++++----
...TcpClientProducerIdleConnectionTimeoutTest.java | 28 ++++---
...roducerOptionalEndOfDataWithValidationTest.java | 2 +-
...ucerOptionalEndOfDataWithoutValidationTest.java | 2 +-
...roducerRequiredEndOfDataWithValidationTest.java | 2 +-
...ucerRequiredEndOfDataWithoutValidationTest.java | 2 +-
.../component/mllp/MllpTcpServerCharsetTest.java | 8 +-
...oAcknowledgementWithBridgeErrorHandlerTest.java | 22 +++---
...knowledgementWithoutBridgeErrorHandlerTest.java | 20 +++--
.../mllp/MllpTcpServerConsumerBindTimeoutTest.java | 9 ++-
.../mllp/MllpTcpServerConsumerConnectionTest.java | 12 ++-
...lAcknowledgementWithBridgeErrorHandlerTest.java | 20 +++--
...knowledgementWithoutBridgeErrorHandlerTest.java | 20 +++--
.../MllpTcpServerConsumerMessageHeadersTest.java | 42 ++++++-----
...MllpTcpServerConsumerMulitpleTcpPacketTest.java | 15 ++--
...onsumerOptionalEndOfDataWithValidationTest.java | 6 +-
...umerOptionalEndOfDataWithoutValidationTest.java | 7 +-
...onsumerRequiredEndOfDataWithValidationTest.java | 6 +-
...umerRequiredEndOfDataWithoutValidationTest.java | 6 +-
.../mllp/MllpTcpServerConsumerTransactionTest.java | 15 ++--
.../component/mllp/MllpWriteExceptionTest.java | 10 +--
...tProducerEndOfDataAndValidationTestSupport.java | 28 +++----
...cpServerConsumerAcknowledgementTestSupport.java | 12 +--
...rConsumerEndOfDataAndValidationTestSupport.java | 56 ++++++++------
.../camel/component/mllp/internal/Hl7UtilTest.java | 34 ++++-----
.../internal/MllpSocketBufferReadFromTest.java | 10 +--
.../mllp/internal/MllpSocketBufferTest.java | 46 ++++++------
.../mllp/internal/MllpSocketBufferWriteTest.java | 46 +++++-------
.../mllp/internal/SocketBufferTestSupport.java | 4 +-
.../mllp/support/EmbeddedActiveMQBroker.java | 85 ++++++++++++++++++++++
.../camel/test/executor/PooledExecutorTest.java | 10 +--
.../test/junit/rule/mllp/MllpClientResource.java | 14 ++--
.../test/junit/rule/mllp/MllpServerResource.java | 14 ++--
.../org/apache/camel/test/tcp/JavaSocketTests.java | 17 +++--
55 files changed, 533 insertions(+), 368 deletions(-)
diff --git a/components/camel-mllp/pom.xml b/components/camel-mllp/pom.xml
index 7775416..cde2b1b 100644
--- a/components/camel-mllp/pom.xml
+++ b/components/camel-mllp/pom.xml
@@ -45,7 +45,12 @@
<!-- testing -->
<dependency>
<groupId>org.apache.camel</groupId>
- <artifactId>camel-test</artifactId>
+ <artifactId>camel-test-junit5</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>hamcrest</artifactId>
<scope>test</scope>
</dependency>
<dependency>
@@ -64,6 +69,11 @@
<version>${activemq-version}</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
<!-- test logging -->
<dependency>
diff --git a/components/camel-mllp/src/test/java/org/apache/camel/MllpTcpServerConsumerLenientBindTest.java b/components/camel-mllp/src/test/java/org/apache/camel/MllpTcpServerConsumerLenientBindTest.java
index 54925ce..561ec67 100644
--- a/components/camel-mllp/src/test/java/org/apache/camel/MllpTcpServerConsumerLenientBindTest.java
+++ b/components/camel-mllp/src/test/java/org/apache/camel/MllpTcpServerConsumerLenientBindTest.java
@@ -24,16 +24,21 @@ import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.test.AvailablePortFinder;
import org.apache.camel.test.junit.rule.mllp.MllpClientResource;
import org.apache.camel.test.junit.rule.mllp.MllpJUnitResourceTimeoutException;
-import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.camel.test.junit5.CamelTestSupport;
import org.apache.camel.test.mllp.Hl7TestMessageGenerator;
-import org.junit.Rule;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+import static org.apache.camel.test.junit5.TestSupport.assertIsInstanceOf;
+import static org.apache.camel.test.junit5.TestSupport.assertStringContains;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public class MllpTcpServerConsumerLenientBindTest extends CamelTestSupport {
static final int RECEIVE_TIMEOUT = 1000;
static final int READ_TIMEOUT = 500;
- @Rule
+ @RegisterExtension
public MllpClientResource mllpClient = new MllpClientResource();
@EndpointInject("mock://result")
diff --git a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpAcknowledgementDeliveryExceptionTest.java b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpAcknowledgementDeliveryExceptionTest.java
index 13d696b..805a93a 100644
--- a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpAcknowledgementDeliveryExceptionTest.java
+++ b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpAcknowledgementDeliveryExceptionTest.java
@@ -16,11 +16,11 @@
*/
package org.apache.camel.component.mllp;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Tests for the class.
diff --git a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpAcknowledgementExceptionTest.java b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpAcknowledgementExceptionTest.java
index 791b2af..a8b861b 100644
--- a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpAcknowledgementExceptionTest.java
+++ b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpAcknowledgementExceptionTest.java
@@ -16,12 +16,12 @@
*/
package org.apache.camel.component.mllp;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Tests for the class.
diff --git a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpAcknowledgementReceiveExceptionTest.java b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpAcknowledgementReceiveExceptionTest.java
index 075e0ab..0e2e4b4 100644
--- a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpAcknowledgementReceiveExceptionTest.java
+++ b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpAcknowledgementReceiveExceptionTest.java
@@ -16,12 +16,12 @@
*/
package org.apache.camel.component.mllp;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Tests for the class.
diff --git a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpAcknowledgementTimeoutExceptionTest.java b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpAcknowledgementTimeoutExceptionTest.java
index 4caa1b4..e956e30 100644
--- a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpAcknowledgementTimeoutExceptionTest.java
+++ b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpAcknowledgementTimeoutExceptionTest.java
@@ -16,12 +16,12 @@
*/
package org.apache.camel.component.mllp;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Tests for the class.
diff --git a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpApplicationErrorAcknowledgementExceptionTest.java b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpApplicationErrorAcknowledgementExceptionTest.java
index 09b4c38..1b74fd9 100644
--- a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpApplicationErrorAcknowledgementExceptionTest.java
+++ b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpApplicationErrorAcknowledgementExceptionTest.java
@@ -16,13 +16,13 @@
*/
package org.apache.camel.component.mllp;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Tests for the class.
diff --git a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpApplicationRejectAcknowledgementExceptionTest.java b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpApplicationRejectAcknowledgementExceptionTest.java
index 225beb6..837e5b1 100644
--- a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpApplicationRejectAcknowledgementExceptionTest.java
+++ b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpApplicationRejectAcknowledgementExceptionTest.java
@@ -16,13 +16,13 @@
*/
package org.apache.camel.component.mllp;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Tests for the class.
diff --git a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpCommitErrorAcknowledgementExceptionTest.java b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpCommitErrorAcknowledgementExceptionTest.java
index 6ad3a59..3a58211 100644
--- a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpCommitErrorAcknowledgementExceptionTest.java
+++ b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpCommitErrorAcknowledgementExceptionTest.java
@@ -16,13 +16,13 @@
*/
package org.apache.camel.component.mllp;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Tests for the class.
diff --git a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpCommitRejectAcknowledgementExceptionTest.java b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpCommitRejectAcknowledgementExceptionTest.java
index 9ffd6ee..fcb1846 100644
--- a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpCommitRejectAcknowledgementExceptionTest.java
+++ b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpCommitRejectAcknowledgementExceptionTest.java
@@ -16,13 +16,13 @@
*/
package org.apache.camel.component.mllp;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Tests for the class.
diff --git a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpComponentTest.java b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpComponentTest.java
index 8813894..96b4d3a 100644
--- a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpComponentTest.java
+++ b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpComponentTest.java
@@ -16,14 +16,14 @@
*/
package org.apache.camel.component.mllp;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Tests for the class.
@@ -34,7 +34,7 @@ public class MllpComponentTest {
MllpComponent instance;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
initialLogPhiValue = MllpComponent.logPhi;
initialLogPhiMaxBytesValue = MllpComponent.logPhiMaxBytes;
@@ -42,7 +42,7 @@ public class MllpComponentTest {
instance = new MllpComponent();
}
- @After
+ @AfterEach
public void tearDown() throws Exception {
MllpComponent.logPhi = initialLogPhiValue;
MllpComponent.logPhiMaxBytes = initialLogPhiMaxBytesValue;
diff --git a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpEndpointTest.java b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpEndpointTest.java
index b336be3..1882ead 100644
--- a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpEndpointTest.java
+++ b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpEndpointTest.java
@@ -16,9 +16,9 @@
*/
package org.apache.camel.component.mllp;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Tests for the MllpEndpoint class.
diff --git a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpExceptionTest.java b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpExceptionTest.java
index 2d73bd8..6038ac6 100644
--- a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpExceptionTest.java
+++ b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpExceptionTest.java
@@ -16,12 +16,12 @@
*/
package org.apache.camel.component.mllp;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
public class MllpExceptionTest extends MllpExceptionTestSupport {
static final String EXCEPTION_MESSAGE = "Test MllpException";
@@ -30,7 +30,7 @@ public class MllpExceptionTest extends MllpExceptionTestSupport {
MllpException instance;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
instance = new MllpException(EXCEPTION_MESSAGE, HL7_MESSAGE_BYTES, HL7_ACKNOWLEDGEMENT_BYTES);
}
diff --git a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpExceptionTestSupport.java b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpExceptionTestSupport.java
index aa7f10e..07a4590 100644
--- a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpExceptionTestSupport.java
+++ b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpExceptionTestSupport.java
@@ -16,7 +16,7 @@
*/
package org.apache.camel.component.mllp;
-import org.junit.After;
+import org.junit.jupiter.api.AfterEach;
public class MllpExceptionTestSupport {
public static final String HL7_MESSAGE =
@@ -34,7 +34,7 @@ public class MllpExceptionTestSupport {
public static final Exception CAUSE = new Exception("Dummy Exception");
- @After
+ @AfterEach
public void tearDown() throws Exception {
System.clearProperty(MllpComponent.MLLP_LOG_PHI_PROPERTY);
System.clearProperty(MllpComponent.MLLP_LOG_PHI_MAX_BYTES_PROPERTY);
diff --git a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpInvalidAcknowledgementExceptionTest.java b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpInvalidAcknowledgementExceptionTest.java
index b7163f1..48ec7e9 100644
--- a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpInvalidAcknowledgementExceptionTest.java
+++ b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpInvalidAcknowledgementExceptionTest.java
@@ -16,12 +16,12 @@
*/
package org.apache.camel.component.mllp;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Tests for the class.
diff --git a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpInvalidMessageExceptionTest.java b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpInvalidMessageExceptionTest.java
index a82eea0..c98214f 100644
--- a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpInvalidMessageExceptionTest.java
+++ b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpInvalidMessageExceptionTest.java
@@ -16,12 +16,12 @@
*/
package org.apache.camel.component.mllp;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Tests for the class.
diff --git a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpMaxConcurrentConsumersTest.java b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpMaxConcurrentConsumersTest.java
index 51b04a7..3845028 100644
--- a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpMaxConcurrentConsumersTest.java
+++ b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpMaxConcurrentConsumersTest.java
@@ -27,19 +27,21 @@ import org.apache.camel.impl.DefaultCamelContext;
import org.apache.camel.test.AvailablePortFinder;
import org.apache.camel.test.junit.rule.mllp.MllpClientResource;
import org.apache.camel.test.junit.rule.mllp.MllpJUnitResourceException;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Rule;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+import static org.junit.jupiter.api.Assertions.assertThrows;
/**
* Tests related to maxConcurrentConsumers configuration
*/
public class MllpMaxConcurrentConsumersTest extends CamelTestSupport {
- @Rule
+ @RegisterExtension
public MllpClientResource mllpClient = new MllpClientResource();
- @Rule
+ @RegisterExtension
public MllpClientResource mllpClient2 = new MllpClientResource();
@EndpointInject(value = "mock://result")
@@ -85,7 +87,7 @@ public class MllpMaxConcurrentConsumersTest extends CamelTestSupport {
assertMockEndpointsSatisfied(10, TimeUnit.SECONDS);
}
- @Test(expected = MllpJUnitResourceException.class)
+ @Test
public void testConcurrentConsumersMoreThanMaxConsumers() throws Exception {
addTestRoute(1);
result.expectedMessageCount(1);
@@ -98,7 +100,8 @@ public class MllpMaxConcurrentConsumersTest extends CamelTestSupport {
assertMockEndpointsSatisfied(10, TimeUnit.SECONDS);
// second connection should fail
- mllpClient2.connect();
+ assertThrows(MllpJUnitResourceException.class,
+ () -> mllpClient2.connect());
}
void addTestRoute(int maxConcurrentConsumers) throws Exception {
diff --git a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpNegativeAcknowledgementExceptionTest.java b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpNegativeAcknowledgementExceptionTest.java
index 65ca66d..84b8d05 100644
--- a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpNegativeAcknowledgementExceptionTest.java
+++ b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpNegativeAcknowledgementExceptionTest.java
@@ -16,12 +16,12 @@
*/
package org.apache.camel.component.mllp;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Tests for the class.
diff --git a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpProducerConsumerLoopbackTest.java b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpProducerConsumerLoopbackTest.java
index 7e84e9e..af19fac 100644
--- a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpProducerConsumerLoopbackTest.java
+++ b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpProducerConsumerLoopbackTest.java
@@ -26,17 +26,21 @@ import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.impl.DefaultCamelContext;
import org.apache.camel.test.AvailablePortFinder;
-import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.camel.test.junit5.CamelTestSupport;
import org.apache.camel.test.mllp.Hl7TestMessageGenerator;
import org.apache.camel.test.mllp.PassthroughProcessor;
import org.hamcrest.CoreMatchers;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
-import static org.junit.Assume.assumeTrue;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assumptions.assumeTrue;
public class MllpProducerConsumerLoopbackTest extends CamelTestSupport {
+
+ Logger log = LoggerFactory.getLogger(MllpProducerConsumerLoopbackTest.class);
int mllpPort = AvailablePortFinder.getNextAvailable();
String mllpHost = "localhost";
@@ -46,9 +50,10 @@ public class MllpProducerConsumerLoopbackTest extends CamelTestSupport {
@EndpointInject("mock://acknowledged")
MockEndpoint acknowledged;
- @BeforeClass
+ @BeforeAll
public static void setUpClass() throws Exception {
- assumeTrue("Skipping test running in CI server - Fails sometimes on CI server with address already in use", System.getenv("BUILD_ID") == null);
+ assumeTrue(System.getenv("BUILD_ID") == null,
+ "Skipping test running in CI server - Fails sometimes on CI server with address already in use");
}
@Override
@@ -97,7 +102,7 @@ public class MllpProducerConsumerLoopbackTest extends CamelTestSupport {
acknowledged.expectedBodiesReceived(testMessage);
String acknowledgement = source.requestBody((Object) testMessage, String.class);
- Assert.assertThat("Should be acknowledgment for message 1", acknowledgement, CoreMatchers.containsString(String.format("MSA|AA|00001")));
+ assertThat("Should be acknowledgment for message 1", acknowledgement, CoreMatchers.containsString(String.format("MSA|AA|00001")));
assertMockEndpointsSatisfied(60, TimeUnit.SECONDS);
}
@@ -112,7 +117,7 @@ public class MllpProducerConsumerLoopbackTest extends CamelTestSupport {
String testMessage = Hl7TestMessageGenerator.generateMessage(i);
acknowledged.message(i - 1).body().isEqualTo(testMessage);
String acknowledgement = source.requestBody((Object) testMessage, String.class);
- Assert.assertThat("Should be acknowledgment for message " + i, acknowledgement, CoreMatchers.containsString(String.format("MSA|AA|%05d", i)));
+ assertThat("Should be acknowledgment for message " + i, acknowledgement, CoreMatchers.containsString(String.format("MSA|AA|%05d", i)));
}
assertMockEndpointsSatisfied(60, TimeUnit.SECONDS);
diff --git a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpReceiveExceptionTest.java b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpReceiveExceptionTest.java
index a2780eb..d5588f2 100644
--- a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpReceiveExceptionTest.java
+++ b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpReceiveExceptionTest.java
@@ -16,12 +16,12 @@
*/
package org.apache.camel.component.mllp;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Tests for the class.
diff --git a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpSocketExceptionTest.java b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpSocketExceptionTest.java
index bcb9169..83d067f 100644
--- a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpSocketExceptionTest.java
+++ b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpSocketExceptionTest.java
@@ -16,11 +16,11 @@
*/
package org.apache.camel.component.mllp;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
/**
* Tests for the class.
diff --git a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpClientProducerConnectionErrorTest.java b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpClientProducerConnectionErrorTest.java
index 637864d..1aabab2 100644
--- a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpClientProducerConnectionErrorTest.java
+++ b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpClientProducerConnectionErrorTest.java
@@ -29,13 +29,17 @@ import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.impl.DefaultCamelContext;
import org.apache.camel.test.AvailablePortFinder;
import org.apache.camel.test.junit.rule.mllp.MllpServerResource;
-import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.camel.test.junit5.CamelTestSupport;
import org.apache.camel.test.mllp.Hl7TestMessageGenerator;
-import org.junit.Rule;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public class MllpTcpClientProducerConnectionErrorTest extends CamelTestSupport {
- @Rule
+
+ @RegisterExtension
public MllpServerResource mllpServer = new MllpServerResource("localhost", AvailablePortFinder.getNextAvailable());
@EndpointInject("direct://source")
@@ -121,13 +125,13 @@ public class MllpTcpClientProducerConnectionErrorTest extends CamelTestSupport {
// Need to send one message to get the connection established
source.sendBody(Hl7TestMessageGenerator.generateMessage());
- assertTrue("Should have completed an exchange", oneDone.matches(5, TimeUnit.SECONDS));
+ assertTrue(oneDone.matches(5, TimeUnit.SECONDS), "Should have completed an exchange");
mllpServer.closeClientConnections();
source.sendBody(Hl7TestMessageGenerator.generateMessage());
- assertTrue("Should have completed two exchanges", twoDone.matches(5, TimeUnit.SECONDS));
+ assertTrue(twoDone.matches(5, TimeUnit.SECONDS), "Should have completed two exchanges");
assertMockEndpointsSatisfied(5, TimeUnit.SECONDS);
}
@@ -150,12 +154,12 @@ public class MllpTcpClientProducerConnectionErrorTest extends CamelTestSupport {
// Need to send one message to get the connection established
source.sendBody(Hl7TestMessageGenerator.generateMessage());
- assertTrue("Should have completed an exchange", oneDone.matches(5, TimeUnit.SECONDS));
+ assertTrue(oneDone.matches(5, TimeUnit.SECONDS), "Should have completed an exchange");
mllpServer.resetClientConnections();
source.sendBody(Hl7TestMessageGenerator.generateMessage());
- assertTrue("Should have completed two exchanges", twoDone.matches(5, TimeUnit.SECONDS));
+ assertTrue(twoDone.matches(5, TimeUnit.SECONDS), "Should have completed two exchanges");
assertMockEndpointsSatisfied(5, TimeUnit.SECONDS);
}
@@ -174,7 +178,7 @@ public class MllpTcpClientProducerConnectionErrorTest extends CamelTestSupport {
source.sendBody(Hl7TestMessageGenerator.generateMessage());
- assertTrue("Should have completed an exchange", done.matches(5, TimeUnit.SECONDS));
+ assertTrue(done.matches(5, TimeUnit.SECONDS), "Should have completed an exchange");
assertMockEndpointsSatisfied(5, TimeUnit.SECONDS);
}
@@ -193,7 +197,7 @@ public class MllpTcpClientProducerConnectionErrorTest extends CamelTestSupport {
source.sendBody(Hl7TestMessageGenerator.generateMessage());
- assertTrue("Should have completed an exchange", done.matches(5, TimeUnit.SECONDS));
+ assertTrue(done.matches(5, TimeUnit.SECONDS), "Should have completed an exchange");
assertMockEndpointsSatisfied(5, TimeUnit.SECONDS);
}
@@ -214,12 +218,12 @@ public class MllpTcpClientProducerConnectionErrorTest extends CamelTestSupport {
source.sendBody(Hl7TestMessageGenerator.generateMessage());
- assertTrue("Should have completed an exchange", done.matches(5, TimeUnit.SECONDS));
+ assertTrue(done.matches(5, TimeUnit.SECONDS), "Should have completed an exchange");
assertMockEndpointsSatisfied(5, TimeUnit.SECONDS);
// Depending on the timing, either a write or a receive exception will be thrown
- assertEquals("Either a write or a receive exception should have been be thrown", 1, writeEx.getExchanges().size() + acknowledgementEx.getExchanges().size());
+ assertEquals(1, writeEx.getExchanges().size() + acknowledgementEx.getExchanges().size(), "Either a write or a receive exception should have been be thrown");
}
@Test()
@@ -238,12 +242,12 @@ public class MllpTcpClientProducerConnectionErrorTest extends CamelTestSupport {
source.sendBody(Hl7TestMessageGenerator.generateMessage());
- assertTrue("Should have completed an exchange", done.matches(5, TimeUnit.SECONDS));
+ assertTrue(done.matches(5, TimeUnit.SECONDS), "Should have completed an exchange");
assertMockEndpointsSatisfied(5, TimeUnit.SECONDS);
// Depending on the timing, either a write or a receive exception will be thrown
- assertEquals("Either a write or a receive exception should have been be thrown", 1, writeEx.getExchanges().size() + acknowledgementEx.getExchanges().size());
+ assertEquals(1, writeEx.getExchanges().size() + acknowledgementEx.getExchanges().size(), "Either a write or a receive exception should have been be thrown");
}
@Test()
@@ -264,7 +268,7 @@ public class MllpTcpClientProducerConnectionErrorTest extends CamelTestSupport {
source.sendBody(Hl7TestMessageGenerator.generateMessage());
- assertTrue("Should have completed an exchange", done.matches(5, TimeUnit.SECONDS));
+ assertTrue(done.matches(5, TimeUnit.SECONDS), "Should have completed an exchange");
assertMockEndpointsSatisfied(5, TimeUnit.SECONDS);
}
diff --git a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpClientProducerIdleConnectionTimeoutTest.java b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpClientProducerIdleConnectionTimeoutTest.java
index cdf7628..634ee8d 100644
--- a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpClientProducerIdleConnectionTimeoutTest.java
+++ b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpClientProducerIdleConnectionTimeoutTest.java
@@ -29,19 +29,28 @@ import org.apache.camel.impl.DefaultCamelContext;
import org.apache.camel.test.AvailablePortFinder;
import org.apache.camel.test.junit.rule.mllp.MllpJUnitResourceException;
import org.apache.camel.test.junit.rule.mllp.MllpServerResource;
-import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.camel.test.junit5.CamelTestSupport;
import org.apache.camel.test.mllp.Hl7TestMessageGenerator;
-import org.junit.Rule;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
public class MllpTcpClientProducerIdleConnectionTimeoutTest extends CamelTestSupport {
+
static final int CONNECT_TIMEOUT = 500;
static final int RECEIVE_TIMEOUT = 1000;
static final int READ_TIMEOUT = 500;
static final int IDLE_TIMEOUT = RECEIVE_TIMEOUT * 3;
- @Rule
- public MllpServerResource mllpServer = new MllpServerResource("localhost", AvailablePortFinder.getNextAvailable());
+ Logger log = LoggerFactory.getLogger(MllpTcpClientProducerIdleConnectionTimeoutTest.class);
+
+ @RegisterExtension
+ MllpServerResource mllpServer = new MllpServerResource("localhost", AvailablePortFinder.getNextAvailable());
@EndpointInject("direct://source")
ProducerTemplate source;
@@ -94,7 +103,7 @@ public class MllpTcpClientProducerIdleConnectionTimeoutTest extends CamelTestSup
};
}
- @Test(expected = MllpJUnitResourceException.class)
+ @Test
public void testIdleConnectionTimeout() throws Exception {
complete.expectedMessageCount(2);
writeEx.expectedMessageCount(0);
@@ -108,13 +117,14 @@ public class MllpTcpClientProducerIdleConnectionTimeoutTest extends CamelTestSup
Thread.sleep(IDLE_TIMEOUT / 2);
source.sendBody(Hl7TestMessageGenerator.generateMessage());
- assertTrue("Should have completed two exchanges", done.matches(5, TimeUnit.SECONDS));
+ assertTrue(done.matches(5, TimeUnit.SECONDS), "Should have completed two exchanges");
assertMockEndpointsSatisfied(5, TimeUnit.SECONDS);
Thread.sleep((long) (IDLE_TIMEOUT * 1.1));
- mllpServer.checkClientConnections();
+ assertThrows(MllpJUnitResourceException.class,
+ () -> mllpServer.checkClientConnections());
}
@Test
@@ -131,7 +141,7 @@ public class MllpTcpClientProducerIdleConnectionTimeoutTest extends CamelTestSup
Thread.sleep(IDLE_TIMEOUT / 2);
source.sendBody(Hl7TestMessageGenerator.generateMessage());
- assertTrue("Should have completed two exchanges", done.matches(5, TimeUnit.SECONDS));
+ assertTrue(done.matches(5, TimeUnit.SECONDS), "Should have completed two exchanges");
Thread.sleep((long) (IDLE_TIMEOUT * 1.1));
diff --git a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpClientProducerOptionalEndOfDataWithValidationTest.java b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpClientProducerOptionalEndOfDataWithValidationTest.java
index 0dd3b42..65d669d 100644
--- a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpClientProducerOptionalEndOfDataWithValidationTest.java
+++ b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpClientProducerOptionalEndOfDataWithValidationTest.java
@@ -16,7 +16,7 @@
*/
package org.apache.camel.component.mllp;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class MllpTcpClientProducerOptionalEndOfDataWithValidationTest extends TcpClientProducerEndOfDataAndValidationTestSupport {
@Override
diff --git a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpClientProducerOptionalEndOfDataWithoutValidationTest.java b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpClientProducerOptionalEndOfDataWithoutValidationTest.java
index 8c70594..26673b1 100644
--- a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpClientProducerOptionalEndOfDataWithoutValidationTest.java
+++ b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpClientProducerOptionalEndOfDataWithoutValidationTest.java
@@ -16,7 +16,7 @@
*/
package org.apache.camel.component.mllp;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class MllpTcpClientProducerOptionalEndOfDataWithoutValidationTest extends TcpClientProducerEndOfDataAndValidationTestSupport {
@Override
diff --git a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpClientProducerRequiredEndOfDataWithValidationTest.java b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpClientProducerRequiredEndOfDataWithValidationTest.java
index 250ab19..1fa62cd 100644
--- a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpClientProducerRequiredEndOfDataWithValidationTest.java
+++ b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpClientProducerRequiredEndOfDataWithValidationTest.java
@@ -16,7 +16,7 @@
*/
package org.apache.camel.component.mllp;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class MllpTcpClientProducerRequiredEndOfDataWithValidationTest extends TcpClientProducerEndOfDataAndValidationTestSupport {
diff --git a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpClientProducerRequiredEndOfDataWithoutValidationTest.java b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpClientProducerRequiredEndOfDataWithoutValidationTest.java
index 4c94705..550282f 100644
--- a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpClientProducerRequiredEndOfDataWithoutValidationTest.java
+++ b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpClientProducerRequiredEndOfDataWithoutValidationTest.java
@@ -16,7 +16,7 @@
*/
package org.apache.camel.component.mllp;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class MllpTcpClientProducerRequiredEndOfDataWithoutValidationTest extends TcpClientProducerEndOfDataAndValidationTestSupport {
diff --git a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpServerCharsetTest.java b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpServerCharsetTest.java
index 798f89b..da8fbf7 100644
--- a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpServerCharsetTest.java
+++ b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpServerCharsetTest.java
@@ -26,9 +26,9 @@ import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.impl.DefaultCamelContext;
import org.apache.camel.test.AvailablePortFinder;
import org.apache.camel.test.junit.rule.mllp.MllpClientResource;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Rule;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
public class MllpTcpServerCharsetTest extends CamelTestSupport {
static final String TEST_MESSAGE =
@@ -44,7 +44,7 @@ public class MllpTcpServerCharsetTest extends CamelTestSupport {
static final String TARGET_URI = "mock://target";
- @Rule
+ @RegisterExtension
public MllpClientResource mllpClient = new MllpClientResource();
@EndpointInject(TARGET_URI)
diff --git a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpServerConsumerAutoAcknowledgementWithBridgeErrorHandlerTest.java b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpServerConsumerAutoAcknowledgementWithBridgeErrorHandlerTest.java
index a21a689..b572462 100644
--- a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpServerConsumerAutoAcknowledgementWithBridgeErrorHandlerTest.java
+++ b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpServerConsumerAutoAcknowledgementWithBridgeErrorHandlerTest.java
@@ -17,10 +17,14 @@
package org.apache.camel.component.mllp;
import org.apache.camel.Exchange;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import static org.apache.camel.test.junit5.TestSupport.assertIsInstanceOf;
import static org.hamcrest.CoreMatchers.endsWith;
import static org.hamcrest.CoreMatchers.startsWith;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
public class MllpTcpServerConsumerAutoAcknowledgementWithBridgeErrorHandlerTest extends TcpServerConsumerAcknowledgementTestSupport {
@Override
@@ -65,7 +69,7 @@ public class MllpTcpServerConsumerAutoAcknowledgementWithBridgeErrorHandlerTest
Exchange failureExchange = failure.getExchanges().get(0);
Object failureException = failureExchange.getProperty(MllpConstants.MLLP_ACKNOWLEDGEMENT_EXCEPTION);
- assertNotNull("OnFailureOnly exchange should have a " + MllpConstants.MLLP_ACKNOWLEDGEMENT_EXCEPTION + " property", failureException);
+ assertNotNull(failureException, "OnFailureOnly exchange should have a " + MllpConstants.MLLP_ACKNOWLEDGEMENT_EXCEPTION + " property");
assertIsInstanceOf(Exception.class, failureException);
}
@@ -79,10 +83,10 @@ public class MllpTcpServerConsumerAutoAcknowledgementWithBridgeErrorHandlerTest
unparsableMessage(testMessage);
- assertNull("Should not have the exception in the exchange property", result.getReceivedExchanges().get(0).getProperty(Exchange.EXCEPTION_CAUGHT));
- assertNull("Should not have the exception in the exchange property", complete.getReceivedExchanges().get(0).getProperty(Exchange.EXCEPTION_CAUGHT));
+ assertNull(result.getReceivedExchanges().get(0).getProperty(Exchange.EXCEPTION_CAUGHT), "Should not have the exception in the exchange property");
+ assertNull(complete.getReceivedExchanges().get(0).getProperty(Exchange.EXCEPTION_CAUGHT), "Should not have the exception in the exchange property");
- assertNotNull("Should have the exception in the exchange property", ackGenerationEx.getReceivedExchanges().get(0).getProperty(Exchange.EXCEPTION_CAUGHT));
+ assertNotNull(ackGenerationEx.getReceivedExchanges().get(0).getProperty(Exchange.EXCEPTION_CAUGHT), "Should have the exception in the exchange property");
}
@Test
@@ -94,8 +98,8 @@ public class MllpTcpServerConsumerAutoAcknowledgementWithBridgeErrorHandlerTest
unparsableMessage(testMessage);
- assertNull("Should not have the exception in the exchange property", result.getReceivedExchanges().get(0).getProperty(Exchange.EXCEPTION_CAUGHT));
- assertNull("Should not have the exception in the exchange property", complete.getReceivedExchanges().get(0).getProperty(Exchange.EXCEPTION_CAUGHT));
+ assertNull(result.getReceivedExchanges().get(0).getProperty(Exchange.EXCEPTION_CAUGHT), "Should not have the exception in the exchange property");
+ assertNull(complete.getReceivedExchanges().get(0).getProperty(Exchange.EXCEPTION_CAUGHT), "Should not have the exception in the exchange property");
}
@@ -108,8 +112,8 @@ public class MllpTcpServerConsumerAutoAcknowledgementWithBridgeErrorHandlerTest
unparsableMessage(testMessage);
- assertNull("Should not have the exception in the exchange property", result.getReceivedExchanges().get(0).getProperty(Exchange.EXCEPTION_CAUGHT));
- assertNull("Should not have the exception in the exchange property", complete.getReceivedExchanges().get(0).getProperty(Exchange.EXCEPTION_CAUGHT));
+ assertNull(result.getReceivedExchanges().get(0).getProperty(Exchange.EXCEPTION_CAUGHT), "Should not have the exception in the exchange property");
+ assertNull(complete.getReceivedExchanges().get(0).getProperty(Exchange.EXCEPTION_CAUGHT), "Should not have the exception in the exchange property");
}
}
diff --git a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpServerConsumerAutoAcknowledgementWithoutBridgeErrorHandlerTest.java b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpServerConsumerAutoAcknowledgementWithoutBridgeErrorHandlerTest.java
index a737276..f26f902 100644
--- a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpServerConsumerAutoAcknowledgementWithoutBridgeErrorHandlerTest.java
+++ b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpServerConsumerAutoAcknowledgementWithoutBridgeErrorHandlerTest.java
@@ -17,10 +17,14 @@
package org.apache.camel.component.mllp;
import org.apache.camel.Exchange;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import static org.apache.camel.test.junit5.TestSupport.assertIsInstanceOf;
import static org.hamcrest.CoreMatchers.endsWith;
import static org.hamcrest.CoreMatchers.startsWith;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
public class MllpTcpServerConsumerAutoAcknowledgementWithoutBridgeErrorHandlerTest extends TcpServerConsumerAcknowledgementTestSupport {
@Override
@@ -65,7 +69,7 @@ public class MllpTcpServerConsumerAutoAcknowledgementWithoutBridgeErrorHandlerTe
Exchange failureExchange = failure.getExchanges().get(0);
Object failureException = failureExchange.getProperty(MllpConstants.MLLP_ACKNOWLEDGEMENT_EXCEPTION);
- assertNotNull("OnFailureOnly exchange should have a " + MllpConstants.MLLP_ACKNOWLEDGEMENT_EXCEPTION + " property", failureException);
+ assertNotNull(failureException, "OnFailureOnly exchange should have a " + MllpConstants.MLLP_ACKNOWLEDGEMENT_EXCEPTION + " property");
assertIsInstanceOf(Exception.class, failureException);
}
@@ -78,8 +82,8 @@ public class MllpTcpServerConsumerAutoAcknowledgementWithoutBridgeErrorHandlerTe
unparsableMessage(testMessage);
- assertNull("Should not have the exception in the exchange property", result.getReceivedExchanges().get(0).getProperty(Exchange.EXCEPTION_CAUGHT));
- assertNull("Should not have the exception in the exchange property", complete.getReceivedExchanges().get(0).getProperty(Exchange.EXCEPTION_CAUGHT));
+ assertNull(result.getReceivedExchanges().get(0).getProperty(Exchange.EXCEPTION_CAUGHT), "Should not have the exception in the exchange property");
+ assertNull(complete.getReceivedExchanges().get(0).getProperty(Exchange.EXCEPTION_CAUGHT), "Should not have the exception in the exchange property");
}
@Test
@@ -91,8 +95,8 @@ public class MllpTcpServerConsumerAutoAcknowledgementWithoutBridgeErrorHandlerTe
unparsableMessage(testMessage);
- assertNull("Should not have the exception in the exchange property", result.getReceivedExchanges().get(0).getProperty(Exchange.EXCEPTION_CAUGHT));
- assertNull("Should not have the exception in the exchange property", complete.getReceivedExchanges().get(0).getProperty(Exchange.EXCEPTION_CAUGHT));
+ assertNull(result.getReceivedExchanges().get(0).getProperty(Exchange.EXCEPTION_CAUGHT), "Should not have the exception in the exchange property");
+ assertNull(complete.getReceivedExchanges().get(0).getProperty(Exchange.EXCEPTION_CAUGHT), "Should not have the exception in the exchange property");
}
@@ -105,8 +109,8 @@ public class MllpTcpServerConsumerAutoAcknowledgementWithoutBridgeErrorHandlerTe
unparsableMessage(testMessage);
- assertNull("Should not have the exception in the exchange property", result.getReceivedExchanges().get(0).getProperty(Exchange.EXCEPTION_CAUGHT));
- assertNull("Should not have the exception in the exchange property", complete.getReceivedExchanges().get(0).getProperty(Exchange.EXCEPTION_CAUGHT));
+ assertNull(result.getReceivedExchanges().get(0).getProperty(Exchange.EXCEPTION_CAUGHT), "Should not have the exception in the exchange property");
+ assertNull(complete.getReceivedExchanges().get(0).getProperty(Exchange.EXCEPTION_CAUGHT), "Should not have the exception in the exchange property");
}
}
diff --git a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpServerConsumerBindTimeoutTest.java b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpServerConsumerBindTimeoutTest.java
index 6a6b31d..377e6ee 100644
--- a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpServerConsumerBindTimeoutTest.java
+++ b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpServerConsumerBindTimeoutTest.java
@@ -27,13 +27,14 @@ import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.impl.DefaultCamelContext;
import org.apache.camel.test.AvailablePortFinder;
import org.apache.camel.test.junit.rule.mllp.MllpClientResource;
-import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.camel.test.junit5.CamelTestSupport;
import org.apache.camel.test.mllp.Hl7TestMessageGenerator;
-import org.junit.Rule;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
public class MllpTcpServerConsumerBindTimeoutTest extends CamelTestSupport {
- @Rule
+
+ @RegisterExtension
public MllpClientResource mllpClient = new MllpClientResource();
@EndpointInject("mock://result")
diff --git a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpServerConsumerConnectionTest.java b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpServerConsumerConnectionTest.java
index 0faa6d0..7290938 100644
--- a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpServerConsumerConnectionTest.java
+++ b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpServerConsumerConnectionTest.java
@@ -25,15 +25,19 @@ import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.test.AvailablePortFinder;
import org.apache.camel.test.junit.rule.mllp.MllpClientResource;
import org.apache.camel.test.junit.rule.mllp.MllpJUnitResourceException;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Rule;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.fail;
public class MllpTcpServerConsumerConnectionTest extends CamelTestSupport {
static final int RECEIVE_TIMEOUT = 1000;
static final int READ_TIMEOUT = 500;
- @Rule
+ @RegisterExtension
public MllpClientResource mllpClient = new MllpClientResource();
diff --git a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpServerConsumerManualAcknowledgementWithBridgeErrorHandlerTest.java b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpServerConsumerManualAcknowledgementWithBridgeErrorHandlerTest.java
index f01856a..ae90808 100644
--- a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpServerConsumerManualAcknowledgementWithBridgeErrorHandlerTest.java
+++ b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpServerConsumerManualAcknowledgementWithBridgeErrorHandlerTest.java
@@ -17,7 +17,11 @@
package org.apache.camel.component.mllp;
import org.apache.camel.Exchange;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.apache.camel.test.junit5.TestSupport.assertIsInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
public class MllpTcpServerConsumerManualAcknowledgementWithBridgeErrorHandlerTest extends TcpServerConsumerAcknowledgementTestSupport {
@Override
@@ -56,7 +60,7 @@ public class MllpTcpServerConsumerManualAcknowledgementWithBridgeErrorHandlerTes
Exchange failureExchange = failure.getExchanges().get(0);
Object failureException = failureExchange.getProperty(MllpConstants.MLLP_ACKNOWLEDGEMENT_EXCEPTION);
- assertNotNull("OnFailureOnly exchange should have a " + MllpConstants.MLLP_ACKNOWLEDGEMENT_EXCEPTION + " property", failureException);
+ assertNotNull(failureException, "OnFailureOnly exchange should have a " + MllpConstants.MLLP_ACKNOWLEDGEMENT_EXCEPTION + " property");
assertIsInstanceOf(Exception.class, failureException);
}
@@ -70,8 +74,8 @@ public class MllpTcpServerConsumerManualAcknowledgementWithBridgeErrorHandlerTes
unparsableMessage(testMessage);
- assertNull("Should not have the exception in the exchange property", result.getReceivedExchanges().get(0).getProperty(Exchange.EXCEPTION_CAUGHT));
- assertNull("Should not have the exception in the exchange property", complete.getReceivedExchanges().get(0).getProperty(Exchange.EXCEPTION_CAUGHT));
+ assertNull(result.getReceivedExchanges().get(0).getProperty(Exchange.EXCEPTION_CAUGHT), "Should not have the exception in the exchange property");
+ assertNull(complete.getReceivedExchanges().get(0).getProperty(Exchange.EXCEPTION_CAUGHT), "Should not have the exception in the exchange property");
}
@Test
@@ -84,8 +88,8 @@ public class MllpTcpServerConsumerManualAcknowledgementWithBridgeErrorHandlerTes
unparsableMessage(testMessage);
- assertNull("Should not have the exception in the exchange property", result.getReceivedExchanges().get(0).getProperty(Exchange.EXCEPTION_CAUGHT));
- assertNull("Should not have the exception in the exchange property", complete.getReceivedExchanges().get(0).getProperty(Exchange.EXCEPTION_CAUGHT));
+ assertNull(result.getReceivedExchanges().get(0).getProperty(Exchange.EXCEPTION_CAUGHT), "Should not have the exception in the exchange property");
+ assertNull(complete.getReceivedExchanges().get(0).getProperty(Exchange.EXCEPTION_CAUGHT), "Should not have the exception in the exchange property");
}
@@ -99,8 +103,8 @@ public class MllpTcpServerConsumerManualAcknowledgementWithBridgeErrorHandlerTes
unparsableMessage(testMessage);
- assertNull("Should not have the exception in the exchange property", result.getReceivedExchanges().get(0).getProperty(Exchange.EXCEPTION_CAUGHT));
- assertNull("Should not have the exception in the exchange property", complete.getReceivedExchanges().get(0).getProperty(Exchange.EXCEPTION_CAUGHT));
+ assertNull(result.getReceivedExchanges().get(0).getProperty(Exchange.EXCEPTION_CAUGHT), "Should not have the exception in the exchange property");
+ assertNull(complete.getReceivedExchanges().get(0).getProperty(Exchange.EXCEPTION_CAUGHT), "Should not have the exception in the exchange property");
}
}
diff --git a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpServerConsumerManualAcknowledgementWithoutBridgeErrorHandlerTest.java b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpServerConsumerManualAcknowledgementWithoutBridgeErrorHandlerTest.java
index 27f5b65..7618456 100644
--- a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpServerConsumerManualAcknowledgementWithoutBridgeErrorHandlerTest.java
+++ b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpServerConsumerManualAcknowledgementWithoutBridgeErrorHandlerTest.java
@@ -17,7 +17,11 @@
package org.apache.camel.component.mllp;
import org.apache.camel.Exchange;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.apache.camel.test.junit5.TestSupport.assertIsInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
public class MllpTcpServerConsumerManualAcknowledgementWithoutBridgeErrorHandlerTest extends TcpServerConsumerAcknowledgementTestSupport {
@Override
@@ -56,7 +60,7 @@ public class MllpTcpServerConsumerManualAcknowledgementWithoutBridgeErrorHandler
Exchange failureExchange = failure.getExchanges().get(0);
Object failureException = failureExchange.getProperty(MllpConstants.MLLP_ACKNOWLEDGEMENT_EXCEPTION);
- assertNotNull("OnFailureOnly exchange should have a " + MllpConstants.MLLP_ACKNOWLEDGEMENT_EXCEPTION + " property", failureException);
+ assertNotNull(failureException, "OnFailureOnly exchange should have a " + MllpConstants.MLLP_ACKNOWLEDGEMENT_EXCEPTION + " property");
assertIsInstanceOf(Exception.class, failureException);
}
@@ -69,8 +73,8 @@ public class MllpTcpServerConsumerManualAcknowledgementWithoutBridgeErrorHandler
unparsableMessage(testMessage);
- assertNull("Should not have the exception in the exchange property", result.getReceivedExchanges().get(0).getProperty(Exchange.EXCEPTION_CAUGHT));
- assertNull("Should not have the exception in the exchange property", complete.getReceivedExchanges().get(0).getProperty(Exchange.EXCEPTION_CAUGHT));
+ assertNull(result.getReceivedExchanges().get(0).getProperty(Exchange.EXCEPTION_CAUGHT), "Should not have the exception in the exchange property");
+ assertNull(complete.getReceivedExchanges().get(0).getProperty(Exchange.EXCEPTION_CAUGHT), "Should not have the exception in the exchange property");
}
@Test
@@ -82,8 +86,8 @@ public class MllpTcpServerConsumerManualAcknowledgementWithoutBridgeErrorHandler
unparsableMessage(testMessage);
- assertNull("Should not have the exception in the exchange property", result.getReceivedExchanges().get(0).getProperty(Exchange.EXCEPTION_CAUGHT));
- assertNull("Should not have the exception in the exchange property", complete.getReceivedExchanges().get(0).getProperty(Exchange.EXCEPTION_CAUGHT));
+ assertNull(result.getReceivedExchanges().get(0).getProperty(Exchange.EXCEPTION_CAUGHT), "Should not have the exception in the exchange property");
+ assertNull(complete.getReceivedExchanges().get(0).getProperty(Exchange.EXCEPTION_CAUGHT), "Should not have the exception in the exchange property");
}
@@ -96,8 +100,8 @@ public class MllpTcpServerConsumerManualAcknowledgementWithoutBridgeErrorHandler
unparsableMessage(testMessage);
- assertNull("Should not have the exception in the exchange property", result.getReceivedExchanges().get(0).getProperty(Exchange.EXCEPTION_CAUGHT));
- assertNull("Should not have the exception in the exchange property", complete.getReceivedExchanges().get(0).getProperty(Exchange.EXCEPTION_CAUGHT));
+ assertNull(result.getReceivedExchanges().get(0).getProperty(Exchange.EXCEPTION_CAUGHT), "Should not have the exception in the exchange property");
+ assertNull(complete.getReceivedExchanges().get(0).getProperty(Exchange.EXCEPTION_CAUGHT), "Should not have the exception in the exchange property");
}
}
diff --git a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpServerConsumerMessageHeadersTest.java b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpServerConsumerMessageHeadersTest.java
index 975dd8a..d7784bf 100644
--- a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpServerConsumerMessageHeadersTest.java
+++ b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpServerConsumerMessageHeadersTest.java
@@ -27,12 +27,16 @@ import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.impl.DefaultCamelContext;
import org.apache.camel.test.AvailablePortFinder;
import org.apache.camel.test.junit.rule.mllp.MllpClientResource;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Rule;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
public class MllpTcpServerConsumerMessageHeadersTest extends CamelTestSupport {
- @Rule
+
+ @RegisterExtension
public MllpClientResource mllpClient = new MllpClientResource();
@EndpointInject("mock://result")
@@ -92,8 +96,8 @@ public class MllpTcpServerConsumerMessageHeadersTest extends CamelTestSupport {
Message message = result.getExchanges().get(0).getIn();
- assertNotNull("Should have header" + MllpConstants.MLLP_LOCAL_ADDRESS, message.getHeader(MllpConstants.MLLP_LOCAL_ADDRESS));
- assertNotNull("Should have header" + MllpConstants.MLLP_REMOTE_ADDRESS, message.getHeader(MllpConstants.MLLP_REMOTE_ADDRESS));
+ assertNotNull(message.getHeader(MllpConstants.MLLP_LOCAL_ADDRESS), "Should have header" + MllpConstants.MLLP_LOCAL_ADDRESS);
+ assertNotNull(message.getHeader(MllpConstants.MLLP_REMOTE_ADDRESS), "Should have header" + MllpConstants.MLLP_REMOTE_ADDRESS);
}
@@ -113,19 +117,19 @@ public class MllpTcpServerConsumerMessageHeadersTest extends CamelTestSupport {
Message message = result.getExchanges().get(0).getIn();
- assertNotNull("Should have header" + MllpConstants.MLLP_LOCAL_ADDRESS, message.getHeader(MllpConstants.MLLP_LOCAL_ADDRESS));
- assertNotNull("Should have header" + MllpConstants.MLLP_REMOTE_ADDRESS, message.getHeader(MllpConstants.MLLP_REMOTE_ADDRESS));
-
- assertNull("Should NOT have header" + MllpConstants.MLLP_SENDING_APPLICATION, message.getHeader(MllpConstants.MLLP_SENDING_APPLICATION));
- assertNull("Should NOT have header" + MllpConstants.MLLP_SENDING_FACILITY, message.getHeader(MllpConstants.MLLP_SENDING_FACILITY));
- assertNull("Should NOT have header" + MllpConstants.MLLP_RECEIVING_APPLICATION, message.getHeader(MllpConstants.MLLP_RECEIVING_APPLICATION));
- assertNull("Should NOT have header" + MllpConstants.MLLP_TIMESTAMP, message.getHeader(MllpConstants.MLLP_TIMESTAMP));
- assertNull("Should NOT have header" + MllpConstants.MLLP_SECURITY, message.getHeader(MllpConstants.MLLP_SECURITY));
- assertNull("Should NOT have header" + MllpConstants.MLLP_MESSAGE_TYPE, message.getHeader(MllpConstants.MLLP_MESSAGE_TYPE));
- assertNull("Should NOT have header" + MllpConstants.MLLP_EVENT_TYPE, message.getHeader(MllpConstants.MLLP_EVENT_TYPE));
- assertNull("Should NOT have header" + MllpConstants.MLLP_MESSAGE_CONTROL, message.getHeader(MllpConstants.MLLP_MESSAGE_CONTROL));
- assertNull("Should NOT have header" + MllpConstants.MLLP_PROCESSING_ID, message.getHeader(MllpConstants.MLLP_PROCESSING_ID));
- assertNull("Should NOT have header" + MllpConstants.MLLP_VERSION_ID, message.getHeader(MllpConstants.MLLP_VERSION_ID));
+ assertNotNull(message.getHeader(MllpConstants.MLLP_LOCAL_ADDRESS), "Should have header" + MllpConstants.MLLP_LOCAL_ADDRESS);
+ assertNotNull(message.getHeader(MllpConstants.MLLP_REMOTE_ADDRESS), "Should have header" + MllpConstants.MLLP_REMOTE_ADDRESS);
+
+ assertNull(message.getHeader(MllpConstants.MLLP_SENDING_APPLICATION), "Should NOT have header" + MllpConstants.MLLP_SENDING_APPLICATION);
+ assertNull(message.getHeader(MllpConstants.MLLP_SENDING_FACILITY), "Should NOT have header" + MllpConstants.MLLP_SENDING_FACILITY);
+ assertNull(message.getHeader(MllpConstants.MLLP_RECEIVING_APPLICATION), "Should NOT have header" + MllpConstants.MLLP_RECEIVING_APPLICATION);
+ assertNull(message.getHeader(MllpConstants.MLLP_TIMESTAMP), "Should NOT have header" + MllpConstants.MLLP_TIMESTAMP);
+ assertNull(message.getHeader(MllpConstants.MLLP_SECURITY), "Should NOT have header" + MllpConstants.MLLP_SECURITY);
+ assertNull(message.getHeader(MllpConstants.MLLP_MESSAGE_TYPE), "Should NOT have header" + MllpConstants.MLLP_MESSAGE_TYPE);
+ assertNull(message.getHeader(MllpConstants.MLLP_EVENT_TYPE), "Should NOT have header" + MllpConstants.MLLP_EVENT_TYPE);
+ assertNull(message.getHeader(MllpConstants.MLLP_MESSAGE_CONTROL), "Should NOT have header" + MllpConstants.MLLP_MESSAGE_CONTROL);
+ assertNull(message.getHeader(MllpConstants.MLLP_PROCESSING_ID), "Should NOT have header" + MllpConstants.MLLP_PROCESSING_ID);
+ assertNull(message.getHeader(MllpConstants.MLLP_VERSION_ID), "Should NOT have header" + MllpConstants.MLLP_VERSION_ID);
}
void addTestRoute(final boolean hl7Headers) throws Exception {
diff --git a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpServerConsumerMulitpleTcpPacketTest.java b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpServerConsumerMulitpleTcpPacketTest.java
index 33d1b24..66dd01b 100644
--- a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpServerConsumerMulitpleTcpPacketTest.java
+++ b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpServerConsumerMulitpleTcpPacketTest.java
@@ -26,16 +26,17 @@ import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.impl.DefaultCamelContext;
import org.apache.camel.test.AvailablePortFinder;
import org.apache.camel.test.junit.rule.mllp.MllpClientResource;
-import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.camel.test.junit5.CamelTestSupport;
import org.apache.camel.test.mllp.Hl7TestMessageGenerator;
import org.apache.camel.test.mllp.PassthroughProcessor;
import org.hamcrest.CoreMatchers;
-import org.junit.Assert;
-import org.junit.Rule;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+import static org.hamcrest.MatcherAssert.assertThat;
public class MllpTcpServerConsumerMulitpleTcpPacketTest extends CamelTestSupport {
- @Rule
+ @RegisterExtension
public MllpClientResource mllpClient = new MllpClientResource();
@EndpointInject("mock://result")
@@ -93,7 +94,7 @@ public class MllpTcpServerConsumerMulitpleTcpPacketTest extends CamelTestSupport
assertMockEndpointsSatisfied(10, TimeUnit.SECONDS);
- Assert.assertThat("Should be acknowledgment for message 1", acknowledgement, CoreMatchers.containsString(String.format("MSA|AA|00001")));
+ assertThat("Should be acknowledgment for message 1", acknowledgement, CoreMatchers.containsString(String.format("MSA|AA|00001")));
}
@@ -110,7 +111,7 @@ public class MllpTcpServerConsumerMulitpleTcpPacketTest extends CamelTestSupport
result.message(i - 1).body().isEqualTo(testMessage);
mllpClient.sendFramedDataInMultiplePackets(testMessage, (byte) '\r');
String acknowledgement = mllpClient.receiveFramedData();
- Assert.assertThat("Should be acknowledgment for message " + i, acknowledgement, CoreMatchers.containsString(String.format("MSA|AA|%05d", i)));
+ assertThat("Should be acknowledgment for message " + i, acknowledgement, CoreMatchers.containsString(String.format("MSA|AA|%05d", i)));
}
assertMockEndpointsSatisfied(10, TimeUnit.SECONDS);
diff --git a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpServerConsumerOptionalEndOfDataWithValidationTest.java b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpServerConsumerOptionalEndOfDataWithValidationTest.java
index 4760ff1..95d019a 100644
--- a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpServerConsumerOptionalEndOfDataWithValidationTest.java
+++ b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpServerConsumerOptionalEndOfDataWithValidationTest.java
@@ -20,7 +20,9 @@ import java.util.concurrent.TimeUnit;
import org.apache.camel.builder.NotifyBuilder;
import org.apache.camel.test.mllp.Hl7TestMessageGenerator;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
public class MllpTcpServerConsumerOptionalEndOfDataWithValidationTest extends TcpServerConsumerEndOfDataAndValidationTestSupport {
@@ -78,7 +80,7 @@ public class MllpTcpServerConsumerOptionalEndOfDataWithValidationTest extends Tc
mllpClient.sendFramedData(Hl7TestMessageGenerator.generateMessage().replaceFirst("PID", "PID" + MllpProtocolConstants.END_OF_BLOCK));
- assertTrue("Exchange should have completed", done.matches(5, TimeUnit.SECONDS));
+ assertTrue(done.matches(5, TimeUnit.SECONDS), "Exchange should have completed");
}
@Override
diff --git a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpServerConsumerOptionalEndOfDataWithoutValidationTest.java b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpServerConsumerOptionalEndOfDataWithoutValidationTest.java
index a657080..99f140e 100644
--- a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpServerConsumerOptionalEndOfDataWithoutValidationTest.java
+++ b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpServerConsumerOptionalEndOfDataWithoutValidationTest.java
@@ -20,7 +20,9 @@ import java.util.concurrent.TimeUnit;
import org.apache.camel.builder.NotifyBuilder;
import org.apache.camel.test.mllp.Hl7TestMessageGenerator;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
public class MllpTcpServerConsumerOptionalEndOfDataWithoutValidationTest extends TcpServerConsumerEndOfDataAndValidationTestSupport {
@@ -70,7 +72,8 @@ public class MllpTcpServerConsumerOptionalEndOfDataWithoutValidationTest extends
mllpClient.sendFramedData(Hl7TestMessageGenerator.generateMessage().replaceFirst("PID", "PID" + MllpProtocolConstants.END_OF_BLOCK));
- assertTrue("Exchange should have completed", done.matches(5, TimeUnit.SECONDS)); }
+ assertTrue(done.matches(5, TimeUnit.SECONDS), "Exchange should have completed");
+ }
@Override
public void testNthMessageContainingEmbeddedEndOfBlock() throws Exception {
diff --git a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpServerConsumerRequiredEndOfDataWithValidationTest.java b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpServerConsumerRequiredEndOfDataWithValidationTest.java
index 641faf5..1e13f25 100644
--- a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpServerConsumerRequiredEndOfDataWithValidationTest.java
+++ b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpServerConsumerRequiredEndOfDataWithValidationTest.java
@@ -20,7 +20,9 @@ import java.util.concurrent.TimeUnit;
import org.apache.camel.builder.NotifyBuilder;
import org.apache.camel.test.mllp.Hl7TestMessageGenerator;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertFalse;
public class MllpTcpServerConsumerRequiredEndOfDataWithValidationTest extends TcpServerConsumerEndOfDataAndValidationTestSupport {
@@ -77,7 +79,7 @@ public class MllpTcpServerConsumerRequiredEndOfDataWithValidationTest extends Tc
mllpClient.sendFramedData(Hl7TestMessageGenerator.generateMessage().replaceFirst("PID", "PID" + MllpProtocolConstants.END_OF_BLOCK));
- assertFalse("Exchange should not have completed", done.matches(5, TimeUnit.SECONDS));
+ assertFalse(done.matches(5, TimeUnit.SECONDS), "Exchange should not have completed");
}
@Override
diff --git a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpServerConsumerRequiredEndOfDataWithoutValidationTest.java b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpServerConsumerRequiredEndOfDataWithoutValidationTest.java
index 3de1c24..9e81d0d 100644
--- a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpServerConsumerRequiredEndOfDataWithoutValidationTest.java
+++ b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpServerConsumerRequiredEndOfDataWithoutValidationTest.java
@@ -20,7 +20,9 @@ import java.util.concurrent.TimeUnit;
import org.apache.camel.builder.NotifyBuilder;
import org.apache.camel.test.mllp.Hl7TestMessageGenerator;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertFalse;
public class MllpTcpServerConsumerRequiredEndOfDataWithoutValidationTest extends TcpServerConsumerEndOfDataAndValidationTestSupport {
@@ -71,7 +73,7 @@ public class MllpTcpServerConsumerRequiredEndOfDataWithoutValidationTest extends
mllpClient.sendFramedData(Hl7TestMessageGenerator.generateMessage().replaceFirst("PID", "PID" + MllpProtocolConstants.END_OF_BLOCK));
- assertFalse("Exchange should not have completed", done.matches(5, TimeUnit.SECONDS));
+ assertFalse(done.matches(5, TimeUnit.SECONDS), "Exchange should not have completed");
}
@Override
diff --git a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpServerConsumerTransactionTest.java b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpServerConsumerTransactionTest.java
index b6de3be..726c1e2 100644
--- a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpServerConsumerTransactionTest.java
+++ b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpServerConsumerTransactionTest.java
@@ -19,27 +19,28 @@ package org.apache.camel.component.mllp;
import java.util.concurrent.TimeUnit;
import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.junit.EmbeddedActiveMQBroker;
import org.apache.camel.BindToRegistry;
import org.apache.camel.CamelContext;
import org.apache.camel.EndpointInject;
import org.apache.camel.LoggingLevel;
import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mllp.support.EmbeddedActiveMQBroker;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.component.sjms.SjmsComponent;
import org.apache.camel.impl.DefaultCamelContext;
import org.apache.camel.test.AvailablePortFinder;
import org.apache.camel.test.junit.rule.mllp.MllpClientResource;
-import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.camel.test.junit5.CamelTestSupport;
import org.apache.camel.test.mllp.Hl7TestMessageGenerator;
-import org.junit.Rule;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
public class MllpTcpServerConsumerTransactionTest extends CamelTestSupport {
- @Rule
- public EmbeddedActiveMQBroker broker = new EmbeddedActiveMQBroker();
- @Rule
+ @RegisterExtension
+ public EmbeddedActiveMQBroker broker = new EmbeddedActiveMQBroker("broker");
+
+ @RegisterExtension
public MllpClientResource mllpClient = new MllpClientResource();
@EndpointInject("mock://result")
diff --git a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpWriteExceptionTest.java b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpWriteExceptionTest.java
index 9c0e975e..6bfc56d 100644
--- a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpWriteExceptionTest.java
+++ b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpWriteExceptionTest.java
@@ -16,12 +16,12 @@
*/
package org.apache.camel.component.mllp;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Tests for the class.
diff --git a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/TcpClientProducerEndOfDataAndValidationTestSupport.java b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/TcpClientProducerEndOfDataAndValidationTestSupport.java
index 40e569b..6ed52fa 100644
--- a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/TcpClientProducerEndOfDataAndValidationTestSupport.java
+++ b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/TcpClientProducerEndOfDataAndValidationTestSupport.java
@@ -28,10 +28,12 @@ import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.impl.DefaultCamelContext;
import org.apache.camel.test.AvailablePortFinder;
import org.apache.camel.test.junit.rule.mllp.MllpServerResource;
-import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.camel.test.junit5.CamelTestSupport;
import org.apache.camel.test.mllp.Hl7TestMessageGenerator;
-import org.junit.Rule;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
public abstract class TcpClientProducerEndOfDataAndValidationTestSupport extends CamelTestSupport {
static final int RECEIVE_TIMEOUT = 1000;
@@ -63,7 +65,7 @@ public abstract class TcpClientProducerEndOfDataAndValidationTestSupport extends
+ "MSA|AE|00001|" + '\r'
+ '\n';
- @Rule
+ @RegisterExtension
public MllpServerResource mllpServer = new MllpServerResource("localhost", AvailablePortFinder.getNextAvailable());
@EndpointInject("direct://source")
@@ -201,7 +203,7 @@ public abstract class TcpClientProducerEndOfDataAndValidationTestSupport extends
for (int i = 0; i < expectedAACount; ++i) {
source.sendBody(Hl7TestMessageGenerator.generateMessage(i + 1));
- assertTrue("Messege " + i + " not completed", complete[i].matches(1, TimeUnit.SECONDS));
+ assertTrue(complete[i].matches(1, TimeUnit.SECONDS), "Message " + i + " not completed");
}
}
@@ -230,7 +232,7 @@ public abstract class TcpClientProducerEndOfDataAndValidationTestSupport extends
for (int i = 0; i < expectedAACount; ++i) {
source.sendBody(Hl7TestMessageGenerator.generateMessage(i + 1));
- assertTrue("Messege " + i + " not completed", complete[i].matches(1, TimeUnit.SECONDS));
+ assertTrue(complete[i].matches(1, TimeUnit.SECONDS), "Message " + i + " not completed");
}
}
@@ -251,7 +253,7 @@ public abstract class TcpClientProducerEndOfDataAndValidationTestSupport extends
for (int i = 0; i < messageCount; ++i) {
source.sendBody(Hl7TestMessageGenerator.generateMessage(i + 1));
- assertTrue("Messege " + i + " not completed", complete[i].matches(1, TimeUnit.SECONDS));
+ assertTrue(complete[i].matches(1, TimeUnit.SECONDS), "Message " + i + " not completed");
}
}
@@ -272,13 +274,13 @@ public abstract class TcpClientProducerEndOfDataAndValidationTestSupport extends
mllpServer.disableResponse();
source.sendBody(Hl7TestMessageGenerator.generateMessage(1));
- assertTrue("Messege 1 not completed", complete[0].matches(1, TimeUnit.SECONDS));
+ assertTrue(complete[0].matches(1, TimeUnit.SECONDS), "Message 0 not completed");
mllpServer.enableResponse();
for (int i = 1; i < sendMessageCount; ++i) {
source.sendBody(Hl7TestMessageGenerator.generateMessage(i + 1));
- assertTrue("Messege " + i + " not completed", complete[i].matches(1, TimeUnit.SECONDS));
+ assertTrue(complete[i].matches(1, TimeUnit.SECONDS), "Message " + i + " not completed");
}
}
@@ -300,7 +302,7 @@ public abstract class TcpClientProducerEndOfDataAndValidationTestSupport extends
for (int i = 0; i < sendMessageCount; ++i) {
source.sendBody(Hl7TestMessageGenerator.generateMessage(i + 1));
- assertTrue("Messege " + i + " not completed", complete[i].matches(1, TimeUnit.SECONDS));
+ assertTrue(complete[i].matches(1, TimeUnit.SECONDS), "Message " + i + " not completed");
}
}
@@ -398,7 +400,7 @@ public abstract class TcpClientProducerEndOfDataAndValidationTestSupport extends
for (int i = 0; i < sendMessageCount; ++i) {
source.sendBody(Hl7TestMessageGenerator.generateMessage(i + 1));
- assertTrue("Messege " + i + " not completed", complete[i].matches(1, TimeUnit.SECONDS));
+ assertTrue(complete[i].matches(1, TimeUnit.SECONDS), "Message " + i + " not completed");
}
}
@@ -446,7 +448,7 @@ public abstract class TcpClientProducerEndOfDataAndValidationTestSupport extends
for (int i = 0; i < sendMessageCount; ++i) {
source.sendBody(Hl7TestMessageGenerator.generateMessage(i + 1));
- assertTrue("Messege " + i + " not completed", complete[i].matches(1, TimeUnit.SECONDS));
+ assertTrue(complete[i].matches(1, TimeUnit.SECONDS), "Message " + i + " not completed");
}
}
@@ -468,7 +470,7 @@ public abstract class TcpClientProducerEndOfDataAndValidationTestSupport extends
for (int i = 0; i < messageCount; ++i) {
source.sendBody(Hl7TestMessageGenerator.generateMessage(i + 1));
- assertTrue("Messege " + i + " not completed", complete[i].matches(1, TimeUnit.SECONDS));
+ assertTrue(complete[i].matches(1, TimeUnit.SECONDS), "Message " + i + " not completed");
}
}
diff --git a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/TcpServerConsumerAcknowledgementTestSupport.java b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/TcpServerConsumerAcknowledgementTestSupport.java
index b29d40e..b6904cb 100644
--- a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/TcpServerConsumerAcknowledgementTestSupport.java
+++ b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/TcpServerConsumerAcknowledgementTestSupport.java
@@ -27,8 +27,10 @@ import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.impl.DefaultCamelContext;
import org.apache.camel.test.AvailablePortFinder;
import org.apache.camel.test.junit.rule.mllp.MllpClientResource;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Rule;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
public abstract class TcpServerConsumerAcknowledgementTestSupport extends CamelTestSupport {
static final String TEST_MESSAGE =
@@ -39,7 +41,7 @@ public abstract class TcpServerConsumerAcknowledgementTestSupport extends CamelT
"MSH|^~\\&|^org^sys||APP_A|FAC_A|||ACK^A04^ADT_A04|||2.6" + '\r'
+ "MSA|AA|" + '\r';
- @Rule
+ @RegisterExtension
public MllpClientResource mllpClient = new MllpClientResource();
@EndpointInject("mock://result")
@@ -128,7 +130,7 @@ public abstract class TcpServerConsumerAcknowledgementTestSupport extends CamelT
mllpClient.sendFramedData(TEST_MESSAGE);
- assertTrue("Exchange should have completed", done.matches(10, TimeUnit.SECONDS));
+ assertTrue(done.matches(10, TimeUnit.SECONDS), "Exchange should have completed");
assertMockEndpointsSatisfied();
}
@@ -149,7 +151,7 @@ public abstract class TcpServerConsumerAcknowledgementTestSupport extends CamelT
mllpClient.connect();
mllpClient.sendFramedData(testMessage);
- assertTrue("One exchange should have complete", done.matches(5, TimeUnit.SECONDS));
+ assertTrue(done.matches(5, TimeUnit.SECONDS), "One exchange should have complete");
assertMockEndpointsSatisfied();
}
}
diff --git a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/TcpServerConsumerEndOfDataAndValidationTestSupport.java b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/TcpServerConsumerEndOfDataAndValidationTestSupport.java
index 44c24b0..15c7207 100644
--- a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/TcpServerConsumerEndOfDataAndValidationTestSupport.java
+++ b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/TcpServerConsumerEndOfDataAndValidationTestSupport.java
@@ -30,20 +30,30 @@ import org.apache.camel.impl.DefaultCamelContext;
import org.apache.camel.test.AvailablePortFinder;
import org.apache.camel.test.junit.rule.mllp.MllpClientResource;
import org.apache.camel.test.junit.rule.mllp.MllpJUnitResourceException;
-import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.camel.test.junit5.CamelTestSupport;
import org.apache.camel.test.mllp.Hl7TestMessageGenerator;
-import org.junit.Rule;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public abstract class TcpServerConsumerEndOfDataAndValidationTestSupport extends CamelTestSupport {
+
static final int CONNECT_TIMEOUT = 500;
static final int RECEIVE_TIMEOUT = 1000;
static final int READ_TIMEOUT = 500;
- @Rule
- public MllpClientResource mllpClient = new MllpClientResource();
+ Logger log = LoggerFactory.getLogger(TcpServerConsumerEndOfDataAndValidationTestSupport.class);
+
+ @RegisterExtension
+ MllpClientResource mllpClient = new MllpClientResource();
@EndpointInject("mock://complete")
MockEndpoint complete;
@@ -170,7 +180,7 @@ public abstract class TcpServerConsumerEndOfDataAndValidationTestSupport extends
log.info("Sending TEST_MESSAGE_2");
String acknowledgement2 = mllpClient.sendMessageAndWaitForAcknowledgement(Hl7TestMessageGenerator.generateMessage(2));
- assertTrue("First two normal exchanges did not complete", notify1.matches(RECEIVE_TIMEOUT, TimeUnit.MILLISECONDS));
+ assertTrue(notify1.matches(RECEIVE_TIMEOUT, TimeUnit.MILLISECONDS), "First two normal exchanges did not complete");
log.info("Sending TEST_MESSAGE_3");
mllpClient.setSendEndOfBlock(false);
@@ -193,14 +203,14 @@ public abstract class TcpServerConsumerEndOfDataAndValidationTestSupport extends
log.info("Sending TEST_MESSAGE_5");
String acknowledgement5 = mllpClient.sendMessageAndWaitForAcknowledgement(Hl7TestMessageGenerator.generateMessage(5));
- assertTrue("Remaining exchanges did not complete", notify2.matches(RECEIVE_TIMEOUT, TimeUnit.MILLISECONDS));
+ assertTrue(notify2.matches(RECEIVE_TIMEOUT, TimeUnit.MILLISECONDS), "Remaining exchanges did not complete");
assertMockEndpointsSatisfied(10, TimeUnit.SECONDS);
- assertTrue("Should be acknowledgment for message 1", acknowledgement1.contains("MSA|AA|00001"));
- assertTrue("Should be acknowledgment for message 2", acknowledgement2.contains("MSA|AA|00002"));
- assertTrue("Should be acknowledgment for message 4", acknowledgement4.contains("MSA|AA|00004"));
- assertTrue("Should be acknowledgment for message 5", acknowledgement5.contains("MSA|AA|00005"));
+ assertTrue(acknowledgement1.contains("MSA|AA|00001"), "Should be acknowledgment for message 1");
+ assertTrue(acknowledgement2.contains("MSA|AA|00002"), "Should be acknowledgment for message 2");
+ assertTrue(acknowledgement4.contains("MSA|AA|00004"), "Should be acknowledgment for message 4");
+ assertTrue(acknowledgement5.contains("MSA|AA|00005"), "Should be acknowledgment for message 5");
}
@@ -217,14 +227,14 @@ public abstract class TcpServerConsumerEndOfDataAndValidationTestSupport extends
// Send one message to establish the connection and start the ConsumerClientSocketThread
mllpClient.sendFramedData(Hl7TestMessageGenerator.generateMessage());
- assertTrue("One exchange should have completed", oneDone.matches(RECEIVE_TIMEOUT, TimeUnit.MILLISECONDS));
+ assertTrue(oneDone.matches(RECEIVE_TIMEOUT, TimeUnit.MILLISECONDS), "One exchange should have completed");
mllpClient.setSendEndOfBlock(false);
mllpClient.setSendEndOfData(false);
mllpClient.sendMessageAndWaitForAcknowledgement(Hl7TestMessageGenerator.generateMessage());
- assertTrue("Two exchanges should have completed", twoDone.matches(RECEIVE_TIMEOUT, TimeUnit.MILLISECONDS));
+ assertTrue(twoDone.matches(RECEIVE_TIMEOUT, TimeUnit.MILLISECONDS), "Two exchanges should have completed");
}
@@ -248,7 +258,7 @@ public abstract class TcpServerConsumerEndOfDataAndValidationTestSupport extends
try {
log.info("Attempting to send second message");
String acknowledgement = mllpClient.sendMessageAndWaitForAcknowledgement(Hl7TestMessageGenerator.generateMessage(10002));
- assertEquals("If the send doesn't throw an exception, the acknowledgement should be empty", "", acknowledgement);
+ assertEquals("", acknowledgement, "If the send doesn't throw an exception, the acknowledgement should be empty");
} catch (MllpJUnitResourceException expected) {
assertThat("If the send throws an exception, the cause should be a SocketException", expected.getCause(), instanceOf(SocketException.class));
}
@@ -287,13 +297,13 @@ public abstract class TcpServerConsumerEndOfDataAndValidationTestSupport extends
if (i == invalidMessageNumber) {
mllpClient.sendFramedData("INVALID PAYLOAD");
// The component will reset the connection in this case, so we need to reconnect
- assertTrue("Exchange with invalid payload should have completed", invalidMessageDone.matches(5, TimeUnit.SECONDS));
+ assertTrue(invalidMessageDone.matches(5, TimeUnit.SECONDS), "Exchange with invalid payload should have completed");
mllpClient.disconnect();
mllpClient.connect();
} else {
String acknowledgement = mllpClient.sendMessageAndWaitForAcknowledgement(Hl7TestMessageGenerator.generateMessage(i));
- assertNotNull("The acknowledgement returned should not be null", acknowledgement);
- assertNotEquals("An acknowledgement should be received for a valid HL7 message", 0, acknowledgement.length());
+ assertNotNull(acknowledgement, "The acknowledgement returned should not be null");
+ assertNotEquals(0, acknowledgement.length(), "An acknowledgement should be received for a valid HL7 message");
}
}
}
@@ -308,7 +318,7 @@ public abstract class TcpServerConsumerEndOfDataAndValidationTestSupport extends
mllpClient.sendMessageAndWaitForAcknowledgement(Hl7TestMessageGenerator.generateMessage().replaceFirst("PID", "PID" + MllpProtocolConstants.START_OF_BLOCK));
- assertTrue("Exchange should have completed", done.matches(15, TimeUnit.SECONDS));
+ assertTrue(done.matches(15, TimeUnit.SECONDS), "Exchange should have completed");
}
@@ -355,7 +365,7 @@ public abstract class TcpServerConsumerEndOfDataAndValidationTestSupport extends
if (i == invalidMessageNumber) {
mllpClient.sendFramedData(message.replaceFirst("PID", "PID" + MllpProtocolConstants.END_OF_BLOCK));
- assertTrue("Exchange containing invalid message should have completed", invalidMessageDone.matches(5, TimeUnit.SECONDS));
+ assertTrue(invalidMessageDone.matches(5, TimeUnit.SECONDS), "Exchange containing invalid message should have completed");
// The component may reset the connection in this case, so reconnect if needed
/*
// TODO: Figure out why this isn't working
@@ -390,17 +400,17 @@ public abstract class TcpServerConsumerEndOfDataAndValidationTestSupport extends
String message = Hl7TestMessageGenerator.generateMessage(i);
if (i == messageCount / 2) {
mllpClient.sendFramedData(message.replaceFirst("PID", "PID" + MllpProtocolConstants.END_OF_BLOCK));
- assertTrue("Invalid message should have completed", done.matches(15, TimeUnit.SECONDS));
+ assertTrue(done.matches(15, TimeUnit.SECONDS), "Invalid message should have completed");
mllpClient.disconnect();
mllpClient.connect();
} else {
String acknowledgement = mllpClient.sendMessageAndWaitForAcknowledgement(message);
- assertNotNull("The acknowledgement returned should not be null", acknowledgement);
- assertNotEquals("An acknowledgement should be received for a valid HL7 message", 0, acknowledgement.length());
+ assertNotNull(acknowledgement, "The acknowledgement returned should not be null");
+ assertNotEquals(0, acknowledgement.length(), "An acknowledgement should be received for a valid HL7 message");
}
}
- assertTrue("Exchanges should have completed", done.matches(15, TimeUnit.SECONDS));
+ assertTrue(done.matches(15, TimeUnit.SECONDS), "Exchanges should have completed");
}
@Test
diff --git a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/internal/Hl7UtilTest.java b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/internal/Hl7UtilTest.java
index 35548d8..499b7d4 100644
--- a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/internal/Hl7UtilTest.java
+++ b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/internal/Hl7UtilTest.java
@@ -21,14 +21,15 @@ import java.io.ByteArrayOutputStream;
import org.apache.camel.component.mllp.MllpAcknowledgementGenerationException;
import org.apache.camel.component.mllp.MllpProtocolConstants;
import org.apache.camel.test.stub.camel.MllpEndpointStub;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import static org.hamcrest.CoreMatchers.endsWith;
import static org.hamcrest.CoreMatchers.startsWith;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.fail;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.fail;
public class Hl7UtilTest {
// @formatter:off
@@ -83,7 +84,7 @@ public class Hl7UtilTest {
public void testGenerateInvalidPayloadExceptionMessage() throws Exception {
String message = Hl7Util.generateInvalidPayloadExceptionMessage(TEST_MESSAGE.getBytes());
- assertNull("Valid payload should result in a null message", message);
+ assertNull(message, "Valid payload should result in a null message");
}
@Test
@@ -91,7 +92,7 @@ public class Hl7UtilTest {
byte[] payload = TEST_MESSAGE.getBytes();
String message = Hl7Util.generateInvalidPayloadExceptionMessage(payload, payload.length * 2);
- assertNull("Valid payload should result in a null message", message);
+ assertNull(message, "Valid payload should result in a null message");
}
@Test
@@ -182,12 +183,11 @@ public class Hl7UtilTest {
*
* @throws Exception in the event of a test error.
*/
- @Test(expected = MllpAcknowledgementGenerationException.class)
+ @Test
public void testGenerateAcknowledgementPayloadFromNullMessage() throws Exception {
MllpSocketBuffer mllpSocketBuffer = new MllpSocketBuffer(new MllpEndpointStub());
- Hl7Util.generateAcknowledgementPayload(mllpSocketBuffer, null, "AA");
-
- assertEquals(EXPECTED_ACKNOWLEDGEMENT_PAYLOAD, mllpSocketBuffer.toString());
+ assertThrows(MllpAcknowledgementGenerationException.class,
+ () -> Hl7Util.generateAcknowledgementPayload(mllpSocketBuffer, null, "AA"));
}
/**
@@ -195,12 +195,11 @@ public class Hl7UtilTest {
*
* @throws Exception in the event of a test error.
*/
- @Test(expected = MllpAcknowledgementGenerationException.class)
+ @Test
public void testGenerateAcknowledgementPayloadFromEmptyMessage() throws Exception {
MllpSocketBuffer mllpSocketBuffer = new MllpSocketBuffer(new MllpEndpointStub());
- Hl7Util.generateAcknowledgementPayload(mllpSocketBuffer, new byte[0], "AA");
-
- assertEquals(EXPECTED_ACKNOWLEDGEMENT_PAYLOAD, mllpSocketBuffer.toString());
+ assertThrows(MllpAcknowledgementGenerationException.class,
+ () -> Hl7Util.generateAcknowledgementPayload(mllpSocketBuffer, new byte[0], "AA"));
}
/**
@@ -208,12 +207,13 @@ public class Hl7UtilTest {
*
* @throws Exception in the event of a test error.
*/
- @Test(expected = MllpAcknowledgementGenerationException.class)
+ @Test
public void testGenerateAcknowledgementPayloadWithoutEnoughFields() throws Exception {
final byte[] testMessage = TEST_MESSAGE.replace("||ORM^O01|00001|D|2.3|||||||", "").getBytes();
MllpSocketBuffer mllpSocketBuffer = new MllpSocketBuffer(new MllpEndpointStub());
- Hl7Util.generateAcknowledgementPayload(mllpSocketBuffer, testMessage, "AA");
+ assertThrows(MllpAcknowledgementGenerationException.class,
+ () -> Hl7Util.generateAcknowledgementPayload(mllpSocketBuffer, testMessage, "AA"));
}
/**
diff --git a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/internal/MllpSocketBufferReadFromTest.java b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/internal/MllpSocketBufferReadFromTest.java
index 324f405..60e9a15 100644
--- a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/internal/MllpSocketBufferReadFromTest.java
+++ b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/internal/MllpSocketBufferReadFromTest.java
@@ -20,11 +20,11 @@ import java.net.SocketTimeoutException;
import org.apache.camel.test.stub.tcp.SocketInputStreamStub;
import org.apache.camel.test.stub.tcp.SocketStub;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.fail;
/**
* Tests for the class.
@@ -34,7 +34,7 @@ public class MllpSocketBufferReadFromTest extends SocketBufferTestSupport {
SocketInputStreamStub inputStreamStub;
@Override
- @Before
+ @BeforeEach
public void setUp() throws Exception {
super.setUp();
diff --git a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/internal/MllpSocketBufferTest.java b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/internal/MllpSocketBufferTest.java
index 3d3d409..a674cae 100644
--- a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/internal/MllpSocketBufferTest.java
+++ b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/internal/MllpSocketBufferTest.java
@@ -17,14 +17,14 @@
package org.apache.camel.component.mllp.internal;
import org.apache.camel.component.mllp.MllpProtocolConstants;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
/**
* Tests for the MllpSocketBuffer class.
@@ -299,7 +299,7 @@ public class MllpSocketBufferTest extends SocketBufferTestSupport {
@Test
public void testGetStartOfBlockIndex() throws Exception {
int expected = -1;
- assertEquals("Unexpected initial value", expected, instance.getStartOfBlockIndex());
+ assertEquals(expected, instance.getStartOfBlockIndex(), "Unexpected initial value");
expected = 0;
instance.startOfBlockIndex = expected;
@@ -318,7 +318,7 @@ public class MllpSocketBufferTest extends SocketBufferTestSupport {
@Test
public void tesGgetEndOfBlockIndex() throws Exception {
int expected = -1;
- assertEquals("Unexpected initial value", expected, instance.getEndOfBlockIndex());
+ assertEquals(expected, instance.getEndOfBlockIndex(), "Unexpected initial value");
expected = 0;
instance.endOfBlockIndex = expected;
@@ -337,7 +337,7 @@ public class MllpSocketBufferTest extends SocketBufferTestSupport {
@Test
public void testHasCompleteEnvelopeWithRequiredEndOfData() throws Exception {
endpoint.setRequireEndOfData(true);
- assertFalse("Unexpected initial value", instance.hasCompleteEnvelope());
+ assertFalse(instance.hasCompleteEnvelope(), "Unexpected initial value");
instance.write(MllpProtocolConstants.START_OF_BLOCK);
assertFalse(instance.hasCompleteEnvelope());
@@ -363,7 +363,7 @@ public class MllpSocketBufferTest extends SocketBufferTestSupport {
@Test
public void testHasCompleteEnvelopeWithOptionalEndOfData() throws Exception {
endpoint.setRequireEndOfData(false);
- assertFalse("Unexpected initial value", instance.hasCompleteEnvelope());
+ assertFalse(instance.hasCompleteEnvelope(), "Unexpected initial value");
instance.write(MllpProtocolConstants.START_OF_BLOCK);
assertFalse(instance.hasCompleteEnvelope());
@@ -388,7 +388,7 @@ public class MllpSocketBufferTest extends SocketBufferTestSupport {
*/
@Test
public void testHasStartOfBlock() throws Exception {
- assertFalse("Unexpected initial value", instance.hasStartOfBlock());
+ assertFalse(instance.hasStartOfBlock(), "Unexpected initial value");
instance.write(MllpProtocolConstants.START_OF_BLOCK);
assertTrue(instance.hasStartOfBlock());
@@ -413,10 +413,10 @@ public class MllpSocketBufferTest extends SocketBufferTestSupport {
*/
@Test
public void testHasEndOfBlock() throws Exception {
- assertFalse("Unexpected initial value", instance.hasEndOfBlock());
+ assertFalse(instance.hasEndOfBlock(), "Unexpected initial value");
instance.write(MllpProtocolConstants.END_OF_BLOCK);
- assertFalse("START_OF_BLOCK before an END_OF_BLOCK", instance.hasEndOfBlock());
+ assertFalse(instance.hasEndOfBlock(), "START_OF_BLOCK before an END_OF_BLOCK");
instance.reset();
assertFalse(instance.hasEndOfBlock());
@@ -456,7 +456,7 @@ public class MllpSocketBufferTest extends SocketBufferTestSupport {
*/
@Test
public void testHasEndOfData() throws Exception {
- assertFalse("Unexpected initial value", instance.hasEndOfData());
+ assertFalse(instance.hasEndOfData(), "Unexpected initial value");
// Test just the END_OF_DATA
instance.write(MllpProtocolConstants.END_OF_DATA);
@@ -470,7 +470,7 @@ public class MllpSocketBufferTest extends SocketBufferTestSupport {
assertFalse(instance.hasEndOfData());
instance.write(MllpProtocolConstants.END_OF_DATA);
- assertFalse("Need a START_OF_BLOCK before the END_OF_DATA", instance.hasEndOfData());
+ assertFalse(instance.hasEndOfData(), "Need a START_OF_BLOCK before the END_OF_DATA");
instance.reset();
assertFalse(instance.hasEndOfData());
@@ -513,7 +513,7 @@ public class MllpSocketBufferTest extends SocketBufferTestSupport {
*/
@Test
public void testhasOutOfBandData() throws Exception {
- assertFalse("Unexpected initial value", instance.hasOutOfBandData());
+ assertFalse(instance.hasOutOfBandData(), "Unexpected initial value");
instance.write(buildTestBytes(true, true, true));
assertFalse(instance.hasOutOfBandData());
@@ -536,7 +536,7 @@ public class MllpSocketBufferTest extends SocketBufferTestSupport {
*/
@Test
public void testHasLeadingOutOfBandData() throws Exception {
- assertFalse("Unexpected initial value", instance.hasLeadingOutOfBandData());
+ assertFalse(instance.hasLeadingOutOfBandData(), "Unexpected initial value");
instance.write(buildTestBytes(true, true, true));
assertFalse(instance.hasLeadingOutOfBandData());
@@ -561,7 +561,7 @@ public class MllpSocketBufferTest extends SocketBufferTestSupport {
public void testHasTrailingOutOfBandDataWithRequiredEndOfData() throws Exception {
endpoint.setRequireEndOfData(true);
- assertFalse("Unexpected initial value", instance.hasTrailingOutOfBandData());
+ assertFalse(instance.hasTrailingOutOfBandData(), "Unexpected initial value");
instance.write(buildTestBytes(true, true, true));
assertFalse(instance.hasTrailingOutOfBandData());
@@ -594,7 +594,7 @@ public class MllpSocketBufferTest extends SocketBufferTestSupport {
public void testHasTrailingOutOfBandDataWithOptionalEndOfData() throws Exception {
endpoint.setRequireEndOfData(false);
- assertFalse("Unexpected initial value", instance.hasTrailingOutOfBandData());
+ assertFalse(instance.hasTrailingOutOfBandData(), "Unexpected initial value");
instance.write(buildTestBytes(true, true, true));
assertFalse(instance.hasTrailingOutOfBandData());
@@ -625,7 +625,7 @@ public class MllpSocketBufferTest extends SocketBufferTestSupport {
*/
@Test
public void testGetLeadingOutOfBandData() throws Exception {
- assertNull("Unexpected initial value", instance.getLeadingOutOfBandData());
+ assertNull(instance.getLeadingOutOfBandData(), "Unexpected initial value");
instance.write(buildTestBytes(true, true, true));
assertNull(instance.getLeadingOutOfBandData());
@@ -651,7 +651,7 @@ public class MllpSocketBufferTest extends SocketBufferTestSupport {
public void testGetTrailingOutOfBandDataWithRequiredEndOfData() throws Exception {
endpoint.setRequireEndOfData(true);
- assertNull("Unexpected initial value", instance.getTrailingOutOfBandData());
+ assertNull(instance.getTrailingOutOfBandData(), "Unexpected initial value");
// Test with END_OF_DATA
instance.write(buildTestBytes(true, true, true));
@@ -701,7 +701,7 @@ public class MllpSocketBufferTest extends SocketBufferTestSupport {
public void testGetTrailingOutOfBandDataWithOptionalEndOfData() throws Exception {
endpoint.setRequireEndOfData(false);
- assertNull("Unexpected initial value", instance.getTrailingOutOfBandData());
+ assertNull(instance.getTrailingOutOfBandData(), "Unexpected initial value");
// Test with END_OF_DATA
instance.write(buildTestBytes(true, true, true));
diff --git a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/internal/MllpSocketBufferWriteTest.java b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/internal/MllpSocketBufferWriteTest.java
index 3c44931..5094014 100644
--- a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/internal/MllpSocketBufferWriteTest.java
+++ b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/internal/MllpSocketBufferWriteTest.java
@@ -20,11 +20,12 @@ import java.net.SocketTimeoutException;
import org.apache.camel.component.mllp.MllpProtocolConstants;
import org.apache.camel.test.stub.tcp.SocketStub;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.fail;
/**
* Tests for the overridden methods in the MllpSocketBuffer class.
@@ -335,15 +336,12 @@ public class MllpSocketBufferWriteTest extends SocketBufferTestSupport {
assertEquals(expectedMessage, expectedEx.getMessage());
}
- try {
- instance.write("BLAH".getBytes());
- instance.ensureCapacity(MllpSocketBuffer.MAX_BUFFER_SIZE);
- fail("Should have thrown an exception");
- } catch (IllegalStateException expectedEx) {
- String expectedMessage = "Cannot increase the buffer size <2048> in order to increase the available capacity from <2044> to <1073741824>"
- + " because the required buffer size <1073741828> exceeds the maximum buffer size <1073741824>";
- assertEquals(expectedMessage, expectedEx.getMessage());
- }
+ instance.write("BLAH".getBytes());
+ IllegalStateException expectedEx = assertThrows(IllegalStateException.class,
+ () -> instance.ensureCapacity(MllpSocketBuffer.MAX_BUFFER_SIZE));
+ String expectedMessage = "Cannot increase the buffer size <2048> in order to increase the available capacity from <2044> to <1073741824>"
+ + " because the required buffer size <1073741828> exceeds the maximum buffer size <1073741824>";
+ assertEquals(expectedMessage, expectedEx.getMessage());
}
/**
@@ -357,16 +355,11 @@ public class MllpSocketBufferWriteTest extends SocketBufferTestSupport {
instance.ensureCapacity(MllpSocketBuffer.MAX_BUFFER_SIZE);
- try {
- instance.ensureCapacity(MllpSocketBuffer.MAX_BUFFER_SIZE + 1);
- fail("Should have thrown an exception");
- } catch (IllegalStateException expectedEx) {
- String expectedMessage = "Cannot increase the buffer size from <1073741824> to <1073741825> in order to increase the available capacity"
- + " from <1073741824> to <1073741825> because the buffer is already the maximum size <1073741824>";
- assertEquals(expectedMessage, expectedEx.getMessage());
- }
-
-
+ IllegalStateException expectedEx = assertThrows(IllegalStateException.class,
+ () -> instance.ensureCapacity(MllpSocketBuffer.MAX_BUFFER_SIZE + 1));
+ String expectedMessage = "Cannot increase the buffer size from <1073741824> to <1073741825> in order to increase the available capacity"
+ + " from <1073741824> to <1073741825> because the buffer is already the maximum size <1073741824>";
+ assertEquals(expectedMessage, expectedEx.getMessage());
}
/**
@@ -374,7 +367,7 @@ public class MllpSocketBufferWriteTest extends SocketBufferTestSupport {
*
* @throws Exception in the event of a test error.
*/
- @Test(expected = SocketTimeoutException.class)
+ @Test
public void testReadFrom() throws Exception {
SocketStub socketStub = new SocketStub();
socketStub.inputStreamStub
@@ -384,9 +377,8 @@ public class MllpSocketBufferWriteTest extends SocketBufferTestSupport {
endpoint.setReceiveTimeout(500);
endpoint.setReadTimeout(100);
- instance.readFrom(socketStub);
-
- assertArrayEquals("FOOBAR".getBytes(), instance.toByteArray());
+ assertThrows(SocketTimeoutException.class,
+ () -> instance.readFrom(socketStub));
}
}
diff --git a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/internal/SocketBufferTestSupport.java b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/internal/SocketBufferTestSupport.java
index 4beed2b..e6b3a4c 100644
--- a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/internal/SocketBufferTestSupport.java
+++ b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/internal/SocketBufferTestSupport.java
@@ -23,7 +23,7 @@ import org.apache.camel.component.mllp.MllpComponent;
import org.apache.camel.component.mllp.MllpConfiguration;
import org.apache.camel.component.mllp.MllpEndpoint;
import org.apache.camel.component.mllp.MllpProtocolConstants;
-import org.junit.Before;
+import org.junit.jupiter.api.BeforeEach;
public class SocketBufferTestSupport {
static final String TEST_HL7_MESSAGE =
@@ -33,7 +33,7 @@ public class SocketBufferTestSupport {
MllpEndpoint endpoint;
MllpSocketBuffer instance;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
endpoint = new MllpEndpoint("mllp://dummy", new MllpComponent(), new MllpConfiguration());
instance = new MllpSocketBuffer(endpoint);
diff --git a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/support/EmbeddedActiveMQBroker.java b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/support/EmbeddedActiveMQBroker.java
new file mode 100644
index 0000000..04e4a16
--- /dev/null
+++ b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/support/EmbeddedActiveMQBroker.java
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.mllp.support;
+
+import org.apache.activemq.broker.BrokerService;
+import org.apache.activemq.store.memory.MemoryPersistenceAdapter;
+import org.apache.camel.test.AvailablePortFinder;
+import org.junit.jupiter.api.extension.AfterEachCallback;
+import org.junit.jupiter.api.extension.BeforeEachCallback;
+import org.junit.jupiter.api.extension.ExtensionContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * JUnit Test aspect that creates an embedded ActiveMQ broker at the beginning of each test and shuts it down after.
+ */
+public class EmbeddedActiveMQBroker implements BeforeEachCallback, AfterEachCallback {
+
+ private final Logger log = LoggerFactory.getLogger(EmbeddedActiveMQBroker.class);
+ private final String brokerId;
+ private BrokerService brokerService;
+ private final String tcpConnectorUri;
+
+ public EmbeddedActiveMQBroker(String brokerId) {
+ if ((brokerId == null) || (brokerId.isEmpty())) {
+ throw new IllegalArgumentException("brokerId is empty");
+ }
+ this.brokerId = brokerId;
+ tcpConnectorUri = "tcp://localhost:" + AvailablePortFinder.getNextAvailable();
+
+ brokerService = new BrokerService();
+ brokerService.setBrokerId(brokerId);
+ brokerService.setPersistent(false);
+ brokerService.setUseJmx(false);
+ try {
+ brokerService.setPersistenceAdapter(new MemoryPersistenceAdapter());
+ brokerService.addConnector(tcpConnectorUri);
+ } catch (Exception e) {
+ throw new RuntimeException("Problem creating brokerService", e);
+ }
+ }
+
+ @Override
+ public void beforeEach(ExtensionContext context) throws Exception {
+ log.info("Starting embedded broker[{}] on {}", brokerId, tcpConnectorUri);
+ brokerService.start();
+ }
+
+ @Override
+ public void afterEach(ExtensionContext context) throws Exception {
+ try {
+ log.info("Stopping embedded broker[{}]", brokerId);
+ brokerService.stop();
+ } catch (Exception e) {
+ throw new RuntimeException("Exception shutting down broker service", e);
+ }
+ }
+
+ public String getTcpConnectorUri() {
+ return tcpConnectorUri;
+ }
+
+ public String getVmURL() {
+ return this.getVmURL(true);
+ }
+
+ public String getVmURL(boolean failoverURL) {
+ return failoverURL ? String.format("failover:(%s?create=false)", this.brokerService.getVmConnectorURI().toString()) : this.brokerService.getVmConnectorURI().toString() + "?create=false";
+ }
+
+}
diff --git a/components/camel-mllp/src/test/java/org/apache/camel/test/executor/PooledExecutorTest.java b/components/camel-mllp/src/test/java/org/apache/camel/test/executor/PooledExecutorTest.java
index b95b392..b7c81ba 100644
--- a/components/camel-mllp/src/test/java/org/apache/camel/test/executor/PooledExecutorTest.java
+++ b/components/camel-mllp/src/test/java/org/apache/camel/test/executor/PooledExecutorTest.java
@@ -18,9 +18,9 @@ package org.apache.camel.test.executor;
import java.util.concurrent.RejectedExecutionException;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -30,12 +30,12 @@ public class PooledExecutorTest {
TestExecutor instance;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
instance = new TestExecutor(THREAD_COUNT);
}
- @After
+ @AfterEach
public void tearDown() throws Exception {
instance.stop();
}
diff --git a/components/camel-mllp/src/test/java/org/apache/camel/test/junit/rule/mllp/MllpClientResource.java b/components/camel-mllp/src/test/java/org/apache/camel/test/junit/rule/mllp/MllpClientResource.java
index 6765fba..e95b591 100644
--- a/components/camel-mllp/src/test/java/org/apache/camel/test/junit/rule/mllp/MllpClientResource.java
+++ b/components/camel-mllp/src/test/java/org/apache/camel/test/junit/rule/mllp/MllpClientResource.java
@@ -25,7 +25,9 @@ import java.net.Socket;
import java.net.SocketException;
import java.net.SocketTimeoutException;
-import org.junit.rules.ExternalResource;
+import org.junit.jupiter.api.extension.AfterEachCallback;
+import org.junit.jupiter.api.extension.BeforeEachCallback;
+import org.junit.jupiter.api.extension.ExtensionContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -34,7 +36,8 @@ import org.slf4j.LoggerFactory;
*
* The client can be configured to simulate a large number of error conditions.
*/
-public class MllpClientResource extends ExternalResource {
+public class MllpClientResource implements BeforeEachCallback, AfterEachCallback {
+
static final char START_OF_BLOCK = 0x0b;
static final char END_OF_BLOCK = 0x1c;
static final char END_OF_DATA = 0x0d;
@@ -77,17 +80,14 @@ public class MllpClientResource extends ExternalResource {
}
@Override
- protected void before() throws Throwable {
+ public void beforeEach(ExtensionContext context) throws Exception {
if (0 < mllpPort) {
this.connect();
}
-
- super.before();
}
@Override
- protected void after() {
- super.after();
+ public void afterEach(ExtensionContext context) throws Exception {
this.close();
}
diff --git a/components/camel-mllp/src/test/java/org/apache/camel/test/junit/rule/mllp/MllpServerResource.java b/components/camel-mllp/src/test/java/org/apache/camel/test/junit/rule/mllp/MllpServerResource.java
index b45c88a..e6129e2 100644
--- a/components/camel-mllp/src/test/java/org/apache/camel/test/junit/rule/mllp/MllpServerResource.java
+++ b/components/camel-mllp/src/test/java/org/apache/camel/test/junit/rule/mllp/MllpServerResource.java
@@ -31,7 +31,9 @@ import java.util.List;
import java.util.regex.Pattern;
import org.apache.camel.component.mllp.MllpProtocolConstants;
-import org.junit.rules.ExternalResource;
+import org.junit.jupiter.api.extension.AfterEachCallback;
+import org.junit.jupiter.api.extension.BeforeEachCallback;
+import org.junit.jupiter.api.extension.ExtensionContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -40,7 +42,8 @@ import org.slf4j.LoggerFactory;
*
* The server can be configured to simulate a large number of error conditions.
*/
-public class MllpServerResource extends ExternalResource {
+public class MllpServerResource implements BeforeEachCallback, AfterEachCallback {
+
Logger log = LoggerFactory.getLogger(this.getClass());
String listenHost;
@@ -154,16 +157,13 @@ public class MllpServerResource extends ExternalResource {
}
}
-
@Override
- protected void before() throws Throwable {
+ public void beforeEach(ExtensionContext context) throws Exception {
startup();
- super.before();
}
@Override
- protected void after() {
- super.after();
+ public void afterEach(ExtensionContext context) throws Exception {
shutdown();
}
diff --git a/components/camel-mllp/src/test/java/org/apache/camel/test/tcp/JavaSocketTests.java b/components/camel-mllp/src/test/java/org/apache/camel/test/tcp/JavaSocketTests.java
index c049c06..aae8cb1 100644
--- a/components/camel-mllp/src/test/java/org/apache/camel/test/tcp/JavaSocketTests.java
+++ b/components/camel-mllp/src/test/java/org/apache/camel/test/tcp/JavaSocketTests.java
@@ -25,14 +25,15 @@ import java.net.ServerSocket;
import java.net.Socket;
import java.net.SocketTimeoutException;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.fail;
+
/**
* Various tests used to validate the behaviour of Java Sockets.
@@ -42,7 +43,7 @@ import static org.junit.Assert.fail;
*
* NOTE: This class may be deleted in the future
*/
-@Ignore(value = "Tests validating Java Socket behaviours")
+@Disabled(value = "Tests validating Java Socket behaviours")
public class JavaSocketTests {
Logger log = LoggerFactory.getLogger(this.getClass());
@@ -51,12 +52,12 @@ public class JavaSocketTests {
int messageCount = 10;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
serverSocket = new ServerSocket(0);
}
- @After
+ @AfterEach
public void tearDown() throws Exception {
if (null != clientSocket) {
clientSocket.close();