This is an automated email from the ASF dual-hosted git repository. gnodet pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel.git
commit 374cc52ff7d06def877354f29b1e6d5853d6946d Author: Guillaume Nodet <gno...@gmail.com> AuthorDate: Mon Jul 20 10:32:54 2020 +0200 [CAMEL-11807] Upgrade camel-reactive-streams to junit5 --- components/camel-reactive-streams/pom.xml | 6 +++--- .../engine/DefaultCamelReactiveStreamsService.java | 8 ++++---- .../BackpressurePublisherRoutePolicyTest.java | 11 ++++++---- .../reactive/streams/BackpressureStrategyTest.java | 15 ++++++++------ .../streams/BackpressureSubscriberTest.java | 17 ++++++++------- .../reactive/streams/BasicPublisherTest.java | 19 ++++++++++------- .../reactive/streams/BasicSubscriberTest.java | 8 +++++--- .../component/reactive/streams/BeanCallTest.java | 23 +++++++++++++-------- .../reactive/streams/CamelReactiveStreamsTest.java | 24 ++++++++++++---------- .../reactive/streams/ConcurrentConsumersTest.java | 8 +++++--- .../reactive/streams/DelayedMonoPublisherTest.java | 23 +++++++++++++-------- .../reactive/streams/DirectClientAPITest.java | 21 +++++++++++-------- .../component/reactive/streams/EventTypeTest.java | 16 ++++++++------- .../reactive/streams/ExchangeRequestTest.java | 9 +++++--- .../streams/PublisherTypeConversionTest.java | 8 +++++--- .../reactive/streams/ReactiveStreamsJMXTest.java | 10 ++++++--- .../reactive/streams/RequestRefillTest.java | 9 +++++--- .../platforms/AbstractPlatformTestSupport.java | 11 ++++++---- .../support/ReactiveStreamsTestSupport.java | 2 +- .../CamelPublisherConversionVerificationTest.java | 2 +- .../tck/CamelPublisherVerificationTest.java | 2 +- .../CamelSubscriberConversionVerificationTest.java | 2 +- .../tck/CamelSubscriberVerificationTest.java | 2 +- 23 files changed, 153 insertions(+), 103 deletions(-) diff --git a/components/camel-reactive-streams/pom.xml b/components/camel-reactive-streams/pom.xml index a5d3b4b..bcd3b53 100644 --- a/components/camel-reactive-streams/pom.xml +++ b/components/camel-reactive-streams/pom.xml @@ -69,7 +69,7 @@ </dependency> <dependency> <groupId>org.apache.camel</groupId> - <artifactId>camel-test</artifactId> + <artifactId>camel-test-junit5</artifactId> <scope>test</scope> </dependency> <dependency> @@ -78,8 +78,8 @@ <scope>test</scope> </dependency> <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> + <groupId>org.junit.jupiter</groupId> + <artifactId>junit-jupiter</artifactId> <scope>test</scope> </dependency> <dependency> diff --git a/components/camel-reactive-streams/src/main/java/org/apache/camel/component/reactive/streams/engine/DefaultCamelReactiveStreamsService.java b/components/camel-reactive-streams/src/main/java/org/apache/camel/component/reactive/streams/engine/DefaultCamelReactiveStreamsService.java index a9238e4..bb6444f 100644 --- a/components/camel-reactive-streams/src/main/java/org/apache/camel/component/reactive/streams/engine/DefaultCamelReactiveStreamsService.java +++ b/components/camel-reactive-streams/src/main/java/org/apache/camel/component/reactive/streams/engine/DefaultCamelReactiveStreamsService.java @@ -216,7 +216,7 @@ public class DefaultCamelReactiveStreamsService extends ServiceSupport implement String uuid = context.getUuidGenerator().generateUuid(); new RouteBuilder() { @Override - public void configure() throws Exception { + public void configure() { from(u) .to("reactive-streams:" + uuid); } @@ -241,7 +241,7 @@ public class DefaultCamelReactiveStreamsService extends ServiceSupport implement String uuid = context.getUuidGenerator().generateUuid(); new RouteBuilder() { @Override - public void configure() throws Exception { + public void configure() { from("reactive-streams:" + uuid) .to(uri); } @@ -265,7 +265,7 @@ public class DefaultCamelReactiveStreamsService extends ServiceSupport implement String uuid = context.getUuidGenerator().generateUuid(); new RouteBuilder() { @Override - public void configure() throws Exception { + public void configure() { from("reactive-streams:" + uuid) .to(u); } @@ -299,7 +299,7 @@ public class DefaultCamelReactiveStreamsService extends ServiceSupport implement try { new RouteBuilder() { @Override - public void configure() throws Exception { + public void configure() { from(uri) .process(exchange -> { Exchange copy = exchange.copy(); diff --git a/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/BackpressurePublisherRoutePolicyTest.java b/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/BackpressurePublisherRoutePolicyTest.java index 8fa3605..9cffe9c 100644 --- a/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/BackpressurePublisherRoutePolicyTest.java +++ b/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/BackpressurePublisherRoutePolicyTest.java @@ -26,11 +26,14 @@ import org.apache.camel.StatefulService; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.reactive.streams.api.CamelReactiveStreams; import org.apache.camel.component.reactive.streams.support.TestSubscriber; -import org.apache.camel.test.junit4.CamelTestSupport; +import org.apache.camel.test.junit5.CamelTestSupport; import org.apache.camel.throttling.ThrottlingInflightRoutePolicy; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.reactivestreams.Publisher; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + public class BackpressurePublisherRoutePolicyTest extends CamelTestSupport { @Test @@ -40,7 +43,7 @@ public class BackpressurePublisherRoutePolicyTest extends CamelTestSupport { new RouteBuilder() { @Override - public void configure() throws Exception { + public void configure() { ThrottlingInflightRoutePolicy policy = new ThrottlingInflightRoutePolicy(); policy.setMaxInflightExchanges(10); policy.setScope(ThrottlingInflightRoutePolicy.ThrottlingScope.Route); @@ -99,7 +102,7 @@ public class BackpressurePublisherRoutePolicyTest extends CamelTestSupport { new RouteBuilder() { @Override - public void configure() throws Exception { + public void configure() { ThrottlingInflightRoutePolicy policy = new ThrottlingInflightRoutePolicy(); policy.setMaxInflightExchanges(10); policy.setScope(ThrottlingInflightRoutePolicy.ThrottlingScope.Route); diff --git a/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/BackpressureStrategyTest.java b/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/BackpressureStrategyTest.java index 8fe5539..6814051 100644 --- a/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/BackpressureStrategyTest.java +++ b/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/BackpressureStrategyTest.java @@ -25,8 +25,11 @@ import org.apache.camel.Exchange; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.reactive.streams.api.CamelReactiveStreams; import org.apache.camel.component.reactive.streams.support.TestSubscriber; -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; +import static org.junit.jupiter.api.Assertions.assertTrue; public class BackpressureStrategyTest extends CamelTestSupport { @@ -35,7 +38,7 @@ public class BackpressureStrategyTest extends CamelTestSupport { new RouteBuilder() { @Override - public void configure() throws Exception { + public void configure() { from("timer:gen?period=20&repeatCount=20") .setBody().header(Exchange.TIMER_COUNTER) .to("reactive-streams:integers"); @@ -72,7 +75,7 @@ public class BackpressureStrategyTest extends CamelTestSupport { new RouteBuilder() { @Override - public void configure() throws Exception { + public void configure() { from("timer:gen?period=20&repeatCount=20") .setBody().header(Exchange.TIMER_COUNTER) .to("reactive-streams:integers"); @@ -118,7 +121,7 @@ public class BackpressureStrategyTest extends CamelTestSupport { new RouteBuilder() { @Override - public void configure() throws Exception { + public void configure() { from("timer:gen?period=20&repeatCount=20") .setBody().header(Exchange.TIMER_COUNTER) .to("reactive-streams:integers"); @@ -160,7 +163,7 @@ public class BackpressureStrategyTest extends CamelTestSupport { public void testBackpressureDropStrategyInEndpoint() throws Exception { new RouteBuilder() { @Override - public void configure() throws Exception { + public void configure() { from("timer:gen?period=20&repeatCount=20") .setBody().header(Exchange.TIMER_COUNTER) .to("reactive-streams:integers?backpressureStrategy=OLDEST"); diff --git a/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/BackpressureSubscriberTest.java b/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/BackpressureSubscriberTest.java index 9c0949b..af7fef2 100644 --- a/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/BackpressureSubscriberTest.java +++ b/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/BackpressureSubscriberTest.java @@ -23,12 +23,15 @@ import org.apache.camel.RoutesBuilder; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.component.reactive.streams.api.CamelReactiveStreams; -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.assertTrue; /** * Test backpressure from the consumer side. */ +@SuppressWarnings("unused") public class BackpressureSubscriberTest extends CamelTestSupport { @Test @@ -46,7 +49,7 @@ public class BackpressureSubscriberTest extends CamelTestSupport { // Maximum one inflight exchange, even if multiple consumer threads are present // Must take at least 50 * 10 = 500ms - assertTrue("Exchange completed too early", end - start >= 500); + assertTrue(end - start >= 500, "Exchange completed too early"); } @Test @@ -64,7 +67,7 @@ public class BackpressureSubscriberTest extends CamelTestSupport { // Maximum one inflight exchange, even if multiple consumer threads are present // Must take at least 300 * 2 = 600ms - assertTrue("Exchange completed too early", end - start >= 600); + assertTrue(end - start >= 600, "Exchange completed too early"); } @Test @@ -81,14 +84,14 @@ public class BackpressureSubscriberTest extends CamelTestSupport { // Maximum 5 inflight exchanges // Must take at least 100 * (40 / 5) = 800ms - assertTrue("Exchange completed too early", end - start >= 800); + assertTrue(end - start >= 800, "Exchange completed too early"); } @Override - protected RoutesBuilder createRouteBuilder() throws Exception { + protected RoutesBuilder createRouteBuilder() { return new RouteBuilder() { @Override - public void configure() throws Exception { + public void configure() { from("reactive-streams:slowNumbers?concurrentConsumers=10&maxInflightExchanges=1") .process(x -> Thread.sleep(50)) .to("mock:endpoint"); diff --git a/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/BasicPublisherTest.java b/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/BasicPublisherTest.java index 1ea3d6b..7e425a5 100644 --- a/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/BasicPublisherTest.java +++ b/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/BasicPublisherTest.java @@ -27,8 +27,12 @@ import org.apache.camel.Exchange; import org.apache.camel.FailedToStartRouteException; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.reactive.streams.api.CamelReactiveStreams; -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; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; public class BasicPublisherTest extends CamelTestSupport { @@ -37,7 +41,7 @@ public class BasicPublisherTest extends CamelTestSupport { new RouteBuilder() { @Override - public void configure() throws Exception { + public void configure() { from("timer:tick?period=5&repeatCount=30") .setBody().header(Exchange.TIMER_COUNTER) .to("reactive-streams:pub"); @@ -67,7 +71,7 @@ public class BasicPublisherTest extends CamelTestSupport { new RouteBuilder() { @Override - public void configure() throws Exception { + public void configure() { from("timer:tick?period=50") .setBody().header(Exchange.TIMER_COUNTER) .to("reactive-streams:unbounded"); @@ -104,12 +108,12 @@ public class BasicPublisherTest extends CamelTestSupport { disp3.dispose(); } - @Test(expected = FailedToStartRouteException.class) + @Test public void testOnlyOneCamelProducerPerPublisher() throws Exception { new RouteBuilder() { @Override - public void configure() throws Exception { + public void configure() { from("direct:one") .to("reactive-streams:stream"); @@ -118,7 +122,8 @@ public class BasicPublisherTest extends CamelTestSupport { } }.addRoutesToCamelContext(context); - context.start(); + assertThrows(FailedToStartRouteException.class, + () -> context.start()); } @Override diff --git a/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/BasicSubscriberTest.java b/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/BasicSubscriberTest.java index c91d7e1..f3aa0a5 100644 --- a/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/BasicSubscriberTest.java +++ b/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/BasicSubscriberTest.java @@ -21,11 +21,13 @@ import org.apache.camel.RoutesBuilder; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.component.reactive.streams.api.CamelReactiveStreams; -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.reactivestreams.Publisher; import org.reactivestreams.Subscriber; +import static org.junit.jupiter.api.Assertions.assertEquals; + public class BasicSubscriberTest extends CamelTestSupport { @Test @@ -67,7 +69,7 @@ public class BasicSubscriberTest extends CamelTestSupport { protected RoutesBuilder createRouteBuilder() throws Exception { return new RouteBuilder() { @Override - public void configure() throws Exception { + public void configure() { from("reactive-streams:sub") .to("mock:sub1"); diff --git a/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/BeanCallTest.java b/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/BeanCallTest.java index cd92061..057469a 100644 --- a/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/BeanCallTest.java +++ b/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/BeanCallTest.java @@ -26,17 +26,22 @@ import org.apache.camel.Header; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.component.reactive.streams.util.UnwrapStreamProcessor; -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.reactivestreams.Publisher; +import static org.apache.camel.test.junit5.TestSupport.assertListSize; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +@SuppressWarnings("unused") public class BeanCallTest extends CamelTestSupport { @Test public void beanCallTest() throws Exception { new RouteBuilder() { @Override - public void configure() throws Exception { + public void configure() { onException(Throwable.class).to("direct:handle").handled(true); @@ -68,7 +73,7 @@ public class BeanCallTest extends CamelTestSupport { public void beanCallWithErrorTest() throws Exception { new RouteBuilder() { @Override - public void configure() throws Exception { + public void configure() { onException(Throwable.class).to("direct:handle").handled(true); @@ -99,7 +104,7 @@ public class BeanCallTest extends CamelTestSupport { public void beanCallHeaderMappingTest() throws Exception { new RouteBuilder() { @Override - public void configure() throws Exception { + public void configure() { onException(Throwable.class).to("direct:handle").handled(true); @@ -130,7 +135,7 @@ public class BeanCallTest extends CamelTestSupport { public void beanCallEmptyPublisherTest() throws Exception { new RouteBuilder() { @Override - public void configure() throws Exception { + public void configure() { onException(Throwable.class).to("direct:handle").handled(true); @@ -156,14 +161,14 @@ public class BeanCallTest extends CamelTestSupport { Exchange exchange = mock.getExchanges().get(0); Object body = exchange.getIn().getBody(); - assertEquals(new Integer(1), body); // unchanged + assertEquals(1, body); // unchanged } @Test public void beanCallTwoElementsTest() throws Exception { new RouteBuilder() { @Override - public void configure() throws Exception { + public void configure() { onException(Throwable.class).to("direct:handle").handled(true); @@ -201,7 +206,7 @@ public class BeanCallTest extends CamelTestSupport { public void beanCallStdReturnTypeTest() throws Exception { new RouteBuilder() { @Override - public void configure() throws Exception { + public void configure() { onException(Throwable.class).to("direct:handle").handled(true); diff --git a/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/CamelReactiveStreamsTest.java b/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/CamelReactiveStreamsTest.java index 6e01657..b325e6e 100644 --- a/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/CamelReactiveStreamsTest.java +++ b/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/CamelReactiveStreamsTest.java @@ -22,8 +22,10 @@ import org.apache.camel.component.reactive.streams.engine.DefaultCamelReactiveSt import org.apache.camel.component.reactive.streams.support.ReactiveStreamsTestService; import org.apache.camel.impl.DefaultCamelContext; import org.apache.camel.support.SimpleRegistry; -import org.junit.Assert; -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.assertTrue; public class CamelReactiveStreamsTest { @@ -34,7 +36,7 @@ public class CamelReactiveStreamsTest { context.start(); CamelReactiveStreamsService service1 = CamelReactiveStreams.get(context); - Assert.assertTrue(service1 instanceof DefaultCamelReactiveStreamsService); + assertTrue(service1 instanceof DefaultCamelReactiveStreamsService); } finally { context.stop(); } @@ -49,8 +51,8 @@ public class CamelReactiveStreamsTest { CamelReactiveStreamsService service1 = CamelReactiveStreams.get(context); CamelReactiveStreamsService service2 = CamelReactiveStreams.get(context); - Assert.assertTrue(service1 instanceof DefaultCamelReactiveStreamsService); - Assert.assertEquals(service1, service2); + assertTrue(service1 instanceof DefaultCamelReactiveStreamsService); + assertEquals(service1, service2); } finally { context.stop(); } @@ -72,9 +74,9 @@ public class CamelReactiveStreamsTest { CamelReactiveStreamsService service1 = CamelReactiveStreams.get(context); CamelReactiveStreamsService service2 = CamelReactiveStreams.get(context); - Assert.assertEquals(service1, service2); - Assert.assertTrue(service1 instanceof ReactiveStreamsTestService); - Assert.assertEquals("from-registry", service1.getId()); + assertEquals(service1, service2); + assertTrue(service1 instanceof ReactiveStreamsTestService); + assertEquals("from-registry", service1.getId()); } finally { context.stop(); } @@ -94,9 +96,9 @@ public class CamelReactiveStreamsTest { CamelReactiveStreamsService service1 = CamelReactiveStreams.get(context); CamelReactiveStreamsService service2 = CamelReactiveStreams.get(context); - Assert.assertEquals(service1, service2); - Assert.assertTrue(service1 instanceof ReactiveStreamsTestService); - Assert.assertEquals("test-service", service1.getId()); + assertEquals(service1, service2); + assertTrue(service1 instanceof ReactiveStreamsTestService); + assertEquals("test-service", service1.getId()); } finally { context.stop(); } diff --git a/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/ConcurrentConsumersTest.java b/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/ConcurrentConsumersTest.java index cdbf4c1..a1d0ded 100644 --- a/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/ConcurrentConsumersTest.java +++ b/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/ConcurrentConsumersTest.java @@ -27,8 +27,10 @@ import org.apache.camel.RoutesBuilder; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.component.reactive.streams.api.CamelReactiveStreams; -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; /** * Test the behaviour of the consumer side when using a different number of consumer threads. @@ -86,7 +88,7 @@ public class ConcurrentConsumersTest extends CamelTestSupport { protected RoutesBuilder createRouteBuilder() throws Exception { return new RouteBuilder() { @Override - public void configure() throws Exception { + public void configure() { from("reactive-streams:singleConsumer") .process(x -> x.getIn().setHeader("thread", Thread.currentThread().getId())) diff --git a/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/DelayedMonoPublisherTest.java b/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/DelayedMonoPublisherTest.java index 1c1451a0..d89780d 100644 --- a/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/DelayedMonoPublisherTest.java +++ b/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/DelayedMonoPublisherTest.java @@ -30,10 +30,11 @@ import org.apache.camel.component.reactive.streams.engine.DelayedMonoPublisher; import org.apache.camel.component.reactive.streams.support.TestSubscriber; import org.junit.After; import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertThrows; public class DelayedMonoPublisherTest { @@ -256,34 +257,38 @@ public class DelayedMonoPublisherTest { assertEquals(new Integer(2), res); } - @Test(expected = IllegalStateException.class) + @Test public void testDataOrExceptionAllowed() throws Exception { DelayedMonoPublisher<Integer> pub = new DelayedMonoPublisher<>(service); Exception ex = new RuntimeException("An exception"); pub.setException(ex); - pub.setData(1); + assertThrows(IllegalStateException.class, + () -> pub.setData(1)); } - @Test(expected = IllegalStateException.class) + @Test public void testDataOrExceptionAllowed2() throws Exception { DelayedMonoPublisher<Integer> pub = new DelayedMonoPublisher<>(service); pub.setData(1); Exception ex = new RuntimeException("An exception"); - pub.setException(ex); + assertThrows(IllegalStateException.class, + () -> pub.setException(ex)); } - @Test(expected = IllegalStateException.class) + @Test public void testOnlyOneDataAllowed() throws Exception { DelayedMonoPublisher<Integer> pub = new DelayedMonoPublisher<>(service); pub.setData(1); - pub.setData(2); + assertThrows(IllegalStateException.class, + () -> pub.setData(2)); } - @Test(expected = IllegalStateException.class) + @Test public void testOnlyOneExceptionAllowed() throws Exception { DelayedMonoPublisher<Integer> pub = new DelayedMonoPublisher<>(service); pub.setException(new RuntimeException("An exception")); - pub.setException(new RuntimeException("An exception")); + assertThrows(IllegalStateException.class, + () -> pub.setException(new RuntimeException("An exception"))); } } diff --git a/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/DirectClientAPITest.java b/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/DirectClientAPITest.java index 4d0faab..5028bc8 100644 --- a/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/DirectClientAPITest.java +++ b/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/DirectClientAPITest.java @@ -29,9 +29,12 @@ import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.component.reactive.streams.support.ReactiveStreamsTestSupport; import org.assertj.core.api.Assertions; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.reactivestreams.Publisher; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + public class DirectClientAPITest extends ReactiveStreamsTestSupport { @BindToRegistry("hello") @@ -89,7 +92,7 @@ public class DirectClientAPITest extends ReactiveStreamsTestSupport { new RouteBuilder() { @Override - public void configure() throws Exception { + public void configure() { from("direct:data").to("mock:result"); } }.addRoutesToCamelContext(context); @@ -105,7 +108,7 @@ public class DirectClientAPITest extends ReactiveStreamsTestSupport { int idx = 1; for (Exchange ex : mock.getExchanges()) { Integer num = ex.getIn().getBody(Integer.class); - assertEquals(new Integer(idx++), num); + assertEquals(Integer.valueOf(idx++), num); } } @@ -127,7 +130,7 @@ public class DirectClientAPITest extends ReactiveStreamsTestSupport { BlockingQueue<String> queue = new LinkedBlockingDeque<>(); - Flowable.just(1, 2, 3).flatMap(camel.to("bean:hello")::apply).map(ex -> ex.getOut().getBody(String.class)).doOnNext(queue::add).subscribe(); + Flowable.just(1, 2, 3).flatMap(camel.to("bean:hello")::apply).map(ex -> ex.getMessage().getBody(String.class)).doOnNext(queue::add).subscribe(); check3HelloInQueue(queue); } @@ -147,7 +150,7 @@ public class DirectClientAPITest extends ReactiveStreamsTestSupport { BlockingQueue<String> queue = new LinkedBlockingDeque<>(); - Flowable.just(1, 2, 3).flatMap(e -> camel.to("bean:hello", e)).map(ex -> ex.getOut().getBody(String.class)).doOnNext(queue::add).subscribe(); + Flowable.just(1, 2, 3).flatMap(e -> camel.to("bean:hello", e)).map(ex -> ex.getMessage().getBody(String.class)).doOnNext(queue::add).subscribe(); check3HelloInQueue(queue); } @@ -158,7 +161,7 @@ public class DirectClientAPITest extends ReactiveStreamsTestSupport { new RouteBuilder() { @Override - public void configure() throws Exception { + public void configure() { from("direct:proxy").to("bean:hello").setBody().simple("proxy to ${body}"); } }.addRoutesToCamelContext(context); @@ -179,7 +182,7 @@ public class DirectClientAPITest extends ReactiveStreamsTestSupport { new RouteBuilder() { @Override - public void configure() throws Exception { + public void configure() { from("direct:source").to("direct:stream").setBody().simple("after stream: ${body}").to("mock:dest"); } }.addRoutesToCamelContext(context); @@ -188,7 +191,7 @@ public class DirectClientAPITest extends ReactiveStreamsTestSupport { camel.process("direct:stream", p -> Flowable.fromPublisher(p).map(exchange -> { int val = exchange.getIn().getBody(Integer.class); - exchange.getOut().setBody(-val); + exchange.getMessage().setBody(-val); return exchange; })); @@ -212,7 +215,7 @@ public class DirectClientAPITest extends ReactiveStreamsTestSupport { new RouteBuilder() { @Override - public void configure() throws Exception { + public void configure() { from("direct:source").to("direct:stream").setBody().simple("after stream: ${body}").to("mock:dest"); } }.addRoutesToCamelContext(context); diff --git a/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/EventTypeTest.java b/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/EventTypeTest.java index 78ba89b..482a3c8 100644 --- a/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/EventTypeTest.java +++ b/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/EventTypeTest.java @@ -21,10 +21,12 @@ import org.apache.camel.Exchange; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.component.reactive.streams.api.CamelReactiveStreams; -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.reactivestreams.Subscriber; +import static org.junit.jupiter.api.Assertions.assertEquals; + public class EventTypeTest extends CamelTestSupport { @Test @@ -32,7 +34,7 @@ public class EventTypeTest extends CamelTestSupport { new RouteBuilder() { @Override - public void configure() throws Exception { + public void configure() { from("reactive-streams:numbers?forwardOnComplete=true") .to("mock:endpoint"); } @@ -58,7 +60,7 @@ public class EventTypeTest extends CamelTestSupport { new RouteBuilder() { @Override - public void configure() throws Exception { + public void configure() { from("reactive-streams:numbers") .to("mock:endpoint"); } @@ -82,7 +84,7 @@ public class EventTypeTest extends CamelTestSupport { new RouteBuilder() { @Override - public void configure() throws Exception { + public void configure() { from("reactive-streams:numbers") .to("mock:endpoint"); } @@ -109,7 +111,7 @@ public class EventTypeTest extends CamelTestSupport { new RouteBuilder() { @Override - public void configure() throws Exception { + public void configure() { from("reactive-streams:numbers?forwardOnError=true") .to("mock:endpoint"); } @@ -145,7 +147,7 @@ public class EventTypeTest extends CamelTestSupport { new RouteBuilder() { @Override - public void configure() throws Exception { + public void configure() { from("reactive-streams:numbers") .to("mock:endpoint"); } diff --git a/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/ExchangeRequestTest.java b/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/ExchangeRequestTest.java index cc0534e..5e6f17a 100644 --- a/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/ExchangeRequestTest.java +++ b/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/ExchangeRequestTest.java @@ -23,10 +23,13 @@ import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.reactive.streams.api.CamelReactiveStreams; import org.apache.camel.component.reactive.streams.api.CamelReactiveStreamsService; import org.apache.camel.support.DefaultExchange; -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.reactivestreams.Publisher; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + public class ExchangeRequestTest extends CamelTestSupport { @Test @@ -74,7 +77,7 @@ public class ExchangeRequestTest extends CamelTestSupport { protected RoutesBuilder createRouteBuilder() throws Exception { return new RouteBuilder() { @Override - public void configure() throws Exception { + public void configure() { from("reactive-streams:data") .setBody().constant("123"); diff --git a/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/PublisherTypeConversionTest.java b/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/PublisherTypeConversionTest.java index bab4254..9a1022e 100644 --- a/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/PublisherTypeConversionTest.java +++ b/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/PublisherTypeConversionTest.java @@ -26,8 +26,10 @@ import org.apache.camel.Exchange; import org.apache.camel.RoutesBuilder; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.reactive.streams.api.CamelReactiveStreams; -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 PublisherTypeConversionTest extends CamelTestSupport { @@ -72,7 +74,7 @@ public class PublisherTypeConversionTest extends CamelTestSupport { protected RoutesBuilder createRouteBuilder() throws Exception { return new RouteBuilder() { @Override - public void configure() throws Exception { + public void configure() { from("timer:tick?period=50&repeatCount=1") .setBody().constant(123) .to("reactive-streams:pub"); diff --git a/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/ReactiveStreamsJMXTest.java b/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/ReactiveStreamsJMXTest.java index 6913525..1909b52 100644 --- a/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/ReactiveStreamsJMXTest.java +++ b/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/ReactiveStreamsJMXTest.java @@ -34,10 +34,14 @@ import org.apache.camel.RoutesBuilder; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.reactive.streams.api.CamelReactiveStreams; import org.apache.camel.component.reactive.streams.api.CamelReactiveStreamsService; -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 reactor.core.publisher.Flux; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + /** * Test exposed services on JMX. */ @@ -111,7 +115,7 @@ public class ReactiveStreamsJMXTest extends CamelTestSupport { protected RoutesBuilder createRouteBuilder() throws Exception { return new RouteBuilder() { @Override - public void configure() throws Exception { + public void configure() { from("reactive-streams:unbounded?maxInflightExchanges=-1") .delayer(1) .to("mock:unbounded-endpoint"); diff --git a/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/RequestRefillTest.java b/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/RequestRefillTest.java index 8ed981d..3e1170e 100644 --- a/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/RequestRefillTest.java +++ b/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/RequestRefillTest.java @@ -25,11 +25,14 @@ import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.component.reactive.streams.api.CamelReactiveStreams; import org.apache.camel.component.reactive.streams.api.CamelReactiveStreamsService; -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.reactivestreams.Publisher; import reactor.core.publisher.Flux; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + /** * Test the number of refill requests that are sent to a published from a Camel consumer. */ @@ -98,7 +101,7 @@ public class RequestRefillTest extends CamelTestSupport { protected RoutesBuilder createRouteBuilder() throws Exception { return new RouteBuilder() { @Override - public void configure() throws Exception { + public void configure() { from("reactive-streams:unbounded?maxInflightExchanges=-1") .delayer(1) .to("mock:unbounded-endpoint"); diff --git a/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/platforms/AbstractPlatformTestSupport.java b/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/platforms/AbstractPlatformTestSupport.java index e608c69..cf41096 100644 --- a/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/platforms/AbstractPlatformTestSupport.java +++ b/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/platforms/AbstractPlatformTestSupport.java @@ -27,11 +27,14 @@ import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.component.reactive.streams.api.CamelReactiveStreams; import org.apache.camel.component.reactive.streams.api.CamelReactiveStreamsService; -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.reactivestreams.Publisher; import org.reactivestreams.Subscriber; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + /** * */ @@ -44,7 +47,7 @@ public abstract class AbstractPlatformTestSupport extends CamelTestSupport { new RouteBuilder() { @Override - public void configure() throws Exception { + public void configure() { from("direct:endpoint") .to("reactive-streams:integers"); } @@ -82,7 +85,7 @@ public abstract class AbstractPlatformTestSupport extends CamelTestSupport { new RouteBuilder() { @Override - public void configure() throws Exception { + public void configure() { from("reactive-streams:integers") .to("mock:endpoint"); } diff --git a/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/support/ReactiveStreamsTestSupport.java b/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/support/ReactiveStreamsTestSupport.java index 30270c4..0846f25 100644 --- a/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/support/ReactiveStreamsTestSupport.java +++ b/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/support/ReactiveStreamsTestSupport.java @@ -18,7 +18,7 @@ package org.apache.camel.component.reactive.streams.support; import org.apache.camel.component.reactive.streams.api.CamelReactiveStreams; import org.apache.camel.component.reactive.streams.api.CamelReactiveStreamsService; -import org.apache.camel.test.junit4.CamelTestSupport; +import org.apache.camel.test.junit5.CamelTestSupport; import org.junit.Before; public class ReactiveStreamsTestSupport extends CamelTestSupport { diff --git a/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/tck/CamelPublisherConversionVerificationTest.java b/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/tck/CamelPublisherConversionVerificationTest.java index 87accd9..04d2225 100644 --- a/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/tck/CamelPublisherConversionVerificationTest.java +++ b/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/tck/CamelPublisherConversionVerificationTest.java @@ -41,7 +41,7 @@ public class CamelPublisherConversionVerificationTest extends PublisherVerificat RouteBuilder builder = new RouteBuilder() { @Override - public void configure() throws Exception { + public void configure() { from("timer:tick?delay=500&period=50&repeatCount=" + l) .setBody().simple("${random(1000)}") .to("reactive-streams:prod"); diff --git a/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/tck/CamelPublisherVerificationTest.java b/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/tck/CamelPublisherVerificationTest.java index 1a88c42..898790a 100644 --- a/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/tck/CamelPublisherVerificationTest.java +++ b/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/tck/CamelPublisherVerificationTest.java @@ -41,7 +41,7 @@ public class CamelPublisherVerificationTest extends PublisherVerification<Exchan RouteBuilder builder = new RouteBuilder() { @Override - public void configure() throws Exception { + public void configure() { from("timer:tick?delay=500&period=50&repeatCount=" + l) .to("reactive-streams:prod"); } diff --git a/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/tck/CamelSubscriberConversionVerificationTest.java b/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/tck/CamelSubscriberConversionVerificationTest.java index 2c3e30f..f3f31d2 100644 --- a/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/tck/CamelSubscriberConversionVerificationTest.java +++ b/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/tck/CamelSubscriberConversionVerificationTest.java @@ -40,7 +40,7 @@ public class CamelSubscriberConversionVerificationTest extends SubscriberBlackbo RouteBuilder builder = new RouteBuilder() { @Override - public void configure() throws Exception { + public void configure() { from("reactive-streams:sub?maxInflightExchanges=20") .to("log:INFO"); } diff --git a/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/tck/CamelSubscriberVerificationTest.java b/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/tck/CamelSubscriberVerificationTest.java index 8b18f5f..dacce97 100644 --- a/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/tck/CamelSubscriberVerificationTest.java +++ b/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/tck/CamelSubscriberVerificationTest.java @@ -42,7 +42,7 @@ public class CamelSubscriberVerificationTest extends SubscriberBlackboxVerificat RouteBuilder builder = new RouteBuilder() { @Override - public void configure() throws Exception { + public void configure() { from("reactive-streams:sub?maxInflightExchanges=20") .to("log:INFO"); }