You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by al...@apache.org on 2020/03/27 18:21:19 UTC
[camel] branch master updated: CAMEL-11807 Migrated
camel-base64/beanio/beanstalk tests to JUnit 5
This is an automated email from the ASF dual-hosted git repository.
aldettinger pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/master by this push:
new 821ba0e CAMEL-11807 Migrated camel-base64/beanio/beanstalk tests to JUnit 5
821ba0e is described below
commit 821ba0e28e4b13cc74cac31d7322c6650804b7fe
Author: aldettinger <al...@gmail.com>
AuthorDate: Fri Mar 27 18:54:08 2020 +0100
CAMEL-11807 Migrated camel-base64/beanio/beanstalk tests to JUnit 5
---
components/camel-base64/pom.xml | 4 +-
.../base64/Base64DataFormatDSLDefaultsTest.java | 4 +-
.../base64/Base64DataFormatDefaultsTest.java | 6 +-
.../base64/Base64DataFormatLineEndingsTest.java | 6 +-
.../base64/Base64DataFormatLineLengthTest.java | 6 +-
.../base64/Base64DataFormatTestBase.java | 8 +-
.../base64/SpringBase64DataFormatDefaultsTest.java | 6 +-
.../SpringBase64DataFormatLineEndingsTest.java | 6 +-
.../SpringBase64DataFormatLineLengthTest.java | 6 +-
.../base64/SpringBase64DataFormatTestBase.java | 4 +-
components/camel-beanio/pom.xml | 7 +-
.../beanio/BeanIODataFormatComplexTest.java | 84 ++++++++--------
...rmatSimpleCustomBeanReaderErrorHandlerTest.java | 28 +++---
.../beanio/BeanIODataFormatSimpleTest.java | 18 ++--
...IOSplitterCustomBeanReaderErrorHandlerTest.java | 24 +++--
.../dataformat/beanio/BeanIOSplitterTest.java | 14 +--
.../beanio/BeanIOUnmarshalSingleObjectTest.java | 12 ++-
.../apache/camel/dataformat/beanio/Constants.java} | 18 +---
.../beanio/SpringBeanIODataFormatSimpleTest.java | 14 +--
.../camel/dataformat/beanio/csv/CsvTest.java | 36 ++++---
.../beanio/csv/CsvTestWithProperties.java | 4 +-
components/camel-beanstalk/pom.xml | 10 +-
.../component/beanstalk/AwaitingConsumerTest.java | 15 ++-
.../beanstalk/BeanstalkMockTestSupport.java | 19 ++--
.../beanstalk/ConnectionSettingsTest.java | 40 ++++----
.../beanstalk/ConsumerCompletionTest.java | 18 ++--
.../beanstalk/ConsumerToProducerHeadersTest.java | 8 +-
.../camel/component/beanstalk/EndpointTest.java | 52 +++++-----
.../component/beanstalk/ImmediateConsumerTest.java | 12 +--
.../camel/component/beanstalk/ProducerTest.java | 112 +++++++++++----------
.../integration/BeanstalkCamelTestSupport.java | 6 +-
.../integration/BuryProducerIntegrationTest.java | 38 +++----
.../integration/ConsumerIntegrationTest.java | 4 +-
.../integration/DeleteProducerIntegrationTest.java | 30 +++---
.../integration/PutProducerIntegrationTest.java | 34 ++++---
.../ReleaseProducerIntegrationTest.java | 38 +++----
.../integration/TouchProducerIntegrationTest.java | 38 +++----
37 files changed, 411 insertions(+), 378 deletions(-)
diff --git a/components/camel-base64/pom.xml b/components/camel-base64/pom.xml
index a15e09c..1fea710 100644
--- a/components/camel-base64/pom.xml
+++ b/components/camel-base64/pom.xml
@@ -49,12 +49,12 @@
<!-- testing -->
<dependency>
<groupId>org.apache.camel</groupId>
- <artifactId>camel-test-spring</artifactId>
+ <artifactId>camel-test-spring-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
- <artifactId>camel-test</artifactId>
+ <artifactId>camel-test-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
diff --git a/components/camel-base64/src/test/java/org/apache/camel/dataformat/base64/Base64DataFormatDSLDefaultsTest.java b/components/camel-base64/src/test/java/org/apache/camel/dataformat/base64/Base64DataFormatDSLDefaultsTest.java
index 392fc9c..5d808f8 100644
--- a/components/camel-base64/src/test/java/org/apache/camel/dataformat/base64/Base64DataFormatDSLDefaultsTest.java
+++ b/components/camel-base64/src/test/java/org/apache/camel/dataformat/base64/Base64DataFormatDSLDefaultsTest.java
@@ -21,11 +21,11 @@ import org.apache.camel.builder.RouteBuilder;
public class Base64DataFormatDSLDefaultsTest extends Base64DataFormatDefaultsTest {
@Override
- protected RouteBuilder createRouteBuilder() throws Exception {
+ protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
@Override
- public void configure() throws Exception {
+ public void configure() {
from("direct:startEncode").marshal().base64().to("mock:result");
from("direct:startDecode").unmarshal().base64().to("mock:result");
diff --git a/components/camel-base64/src/test/java/org/apache/camel/dataformat/base64/Base64DataFormatDefaultsTest.java b/components/camel-base64/src/test/java/org/apache/camel/dataformat/base64/Base64DataFormatDefaultsTest.java
index 57ca333..325093a 100644
--- a/components/camel-base64/src/test/java/org/apache/camel/dataformat/base64/Base64DataFormatDefaultsTest.java
+++ b/components/camel-base64/src/test/java/org/apache/camel/dataformat/base64/Base64DataFormatDefaultsTest.java
@@ -16,7 +16,7 @@
*/
package org.apache.camel.dataformat.base64;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class Base64DataFormatDefaultsTest extends Base64DataFormatTestBase {
@@ -44,12 +44,12 @@ public class Base64DataFormatDefaultsTest extends Base64DataFormatTestBase {
}
@Test
- public void testEncode() throws Exception {
+ void testEncode() throws Exception {
runEncoderTest(DECODED, ENCODED.getBytes());
}
@Test
- public void testDecode() throws Exception {
+ void testDecode() throws Exception {
runDecoderTest(ENCODED.getBytes(), DECODED);
}
diff --git a/components/camel-base64/src/test/java/org/apache/camel/dataformat/base64/Base64DataFormatLineEndingsTest.java b/components/camel-base64/src/test/java/org/apache/camel/dataformat/base64/Base64DataFormatLineEndingsTest.java
index 6ff1292..0e577e7 100644
--- a/components/camel-base64/src/test/java/org/apache/camel/dataformat/base64/Base64DataFormatLineEndingsTest.java
+++ b/components/camel-base64/src/test/java/org/apache/camel/dataformat/base64/Base64DataFormatLineEndingsTest.java
@@ -16,7 +16,7 @@
*/
package org.apache.camel.dataformat.base64;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class Base64DataFormatLineEndingsTest extends Base64DataFormatTestBase {
@@ -46,12 +46,12 @@ public class Base64DataFormatLineEndingsTest extends Base64DataFormatTestBase {
}
@Test
- public void testEncode() throws Exception {
+ void testEncode() throws Exception {
runEncoderTest(DECODED, ENCODED.getBytes());
}
@Test
- public void testDecode() throws Exception {
+ void testDecode() throws Exception {
runDecoderTest(ENCODED.getBytes(), DECODED);
}
}
diff --git a/components/camel-base64/src/test/java/org/apache/camel/dataformat/base64/Base64DataFormatLineLengthTest.java b/components/camel-base64/src/test/java/org/apache/camel/dataformat/base64/Base64DataFormatLineLengthTest.java
index ddca72ac..b919f19 100644
--- a/components/camel-base64/src/test/java/org/apache/camel/dataformat/base64/Base64DataFormatLineLengthTest.java
+++ b/components/camel-base64/src/test/java/org/apache/camel/dataformat/base64/Base64DataFormatLineLengthTest.java
@@ -16,7 +16,7 @@
*/
package org.apache.camel.dataformat.base64;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class Base64DataFormatLineLengthTest extends Base64DataFormatTestBase {
@@ -48,12 +48,12 @@ public class Base64DataFormatLineLengthTest extends Base64DataFormatTestBase {
}
@Test
- public void testEncode() throws Exception {
+ void testEncode() throws Exception {
runEncoderTest(DECODED, ENCODED.getBytes());
}
@Test
- public void testDecode() throws Exception {
+ void testDecode() throws Exception {
runDecoderTest(ENCODED.getBytes(), DECODED);
}
diff --git a/components/camel-base64/src/test/java/org/apache/camel/dataformat/base64/Base64DataFormatTestBase.java b/components/camel-base64/src/test/java/org/apache/camel/dataformat/base64/Base64DataFormatTestBase.java
index 1a92267..5509545 100644
--- a/components/camel-base64/src/test/java/org/apache/camel/dataformat/base64/Base64DataFormatTestBase.java
+++ b/components/camel-base64/src/test/java/org/apache/camel/dataformat/base64/Base64DataFormatTestBase.java
@@ -19,7 +19,9 @@ package org.apache.camel.dataformat.base64;
import org.apache.camel.EndpointInject;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.camel.test.junit5.CamelTestSupport;
+
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
public abstract class Base64DataFormatTestBase extends CamelTestSupport {
@@ -123,11 +125,11 @@ public abstract class Base64DataFormatTestBase extends CamelTestSupport {
}
@Override
- protected RouteBuilder createRouteBuilder() throws Exception {
+ protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
@Override
- public void configure() throws Exception {
+ public void configure() {
from("direct:startEncode").marshal(format).to("mock:result");
from("direct:startDecode").unmarshal(format).to("mock:result");
diff --git a/components/camel-base64/src/test/java/org/apache/camel/dataformat/base64/SpringBase64DataFormatDefaultsTest.java b/components/camel-base64/src/test/java/org/apache/camel/dataformat/base64/SpringBase64DataFormatDefaultsTest.java
index a296c6f..5c3ae33 100644
--- a/components/camel-base64/src/test/java/org/apache/camel/dataformat/base64/SpringBase64DataFormatDefaultsTest.java
+++ b/components/camel-base64/src/test/java/org/apache/camel/dataformat/base64/SpringBase64DataFormatDefaultsTest.java
@@ -16,7 +16,7 @@
*/
package org.apache.camel.dataformat.base64;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
@@ -53,12 +53,12 @@ public class SpringBase64DataFormatDefaultsTest extends SpringBase64DataFormatTe
}
@Test
- public void testEncode() throws Exception {
+ void testEncode() throws Exception {
runEncoderTest(DECODED, ENCODED.getBytes());
}
@Test
- public void testDecode() throws Exception {
+ void testDecode() throws Exception {
runDecoderTest(ENCODED.getBytes(), DECODED);
}
diff --git a/components/camel-base64/src/test/java/org/apache/camel/dataformat/base64/SpringBase64DataFormatLineEndingsTest.java b/components/camel-base64/src/test/java/org/apache/camel/dataformat/base64/SpringBase64DataFormatLineEndingsTest.java
index 4c083ae..c6493ff 100644
--- a/components/camel-base64/src/test/java/org/apache/camel/dataformat/base64/SpringBase64DataFormatLineEndingsTest.java
+++ b/components/camel-base64/src/test/java/org/apache/camel/dataformat/base64/SpringBase64DataFormatLineEndingsTest.java
@@ -16,7 +16,7 @@
*/
package org.apache.camel.dataformat.base64;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
@@ -51,12 +51,12 @@ public class SpringBase64DataFormatLineEndingsTest extends SpringBase64DataForma
}
@Test
- public void testEncode() throws Exception {
+ void testEncode() throws Exception {
runEncoderTest(DECODED, ENCODED.getBytes());
}
@Test
- public void testDecode() throws Exception {
+ void testDecode() throws Exception {
runDecoderTest(ENCODED.getBytes(), DECODED);
}
diff --git a/components/camel-base64/src/test/java/org/apache/camel/dataformat/base64/SpringBase64DataFormatLineLengthTest.java b/components/camel-base64/src/test/java/org/apache/camel/dataformat/base64/SpringBase64DataFormatLineLengthTest.java
index 188f733..bf2b87e 100644
--- a/components/camel-base64/src/test/java/org/apache/camel/dataformat/base64/SpringBase64DataFormatLineLengthTest.java
+++ b/components/camel-base64/src/test/java/org/apache/camel/dataformat/base64/SpringBase64DataFormatLineLengthTest.java
@@ -16,7 +16,7 @@
*/
package org.apache.camel.dataformat.base64;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
@@ -47,12 +47,12 @@ public class SpringBase64DataFormatLineLengthTest extends SpringBase64DataFormat
+ "p6YptdCEK3P27QzZsSASAByd5jxHMiIBkdwGzj1501xZ7hFLJDXDTQ==\r\n";
@Test
- public void testEncode() throws Exception {
+ void testEncode() throws Exception {
runEncoderTest(DECODED, ENCODED.getBytes());
}
@Test
- public void testDecode() throws Exception {
+ void testDecode() throws Exception {
runDecoderTest(ENCODED.getBytes(), DECODED);
}
diff --git a/components/camel-base64/src/test/java/org/apache/camel/dataformat/base64/SpringBase64DataFormatTestBase.java b/components/camel-base64/src/test/java/org/apache/camel/dataformat/base64/SpringBase64DataFormatTestBase.java
index 232aee7..b914793 100644
--- a/components/camel-base64/src/test/java/org/apache/camel/dataformat/base64/SpringBase64DataFormatTestBase.java
+++ b/components/camel-base64/src/test/java/org/apache/camel/dataformat/base64/SpringBase64DataFormatTestBase.java
@@ -18,7 +18,9 @@ package org.apache.camel.dataformat.base64;
import org.apache.camel.EndpointInject;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.spring.CamelSpringTestSupport;
+import org.apache.camel.test.spring.junit5.CamelSpringTestSupport;
+
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
public abstract class SpringBase64DataFormatTestBase extends CamelSpringTestSupport {
diff --git a/components/camel-beanio/pom.xml b/components/camel-beanio/pom.xml
index 7a878b2..0aa6c51 100644
--- a/components/camel-beanio/pom.xml
+++ b/components/camel-beanio/pom.xml
@@ -50,12 +50,7 @@
<!-- testing -->
<dependency>
<groupId>org.apache.camel</groupId>
- <artifactId>camel-test-spring</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <artifactId>camel-test-spring-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
diff --git a/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/BeanIODataFormatComplexTest.java b/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/BeanIODataFormatComplexTest.java
index bf9c6f8..b813f26 100644
--- a/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/BeanIODataFormatComplexTest.java
+++ b/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/BeanIODataFormatComplexTest.java
@@ -25,52 +25,54 @@ import java.util.Locale;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.camel.test.junit5.CamelTestSupport;
import org.beanio.InvalidRecordException;
import org.beanio.UnexpectedRecordException;
import org.beanio.UnidentifiedRecordException;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+
+import static org.apache.camel.test.junit5.TestSupport.assertIsInstanceOf;
public class BeanIODataFormatComplexTest extends CamelTestSupport {
private static Locale defaultLocale;
- private final String recordData = "0001917A112345.678900 " + LS
- + "0002374A159303290.020 " + LS
- + "0015219B1SECURITY ONE " + LS
- + "END OF SECTION 1 " + LS
- + "0076647A10.0000000001 " + LS
- + "0135515A1999999999999 " + LS
- + "2000815B1SECURITY TWO " + LS
- + "2207122B1SECURITY THR " + LS
- + "END OF FILE 000007 " + LS;
-
- private final String data = "0000000A1030808PRICE " + LS
- + "0000000B1030808SECURITY " + LS
- + "HEADER END " + LS
+ private final String recordData = "0001917A112345.678900 " + Constants.LS
+ + "0002374A159303290.020 " + Constants.LS
+ + "0015219B1SECURITY ONE " + Constants.LS
+ + "END OF SECTION 1 " + Constants.LS
+ + "0076647A10.0000000001 " + Constants.LS
+ + "0135515A1999999999999 " + Constants.LS
+ + "2000815B1SECURITY TWO " + Constants.LS
+ + "2207122B1SECURITY THR " + Constants.LS
+ + "END OF FILE 000007 " + Constants.LS;
+
+ private final String data = "0000000A1030808PRICE " + Constants.LS
+ + "0000000B1030808SECURITY " + Constants.LS
+ + "HEADER END " + Constants.LS
+ recordData;
- private final String unExpectedData = "0000000A1030808PRICE " + LS
- + "0000000B1030808SECURITY " + LS
- + "0000000B1030808SECURITY " + LS
- + "HEADER END " + LS
+ private final String unExpectedData = "0000000A1030808PRICE " + Constants.LS
+ + "0000000B1030808SECURITY " + Constants.LS
+ + "0000000B1030808SECURITY " + Constants.LS
+ + "HEADER END " + Constants.LS
+ recordData;
- private final String invalidData = "0000000A1030808PRICE " + LS
- + "0000000B1030808SECURITY EXTRA DATA" + LS
- + "0000000B1030808SECURITY " + LS
- + "HEADER END " + LS
+ private final String invalidData = "0000000A1030808PRICE " + Constants.LS
+ + "0000000B1030808SECURITY EXTRA DATA" + Constants.LS
+ + "0000000B1030808SECURITY " + Constants.LS
+ + "HEADER END " + Constants.LS
+ recordData;
- private final String unidentifiedData = "0000000A1030808PRICE " + LS
- + "0000000C1030808SECURITY " + LS
- + "0000000B1030808SECURITY " + LS
- + "HEADER END " + LS
+ private final String unidentifiedData = "0000000A1030808PRICE " + Constants.LS
+ + "0000000C1030808SECURITY " + Constants.LS
+ + "0000000B1030808SECURITY " + Constants.LS
+ + "HEADER END " + Constants.LS
+ recordData;
- @BeforeClass
+ @BeforeAll
public static void setLocale() {
if (!Locale.getDefault().equals(Locale.ENGLISH)) {
@@ -81,7 +83,7 @@ public class BeanIODataFormatComplexTest extends CamelTestSupport {
}
}
- @AfterClass
+ @AfterAll
public static void resetLocale() {
if (defaultLocale != null) {
Locale.setDefault(defaultLocale);
@@ -89,7 +91,7 @@ public class BeanIODataFormatComplexTest extends CamelTestSupport {
}
@Test
- public void testMarshal() throws Exception {
+ void testMarshal() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:beanio-marshal");
mock.expectedBodiesReceived(data);
@@ -99,7 +101,7 @@ public class BeanIODataFormatComplexTest extends CamelTestSupport {
}
@Test
- public void testUnmarshal() throws Exception {
+ void testUnmarshal() throws Exception {
context.setTracing(true);
MockEndpoint mock = getMockEndpoint("mock:beanio-unmarshal");
mock.expectedBodiesReceived(createTestData(false));
@@ -110,7 +112,7 @@ public class BeanIODataFormatComplexTest extends CamelTestSupport {
}
@Test
- public void testUnmarshalUnexpected() throws Exception {
+ void testUnmarshalUnexpected() throws Exception {
Throwable ex = null;
try {
@@ -123,7 +125,7 @@ public class BeanIODataFormatComplexTest extends CamelTestSupport {
}
@Test
- public void testUnmarshalInvalid() throws Exception {
+ void testUnmarshalInvalid() throws Exception {
Throwable ex = null;
try {
@@ -136,7 +138,7 @@ public class BeanIODataFormatComplexTest extends CamelTestSupport {
}
@Test
- public void testUnmarshalUnidentifiedIgnore() throws Exception {
+ void testUnmarshalUnidentifiedIgnore() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:beanio-unmarshal");
mock.expectedBodiesReceived(createTestData(false));
template.sendBody("direct:unmarshal-forgiving", unidentifiedData);
@@ -144,7 +146,7 @@ public class BeanIODataFormatComplexTest extends CamelTestSupport {
}
@Test
- public void testUnmarshalUnexpectedIgnore() throws Exception {
+ void testUnmarshalUnexpectedIgnore() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:beanio-unmarshal");
mock.expectedBodiesReceived(createTestData(false));
template.sendBody("direct:unmarshal-forgiving", unExpectedData);
@@ -152,7 +154,7 @@ public class BeanIODataFormatComplexTest extends CamelTestSupport {
}
@Test
- public void testUnmarshalInvalidIgnore() throws Exception {
+ void testUnmarshalInvalidIgnore() throws Exception {
context.setTracing(true);
MockEndpoint mock = getMockEndpoint("mock:beanio-unmarshal");
mock.expectedBodiesReceived(createTestData(true));
@@ -161,7 +163,7 @@ public class BeanIODataFormatComplexTest extends CamelTestSupport {
}
@Test
- public void testUnmarshalUnidentified() throws Exception {
+ void testUnmarshalUnidentified() {
Throwable ex = null;
try {
@@ -212,10 +214,10 @@ public class BeanIODataFormatComplexTest extends CamelTestSupport {
}
@Override
- protected RouteBuilder createRouteBuilder() throws Exception {
+ protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
@Override
- public void configure() throws Exception {
+ public void configure() {
BeanIODataFormat format = new BeanIODataFormat("org/apache/camel/dataformat/beanio/mappings.xml", "securityData");
BeanIODataFormat forgivingFormat = new BeanIODataFormat("org/apache/camel/dataformat/beanio/mappings.xml", "securityData");
diff --git a/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/BeanIODataFormatSimpleCustomBeanReaderErrorHandlerTest.java b/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/BeanIODataFormatSimpleCustomBeanReaderErrorHandlerTest.java
index c0fafc0..353b39d 100644
--- a/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/BeanIODataFormatSimpleCustomBeanReaderErrorHandlerTest.java
+++ b/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/BeanIODataFormatSimpleCustomBeanReaderErrorHandlerTest.java
@@ -23,25 +23,27 @@ import java.util.List;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
public class BeanIODataFormatSimpleCustomBeanReaderErrorHandlerTest extends CamelTestSupport {
// START SNIPPET: e2
private static final String FIXED_DATA =
- "Joe,Smith,Developer,75000,10012009" + LS
- + "Jane,Doe,Architect,80000,01152008" + LS
- + "Jon,Anderson,Manager,85000,03182007" + LS;
+ "Joe,Smith,Developer,75000,10012009" + Constants.LS
+ + "Jane,Doe,Architect,80000,01152008" + Constants.LS
+ + "Jon,Anderson,Manager,85000,03182007" + Constants.LS;
// END SNIPPET: e2
private static final String FIXED_FAIL_DATA =
- "Joe,Smith,Developer,75000,10012009" + LS
- + "Jane,Doe,Architect,80000,01152008" + LS
- + "Jon,Anderson,Manager,XXX,03182007" + LS;
+ "Joe,Smith,Developer,75000,10012009" + Constants.LS
+ + "Jane,Doe,Architect,80000,01152008" + Constants.LS
+ + "Jon,Anderson,Manager,XXX,03182007" + Constants.LS;
@Test
- public void testMarshal() throws Exception {
+ void testMarshal() throws Exception {
List<Employee> employees = getEmployees();
MockEndpoint mock = getMockEndpoint("mock:beanio-marshal");
@@ -53,7 +55,7 @@ public class BeanIODataFormatSimpleCustomBeanReaderErrorHandlerTest extends Came
}
@Test
- public void testUnmarshal() throws Exception {
+ void testUnmarshal() throws Exception {
List<Employee> employees = getEmployees();
MockEndpoint mock = getMockEndpoint("mock:beanio-unmarshal");
@@ -65,7 +67,7 @@ public class BeanIODataFormatSimpleCustomBeanReaderErrorHandlerTest extends Came
}
@Test
- public void testUnmarshalFail() throws Exception {
+ void testUnmarshalFail() throws Exception {
// there should be 1 splitted that failed we get also
MockEndpoint mock = getMockEndpoint("mock:beanio-unmarshal");
mock.expectedMessageCount(3);
@@ -81,10 +83,10 @@ public class BeanIODataFormatSimpleCustomBeanReaderErrorHandlerTest extends Came
}
@Override
- protected RouteBuilder createRouteBuilder() throws Exception {
+ protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
@Override
- public void configure() throws Exception {
+ public void configure() {
// START SNIPPET: e1
// setup beanio data format using the mapping file, loaded from the classpath
BeanIODataFormat format = new BeanIODataFormat(
diff --git a/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/BeanIODataFormatSimpleTest.java b/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/BeanIODataFormatSimpleTest.java
index 6ae6389..6105650 100644
--- a/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/BeanIODataFormatSimpleTest.java
+++ b/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/BeanIODataFormatSimpleTest.java
@@ -24,20 +24,20 @@ import java.util.List;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.spi.DataFormat;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
public class BeanIODataFormatSimpleTest extends CamelTestSupport {
// START SNIPPET: e2
private static final String FIXED_DATA =
- "Joe,Smith,Developer,75000,10012009" + LS
- + "Jane,Doe,Architect,80000,01152008" + LS
- + "Jon,Anderson,Manager,85000,03182007" + LS;
+ "Joe,Smith,Developer,75000,10012009" + Constants.LS
+ + "Jane,Doe,Architect,80000,01152008" + Constants.LS
+ + "Jon,Anderson,Manager,85000,03182007" + Constants.LS;
// END SNIPPET: e2
@Test
- public void testMarshal() throws Exception {
+ void testMarshal() throws Exception {
List<Employee> employees = getEmployees();
MockEndpoint mock = getMockEndpoint("mock:beanio-marshal");
@@ -49,7 +49,7 @@ public class BeanIODataFormatSimpleTest extends CamelTestSupport {
}
@Test
- public void testUnmarshal() throws Exception {
+ void testUnmarshal() throws Exception {
List<Employee> employees = getEmployees();
MockEndpoint mock = getMockEndpoint("mock:beanio-unmarshal");
@@ -61,10 +61,10 @@ public class BeanIODataFormatSimpleTest extends CamelTestSupport {
}
@Override
- protected RouteBuilder createRouteBuilder() throws Exception {
+ protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
@Override
- public void configure() throws Exception {
+ public void configure() {
// START SNIPPET: e1
// setup beanio data format using the mapping file, loaded from the classpath
DataFormat format = new BeanIODataFormat(
diff --git a/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/BeanIOSplitterCustomBeanReaderErrorHandlerTest.java b/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/BeanIOSplitterCustomBeanReaderErrorHandlerTest.java
index 5a5111c..1b6c4ab 100644
--- a/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/BeanIOSplitterCustomBeanReaderErrorHandlerTest.java
+++ b/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/BeanIOSplitterCustomBeanReaderErrorHandlerTest.java
@@ -23,25 +23,27 @@ import java.util.List;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
public class BeanIOSplitterCustomBeanReaderErrorHandlerTest extends CamelTestSupport {
// START SNIPPET: e2
private static final String FIXED_DATA =
- "Joe,Smith,Developer,75000,10012009" + LS
- + "Jane,Doe,Architect,80000,01152008" + LS
- + "Jon,Anderson,Manager,85000,03182007" + LS;
+ "Joe,Smith,Developer,75000,10012009" + Constants.LS
+ + "Jane,Doe,Architect,80000,01152008" + Constants.LS
+ + "Jon,Anderson,Manager,85000,03182007" + Constants.LS;
// END SNIPPET: e2
private static final String FIXED_FAIL_DATA =
- "Joe,Smith,Developer,75000,10012009" + LS
- + "Jane,Doe,Architect,80000,01152008" + LS
- + "Jon,Anderson,Manager,XXX,03182007" + LS;
+ "Joe,Smith,Developer,75000,10012009" + Constants.LS
+ + "Jane,Doe,Architect,80000,01152008" + Constants.LS
+ + "Jon,Anderson,Manager,XXX,03182007" + Constants.LS;
@Test
- public void testSplit() throws Exception {
+ void testSplit() throws Exception {
List<Employee> employees = getEmployees();
MockEndpoint mock = getMockEndpoint("mock:beanio-unmarshal");
@@ -53,7 +55,7 @@ public class BeanIOSplitterCustomBeanReaderErrorHandlerTest extends CamelTestSup
}
@Test
- public void testSplitFail() throws Exception {
+ void testSplitFail() throws Exception {
// there should be 1 splitted that failed we get also
MockEndpoint mock = getMockEndpoint("mock:beanio-unmarshal");
mock.expectedMessageCount(3);
@@ -69,7 +71,7 @@ public class BeanIOSplitterCustomBeanReaderErrorHandlerTest extends CamelTestSup
}
@Override
- protected RouteBuilder createRouteBuilder() throws Exception {
+ protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
diff --git a/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/BeanIOSplitterTest.java b/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/BeanIOSplitterTest.java
index 521e331..073b02c 100644
--- a/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/BeanIOSplitterTest.java
+++ b/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/BeanIOSplitterTest.java
@@ -23,20 +23,20 @@ import java.util.List;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
public class BeanIOSplitterTest extends CamelTestSupport {
// START SNIPPET: e2
private static final String FIXED_DATA =
- "Joe,Smith,Developer,75000,10012009" + LS
- + "Jane,Doe,Architect,80000,01152008" + LS
- + "Jon,Anderson,Manager,85000,03182007" + LS;
+ "Joe,Smith,Developer,75000,10012009" + Constants.LS
+ + "Jane,Doe,Architect,80000,01152008" + Constants.LS
+ + "Jon,Anderson,Manager,85000,03182007" + Constants.LS;
// END SNIPPET: e2
@Test
- public void testSplit() throws Exception {
+ void testSplit() throws Exception {
List<Employee> employees = getEmployees();
MockEndpoint mock = getMockEndpoint("mock:beanio-unmarshal");
@@ -48,7 +48,7 @@ public class BeanIOSplitterTest extends CamelTestSupport {
}
@Override
- protected RouteBuilder createRouteBuilder() throws Exception {
+ protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
diff --git a/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/BeanIOUnmarshalSingleObjectTest.java b/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/BeanIOUnmarshalSingleObjectTest.java
index 51087bc..1d98327 100644
--- a/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/BeanIOUnmarshalSingleObjectTest.java
+++ b/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/BeanIOUnmarshalSingleObjectTest.java
@@ -22,8 +22,10 @@ import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
public class BeanIOUnmarshalSingleObjectTest extends CamelTestSupport {
@@ -31,7 +33,7 @@ public class BeanIOUnmarshalSingleObjectTest extends CamelTestSupport {
private static final String INPUT = "1234:Content starts from here" + NEW_LINE + "then continues" + NEW_LINE + "and ends here.";
@Test
- public void testMultiLineContentUnmarshal() throws Exception {
+ void testMultiLineContentUnmarshal() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(1);
@@ -41,10 +43,10 @@ public class BeanIOUnmarshalSingleObjectTest extends CamelTestSupport {
}
@Override
- protected RouteBuilder createRouteBuilder() throws Exception {
+ protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
@Override
- public void configure() throws Exception {
+ public void configure() {
BeanIODataFormat format = new BeanIODataFormat("org/apache/camel/dataformat/beanio/single-object-mapping.xml", "keyValueStream");
// turn on single mode
format.setUnmarshalSingleObject(true);
diff --git a/components/camel-base64/src/test/java/org/apache/camel/dataformat/base64/Base64DataFormatDSLDefaultsTest.java b/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/Constants.java
similarity index 59%
copy from components/camel-base64/src/test/java/org/apache/camel/dataformat/base64/Base64DataFormatDSLDefaultsTest.java
copy to components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/Constants.java
index 392fc9c..2382d36 100644
--- a/components/camel-base64/src/test/java/org/apache/camel/dataformat/base64/Base64DataFormatDSLDefaultsTest.java
+++ b/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/Constants.java
@@ -14,23 +14,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.dataformat.base64;
+package org.apache.camel.dataformat.beanio;
-import org.apache.camel.builder.RouteBuilder;
+public final class Constants {
-public class Base64DataFormatDSLDefaultsTest extends Base64DataFormatDefaultsTest {
+ public static final String LS = System.lineSeparator();
- @Override
- protected RouteBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
-
- @Override
- public void configure() throws Exception {
- from("direct:startEncode").marshal().base64().to("mock:result");
-
- from("direct:startDecode").unmarshal().base64().to("mock:result");
- }
- };
+ private Constants() {
}
}
diff --git a/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/SpringBeanIODataFormatSimpleTest.java b/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/SpringBeanIODataFormatSimpleTest.java
index aea8c7c..efff3df 100644
--- a/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/SpringBeanIODataFormatSimpleTest.java
+++ b/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/SpringBeanIODataFormatSimpleTest.java
@@ -22,16 +22,16 @@ import java.util.ArrayList;
import java.util.List;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.spring.CamelSpringTestSupport;
-import org.junit.Test;
+import org.apache.camel.test.spring.junit5.CamelSpringTestSupport;
+import org.junit.jupiter.api.Test;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class SpringBeanIODataFormatSimpleTest extends CamelSpringTestSupport {
- private static final String FIXED_DATA = "Joe,Smith,Developer,75000,10012009" + LS
- + "Jane,Doe,Architect,80000,01152008" + LS
- + "Jon,Anderson,Manager,85000,03182007" + LS;
+ private static final String FIXED_DATA = "Joe,Smith,Developer,75000,10012009" + Constants.LS
+ + "Jane,Doe,Architect,80000,01152008" + Constants.LS
+ + "Jon,Anderson,Manager,85000,03182007" + Constants.LS;
@Override
protected AbstractApplicationContext createApplicationContext() {
@@ -39,7 +39,7 @@ public class SpringBeanIODataFormatSimpleTest extends CamelSpringTestSupport {
}
@Test
- public void testMarshal() throws Exception {
+ void testMarshal() throws Exception {
List<Employee> employees = getEmployees();
MockEndpoint mock = getMockEndpoint("mock:beanio-marshal");
@@ -51,7 +51,7 @@ public class SpringBeanIODataFormatSimpleTest extends CamelSpringTestSupport {
}
@Test
- public void testUnmarshal() throws Exception {
+ void testUnmarshal() throws Exception {
List<Employee> employees = getEmployees();
MockEndpoint mock = getMockEndpoint("mock:beanio-unmarshal");
diff --git a/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/csv/CsvTest.java b/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/csv/CsvTest.java
index c931934..cfefee0 100644
--- a/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/csv/CsvTest.java
+++ b/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/csv/CsvTest.java
@@ -24,19 +24,29 @@ import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.dataformat.beanio.BeanIODataFormat;
+import org.apache.camel.dataformat.beanio.Constants;
import org.apache.camel.spi.DataFormat;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public class CsvTest extends CamelTestSupport {
+
+ static final Logger LOG = LoggerFactory.getLogger(CsvTest.class);
+
private static final String FIXED_DATA =
- "James,Strachan,22" + LS + "Claus,Ibsen,21" + LS;
+ "James,Strachan,22" + Constants.LS + "Claus,Ibsen,21" + Constants.LS;
private boolean verbose;
/*
@Test
- public void testMarshal() throws Exception {
+ void testMarshal() throws Exception {
List<Employee> employees = getEmployees();
MockEndpoint mock = getMockEndpoint("mock:beanio-marshal");
@@ -49,7 +59,7 @@ public class CsvTest extends CamelTestSupport {
*/
@Test
- public void testUnmarshal() throws Exception {
+ void testUnmarshal() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:beanio-unmarshal");
mock.expectedMessageCount(2);
@@ -61,7 +71,7 @@ public class CsvTest extends CamelTestSupport {
if (verbose) {
for (Exchange exchange : exchanges) {
Object body = exchange.getIn().getBody();
- log.info("received message {} of class {}", body, body.getClass().getName());
+ LOG.info("received message {} of class {}", body, body.getClass().getName());
}
}
List<Map> results = new ArrayList<>();
@@ -76,22 +86,22 @@ public class CsvTest extends CamelTestSupport {
}
protected static void assertRecord(List<Map> results, int index, String expectedFirstName, String expectedLastName, int expectedAge) {
- assertTrue("Not enough Map messages received: " + results.size(), results.size() > index);
+ assertTrue(results.size() > index, "Not enough Map messages received: " + results.size());
Map map = results.get(index);
- assertNotNull("No map result found for index " + index, map);
+ assertNotNull(map, "No map result found for index " + index);
String text = "bodyAsMap(" + index + ") ";
- assertEquals(text + "firstName", expectedFirstName, map.get("firstName"));
- assertEquals(text + "lastName", expectedLastName, map.get("lastName"));
- assertEquals(text + "age", expectedAge, map.get("age"));
+ assertEquals(expectedFirstName, map.get("firstName"), text + "firstName");
+ assertEquals(expectedLastName, map.get("lastName"), text + "lastName");
+ assertEquals(expectedAge, map.get("age"), text + "age");
}
@Override
- protected RouteBuilder createRouteBuilder() throws Exception {
+ protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
@Override
- public void configure() throws Exception {
+ public void configure() {
// START SNIPPET: e1
// setup beanio data format using the mapping file, loaded from the classpath
DataFormat format = new BeanIODataFormat(
diff --git a/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/csv/CsvTestWithProperties.java b/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/csv/CsvTestWithProperties.java
index c9dc237..de93d66 100644
--- a/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/csv/CsvTestWithProperties.java
+++ b/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/csv/CsvTestWithProperties.java
@@ -24,10 +24,10 @@ import org.apache.camel.dataformat.beanio.BeanIODataFormat;
public class CsvTestWithProperties extends CsvTest {
@Override
- protected RouteBuilder createRouteBuilder() throws Exception {
+ protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
@Override
- public void configure() throws Exception {
+ public void configure() {
// START SNIPPET: e1
// setup beanio data format using the mapping file, loaded from the classpath
BeanIODataFormat format = new BeanIODataFormat(
diff --git a/components/camel-beanstalk/pom.xml b/components/camel-beanstalk/pom.xml
index 48b62a7..3c489ff 100644
--- a/components/camel-beanstalk/pom.xml
+++ b/components/camel-beanstalk/pom.xml
@@ -50,17 +50,17 @@
<!-- test dependencies -->
<dependency>
<groupId>org.apache.camel</groupId>
- <artifactId>camel-test</artifactId>
+ <artifactId>camel-test-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-core</artifactId>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>hamcrest</artifactId>
<scope>test</scope>
</dependency>
<dependency>
diff --git a/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/AwaitingConsumerTest.java b/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/AwaitingConsumerTest.java
index 550e300..b0bc787 100644
--- a/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/AwaitingConsumerTest.java
+++ b/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/AwaitingConsumerTest.java
@@ -21,7 +21,9 @@ import com.surftools.BeanstalkClient.Job;
import org.apache.camel.EndpointInject;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.DisabledOnOs;
+import org.junit.jupiter.api.condition.OS;
import static org.mockito.Mockito.anyInt;
import static org.mockito.Mockito.atLeast;
@@ -30,6 +32,7 @@ import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+@DisabledOnOs(OS.WINDOWS)
public class AwaitingConsumerTest extends BeanstalkMockTestSupport {
@EndpointInject("beanstalk:tube")
@@ -38,10 +41,7 @@ public class AwaitingConsumerTest extends BeanstalkMockTestSupport {
private String testMessage = "hello, world";
@Test
- public void testReceive() throws Exception {
- if (!canTest()) {
- return;
- }
+ void testReceive() throws Exception {
final Job jobMock = mock(Job.class);
final long jobId = 111;
@@ -65,10 +65,7 @@ public class AwaitingConsumerTest extends BeanstalkMockTestSupport {
}
@Test
- public void testBeanstalkException() throws Exception {
- if (!canTest()) {
- return;
- }
+ void testBeanstalkException() throws Exception {
final Job jobMock = mock(Job.class);
final long jobId = 111;
diff --git a/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/BeanstalkMockTestSupport.java b/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/BeanstalkMockTestSupport.java
index 4f6ac62..735fd5e 100644
--- a/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/BeanstalkMockTestSupport.java
+++ b/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/BeanstalkMockTestSupport.java
@@ -17,24 +17,23 @@
package org.apache.camel.component.beanstalk;
import com.surftools.BeanstalkClient.Client;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.After;
-import org.junit.Before;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.condition.DisabledOnOs;
+import org.junit.jupiter.api.condition.OS;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import static org.mockito.Mockito.reset;
+@DisabledOnOs(OS.WINDOWS)
public class BeanstalkMockTestSupport extends CamelTestSupport {
+
@Mock
Client client;
- public boolean canTest() {
- // cannot test on windows
- return !isPlatform("windows");
- }
-
- @Before
+ @BeforeEach
@Override
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
@@ -43,7 +42,7 @@ public class BeanstalkMockTestSupport extends CamelTestSupport {
super.setUp();
}
- @After
+ @AfterEach
@Override
public void tearDown() throws Exception {
super.tearDown();
diff --git a/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/ConnectionSettingsTest.java b/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/ConnectionSettingsTest.java
index 78888e5..d539bef 100644
--- a/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/ConnectionSettingsTest.java
+++ b/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/ConnectionSettingsTest.java
@@ -17,39 +17,41 @@
package org.apache.camel.component.beanstalk;
import com.surftools.BeanstalkClient.Client;
-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.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;
public class ConnectionSettingsTest {
@Test
- public void parseUriTest() {
+ void parseUriTest() {
final ConnectionSettingsFactory factory = BeanstalkComponent.getConnectionSettingsFactory();
- assertEquals("Full URI", new ConnectionSettings("host.domain.tld", 11300, "someTube"), factory.parseUri("host.domain.tld:11300/someTube"));
- assertEquals("No port", new ConnectionSettings("host.domain.tld", Client.DEFAULT_PORT, "someTube"), factory.parseUri("host.domain.tld/someTube"));
- assertEquals("Only tube", new ConnectionSettings(Client.DEFAULT_HOST, Client.DEFAULT_PORT, "someTube"), factory.parseUri("someTube"));
+ assertEquals(new ConnectionSettings("host.domain.tld", 11300, "someTube"), factory.parseUri("host.domain.tld:11300/someTube"), "Full URI");
+ assertEquals(new ConnectionSettings("host.domain.tld", Client.DEFAULT_PORT, "someTube"), factory.parseUri("host.domain.tld/someTube"), "No port");
+ assertEquals(new ConnectionSettings(Client.DEFAULT_HOST, Client.DEFAULT_PORT, "someTube"), factory.parseUri("someTube"), "Only tube");
}
@Test
- public void parseTubesTest() {
+ void parseTubesTest() {
final ConnectionSettingsFactory factory = BeanstalkComponent.getConnectionSettingsFactory();
- assertArrayEquals("Full URI", new String[]{"tube1", "tube2"}, factory.parseUri("host:90/tube1+tube2").tubes);
- assertArrayEquals("No port", new String[]{"tube1", "tube2"}, factory.parseUri("host/tube1+tube2").tubes);
- assertArrayEquals("Only tubes", new String[]{"tube1", "tube2"}, factory.parseUri("tube1+tube2").tubes);
- assertArrayEquals("Empty URI", new String[0], factory.parseUri("").tubes);
+ assertArrayEquals(new String[]{"tube1", "tube2"}, factory.parseUri("host:90/tube1+tube2").tubes, "Full URI");
+ assertArrayEquals(new String[]{"tube1", "tube2"}, factory.parseUri("host/tube1+tube2").tubes, "No port");
+ assertArrayEquals(new String[]{"tube1", "tube2"}, factory.parseUri("tube1+tube2").tubes, "Only tubes");
+ assertArrayEquals(new String[0], factory.parseUri("").tubes, "Empty URI");
}
- @Test(expected = IllegalArgumentException.class)
- public void notValidHost() {
- final ConnectionSettingsFactory factory = BeanstalkComponent.getConnectionSettingsFactory();
- fail(String.format("Calling on not valid URI must raise exception, but got result %s", factory.parseUri("not_valid?host/tube?")));
+ @Test
+ void notValidHost() {
+ assertThrows(IllegalArgumentException.class, () -> {
+ final ConnectionSettingsFactory factory = BeanstalkComponent.getConnectionSettingsFactory();
+ factory.parseUri("not_valid?host/tube?");
+ }, "Calling on not valid URI must raise exception");
}
- @Before
+ @BeforeEach
public void setUp() {
BeanstalkComponent.setConnectionSettingsFactory(new ConnectionSettingsFactory());
}
diff --git a/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/ConsumerCompletionTest.java b/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/ConsumerCompletionTest.java
index abd9ad6..bd44679 100644
--- a/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/ConsumerCompletionTest.java
+++ b/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/ConsumerCompletionTest.java
@@ -25,8 +25,11 @@ import org.apache.camel.Processor;
import org.apache.camel.builder.NotifyBuilder;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.DisabledOnOs;
+import org.junit.jupiter.api.condition.OS;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.Mockito.anyInt;
import static org.mockito.Mockito.atLeast;
@@ -36,6 +39,7 @@ import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+@DisabledOnOs(OS.WINDOWS)
public class ConsumerCompletionTest extends BeanstalkMockTestSupport {
private final String testMessage = "hello, world";
private boolean shouldIdie;
@@ -49,10 +53,7 @@ public class ConsumerCompletionTest extends BeanstalkMockTestSupport {
};
@Test
- public void testDeleteOnComplete() throws Exception {
- if (!canTest()) {
- return;
- }
+ void testDeleteOnComplete() throws Exception {
final long jobId = 111;
final byte[] payload = Helper.stringToBytes(testMessage);
@@ -82,7 +83,7 @@ public class ConsumerCompletionTest extends BeanstalkMockTestSupport {
}
@Test
- public void testReleaseOnFailure() throws Exception {
+ void testReleaseOnFailure() throws Exception {
shouldIdie = true;
final long jobId = 111;
final long priority = BeanstalkComponent.DEFAULT_PRIORITY;
@@ -113,10 +114,7 @@ public class ConsumerCompletionTest extends BeanstalkMockTestSupport {
}
@Test
- public void testBeanstalkException() throws Exception {
- if (!canTest()) {
- return;
- }
+ void testBeanstalkException() throws Exception {
shouldIdie = false;
final Job jobMock = mock(Job.class);
diff --git a/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/ConsumerToProducerHeadersTest.java b/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/ConsumerToProducerHeadersTest.java
index 862753a..dcfb0be 100644
--- a/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/ConsumerToProducerHeadersTest.java
+++ b/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/ConsumerToProducerHeadersTest.java
@@ -24,8 +24,11 @@ import org.apache.camel.EndpointInject;
import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.DisabledOnOs;
+import org.junit.jupiter.api.condition.OS;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.Mockito.atLeastOnce;
@@ -33,6 +36,7 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+@DisabledOnOs(OS.WINDOWS)
public class ConsumerToProducerHeadersTest extends BeanstalkMockTestSupport {
@EndpointInject("beanstalk:tube=A")
@@ -45,7 +49,7 @@ public class ConsumerToProducerHeadersTest extends BeanstalkMockTestSupport {
private Processor b;
@Test
- public void testBeanstalkConsumerToProducer() throws Exception {
+ void testBeanstalkConsumerToProducer() throws Exception {
final long jobId = 111;
String testMessage = "hello, world";
final byte[] payload = Helper.stringToBytes(testMessage);
diff --git a/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/EndpointTest.java b/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/EndpointTest.java
index 8bd9adc..2c6d9c4 100644
--- a/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/EndpointTest.java
+++ b/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/EndpointTest.java
@@ -18,18 +18,18 @@ package org.apache.camel.component.beanstalk;
import org.apache.camel.CamelContext;
import org.apache.camel.impl.DefaultCamelContext;
-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.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
public class EndpointTest {
CamelContext context;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
context = new DefaultCamelContext(false);
context.disableJMX();
@@ -37,44 +37,44 @@ public class EndpointTest {
}
@Test
- public void testPriority() {
+ void testPriority() {
BeanstalkEndpoint endpoint = context.getEndpoint("beanstalk:default?jobPriority=1000", BeanstalkEndpoint.class);
- assertNotNull("Beanstalk endpoint", endpoint);
- assertEquals("Priority", 1000, endpoint.getJobPriority());
+ assertNotNull(endpoint, "Beanstalk endpoint");
+ assertEquals(1000, endpoint.getJobPriority(), "Priority");
}
@Test
- public void testTimeToRun() {
+ void testTimeToRun() {
BeanstalkEndpoint endpoint = context.getEndpoint("beanstalk:default?jobTimeToRun=10", BeanstalkEndpoint.class);
- assertNotNull("Beanstalk endpoint", endpoint);
- assertEquals("Time to run", 10, endpoint.getJobTimeToRun());
+ assertNotNull(endpoint, "Beanstalk endpoint");
+ assertEquals(10, endpoint.getJobTimeToRun(), "Time to run");
}
@Test
- public void testDelay() {
+ void testDelay() {
BeanstalkEndpoint endpoint = context.getEndpoint("beanstalk:default?jobDelay=10", BeanstalkEndpoint.class);
- assertNotNull("Beanstalk endpoint", endpoint);
- assertEquals("Delay", 10, endpoint.getJobDelay());
+ assertNotNull(endpoint, "Beanstalk endpoint");
+ assertEquals(10, endpoint.getJobDelay(), "Delay");
}
@Test
- public void testCommand() {
+ void testCommand() {
BeanstalkEndpoint endpoint = context.getEndpoint("beanstalk:default?command=release", BeanstalkEndpoint.class);
- assertNotNull("Beanstalk endpoint", endpoint);
- assertEquals("Command", BeanstalkComponent.COMMAND_RELEASE, endpoint.getCommand().name());
+ assertNotNull(endpoint, "Beanstalk endpoint");
+ assertEquals(BeanstalkComponent.COMMAND_RELEASE, endpoint.getCommand().name(), "Command");
}
@Test
- public void testTubes() {
+ void testTubes() {
BeanstalkEndpoint endpoint = context.getEndpoint("beanstalk:host:11303/tube1+tube%2B+tube%3F?command=kick", BeanstalkEndpoint.class);
- assertNotNull("Beanstalk endpoint", endpoint);
- assertEquals("Command", BeanstalkComponent.COMMAND_KICK, endpoint.getCommand().name());
- assertEquals("Host", "host", endpoint.conn.host);
- assertArrayEquals("Tubes", new String[]{"tube1", "tube+", "tube?"}, endpoint.conn.tubes);
+ assertNotNull(endpoint, "Beanstalk endpoint");
+ assertEquals(BeanstalkComponent.COMMAND_KICK, endpoint.getCommand().name(), "Command");
+ assertEquals("host", endpoint.conn.host, "Host");
+ assertArrayEquals(new String[]{"tube1", "tube+", "tube?"}, endpoint.conn.tubes, "Tubes");
}
- @After
- public void tearDown() throws Exception {
+ @AfterEach
+ public void tearDown() {
context.stop();
}
}
diff --git a/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/ImmediateConsumerTest.java b/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/ImmediateConsumerTest.java
index 4cc3e07..e8f6b51 100644
--- a/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/ImmediateConsumerTest.java
+++ b/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/ImmediateConsumerTest.java
@@ -21,7 +21,9 @@ import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.DisabledOnOs;
+import org.junit.jupiter.api.condition.OS;
import static org.mockito.Mockito.anyInt;
import static org.mockito.Mockito.atLeast;
@@ -30,6 +32,7 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+@DisabledOnOs(OS.WINDOWS)
public class ImmediateConsumerTest extends BeanstalkMockTestSupport {
final String testMessage = "hello, world";
boolean shouldIdie;
@@ -44,10 +47,7 @@ public class ImmediateConsumerTest extends BeanstalkMockTestSupport {
};
@Test
- public void testDeleteOnSuccess() throws Exception {
- if (!canTest()) {
- return;
- }
+ void testDeleteOnSuccess() throws Exception {
final Job jobMock = mock(Job.class);
final long jobId = 111;
@@ -71,7 +71,7 @@ public class ImmediateConsumerTest extends BeanstalkMockTestSupport {
}
@Test
- public void testDeleteOnFailure() throws Exception {
+ void testDeleteOnFailure() throws Exception {
shouldIdie = true;
final long jobId = 111;
final byte[] payload = Helper.stringToBytes(testMessage);
diff --git a/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/ProducerTest.java b/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/ProducerTest.java
index 9a8f7a5..cbcc03c 100644
--- a/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/ProducerTest.java
+++ b/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/ProducerTest.java
@@ -31,9 +31,15 @@ import org.apache.camel.component.beanstalk.processors.PutCommand;
import org.apache.camel.component.beanstalk.processors.ReleaseCommand;
import org.apache.camel.component.beanstalk.processors.TouchCommand;
import org.apache.camel.component.mock.MockEndpoint;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.DisabledOnOs;
+import org.junit.jupiter.api.condition.OS;
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.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.anyInt;
import static org.mockito.Mockito.anyLong;
import static org.mockito.Mockito.never;
@@ -41,6 +47,7 @@ import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+@DisabledOnOs(OS.WINDOWS)
public class ProducerTest extends BeanstalkMockTestSupport {
@EndpointInject("beanstalk:tube")
@@ -55,7 +62,7 @@ public class ProducerTest extends BeanstalkMockTestSupport {
private final String testMessage = "hello, world";
@Test
- public void testPut() throws Exception {
+ void testPut() throws Exception {
final long priority = BeanstalkComponent.DEFAULT_PRIORITY;
final int delay = BeanstalkComponent.DEFAULT_DELAY;
final int timeToRun = BeanstalkComponent.DEFAULT_TIME_TO_RUN;
@@ -65,19 +72,19 @@ public class ProducerTest extends BeanstalkMockTestSupport {
when(client.put(priority, delay, timeToRun, payload)).thenReturn(jobId);
final Producer producer = endpoint.createProducer();
- assertNotNull("Producer", producer);
+ assertNotNull(producer, "Producer");
assertThat("Producer class", producer, instanceOf(BeanstalkProducer.class));
assertThat("Processor class", ((BeanstalkProducer) producer).getCommand(), instanceOf(PutCommand.class));
// TODO: SetBodyProcessor(?)
final Exchange exchange = template.send(endpoint, ExchangePattern.InOnly, exchange1 -> exchange1.getIn().setBody(testMessage));
- assertEquals("Job ID in exchange", Long.valueOf(jobId), exchange.getIn().getHeader(Headers.JOB_ID, Long.class));
+ assertEquals(Long.valueOf(jobId), exchange.getIn().getHeader(Headers.JOB_ID, Long.class), "Job ID in exchange");
verify(client).put(priority, delay, timeToRun, payload);
}
@Test
- public void testPutOut() throws Exception {
+ void testPutOut() throws Exception {
final long priority = BeanstalkComponent.DEFAULT_PRIORITY;
final int delay = BeanstalkComponent.DEFAULT_DELAY;
final int timeToRun = BeanstalkComponent.DEFAULT_TIME_TO_RUN;
@@ -87,19 +94,19 @@ public class ProducerTest extends BeanstalkMockTestSupport {
when(client.put(priority, delay, timeToRun, payload)).thenReturn(jobId);
Producer producer = endpoint.createProducer();
- assertNotNull("Producer", producer);
+ assertNotNull(producer, "Producer");
assertThat("Producer class", producer, instanceOf(BeanstalkProducer.class));
assertThat("Processor class", ((BeanstalkProducer) producer).getCommand(), instanceOf(PutCommand.class));
// TODO: SetBodyProcessor(?)
final Exchange exchange = template.send(endpoint, ExchangePattern.InOut, exchange1 -> exchange1.getIn().setBody(testMessage));
- assertEquals("Job ID in exchange", Long.valueOf(jobId), exchange.getMessage().getHeader(Headers.JOB_ID, Long.class));
+ assertEquals(Long.valueOf(jobId), exchange.getMessage().getHeader(Headers.JOB_ID, Long.class), "Job ID in exchange");
verify(client).put(priority, delay, timeToRun, payload);
}
@Test
- public void testPutWithHeaders() throws Exception {
+ void testPutWithHeaders() throws Exception {
final long priority = 111;
final int delay = 5;
final int timeToRun = 65;
@@ -107,9 +114,8 @@ public class ProducerTest extends BeanstalkMockTestSupport {
final long jobId = 111;
when(client.put(priority, delay, timeToRun, payload)).thenReturn(jobId);
-
Producer producer = endpoint.createProducer();
- assertNotNull("Producer", producer);
+ assertNotNull(producer, "Producer");
assertThat("Producer class", producer, instanceOf(BeanstalkProducer.class));
assertThat("Processor class", ((BeanstalkProducer) producer).getCommand(), instanceOf(PutCommand.class));
@@ -121,18 +127,18 @@ public class ProducerTest extends BeanstalkMockTestSupport {
exchange1.getIn().setBody(testMessage);
});
- assertEquals("Job ID in exchange", Long.valueOf(jobId), exchange.getIn().getHeader(Headers.JOB_ID, Long.class));
+ assertEquals(Long.valueOf(jobId), exchange.getIn().getHeader(Headers.JOB_ID, Long.class), "Job ID in exchange");
verify(client).put(priority, delay, timeToRun, payload);
}
@Test
- public void testBury() throws Exception {
+ void testBury() throws Exception {
final long priority = BeanstalkComponent.DEFAULT_PRIORITY;
final long jobId = 111;
endpoint.setCommand(BeanstalkCommand.bury);
Producer producer = endpoint.createProducer();
- assertNotNull("Producer", producer);
+ assertNotNull(producer, "Producer");
assertThat("Producer class", producer, instanceOf(BeanstalkProducer.class));
assertThat("Processor class", ((BeanstalkProducer) producer).getCommand(), instanceOf(BuryCommand.class));
@@ -140,35 +146,35 @@ public class ProducerTest extends BeanstalkMockTestSupport {
final Exchange exchange = template.send(endpoint, ExchangePattern.InOnly, exchange1 -> exchange1.getIn().setHeader(Headers.JOB_ID, jobId));
- assertEquals("Op result", Boolean.TRUE, exchange.getIn().getHeader(Headers.RESULT, Boolean.class));
- assertEquals("Job ID in exchange", Long.valueOf(jobId), exchange.getIn().getHeader(Headers.JOB_ID, Long.class));
+ assertEquals(Boolean.TRUE, exchange.getIn().getHeader(Headers.RESULT, Boolean.class), "Op result");
+ assertEquals(Long.valueOf(jobId), exchange.getIn().getHeader(Headers.JOB_ID, Long.class), "Job ID in exchange");
verify(client).bury(jobId, priority);
}
@Test
- public void testBuryNoJobId() throws Exception {
+ void testBuryNoJobId() throws Exception {
endpoint.setCommand(BeanstalkCommand.bury);
Producer producer = endpoint.createProducer();
- assertNotNull("Producer", producer);
+ assertNotNull(producer, "Producer");
assertThat("Producer class", producer, instanceOf(BeanstalkProducer.class));
assertThat("Processor class", ((BeanstalkProducer) producer).getCommand(), instanceOf(BuryCommand.class));
final Exchange exchange = template.send(endpoint, ExchangePattern.InOnly, exchange1 -> {
});
- assertTrue("Exchange failed", exchange.isFailed());
+ assertTrue(exchange.isFailed(), "Exchange failed");
verify(client, never()).bury(anyLong(), anyLong());
}
@Test
- public void testBuryWithHeaders() throws Exception {
+ void testBuryWithHeaders() throws Exception {
final long priority = 1000;
final long jobId = 111;
endpoint.setCommand(BeanstalkCommand.bury);
Producer producer = endpoint.createProducer();
- assertNotNull("Producer", producer);
+ assertNotNull(producer, "Producer");
assertThat("Producer class", producer, instanceOf(BeanstalkProducer.class));
assertThat("Processor class", ((BeanstalkProducer) producer).getCommand(), instanceOf(BuryCommand.class));
@@ -181,18 +187,18 @@ public class ProducerTest extends BeanstalkMockTestSupport {
}
});
- assertEquals("Op result", Boolean.TRUE, exchange.getIn().getHeader(Headers.RESULT, Boolean.class));
- assertEquals("Job ID in exchange", Long.valueOf(jobId), exchange.getIn().getHeader(Headers.JOB_ID, Long.class));
+ assertEquals(Boolean.TRUE, exchange.getIn().getHeader(Headers.RESULT, Boolean.class), "Op result");
+ assertEquals(Long.valueOf(jobId), exchange.getIn().getHeader(Headers.JOB_ID, Long.class), "Job ID in exchange");
verify(client).bury(jobId, priority);
}
@Test
- public void testDelete() throws Exception {
+ void testDelete() throws Exception {
final long jobId = 111;
endpoint.setCommand(BeanstalkCommand.delete);
Producer producer = endpoint.createProducer();
- assertNotNull("Producer", producer);
+ assertNotNull(producer, "Producer");
assertThat("Producer class", producer, instanceOf(BeanstalkProducer.class));
assertThat("Processor class", ((BeanstalkProducer) producer).getCommand(), instanceOf(DeleteCommand.class));
@@ -200,36 +206,36 @@ public class ProducerTest extends BeanstalkMockTestSupport {
final Exchange exchange = template.send(endpoint, ExchangePattern.InOnly, exchange1 -> exchange1.getIn().setHeader(Headers.JOB_ID, jobId));
- assertEquals("Op result", Boolean.TRUE, exchange.getIn().getHeader(Headers.RESULT, Boolean.class));
- assertEquals("Job ID in exchange", Long.valueOf(jobId), exchange.getIn().getHeader(Headers.JOB_ID, Long.class));
+ assertEquals(Boolean.TRUE, exchange.getIn().getHeader(Headers.RESULT, Boolean.class), "Op result");
+ assertEquals(Long.valueOf(jobId), exchange.getIn().getHeader(Headers.JOB_ID, Long.class), "Job ID in exchange");
verify(client).delete(jobId);
}
@Test
- public void testDeleteNoJobId() throws Exception {
+ void testDeleteNoJobId() throws Exception {
endpoint.setCommand(BeanstalkCommand.delete);
Producer producer = endpoint.createProducer();
- assertNotNull("Producer", producer);
+ assertNotNull(producer, "Producer");
assertThat("Producer class", producer, instanceOf(BeanstalkProducer.class));
assertThat("Processor class", ((BeanstalkProducer) producer).getCommand(), instanceOf(DeleteCommand.class));
final Exchange exchange = template.send(endpoint, ExchangePattern.InOnly, exchange1 -> {
});
- assertTrue("Exchange failed", exchange.isFailed());
+ assertTrue(exchange.isFailed(), "Exchange failed");
verify(client, never()).delete(anyLong());
}
@Test
- public void testRelease() throws Exception {
+ void testRelease() throws Exception {
final long priority = BeanstalkComponent.DEFAULT_PRIORITY;
final int delay = BeanstalkComponent.DEFAULT_DELAY;
final long jobId = 111;
endpoint.setCommand(BeanstalkCommand.release);
Producer producer = endpoint.createProducer();
- assertNotNull("Producer", producer);
+ assertNotNull(producer, "Producer");
assertThat("Producer class", producer, instanceOf(BeanstalkProducer.class));
assertThat("Processor class", ((BeanstalkProducer) producer).getCommand(), instanceOf(ReleaseCommand.class));
@@ -237,36 +243,36 @@ public class ProducerTest extends BeanstalkMockTestSupport {
final Exchange exchange = template.send(endpoint, ExchangePattern.InOnly, exchange1 -> exchange1.getIn().setHeader(Headers.JOB_ID, jobId));
- assertEquals("Op result", Boolean.TRUE, exchange.getIn().getHeader(Headers.RESULT, Boolean.class));
- assertEquals("Job ID in exchange", Long.valueOf(jobId), exchange.getIn().getHeader(Headers.JOB_ID, Long.class));
+ assertEquals(Boolean.TRUE, exchange.getIn().getHeader(Headers.RESULT, Boolean.class), "Op result");
+ assertEquals(Long.valueOf(jobId), exchange.getIn().getHeader(Headers.JOB_ID, Long.class), "Job ID in exchange");
verify(client).release(jobId, priority, delay);
}
@Test
- public void testReleaseNoJobId() throws Exception {
+ void testReleaseNoJobId() throws Exception {
endpoint.setCommand(BeanstalkCommand.release);
Producer producer = endpoint.createProducer();
- assertNotNull("Producer", producer);
+ assertNotNull(producer, "Producer");
assertThat("Producer class", producer, instanceOf(BeanstalkProducer.class));
assertThat("Processor class", ((BeanstalkProducer) producer).getCommand(), instanceOf(ReleaseCommand.class));
final Exchange exchange = template.send(endpoint, ExchangePattern.InOnly, exchange1 -> {
});
- assertTrue("Exchange failed", exchange.isFailed());
+ assertTrue(exchange.isFailed(), "Exchange failed");
verify(client, never()).release(anyLong(), anyLong(), anyInt());
}
@Test
- public void testReleaseWithHeaders() throws Exception {
+ void testReleaseWithHeaders() throws Exception {
final long priority = 1001;
final int delay = 124;
final long jobId = 111;
endpoint.setCommand(BeanstalkCommand.release);
Producer producer = endpoint.createProducer();
- assertNotNull("Producer", producer);
+ assertNotNull(producer, "Producer");
assertThat("Producer class", producer, instanceOf(BeanstalkProducer.class));
assertThat("Processor class", ((BeanstalkProducer) producer).getCommand(), instanceOf(ReleaseCommand.class));
@@ -278,18 +284,18 @@ public class ProducerTest extends BeanstalkMockTestSupport {
exchange1.getIn().setHeader(Headers.DELAY, delay);
});
- assertEquals("Op result", Boolean.TRUE, exchange.getIn().getHeader(Headers.RESULT, Boolean.class));
- assertEquals("Job ID in exchange", Long.valueOf(jobId), exchange.getIn().getHeader(Headers.JOB_ID, Long.class));
+ assertEquals(Boolean.TRUE, exchange.getIn().getHeader(Headers.RESULT, Boolean.class), "Op result");
+ assertEquals(Long.valueOf(jobId), exchange.getIn().getHeader(Headers.JOB_ID, Long.class), "Job ID in exchange");
verify(client).release(jobId, priority, delay);
}
@Test
- public void testTouch() throws Exception {
+ void testTouch() throws Exception {
final long jobId = 111;
endpoint.setCommand(BeanstalkCommand.touch);
Producer producer = endpoint.createProducer();
- assertNotNull("Producer", producer);
+ assertNotNull(producer, "Producer");
assertThat("Producer class", producer, instanceOf(BeanstalkProducer.class));
assertThat("Processor class", ((BeanstalkProducer) producer).getCommand(), instanceOf(TouchCommand.class));
@@ -297,29 +303,29 @@ public class ProducerTest extends BeanstalkMockTestSupport {
final Exchange exchange = template.send(endpoint, ExchangePattern.InOnly, exchange1 -> exchange1.getIn().setHeader(Headers.JOB_ID, jobId));
- assertEquals("Op result", Boolean.TRUE, exchange.getIn().getHeader(Headers.RESULT, Boolean.class));
- assertEquals("Job ID in exchange", Long.valueOf(jobId), exchange.getIn().getHeader(Headers.JOB_ID, Long.class));
+ assertEquals(Boolean.TRUE, exchange.getIn().getHeader(Headers.RESULT, Boolean.class), "Op result");
+ assertEquals(Long.valueOf(jobId), exchange.getIn().getHeader(Headers.JOB_ID, Long.class), "Job ID in exchange");
verify(client).touch(jobId);
}
@Test
- public void testTouchNoJobId() throws Exception {
+ void testTouchNoJobId() throws Exception {
endpoint.setCommand(BeanstalkCommand.touch);
Producer producer = endpoint.createProducer();
- assertNotNull("Producer", producer);
+ assertNotNull(producer, "Producer");
assertThat("Producer class", producer, instanceOf(BeanstalkProducer.class));
assertThat("Processor class", ((BeanstalkProducer) producer).getCommand(), instanceOf(TouchCommand.class));
final Exchange exchange = template.send(endpoint, ExchangePattern.InOnly, exchange1 -> {
});
- assertTrue("Exchange failed", exchange.isFailed());
+ assertTrue(exchange.isFailed(), "Exchange failed");
verify(client, never()).touch(anyLong());
}
@Test
- public void testHeaderOverride() throws Exception {
+ void testHeaderOverride() throws Exception {
final long priority = 1020;
final int delay = 50;
final int timeToRun = 75;
@@ -336,13 +342,13 @@ public class ProducerTest extends BeanstalkMockTestSupport {
resultEndpoint.assertIsSatisfied();
final Long jobIdIn = resultEndpoint.getReceivedExchanges().get(0).getIn().getHeader(Headers.JOB_ID, Long.class);
- assertNotNull("Job ID in 'In' message", jobIdIn);
+ assertNotNull(jobIdIn, "Job ID in 'In' message");
verify(client).put(priority, delay, timeToRun, payload);
}
@Test
- public void test1BeanstalkException() throws Exception {
+ void test1BeanstalkException() throws Exception {
final long priority = 1020;
final int delay = 50;
final int timeToRun = 75;
@@ -361,14 +367,14 @@ public class ProducerTest extends BeanstalkMockTestSupport {
resultEndpoint.assertIsSatisfied();
final Long jobIdIn = resultEndpoint.getReceivedExchanges().get(0).getIn().getHeader(Headers.JOB_ID, Long.class);
- assertNotNull("Job ID in 'In' message", jobIdIn);
+ assertNotNull(jobIdIn, "Job ID in 'In' message");
verify(client, times(1)).close();
verify(client, times(2)).put(priority, delay, timeToRun, payload);
}
@Test
- public void test2BeanstalkException() throws Exception {
+ void test2BeanstalkException() throws Exception {
final long jobId = 111;
when(client.touch(jobId))
@@ -377,7 +383,7 @@ public class ProducerTest extends BeanstalkMockTestSupport {
endpoint.setCommand(BeanstalkCommand.touch);
final Exchange exchange = template.send(endpoint, ExchangePattern.InOnly, exchange1 -> exchange1.getIn().setHeader(Headers.JOB_ID, jobId));
- assertTrue("Exchange failed", exchange.isFailed());
+ assertTrue(exchange.isFailed(), "Exchange failed");
verify(client, times(2)).touch(jobId);
verify(client, times(1)).close();
diff --git a/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/integration/BeanstalkCamelTestSupport.java b/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/integration/BeanstalkCamelTestSupport.java
index c629356..1e4deb4 100644
--- a/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/integration/BeanstalkCamelTestSupport.java
+++ b/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/integration/BeanstalkCamelTestSupport.java
@@ -19,8 +19,8 @@ package org.apache.camel.component.beanstalk.integration;
import com.surftools.BeanstalkClient.Client;
import org.apache.camel.component.beanstalk.ConnectionSettings;
import org.apache.camel.component.beanstalk.ConnectionSettingsFactory;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Before;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.BeforeEach;
public abstract class BeanstalkCamelTestSupport extends CamelTestSupport {
protected final ConnectionSettingsFactory connFactory = ConnectionSettingsFactory.DEFAULT;
@@ -28,7 +28,7 @@ public abstract class BeanstalkCamelTestSupport extends CamelTestSupport {
protected Client reader;
protected Client writer;
- @Before
+ @BeforeEach
@Override
public void setUp() throws Exception {
super.setUp();
diff --git a/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/integration/BuryProducerIntegrationTest.java b/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/integration/BuryProducerIntegrationTest.java
index f68837e..55f1796 100644
--- a/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/integration/BuryProducerIntegrationTest.java
+++ b/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/integration/BuryProducerIntegrationTest.java
@@ -26,8 +26,14 @@ import org.apache.camel.ProducerTemplate;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.beanstalk.Headers;
import org.apache.camel.component.mock.MockEndpoint;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public class BuryProducerIntegrationTest extends BeanstalkCamelTestSupport {
@EndpointInject("mock:result")
@@ -36,11 +42,11 @@ public class BuryProducerIntegrationTest extends BeanstalkCamelTestSupport {
@Produce("direct:start")
protected ProducerTemplate direct;
- @Ignore("requires reserve - bury sequence")
+ @Disabled("requires reserve - bury sequence")
@Test
- public void testBury() throws InterruptedException, IOException {
+ void testBury() throws InterruptedException, IOException {
long jobId = writer.put(0, 0, 5, new byte[0]);
- assertTrue("Valid Job Id", jobId > 0);
+ assertTrue(jobId > 0, "Valid Job Id");
resultEndpoint.expectedMessageCount(1);
resultEndpoint.allMessages().header(Headers.JOB_ID).isNotNull();
@@ -50,24 +56,22 @@ public class BuryProducerIntegrationTest extends BeanstalkCamelTestSupport {
assertMockEndpointsSatisfied();
final Long messageJobId = resultEndpoint.getReceivedExchanges().get(0).getIn().getHeader(Headers.JOB_ID, Long.class);
- assertNotNull("Job ID in message", messageJobId);
- assertEquals("Message Job ID equals", jobId, messageJobId.longValue());
+ assertNotNull(messageJobId, "Job ID in message");
+ assertEquals(jobId, messageJobId.longValue(), "Message Job ID equals");
final Job job = reader.reserve(0);
- assertNull("Beanstalk client has no message", job);
+ assertNull(job, "Beanstalk client has no message");
final Job buried = reader.peekBuried();
- assertNotNull("Job in buried", buried);
- assertEquals("Buried job id", jobId, buried.getJobId());
+ assertNotNull(buried, "Job in buried");
+ assertEquals(jobId, buried.getJobId(), "Buried job id");
}
- @Test(expected = CamelExecutionException.class)
- public void testNoJobId() throws InterruptedException, IOException {
- resultEndpoint.expectedMessageCount(0);
- direct.sendBody(new byte[0]);
-
- resultEndpoint.assertIsSatisfied();
- assertListSize("Number of exceptions", resultEndpoint.getFailures(), 1);
+ @Test
+ void testNoJobId() {
+ assertThrows(CamelExecutionException.class, () -> {
+ direct.sendBody(new byte[0]);
+ });
}
@Override
diff --git a/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/integration/ConsumerIntegrationTest.java b/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/integration/ConsumerIntegrationTest.java
index 91f7ea0..6d48fab 100644
--- a/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/integration/ConsumerIntegrationTest.java
+++ b/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/integration/ConsumerIntegrationTest.java
@@ -24,7 +24,7 @@ import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.beanstalk.Headers;
import org.apache.camel.component.beanstalk.Helper;
import org.apache.camel.component.mock.MockEndpoint;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class ConsumerIntegrationTest extends BeanstalkCamelTestSupport {
final String testMessage = "Hello, world!";
@@ -33,7 +33,7 @@ public class ConsumerIntegrationTest extends BeanstalkCamelTestSupport {
MockEndpoint result;
@Test
- public void testReceive() throws IOException, InterruptedException {
+ void testReceive() throws IOException, InterruptedException {
long prio = 0;
int ttr = 10;
final long jobId = writer.put(prio, 0, ttr, Helper.stringToBytes(testMessage));
diff --git a/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/integration/DeleteProducerIntegrationTest.java b/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/integration/DeleteProducerIntegrationTest.java
index 03c812b..55299dd 100644
--- a/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/integration/DeleteProducerIntegrationTest.java
+++ b/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/integration/DeleteProducerIntegrationTest.java
@@ -26,7 +26,13 @@ import org.apache.camel.ProducerTemplate;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.beanstalk.Headers;
import org.apache.camel.component.mock.MockEndpoint;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public class DeleteProducerIntegrationTest extends BeanstalkCamelTestSupport {
@EndpointInject("mock:result")
@@ -36,9 +42,9 @@ public class DeleteProducerIntegrationTest extends BeanstalkCamelTestSupport {
protected ProducerTemplate direct;
@Test
- public void testDelete() throws InterruptedException, IOException {
+ void testDelete() throws InterruptedException, IOException {
long jobId = writer.put(0, 0, 5, new byte[0]);
- assertTrue("Valid Job Id", jobId > 0);
+ assertTrue(jobId > 0, "Valid Job Id");
resultEndpoint.expectedMessageCount(1);
resultEndpoint.allMessages().header(Headers.JOB_ID).isNotNull();
@@ -48,20 +54,18 @@ public class DeleteProducerIntegrationTest extends BeanstalkCamelTestSupport {
assertMockEndpointsSatisfied();
final Long messageJobId = resultEndpoint.getReceivedExchanges().get(0).getIn().getHeader(Headers.JOB_ID, Long.class);
- assertNotNull("Job ID in message", messageJobId);
- assertEquals("Message Job ID equals", jobId, messageJobId.longValue());
+ assertNotNull(messageJobId, "Job ID in message");
+ assertEquals(jobId, messageJobId.longValue(), "Message Job ID equals");
final Job job = reader.peek(jobId);
- assertNull("Job has been deleted", job);
+ assertNull(job, "Job has been deleted");
}
- @Test(expected = CamelExecutionException.class)
- public void testNoJobId() throws InterruptedException, IOException {
- resultEndpoint.expectedMessageCount(0);
- direct.sendBody(new byte[0]);
-
- resultEndpoint.assertIsSatisfied();
- assertListSize("Number of exceptions", resultEndpoint.getFailures(), 1);
+ @Test
+ void testNoJobId() {
+ assertThrows(CamelExecutionException.class, () -> {
+ direct.sendBody(new byte[0]);
+ });
}
@Override
diff --git a/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/integration/PutProducerIntegrationTest.java b/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/integration/PutProducerIntegrationTest.java
index bbbe84b..fa02cf7 100644
--- a/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/integration/PutProducerIntegrationTest.java
+++ b/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/integration/PutProducerIntegrationTest.java
@@ -29,7 +29,11 @@ import org.apache.camel.ProducerTemplate;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.beanstalk.Headers;
import org.apache.camel.component.mock.MockEndpoint;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
public class PutProducerIntegrationTest extends BeanstalkCamelTestSupport {
@@ -42,7 +46,7 @@ public class PutProducerIntegrationTest extends BeanstalkCamelTestSupport {
private final String testMessage = "Hello, world!";
@Test
- public void testPut() throws InterruptedException, IOException {
+ void testPut() throws InterruptedException, IOException {
resultEndpoint.expectedMessageCount(1);
resultEndpoint.allMessages().header(Headers.JOB_ID).isNotNull();
direct.sendBody(testMessage);
@@ -50,35 +54,35 @@ public class PutProducerIntegrationTest extends BeanstalkCamelTestSupport {
resultEndpoint.assertIsSatisfied();
final Long jobId = resultEndpoint.getReceivedExchanges().get(0).getIn().getHeader(Headers.JOB_ID, Long.class);
- assertNotNull("Job ID in 'In' message", jobId);
+ assertNotNull(jobId, "Job ID in 'In' message");
final Job job = reader.reserve(5);
- assertNotNull("Beanstalk client got message", job);
- assertEquals("Job body from the server", testMessage, new String(job.getData()));
- assertEquals("Job ID from the server", jobId.longValue(), job.getJobId());
+ assertNotNull(job, "Beanstalk client got message");
+ assertEquals(testMessage, new String(job.getData()), "Job body from the server");
+ assertEquals(jobId.longValue(), job.getJobId(), "Job ID from the server");
reader.delete(jobId);
}
@Test
- public void testOut() throws InterruptedException, IOException {
+ void testOut() throws InterruptedException, IOException {
final Endpoint endpoint = context.getEndpoint("beanstalk:" + tubeName);
final Exchange exchange = template.send(endpoint, ExchangePattern.InOut, exchange1 -> exchange1.getIn().setBody(testMessage));
final Message out = exchange.getMessage();
- assertNotNull("Out message", out);
+ assertNotNull(out, "Out message");
final Long jobId = out.getHeader(Headers.JOB_ID, Long.class);
- assertNotNull("Job ID in 'Out' message", jobId);
+ assertNotNull(jobId, "Job ID in 'Out' message");
final Job job = reader.reserve(5);
- assertNotNull("Beanstalk client got message", job);
- assertEquals("Job body from the server", testMessage, new String(job.getData()));
- assertEquals("Job ID from the server", jobId.longValue(), job.getJobId());
+ assertNotNull(job, "Beanstalk client got message");
+ assertEquals(testMessage, new String(job.getData()), "Job body from the server");
+ assertEquals(jobId.longValue(), job.getJobId(), "Job ID from the server");
reader.delete(jobId);
}
@Test
- public void testDelay() throws InterruptedException, IOException {
+ void testDelay() throws InterruptedException, IOException {
final byte[] testBytes = new byte[0];
resultEndpoint.expectedMessageCount(1);
@@ -89,10 +93,10 @@ public class PutProducerIntegrationTest extends BeanstalkCamelTestSupport {
resultEndpoint.assertIsSatisfied();
final Long jobId = resultEndpoint.getReceivedExchanges().get(0).getIn().getHeader(Headers.JOB_ID, Long.class);
- assertNotNull("Job ID in message", jobId);
+ assertNotNull(jobId, "Job ID in message");
final Job job = reader.reserve(0);
- assertNull("Beanstalk client has no message", job);
+ assertNull(job, "Beanstalk client has no message");
reader.delete(jobId);
}
diff --git a/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/integration/ReleaseProducerIntegrationTest.java b/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/integration/ReleaseProducerIntegrationTest.java
index a0c0e31..baeee64 100644
--- a/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/integration/ReleaseProducerIntegrationTest.java
+++ b/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/integration/ReleaseProducerIntegrationTest.java
@@ -26,8 +26,14 @@ import org.apache.camel.ProducerTemplate;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.beanstalk.Headers;
import org.apache.camel.component.mock.MockEndpoint;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public class ReleaseProducerIntegrationTest extends BeanstalkCamelTestSupport {
@EndpointInject("mock:result")
@@ -36,11 +42,11 @@ public class ReleaseProducerIntegrationTest extends BeanstalkCamelTestSupport {
@Produce("direct:start")
protected ProducerTemplate direct;
- @Ignore("requires reserve - release sequence")
+ @Disabled("requires reserve - release sequence")
@Test
- public void testBury() throws InterruptedException, IOException {
+ void testBury() throws InterruptedException, IOException {
long jobId = writer.put(0, 0, 5, new byte[0]);
- assertTrue("Valid Job Id", jobId > 0);
+ assertTrue(jobId > 0, "Valid Job Id");
resultEndpoint.expectedMessageCount(1);
resultEndpoint.allMessages().header(Headers.JOB_ID).isNotNull();
@@ -50,24 +56,22 @@ public class ReleaseProducerIntegrationTest extends BeanstalkCamelTestSupport {
assertMockEndpointsSatisfied();
final Long messageJobId = resultEndpoint.getReceivedExchanges().get(0).getIn().getHeader(Headers.JOB_ID, Long.class);
- assertNotNull("Job ID in message", messageJobId);
- assertEquals("Message Job ID equals", jobId, messageJobId.longValue());
+ assertNotNull(messageJobId, "Job ID in message");
+ assertEquals(jobId, messageJobId.longValue(), "Message Job ID equals");
final Job job = reader.reserve(0);
- assertNull("Beanstalk client has no message", job);
+ assertNull(job, "Beanstalk client has no message");
final Job buried = reader.peekBuried();
- assertNotNull("Job in buried", buried);
- assertEquals("Buried job id", jobId, buried.getJobId());
+ assertNotNull(buried, "Job in buried");
+ assertEquals(jobId, buried.getJobId(), "Buried job id");
}
- @Test(expected = CamelExecutionException.class)
- public void testNoJobId() throws InterruptedException, IOException {
- resultEndpoint.expectedMessageCount(0);
- direct.sendBody(new byte[0]);
-
- resultEndpoint.assertIsSatisfied();
- assertListSize("Number of exceptions", resultEndpoint.getFailures(), 1);
+ @Test
+ void testNoJobId() {
+ assertThrows(CamelExecutionException.class, () -> {
+ direct.sendBody(new byte[0]);
+ });
}
@Override
diff --git a/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/integration/TouchProducerIntegrationTest.java b/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/integration/TouchProducerIntegrationTest.java
index 4c7a1a3..e3b1328 100644
--- a/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/integration/TouchProducerIntegrationTest.java
+++ b/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/integration/TouchProducerIntegrationTest.java
@@ -26,8 +26,14 @@ import org.apache.camel.ProducerTemplate;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.beanstalk.Headers;
import org.apache.camel.component.mock.MockEndpoint;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public class TouchProducerIntegrationTest extends BeanstalkCamelTestSupport {
@EndpointInject("mock:result")
@@ -36,11 +42,11 @@ public class TouchProducerIntegrationTest extends BeanstalkCamelTestSupport {
@Produce("direct:start")
protected ProducerTemplate direct;
- @Ignore("requires reserve - touch sequence")
+ @Disabled("requires reserve - touch sequence")
@Test
- public void testBury() throws InterruptedException, IOException {
+ void testBury() throws InterruptedException, IOException {
long jobId = writer.put(0, 0, 5, new byte[0]);
- assertTrue("Valid Job Id", jobId > 0);
+ assertTrue(jobId > 0, "Valid Job Id");
resultEndpoint.expectedMessageCount(1);
resultEndpoint.allMessages().header(Headers.JOB_ID).isNotNull();
@@ -50,24 +56,22 @@ public class TouchProducerIntegrationTest extends BeanstalkCamelTestSupport {
assertMockEndpointsSatisfied();
final Long messageJobId = resultEndpoint.getReceivedExchanges().get(0).getIn().getHeader(Headers.JOB_ID, Long.class);
- assertNotNull("Job ID in message", messageJobId);
- assertEquals("Message Job ID equals", jobId, messageJobId.longValue());
+ assertNotNull(messageJobId, "Job ID in message");
+ assertEquals(jobId, messageJobId.longValue(), "Message Job ID equals");
final Job job = reader.reserve(0);
- assertNull("Beanstalk client has no message", job);
+ assertNull(job, "Beanstalk client has no message");
final Job buried = reader.peekBuried();
- assertNotNull("Job in buried", buried);
- assertEquals("Buried job id", jobId, buried.getJobId());
+ assertNotNull(buried, "Job in buried");
+ assertEquals(jobId, buried.getJobId(), "Buried job id");
}
- @Test(expected = CamelExecutionException.class)
- public void testNoJobId() throws InterruptedException, IOException {
- resultEndpoint.expectedMessageCount(0);
- direct.sendBody(new byte[0]);
-
- resultEndpoint.assertIsSatisfied();
- assertListSize("Number of exceptions", resultEndpoint.getFailures(), 1);
+ @Test
+ void testNoJobId() {
+ assertThrows(CamelExecutionException.class, () -> {
+ direct.sendBody(new byte[0]);
+ });
}
@Override