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 5641c8a CAMEL-11807 Migrated camel-drill/ehcache/elsql tests to JUnit
5
5641c8a is described below
commit 5641c8a5dc9db615183f40e40a15994983b8e535
Author: aldettinger <[email protected]>
AuthorDate: Fri Jun 5 20:03:43 2020 +0200
CAMEL-11807 Migrated camel-drill/ehcache/elsql tests to JUnit 5
---
components/camel-drill/pom.xml | 7 +-
.../apache/camel/component/drill/EndpointTest.java | 9 +-
.../apache/camel/component/drill/ProducerTest.java | 12 +-
components/camel-ehcache/pom.xml | 10 +-
.../ehcache/EhcacheCacheConfigurationTest.java | 20 ++--
.../ehcache/EhcacheComponentConfigurationTest.java | 11 +-
.../ehcache/EhcacheConfigurationTest.java | 13 ++-
.../component/ehcache/EhcacheConsumerTest.java | 6 +-
.../component/ehcache/EhcacheManagerTest.java | 129 +++++++++------------
.../component/ehcache/EhcacheProducerTest.java | 28 +++--
.../ehcache/EhcacheSpringConfigurationTest.java | 11 +-
.../component/ehcache/EhcacheTestSupport.java | 8 +-
.../EhcacheAggregationRepositoryOperationTest.java | 32 ++---
.../EhcacheAggregationRepositoryRoutesTest.java | 8 +-
.../EhcacheIdempotentRepositoryTest.java | 24 ++--
components/camel-elsql/pom.xml | 17 +--
.../camel/component/elsql/ElSqlComponentTest.java | 15 ++-
.../component/elsql/ElSqlConsumerDeleteTest.java | 22 ++--
.../elsql/ElSqlConsumerDynamicParameterTest.java | 19 +--
.../camel/component/elsql/ElSqlConsumerTest.java | 17 +--
.../camel/component/elsql/ElSqlDataSourceTest.java | 15 ++-
.../component/elsql/ElSqlProducerBatchTest.java | 14 +--
.../elsql/ElSqlProducerBodySimpleTest.java | 21 ++--
.../elsql/ElSqlProducerStreamListTest.java | 17 +--
24 files changed, 244 insertions(+), 241 deletions(-)
diff --git a/components/camel-drill/pom.xml b/components/camel-drill/pom.xml
index 0f4c28d..fd0b632 100644
--- a/components/camel-drill/pom.xml
+++ b/components/camel-drill/pom.xml
@@ -55,16 +55,11 @@
<!-- testing -->
<dependency>
<groupId>org.apache.camel</groupId>
- <artifactId>camel-test</artifactId>
+ <artifactId>camel-test-junit5</artifactId>
<optional>true</optional>
<scope>test</scope>
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<scope>test</scope>
diff --git
a/components/camel-drill/src/test/java/org/apache/camel/component/drill/EndpointTest.java
b/components/camel-drill/src/test/java/org/apache/camel/component/drill/EndpointTest.java
index 5b85c45..3fd32dc 100644
---
a/components/camel-drill/src/test/java/org/apache/camel/component/drill/EndpointTest.java
+++
b/components/camel-drill/src/test/java/org/apache/camel/component/drill/EndpointTest.java
@@ -17,8 +17,11 @@
package org.apache.camel.component.drill;
import org.apache.camel.Endpoint;
-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 EndpointTest extends CamelTestSupport {
@@ -29,7 +32,7 @@ public class EndpointTest extends CamelTestSupport {
private static final DrillConnectionMode MODE = DrillConnectionMode.ZK;
@Test
- public void testZKJdbcURL() throws Exception {
+ void testZKJdbcURL() {
Endpoint endpoint = context.getEndpoint("drill://" + HOST + "?port=" +
PORT + "&directory=" + DIRECTORY + "&clusterId=" + CLUSTERID + "&mode=" + MODE);
final String uri = "jdbc:drill:zk=" + HOST + ":" + PORT + "/" +
DIRECTORY + "/" + CLUSTERID;
diff --git
a/components/camel-drill/src/test/java/org/apache/camel/component/drill/ProducerTest.java
b/components/camel-drill/src/test/java/org/apache/camel/component/drill/ProducerTest.java
index 012e82a..4fd1eef 100644
---
a/components/camel-drill/src/test/java/org/apache/camel/component/drill/ProducerTest.java
+++
b/components/camel-drill/src/test/java/org/apache/camel/component/drill/ProducerTest.java
@@ -20,11 +20,11 @@ import java.util.concurrent.TimeUnit;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
-@Ignore("CAMEL-10327: Set host, mode and query to test drill producer (direct
connection mode).")
+@Disabled("CAMEL-10327: Set host, mode and query to test drill producer
(direct connection mode).")
public class ProducerTest extends CamelTestSupport {
private final String host = "localhost";
@@ -33,7 +33,7 @@ public class ProducerTest extends CamelTestSupport {
private final String query = "select * from query";
@Test
- public void testProducer() throws Exception {
+ void testProducer() throws Exception {
template.sendBody("direct:in", "");
MockEndpoint mock = getMockEndpoint("mock:result");
@@ -43,7 +43,7 @@ public class ProducerTest extends CamelTestSupport {
}
@Override
- protected RouteBuilder createRouteBuilder() throws Exception {
+ protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
public void configure() {
from("direct:in").setHeader(DrillConstants.DRILL_QUERY,
constant(query)).to("drill://" + host + "?mode=" + mode.name() + "&port=" +
port).log("${body}")
diff --git a/components/camel-ehcache/pom.xml b/components/camel-ehcache/pom.xml
index 825949e..f8ca4d5 100644
--- a/components/camel-ehcache/pom.xml
+++ b/components/camel-ehcache/pom.xml
@@ -49,18 +49,12 @@
<!-- testing -->
<dependency>
<groupId>org.apache.camel</groupId>
- <artifactId>camel-test</artifactId>
+ <artifactId>camel-test-junit5</artifactId>
<scope>test</scope>
- <exclusions>
- <exclusion>
- <artifactId>hamcrest-core</artifactId>
- <groupId>org.hamcrest</groupId>
- </exclusion>
- </exclusions>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
- <artifactId>camel-test-spring</artifactId>
+ <artifactId>camel-test-spring-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
diff --git
a/components/camel-ehcache/src/test/java/org/apache/camel/component/ehcache/EhcacheCacheConfigurationTest.java
b/components/camel-ehcache/src/test/java/org/apache/camel/component/ehcache/EhcacheCacheConfigurationTest.java
index a5cbb04..eb7febb 100644
---
a/components/camel-ehcache/src/test/java/org/apache/camel/component/ehcache/EhcacheCacheConfigurationTest.java
+++
b/components/camel-ehcache/src/test/java/org/apache/camel/component/ehcache/EhcacheCacheConfigurationTest.java
@@ -19,7 +19,7 @@ package org.apache.camel.component.ehcache;
import org.apache.camel.BindToRegistry;
import org.apache.camel.EndpointInject;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.camel.test.junit5.CamelTestSupport;
import org.ehcache.Cache;
import org.ehcache.CacheManager;
import org.ehcache.UserManagedCache;
@@ -32,7 +32,11 @@ import org.ehcache.config.builders.CacheManagerBuilder;
import org.ehcache.config.builders.ResourcePoolsBuilder;
import org.ehcache.config.units.EntryUnit;
import org.ehcache.config.units.MemoryUnit;
-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.assertTrue;
public class EhcacheCacheConfigurationTest extends CamelTestSupport {
@EndpointInject("ehcache:myProgrammaticCacheConf?configuration=#myProgrammaticConfiguration")
@@ -45,7 +49,7 @@ public class EhcacheCacheConfigurationTest extends
CamelTestSupport {
private EhcacheEndpoint ehcacheCacheManager;
@BindToRegistry("myProgrammaticConfiguration")
- private CacheConfiguration c =
CacheConfigurationBuilder.newCacheConfigurationBuilder(
+ private CacheConfiguration<String, String> c =
CacheConfigurationBuilder.newCacheConfigurationBuilder(
String.class,
String.class,
ResourcePoolsBuilder.newResourcePoolsBuilder()
@@ -69,7 +73,7 @@ public class EhcacheCacheConfigurationTest extends
CamelTestSupport {
// *****************************
@Test
- public void testProgrammaticConfiguration() throws Exception {
+ void testProgrammaticConfiguration() throws Exception {
Cache<String, String> cache = getCache(ehcacheProgrammaticConf,
"myProgrammaticCacheConf");
ResourcePools pools =
cache.getRuntimeConfiguration().getResourcePools();
@@ -85,7 +89,7 @@ public class EhcacheCacheConfigurationTest extends
CamelTestSupport {
}
@Test
- public void testFileConfiguration() throws Exception {
+ void testFileConfiguration() throws Exception {
Cache<String, String> cache = getCache(ehcacheFileConf,
"myFileCacheConf");
ResourcePools pools =
cache.getRuntimeConfiguration().getResourcePools();
@@ -96,7 +100,7 @@ public class EhcacheCacheConfigurationTest extends
CamelTestSupport {
}
@Test
- public void testUserConfiguration() throws Exception {
+ void testUserConfiguration() throws Exception {
fluentTemplate()
.withHeader(EhcacheConstants.ACTION, EhcacheConstants.ACTION_PUT)
.withHeader(EhcacheConstants.KEY, "user-key")
@@ -111,7 +115,7 @@ public class EhcacheCacheConfigurationTest extends
CamelTestSupport {
}
@Test
- public void testCacheManager() throws Exception {
+ void testCacheManager() throws Exception {
assertEquals(
context().getRegistry().lookupByNameAndType("myCacheManager",
CacheManager.class),
ehcacheCacheManager.getManager().getCacheManager()
@@ -140,7 +144,7 @@ public class EhcacheCacheConfigurationTest extends
CamelTestSupport {
// ****************************
@Override
- protected RouteBuilder createRouteBuilder() throws Exception {
+ protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
public void configure() {
from("direct:ehcacheProgrammaticConf")
diff --git
a/components/camel-ehcache/src/test/java/org/apache/camel/component/ehcache/EhcacheComponentConfigurationTest.java
b/components/camel-ehcache/src/test/java/org/apache/camel/component/ehcache/EhcacheComponentConfigurationTest.java
index 01db7f5..7ef0a5a 100644
---
a/components/camel-ehcache/src/test/java/org/apache/camel/component/ehcache/EhcacheComponentConfigurationTest.java
+++
b/components/camel-ehcache/src/test/java/org/apache/camel/component/ehcache/EhcacheComponentConfigurationTest.java
@@ -20,7 +20,7 @@ import org.apache.camel.BindToRegistry;
import org.apache.camel.Component;
import org.apache.camel.EndpointInject;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.camel.test.junit5.CamelTestSupport;
import org.ehcache.Cache;
import org.ehcache.config.ResourcePools;
import org.ehcache.config.ResourceType;
@@ -30,7 +30,10 @@ import org.ehcache.config.builders.CacheManagerBuilder;
import org.ehcache.config.builders.ResourcePoolsBuilder;
import org.ehcache.config.units.EntryUnit;
import org.ehcache.config.units.MemoryUnit;
-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;
public class EhcacheComponentConfigurationTest extends CamelTestSupport {
@EndpointInject("ehcache:myCache")
@@ -62,7 +65,7 @@ public class EhcacheComponentConfigurationTest extends
CamelTestSupport {
// *****************************
@Test
- public void testCacheManager() throws Exception {
+ void testCacheManager() throws Exception {
assertEquals(
context().getRegistry().lookupByNameAndType("ehcache",
EhcacheComponent.class).getCacheManager(),
endpoint.getManager().getCacheManager()
@@ -87,7 +90,7 @@ public class EhcacheComponentConfigurationTest extends
CamelTestSupport {
// ****************************
@Override
- protected RouteBuilder createRouteBuilder() throws Exception {
+ protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
public void configure() {
from("direct:ehcache")
diff --git
a/components/camel-ehcache/src/test/java/org/apache/camel/component/ehcache/EhcacheConfigurationTest.java
b/components/camel-ehcache/src/test/java/org/apache/camel/component/ehcache/EhcacheConfigurationTest.java
index 4db8c5c..6a5b9f1 100644
---
a/components/camel-ehcache/src/test/java/org/apache/camel/component/ehcache/EhcacheConfigurationTest.java
+++
b/components/camel-ehcache/src/test/java/org/apache/camel/component/ehcache/EhcacheConfigurationTest.java
@@ -22,7 +22,7 @@ import org.apache.camel.BindToRegistry;
import org.apache.camel.Component;
import org.apache.camel.EndpointInject;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.camel.test.junit5.CamelTestSupport;
import org.ehcache.Cache;
import org.ehcache.config.CacheRuntimeConfiguration;
import org.ehcache.config.ResourceType;
@@ -31,7 +31,10 @@ import org.ehcache.config.builders.ResourcePoolsBuilder;
import org.ehcache.config.units.EntryUnit;
import org.ehcache.config.units.MemoryUnit;
import org.ehcache.core.Ehcache;
-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 EhcacheConfigurationTest extends CamelTestSupport {
@EndpointInject("ehcache:globalConfig")
@@ -40,7 +43,7 @@ public class EhcacheConfigurationTest extends
CamelTestSupport {
EhcacheEndpoint customConfig;
@BindToRegistry("ehcache")
- public Component createEhcacheComponent() throws Exception {
+ public Component createEhcacheComponent() {
EhcacheComponent component = new EhcacheComponent();
component.setCacheConfiguration(
CacheConfigurationBuilder.newCacheConfigurationBuilder(
@@ -72,7 +75,7 @@ public class EhcacheConfigurationTest extends
CamelTestSupport {
// *****************************
@Test
- public void testConfiguration() throws Exception {
+ void testConfiguration() throws Exception {
Cache<String, String> globalConfigCache =
globalConfig.getManager().getCache("globalConfig", String.class, String.class);
Cache<String, String> customConfigCache =
customConfig.getManager().getCache("customConfig", String.class, String.class);
@@ -97,7 +100,7 @@ public class EhcacheConfigurationTest extends
CamelTestSupport {
// ****************************
@Override
- protected RouteBuilder createRouteBuilder() throws Exception {
+ protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
public void configure() {
from("direct:ehcache")
diff --git
a/components/camel-ehcache/src/test/java/org/apache/camel/component/ehcache/EhcacheConsumerTest.java
b/components/camel-ehcache/src/test/java/org/apache/camel/component/ehcache/EhcacheConsumerTest.java
index 4290855..39e6462 100644
---
a/components/camel-ehcache/src/test/java/org/apache/camel/component/ehcache/EhcacheConsumerTest.java
+++
b/components/camel-ehcache/src/test/java/org/apache/camel/component/ehcache/EhcacheConsumerTest.java
@@ -20,12 +20,12 @@ import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.ehcache.Cache;
import org.ehcache.event.EventType;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class EhcacheConsumerTest extends EhcacheTestSupport {
@Test
- public void testEvents() throws Exception {
+ void testEvents() throws Exception {
String key = generateRandomString();
String[] values = generateRandomArrayOfStrings(2);
@@ -55,7 +55,7 @@ public class EhcacheConsumerTest extends EhcacheTestSupport {
}
@Override
- protected RouteBuilder createRouteBuilder() throws Exception {
+ protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
public void configure() {
fromF("ehcache://%s?cacheManager=#cacheManager&eventTypes=CREATED",
TEST_CACHE_NAME)
diff --git
a/components/camel-ehcache/src/test/java/org/apache/camel/component/ehcache/EhcacheManagerTest.java
b/components/camel-ehcache/src/test/java/org/apache/camel/component/ehcache/EhcacheManagerTest.java
index 902ec23..3aaf1b3 100644
---
a/components/camel-ehcache/src/test/java/org/apache/camel/component/ehcache/EhcacheManagerTest.java
+++
b/components/camel-ehcache/src/test/java/org/apache/camel/component/ehcache/EhcacheManagerTest.java
@@ -24,22 +24,21 @@ import org.ehcache.CacheManager;
import org.ehcache.Status;
import org.ehcache.config.builders.CacheManagerBuilder;
import org.ehcache.xml.XmlConfiguration;
-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.assertSame;
public class EhcacheManagerTest {
@Test
- public void testCacheManagerFromFile() throws Exception {
- CamelContext context = null;
+ void testCacheManagerFromFile() throws Exception {
- try {
- context = new DefaultCamelContext();
+ try (CamelContext context = new DefaultCamelContext()) {
context.addRoutes(new RouteBuilder() {
@Override
- public void configure() throws Exception {
- from("direct:ehcache")
-
.to("ehcache:myCache1?configurationUri=classpath:ehcache/ehcache-file-config.xml")
+ public void configure() {
+
from("direct:ehcache").to("ehcache:myCache1?configurationUri=classpath:ehcache/ehcache-file-config.xml")
.to("ehcache:myCache2?configurationUri=classpath:ehcache/ehcache-file-config.xml");
}
});
@@ -49,40 +48,32 @@ public class EhcacheManagerTest {
EhcacheEndpoint e1 =
context.getEndpoint("ehcache:myCache1?configurationUri=classpath:ehcache/ehcache-file-config.xml",
EhcacheEndpoint.class);
EhcacheEndpoint e2 =
context.getEndpoint("ehcache:myCache2?configurationUri=classpath:ehcache/ehcache-file-config.xml",
EhcacheEndpoint.class);
- Assert.assertEquals(e1.getManager(), e2.getManager());
- Assert.assertEquals(e1.getManager().getCacheManager(),
e2.getManager().getCacheManager());
- Assert.assertEquals(2, e1.getManager().getReferenceCount().get());
- Assert.assertEquals(Status.AVAILABLE,
e1.getManager().getCacheManager().getStatus());
+ assertEquals(e1.getManager(), e2.getManager());
+ assertEquals(e1.getManager().getCacheManager(),
e2.getManager().getCacheManager());
+ assertEquals(2, e1.getManager().getReferenceCount().get());
+ assertEquals(Status.AVAILABLE,
e1.getManager().getCacheManager().getStatus());
context.stop();
- Assert.assertEquals(e1.getManager(), e2.getManager());
- Assert.assertEquals(e1.getManager().getCacheManager(),
e2.getManager().getCacheManager());
- Assert.assertEquals(0, e1.getManager().getReferenceCount().get());
- Assert.assertEquals(Status.UNINITIALIZED,
e1.getManager().getCacheManager().getStatus());
+ assertEquals(e1.getManager(), e2.getManager());
+ assertEquals(e1.getManager().getCacheManager(),
e2.getManager().getCacheManager());
+ assertEquals(0, e1.getManager().getReferenceCount().get());
+ assertEquals(Status.UNINITIALIZED,
e1.getManager().getCacheManager().getStatus());
- } finally {
- if (context != null) {
- context.stop();
- }
}
}
@Test
- public void testCacheManagerFromConfiguration() throws Exception {
- CamelContext context = null;
+ void testCacheManagerFromConfiguration() throws Exception {
- try {
- SimpleRegistry registry = new SimpleRegistry();
- registry.bind("myConf", new
XmlConfiguration(getClass().getResource("/ehcache/ehcache-file-config.xml")));
+ SimpleRegistry registry = new SimpleRegistry();
+ registry.bind("myConf", new
XmlConfiguration(getClass().getResource("/ehcache/ehcache-file-config.xml")));
- context = new DefaultCamelContext(registry);
+ try (CamelContext context = new DefaultCamelContext(registry)) {
context.addRoutes(new RouteBuilder() {
@Override
- public void configure() throws Exception {
- from("direct:ehcache")
-
.to("ehcache:myCache1?cacheManagerConfiguration=#myConf")
-
.to("ehcache:myCache2?cacheManagerConfiguration=#myConf");
+ public void configure() {
+
from("direct:ehcache").to("ehcache:myCache1?cacheManagerConfiguration=#myConf").to("ehcache:myCache2?cacheManagerConfiguration=#myConf");
}
});
@@ -91,70 +82,54 @@ public class EhcacheManagerTest {
EhcacheEndpoint e1 =
context.getEndpoint("ehcache:myCache1?cacheManagerConfiguration=#myConf",
EhcacheEndpoint.class);
EhcacheEndpoint e2 =
context.getEndpoint("ehcache:myCache2?cacheManagerConfiguration=#myConf",
EhcacheEndpoint.class);
- Assert.assertEquals(e1.getManager(), e2.getManager());
- Assert.assertEquals(e1.getManager().getCacheManager(),
e2.getManager().getCacheManager());
- Assert.assertEquals(2, e1.getManager().getReferenceCount().get());
- Assert.assertEquals(Status.AVAILABLE,
e1.getManager().getCacheManager().getStatus());
+ assertEquals(e1.getManager(), e2.getManager());
+ assertEquals(e1.getManager().getCacheManager(),
e2.getManager().getCacheManager());
+ assertEquals(2, e1.getManager().getReferenceCount().get());
+ assertEquals(Status.AVAILABLE,
e1.getManager().getCacheManager().getStatus());
context.stop();
- Assert.assertEquals(e1.getManager(), e2.getManager());
- Assert.assertEquals(e1.getManager().getCacheManager(),
e2.getManager().getCacheManager());
- Assert.assertEquals(0, e1.getManager().getReferenceCount().get());
- Assert.assertEquals(Status.UNINITIALIZED,
e1.getManager().getCacheManager().getStatus());
-
- } finally {
- if (context != null) {
- context.stop();
- }
+ assertEquals(e1.getManager(), e2.getManager());
+ assertEquals(e1.getManager().getCacheManager(),
e2.getManager().getCacheManager());
+ assertEquals(0, e1.getManager().getReferenceCount().get());
+ assertEquals(Status.UNINITIALIZED,
e1.getManager().getCacheManager().getStatus());
}
}
@Test
- public void testCacheManager() throws Exception {
- CamelContext context = null;
- CacheManager cacheManager = null;
+ void testCacheManager() throws Exception {
- try {
- cacheManager =
CacheManagerBuilder.newCacheManagerBuilder().build(true);
+ try (CacheManager cacheManager =
CacheManagerBuilder.newCacheManagerBuilder().build(true)) {
SimpleRegistry registry = new SimpleRegistry();
registry.bind("myManager", cacheManager);
- context = new DefaultCamelContext(registry);
- context.addRoutes(new RouteBuilder() {
- @Override
- public void configure() throws Exception {
- from("direct:ehcache")
- .to("ehcache:myCache1?cacheManager=#myManager")
- .to("ehcache:myCache2?cacheManager=#myManager");
- }
- });
-
- context.start();
+ try (CamelContext context = new DefaultCamelContext(registry)) {
+ context.addRoutes(new RouteBuilder() {
+ @Override
+ public void configure() {
+
from("direct:ehcache").to("ehcache:myCache1?cacheManager=#myManager").to("ehcache:myCache2?cacheManager=#myManager");
+ }
+ });
- EhcacheEndpoint e1 =
context.getEndpoint("ehcache:myCache1?cacheManager=#myManager",
EhcacheEndpoint.class);
- EhcacheEndpoint e2 =
context.getEndpoint("ehcache:myCache2?cacheManager=#myManager",
EhcacheEndpoint.class);
+ context.start();
- Assert.assertSame(e1.getManager(), e2.getManager());
- Assert.assertSame(e1.getManager().getCacheManager(),
e2.getManager().getCacheManager());
- Assert.assertEquals(2, e1.getManager().getReferenceCount().get());
- Assert.assertEquals(Status.AVAILABLE,
e1.getManager().getCacheManager().getStatus());
+ EhcacheEndpoint e1 =
context.getEndpoint("ehcache:myCache1?cacheManager=#myManager",
EhcacheEndpoint.class);
+ EhcacheEndpoint e2 =
context.getEndpoint("ehcache:myCache2?cacheManager=#myManager",
EhcacheEndpoint.class);
- context.stop();
+ assertSame(e1.getManager(), e2.getManager());
+ assertSame(e1.getManager().getCacheManager(),
e2.getManager().getCacheManager());
+ assertEquals(2, e1.getManager().getReferenceCount().get());
+ assertEquals(Status.AVAILABLE,
e1.getManager().getCacheManager().getStatus());
- Assert.assertSame(e1.getManager(), e2.getManager());
- Assert.assertSame(e1.getManager().getCacheManager(),
e2.getManager().getCacheManager());
- Assert.assertEquals(0, e1.getManager().getReferenceCount().get());
- Assert.assertEquals(Status.AVAILABLE,
e1.getManager().getCacheManager().getStatus());
-
- } finally {
- if (context != null) {
context.stop();
+
+ assertSame(e1.getManager(), e2.getManager());
+ assertSame(e1.getManager().getCacheManager(),
e2.getManager().getCacheManager());
+ assertEquals(0, e1.getManager().getReferenceCount().get());
+ assertEquals(Status.AVAILABLE,
e1.getManager().getCacheManager().getStatus());
}
- if (cacheManager != null) {
- cacheManager.close();
- }
+
}
}
}
diff --git
a/components/camel-ehcache/src/test/java/org/apache/camel/component/ehcache/EhcacheProducerTest.java
b/components/camel-ehcache/src/test/java/org/apache/camel/component/ehcache/EhcacheProducerTest.java
index 49ee7aa..be47f48 100644
---
a/components/camel-ehcache/src/test/java/org/apache/camel/component/ehcache/EhcacheProducerTest.java
+++
b/components/camel-ehcache/src/test/java/org/apache/camel/component/ehcache/EhcacheProducerTest.java
@@ -23,7 +23,11 @@ import java.util.stream.Collectors;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.ehcache.Cache;
-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.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public class EhcacheProducerTest extends EhcacheTestSupport {
@@ -32,7 +36,7 @@ public class EhcacheProducerTest extends EhcacheTestSupport {
// ****************************
@Test
- public void testCacheClear() throws Exception {
+ void testCacheClear() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMinimumMessageCount(1);
mock.expectedBodiesReceived((Object)null);
@@ -52,7 +56,7 @@ public class EhcacheProducerTest extends EhcacheTestSupport {
// ****************************
@Test
- public void testCachePut() throws Exception {
+ void testCachePut() throws Exception {
final Cache<Object, Object> cache = getTestCache();
final String key = generateRandomString();
final String val = generateRandomString();
@@ -77,7 +81,7 @@ public class EhcacheProducerTest extends EhcacheTestSupport {
}
@Test
- public void testCachePutAll() throws Exception {
+ void testCachePutAll() throws Exception {
final Cache<Object, Object> cache = getTestCache();
final Map<String, String> map = generateRandomMapOfString(3);
@@ -101,7 +105,7 @@ public class EhcacheProducerTest extends EhcacheTestSupport
{
}
@Test
- public void testCachePutIfAbsent() throws Exception {
+ void testCachePutIfAbsent() throws Exception {
final Cache<Object, Object> cache = getTestCache();
final String key = generateRandomString();
final String val1 = generateRandomString();
@@ -142,7 +146,7 @@ public class EhcacheProducerTest extends EhcacheTestSupport
{
// ****************************
@Test
- public void testCacheGet() throws Exception {
+ void testCacheGet() throws Exception {
final Cache<Object, Object> cache = getTestCache();
final String key = generateRandomString();
final String val = generateRandomString();
@@ -166,7 +170,7 @@ public class EhcacheProducerTest extends EhcacheTestSupport
{
}
@Test
- public void testCacheGetAll() throws Exception {
+ void testCacheGetAll() throws Exception {
final Cache<Object, Object> cache = getTestCache();
final Map<String, String> map = generateRandomMapOfString(3);
final Set<String> keys =
map.keySet().stream().limit(2).collect(Collectors.toSet());
@@ -198,7 +202,7 @@ public class EhcacheProducerTest extends EhcacheTestSupport
{
// ****************************
@Test
- public void testCacheRemove() throws Exception {
+ void testCacheRemove() throws Exception {
final Cache<Object, Object> cache = getTestCache();
final String key = generateRandomString();
final String val = generateRandomString();
@@ -222,7 +226,7 @@ public class EhcacheProducerTest extends EhcacheTestSupport
{
}
@Test
- public void testCacheRemoveIf() throws Exception {
+ void testCacheRemoveIf() throws Exception {
final Cache<Object, Object> cache = getTestCache();
final String key = generateRandomString();
final String val1 = generateRandomString();
@@ -261,7 +265,7 @@ public class EhcacheProducerTest extends EhcacheTestSupport
{
}
@Test
- public void testCacheRemoveAll() throws Exception {
+ void testCacheRemoveAll() throws Exception {
final Cache<Object, Object> cache = getTestCache();
final Map<String, String> map = generateRandomMapOfString(3);
final Set<String> keys =
map.keySet().stream().limit(2).collect(Collectors.toSet());
@@ -289,7 +293,7 @@ public class EhcacheProducerTest extends EhcacheTestSupport
{
// ****************************
@Test
- public void testCacheReplace() throws Exception {
+ void testCacheReplace() throws Exception {
final Cache<Object, Object> cache = getTestCache();
final String key = generateRandomString();
final String val1 = generateRandomString();
@@ -348,7 +352,7 @@ public class EhcacheProducerTest extends EhcacheTestSupport
{
// ****************************
@Override
- protected RouteBuilder createRouteBuilder() throws Exception {
+ protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
public void configure() {
from("direct://start")
diff --git
a/components/camel-ehcache/src/test/java/org/apache/camel/component/ehcache/EhcacheSpringConfigurationTest.java
b/components/camel-ehcache/src/test/java/org/apache/camel/component/ehcache/EhcacheSpringConfigurationTest.java
index cafeec3..614b171 100644
---
a/components/camel-ehcache/src/test/java/org/apache/camel/component/ehcache/EhcacheSpringConfigurationTest.java
+++
b/components/camel-ehcache/src/test/java/org/apache/camel/component/ehcache/EhcacheSpringConfigurationTest.java
@@ -17,17 +17,20 @@
package org.apache.camel.component.ehcache;
import org.apache.camel.EndpointInject;
-import org.apache.camel.test.spring.CamelSpringTestSupport;
+import org.apache.camel.test.spring.junit5.CamelSpringTestSupport;
import org.ehcache.Cache;
import org.ehcache.config.ResourcePools;
import org.ehcache.config.ResourceType;
import org.ehcache.config.SizedResourcePool;
import org.ehcache.config.units.EntryUnit;
import org.ehcache.config.units.MemoryUnit;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
public class EhcacheSpringConfigurationTest extends CamelSpringTestSupport {
@EndpointInject("ehcache://myProgrammaticCacheConf?configuration=#myProgrammaticConfiguration")
@@ -45,7 +48,7 @@ public class EhcacheSpringConfigurationTest extends
CamelSpringTestSupport {
// *****************************
@Test
- public void testProgrammaticConfiguration() throws Exception {
+ void testProgrammaticConfiguration() throws Exception {
Cache<String, String> cache = getCache(ehcacheConf,
"myProgrammaticCacheConf");
ResourcePools pools =
cache.getRuntimeConfiguration().getResourcePools();
@@ -61,7 +64,7 @@ public class EhcacheSpringConfigurationTest extends
CamelSpringTestSupport {
}
@Test
- public void testFileConfiguration() throws Exception {
+ void testFileConfiguration() throws Exception {
Cache<String, String> cache = getCache(ehcacheFileConf,
"myFileCacheConf");
ResourcePools pools =
cache.getRuntimeConfiguration().getResourcePools();
diff --git
a/components/camel-ehcache/src/test/java/org/apache/camel/component/ehcache/EhcacheTestSupport.java
b/components/camel-ehcache/src/test/java/org/apache/camel/component/ehcache/EhcacheTestSupport.java
index d70f88f..eeb64c7 100644
---
a/components/camel-ehcache/src/test/java/org/apache/camel/component/ehcache/EhcacheTestSupport.java
+++
b/components/camel-ehcache/src/test/java/org/apache/camel/component/ehcache/EhcacheTestSupport.java
@@ -28,14 +28,12 @@ import java.util.stream.IntStream;
import org.apache.camel.BindToRegistry;
import
org.apache.camel.component.ehcache.processor.aggregate.EhcacheAggregationRepository;
import org.apache.camel.support.DefaultExchangeHolder;
-import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.camel.test.junit5.CamelTestSupport;
import org.ehcache.Cache;
import org.ehcache.CacheManager;
import org.ehcache.config.Configuration;
import org.ehcache.config.builders.CacheManagerBuilder;
import org.ehcache.xml.XmlConfiguration;
-import org.junit.Rule;
-import org.junit.rules.TestName;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -46,8 +44,6 @@ public class EhcacheTestSupport extends CamelTestSupport {
public static final String IDEMPOTENT_TEST_CACHE_NAME = "idempotent";
public static final String AGGREGATE_TEST_CACHE_NAME = "aggregate";
- @Rule
- public final TestName testName = new TestName();
@BindToRegistry("cacheManager")
protected CacheManager cacheManager;
@@ -85,7 +81,7 @@ public class EhcacheTestSupport extends CamelTestSupport {
return cacheManager.getCache(AGGREGATE_TEST_CACHE_NAME, String.class,
DefaultExchangeHolder.class);
}
- protected EhcacheAggregationRepository createAggregateRepository() throws
Exception {
+ protected EhcacheAggregationRepository createAggregateRepository() {
EhcacheAggregationRepository repository = new
EhcacheAggregationRepository();
repository.setCache(getAggregateCache());
repository.setCacheName("aggregate");
diff --git
a/components/camel-ehcache/src/test/java/org/apache/camel/component/ehcache/processor/aggregate/EhcacheAggregationRepositoryOperationTest.java
b/components/camel-ehcache/src/test/java/org/apache/camel/component/ehcache/processor/aggregate/EhcacheAggregationRepositoryOperationTest.java
index 39bda69..67f2ec2 100644
---
a/components/camel-ehcache/src/test/java/org/apache/camel/component/ehcache/processor/aggregate/EhcacheAggregationRepositoryOperationTest.java
+++
b/components/camel-ehcache/src/test/java/org/apache/camel/component/ehcache/processor/aggregate/EhcacheAggregationRepositoryOperationTest.java
@@ -22,8 +22,14 @@ import org.apache.camel.Exchange;
import org.apache.camel.component.ehcache.EhcacheTestSupport;
import org.apache.camel.support.DefaultExchange;
import org.apache.camel.support.DefaultExchangeHolder;
-import org.junit.After;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public class EhcacheAggregationRepositoryOperationTest extends
EhcacheTestSupport {
private EhcacheAggregationRepository aggregationRepository;
@@ -37,7 +43,7 @@ public class EhcacheAggregationRepositoryOperationTest
extends EhcacheTestSuppor
}
@Override
- @After
+ @AfterEach
public void tearDown() throws Exception {
aggregationRepository.stop();
super.tearDown();
@@ -52,7 +58,7 @@ public class EhcacheAggregationRepositoryOperationTest
extends EhcacheTestSuppor
}
@Test
- public void testAdd() {
+ void testAdd() {
// Given
String key = "Add";
assertFalse(exists(key));
@@ -64,7 +70,7 @@ public class EhcacheAggregationRepositoryOperationTest
extends EhcacheTestSuppor
}
@Test
- public void testGetExists() {
+ void testGetExists() {
// Given
String key = "Get_Exists";
Exchange exchange = new DefaultExchange(context());
@@ -79,7 +85,7 @@ public class EhcacheAggregationRepositoryOperationTest
extends EhcacheTestSuppor
}
@Test
- public void testGetNotExists() {
+ void testGetNotExists() {
// Given
String key = "Get_NotExists";
assertFalse(exists(key));
@@ -90,7 +96,7 @@ public class EhcacheAggregationRepositoryOperationTest
extends EhcacheTestSuppor
}
@Test
- public void testRemoveExists() {
+ void testRemoveExists() {
// Given
String key = "Remove_Exists";
Exchange exchange = new DefaultExchange(context());
@@ -103,7 +109,7 @@ public class EhcacheAggregationRepositoryOperationTest
extends EhcacheTestSuppor
}
@Test
- public void testRemoveNotExists() {
+ void testRemoveNotExists() {
// Given
String key = "RemoveNotExists";
Exchange exchange = new DefaultExchange(context());
@@ -115,7 +121,7 @@ public class EhcacheAggregationRepositoryOperationTest
extends EhcacheTestSuppor
}
@Test
- public void testGetKeys() {
+ void testGetKeys() {
// Given
String[] keys = {"GetKeys1", "GetKeys2"};
addExchanges(keys);
@@ -128,7 +134,7 @@ public class EhcacheAggregationRepositoryOperationTest
extends EhcacheTestSuppor
}
@Test
- public void testConfirmExist() {
+ void testConfirmExist() {
// Given
for (int i = 1; i < 4; i++) {
String key = "Confirm_" + i;
@@ -146,7 +152,7 @@ public class EhcacheAggregationRepositoryOperationTest
extends EhcacheTestSuppor
}
@Test
- public void testConfirmNotExist() {
+ void testConfirmNotExist() {
// Given
String[] keys = new String[3];
for (int i = 1; i < 4; i++) {
@@ -173,7 +179,7 @@ public class EhcacheAggregationRepositoryOperationTest
extends EhcacheTestSuppor
}
@Test
- public void testScan() {
+ void testScan() {
// Given
String[] keys = {"Scan1", "Scan2"};
addExchanges(keys);
@@ -186,7 +192,7 @@ public class EhcacheAggregationRepositoryOperationTest
extends EhcacheTestSuppor
}
@Test
- public void testRecover() {
+ void testRecover() {
// Given
String[] keys = {"Recover1", "Recover2"};
addExchanges(keys);
diff --git
a/components/camel-ehcache/src/test/java/org/apache/camel/component/ehcache/processor/aggregate/EhcacheAggregationRepositoryRoutesTest.java
b/components/camel-ehcache/src/test/java/org/apache/camel/component/ehcache/processor/aggregate/EhcacheAggregationRepositoryRoutesTest.java
index df93364..95d8c21 100644
---
a/components/camel-ehcache/src/test/java/org/apache/camel/component/ehcache/processor/aggregate/EhcacheAggregationRepositoryRoutesTest.java
+++
b/components/camel-ehcache/src/test/java/org/apache/camel/component/ehcache/processor/aggregate/EhcacheAggregationRepositoryRoutesTest.java
@@ -26,7 +26,7 @@ import org.apache.camel.RoutesBuilder;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.ehcache.EhcacheTestSupport;
import org.apache.camel.component.mock.MockEndpoint;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class EhcacheAggregationRepositoryRoutesTest extends EhcacheTestSupport
{
private static final String ENDPOINT_MOCK = "mock:result";
@@ -42,7 +42,7 @@ public class EhcacheAggregationRepositoryRoutesTest extends
EhcacheTestSupport {
private ProducerTemplate producer;
@Test
- public void checkAggregationFromOneRoute() throws Exception {
+ void checkAggregationFromOneRoute() throws Exception {
mock.expectedMessageCount(VALUES.length);
mock.expectedBodiesReceived(SUM);
@@ -68,10 +68,10 @@ public class EhcacheAggregationRepositoryRoutesTest extends
EhcacheTestSupport {
}
@Override
- protected RoutesBuilder createRouteBuilder() throws Exception {
+ protected RoutesBuilder createRouteBuilder() {
return new RouteBuilder() {
@Override
- public void configure() throws Exception {
+ public void configure() {
from(ENDPOINT_DIRECT)
.routeId("AggregatingRouteOne")
.aggregate(header(CORRELATOR))
diff --git
a/components/camel-ehcache/src/test/java/org/apache/camel/component/ehcache/processor/idempotent/EhcacheIdempotentRepositoryTest.java
b/components/camel-ehcache/src/test/java/org/apache/camel/component/ehcache/processor/idempotent/EhcacheIdempotentRepositoryTest.java
index 67a85a3..8bbe26a 100644
---
a/components/camel-ehcache/src/test/java/org/apache/camel/component/ehcache/processor/idempotent/EhcacheIdempotentRepositoryTest.java
+++
b/components/camel-ehcache/src/test/java/org/apache/camel/component/ehcache/processor/idempotent/EhcacheIdempotentRepositoryTest.java
@@ -20,7 +20,11 @@ import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.ehcache.EhcacheTestSupport;
import org.apache.camel.component.mock.MockEndpoint;
import org.ehcache.Cache;
-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.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public class EhcacheIdempotentRepositoryTest extends EhcacheTestSupport {
@@ -43,7 +47,7 @@ public class EhcacheIdempotentRepositoryTest extends
EhcacheTestSupport {
}
@Test
- public void testAdd() throws Exception {
+ void testAdd() {
// add first key
assertTrue(repo.add(key01));
assertTrue(cache.containsKey(key01));
@@ -57,7 +61,7 @@ public class EhcacheIdempotentRepositoryTest extends
EhcacheTestSupport {
}
@Test
- public void testConfirm() throws Exception {
+ void testConfirm() {
// add first key and confirm
assertTrue(repo.add(key01));
assertTrue(repo.confirm(key01));
@@ -67,7 +71,7 @@ public class EhcacheIdempotentRepositoryTest extends
EhcacheTestSupport {
}
@Test
- public void testContains() throws Exception {
+ void testContains() {
assertFalse(repo.contains(key01));
// add key and check again
@@ -77,7 +81,7 @@ public class EhcacheIdempotentRepositoryTest extends
EhcacheTestSupport {
}
@Test
- public void testRemove() throws Exception {
+ void testRemove() {
// add key to remove
assertTrue(repo.add(key01));
assertTrue(repo.add(key02));
@@ -91,7 +95,7 @@ public class EhcacheIdempotentRepositoryTest extends
EhcacheTestSupport {
}
@Test
- public void testClear() throws Exception {
+ void testClear() {
// add key to remove
assertTrue(repo.add(key01));
assertTrue(repo.confirm(key01));
@@ -105,13 +109,13 @@ public class EhcacheIdempotentRepositoryTest extends
EhcacheTestSupport {
}
@Test
- public void testRepositoryInRoute() throws Exception {
+ void testRepositoryInRoute() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:out");
mock.expectedBodiesReceived("a", "b");
// c is a duplicate
// should be started
- assertEquals("Should be started", true, repo.getStatus().isStarted());
+ assertEquals(true, repo.getStatus().isStarted(), "Should be started");
// send 3 message with one duplicated key (key01)
template.sendBodyAndHeader("direct://in", "a", "messageId", key01);
@@ -122,10 +126,10 @@ public class EhcacheIdempotentRepositoryTest extends
EhcacheTestSupport {
}
@Override
- protected RouteBuilder createRouteBuilder() throws Exception {
+ protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
@Override
- public void configure() throws Exception {
+ public void configure() {
from("direct://in")
.idempotentConsumer(header("messageId"), repo)
.to("mock://out");
diff --git a/components/camel-elsql/pom.xml b/components/camel-elsql/pom.xml
index dda8107..1115b7c 100644
--- a/components/camel-elsql/pom.xml
+++ b/components/camel-elsql/pom.xml
@@ -51,17 +51,7 @@
<!-- test dependencies -->
<dependency>
<groupId>org.apache.camel</groupId>
- <artifactId>camel-test-spring</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-test</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <artifactId>camel-test-spring-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
@@ -79,5 +69,10 @@
<artifactId>hsqldb</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>hamcrest</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
diff --git
a/components/camel-elsql/src/test/java/org/apache/camel/component/elsql/ElSqlComponentTest.java
b/components/camel-elsql/src/test/java/org/apache/camel/component/elsql/ElSqlComponentTest.java
index 7ba4d47..5fed7c1 100644
---
a/components/camel-elsql/src/test/java/org/apache/camel/component/elsql/ElSqlComponentTest.java
+++
b/components/camel-elsql/src/test/java/org/apache/camel/component/elsql/ElSqlComponentTest.java
@@ -22,20 +22,23 @@ import java.util.Map;
import org.apache.camel.BindToRegistry;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.After;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabase;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;
+import static org.apache.camel.test.junit5.TestSupport.assertIsInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
public class ElSqlComponentTest extends CamelTestSupport {
@BindToRegistry("dataSource")
private EmbeddedDatabase db = new
EmbeddedDatabaseBuilder().setType(EmbeddedDatabaseType.DERBY).addScript("sql/createAndPopulateDatabase.sql").build();
@Test
- public void testSimpleBody() throws Exception {
+ void testSimpleBody() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(1);
@@ -55,7 +58,7 @@ public class ElSqlComponentTest extends CamelTestSupport {
}
@Override
- @After
+ @AfterEach
public void tearDown() throws Exception {
super.tearDown();
@@ -63,7 +66,7 @@ public class ElSqlComponentTest extends CamelTestSupport {
}
@Override
- protected RouteBuilder createRouteBuilder() throws Exception {
+ protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
public void configure() {
getContext().getComponent("elsql",
ElsqlComponent.class).setDataSource(db);
diff --git
a/components/camel-elsql/src/test/java/org/apache/camel/component/elsql/ElSqlConsumerDeleteTest.java
b/components/camel-elsql/src/test/java/org/apache/camel/component/elsql/ElSqlConsumerDeleteTest.java
index acb8258..da884e3 100644
---
a/components/camel-elsql/src/test/java/org/apache/camel/component/elsql/ElSqlConsumerDeleteTest.java
+++
b/components/camel-elsql/src/test/java/org/apache/camel/component/elsql/ElSqlConsumerDeleteTest.java
@@ -22,15 +22,17 @@ import java.util.Map;
import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabase;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
/**
*
*/
@@ -40,7 +42,7 @@ public class ElSqlConsumerDeleteTest extends CamelTestSupport
{
private JdbcTemplate jdbcTemplate;
@Override
- @Before
+ @BeforeEach
public void setUp() throws Exception {
db = new EmbeddedDatabaseBuilder()
.setType(EmbeddedDatabaseType.DERBY).addScript("sql/createAndPopulateDatabase.sql").build();
@@ -51,7 +53,7 @@ public class ElSqlConsumerDeleteTest extends CamelTestSupport
{
}
@Override
- @After
+ @AfterEach
public void tearDown() throws Exception {
super.tearDown();
@@ -59,7 +61,7 @@ public class ElSqlConsumerDeleteTest extends CamelTestSupport
{
}
@Test
- public void testConsume() throws Exception {
+ void testConsume() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(3);
@@ -84,14 +86,14 @@ public class ElSqlConsumerDeleteTest extends
CamelTestSupport {
break;
}
}
- assertEquals("Should have deleted all 3 rows", new Integer(0),
jdbcTemplate.queryForObject("select count(*) from projects", Integer.class));
+ assertEquals(new Integer(0), jdbcTemplate.queryForObject("select
count(*) from projects", Integer.class), "Should have deleted all 3 rows");
}
@Override
- protected RouteBuilder createRouteBuilder() throws Exception {
+ protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
@Override
- public void configure() throws Exception {
+ public void configure() {
getContext().getComponent("elsql",
ElsqlComponent.class).setDataSource(db);
getContext().getComponent("elsql",
ElsqlComponent.class).setResourceUri("elsql/projects.elsql,elsql/delete.elsql");
diff --git
a/components/camel-elsql/src/test/java/org/apache/camel/component/elsql/ElSqlConsumerDynamicParameterTest.java
b/components/camel-elsql/src/test/java/org/apache/camel/component/elsql/ElSqlConsumerDynamicParameterTest.java
index 192bcf5..540ccec 100644
---
a/components/camel-elsql/src/test/java/org/apache/camel/component/elsql/ElSqlConsumerDynamicParameterTest.java
+++
b/components/camel-elsql/src/test/java/org/apache/camel/component/elsql/ElSqlConsumerDynamicParameterTest.java
@@ -23,13 +23,16 @@ import org.apache.camel.BindToRegistry;
import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.After;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabase;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
/**
*
*/
@@ -41,7 +44,7 @@ public class ElSqlConsumerDynamicParameterTest extends
CamelTestSupport {
private MyIdGenerator idGenerator = new MyIdGenerator();
@Override
- @After
+ @AfterEach
public void tearDown() throws Exception {
super.tearDown();
@@ -49,7 +52,7 @@ public class ElSqlConsumerDynamicParameterTest extends
CamelTestSupport {
}
@Test
- public void testDynamicConsume() throws Exception {
+ void testDynamicConsume() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMinimumMessageCount(3);
@@ -67,14 +70,14 @@ public class ElSqlConsumerDynamicParameterTest extends
CamelTestSupport {
assertEquals("Linux",
exchanges.get(2).getIn().getBody(Map.class).get("PROJECT"));
// and the bean id should be > 1
- assertTrue("Id counter should be > 1", idGenerator.getId() > 1);
+ assertTrue(idGenerator.getId() > 1, "Id counter should be > 1");
}
@Override
- protected RouteBuilder createRouteBuilder() throws Exception {
+ protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
@Override
- public void configure() throws Exception {
+ public void configure() {
from("elsql:projectsByIdBean:elsql/projects.elsql?dataSource=#dataSource&initialDelay=0&delay=50").routeId("foo").noAutoStartup()
.to("mock:result");
}
diff --git
a/components/camel-elsql/src/test/java/org/apache/camel/component/elsql/ElSqlConsumerTest.java
b/components/camel-elsql/src/test/java/org/apache/camel/component/elsql/ElSqlConsumerTest.java
index f2f2d8c..ea2ec70 100644
---
a/components/camel-elsql/src/test/java/org/apache/camel/component/elsql/ElSqlConsumerTest.java
+++
b/components/camel-elsql/src/test/java/org/apache/camel/component/elsql/ElSqlConsumerTest.java
@@ -23,13 +23,16 @@ import org.apache.camel.BindToRegistry;
import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.After;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabase;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
/**
*
*/
@@ -39,7 +42,7 @@ public class ElSqlConsumerTest extends CamelTestSupport {
private EmbeddedDatabase db = new
EmbeddedDatabaseBuilder().setType(EmbeddedDatabaseType.DERBY).addScript("sql/createAndPopulateDatabase.sql").build();
@Override
- @After
+ @AfterEach
public void tearDown() throws Exception {
super.tearDown();
@@ -47,7 +50,7 @@ public class ElSqlConsumerTest extends CamelTestSupport {
}
@Test
- public void testConsume() throws Exception {
+ void testConsume() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMinimumMessageCount(3);
@@ -65,10 +68,10 @@ public class ElSqlConsumerTest extends CamelTestSupport {
}
@Override
- protected RouteBuilder createRouteBuilder() throws Exception {
+ protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
@Override
- public void configure() throws Exception {
+ public void configure() {
from("elsql:allProjects:elsql/projects.elsql?dataSource=#dataSource").to("mock:result");
}
};
diff --git
a/components/camel-elsql/src/test/java/org/apache/camel/component/elsql/ElSqlDataSourceTest.java
b/components/camel-elsql/src/test/java/org/apache/camel/component/elsql/ElSqlDataSourceTest.java
index aef61d0..571013b 100644
---
a/components/camel-elsql/src/test/java/org/apache/camel/component/elsql/ElSqlDataSourceTest.java
+++
b/components/camel-elsql/src/test/java/org/apache/camel/component/elsql/ElSqlDataSourceTest.java
@@ -22,20 +22,23 @@ import java.util.Map;
import org.apache.camel.BindToRegistry;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.After;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabase;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;
+import static org.apache.camel.test.junit5.TestSupport.assertIsInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
public class ElSqlDataSourceTest extends CamelTestSupport {
@BindToRegistry("dataSource")
private EmbeddedDatabase db = new
EmbeddedDatabaseBuilder().setType(EmbeddedDatabaseType.DERBY).addScript("sql/createAndPopulateDatabase.sql").build();
@Test
- public void testSimpleBody() throws Exception {
+ void testSimpleBody() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(1);
@@ -55,7 +58,7 @@ public class ElSqlDataSourceTest extends CamelTestSupport {
}
@Override
- @After
+ @AfterEach
public void tearDown() throws Exception {
super.tearDown();
@@ -63,7 +66,7 @@ public class ElSqlDataSourceTest extends CamelTestSupport {
}
@Override
- protected RouteBuilder createRouteBuilder() throws Exception {
+ protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
public void configure() {
from("direct:simple").to("elsql:projectsById:elsql/projects.elsql?dataSource=#dataSource").to("mock:result");
diff --git
a/components/camel-elsql/src/test/java/org/apache/camel/component/elsql/ElSqlProducerBatchTest.java
b/components/camel-elsql/src/test/java/org/apache/camel/component/elsql/ElSqlProducerBatchTest.java
index 11ecb0a..f8207a8 100644
---
a/components/camel-elsql/src/test/java/org/apache/camel/component/elsql/ElSqlProducerBatchTest.java
+++
b/components/camel-elsql/src/test/java/org/apache/camel/component/elsql/ElSqlProducerBatchTest.java
@@ -23,9 +23,9 @@ import org.apache.camel.BindToRegistry;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.component.sql.SqlConstants;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.After;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabase;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;
@@ -36,7 +36,7 @@ public class ElSqlProducerBatchTest extends CamelTestSupport {
private EmbeddedDatabase db = new
EmbeddedDatabaseBuilder().setType(EmbeddedDatabaseType.DERBY).addScript("sql/createAndPopulateDatabase.sql").build();
@Override
- @After
+ @AfterEach
public void tearDown() throws Exception {
super.tearDown();
@@ -44,7 +44,7 @@ public class ElSqlProducerBatchTest extends CamelTestSupport {
}
@Test
- public void testBatchMode() throws InterruptedException {
+ void testBatchMode() throws InterruptedException {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(1);
mock.message(0).header(SqlConstants.SQL_UPDATE_COUNT).isEqualTo(1);
@@ -60,7 +60,7 @@ public class ElSqlProducerBatchTest extends CamelTestSupport {
}
@Test
- public void testNonBatchMode() throws InterruptedException {
+ void testNonBatchMode() throws InterruptedException {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(1);
mock.message(0).header(SqlConstants.SQL_UPDATE_COUNT).isEqualTo(1);
@@ -79,7 +79,7 @@ public class ElSqlProducerBatchTest extends CamelTestSupport {
}
@Override
- protected RouteBuilder createRouteBuilder() throws Exception {
+ protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
public void configure() {
diff --git
a/components/camel-elsql/src/test/java/org/apache/camel/component/elsql/ElSqlProducerBodySimpleTest.java
b/components/camel-elsql/src/test/java/org/apache/camel/component/elsql/ElSqlProducerBodySimpleTest.java
index 96e7c62..1687e31 100644
---
a/components/camel-elsql/src/test/java/org/apache/camel/component/elsql/ElSqlProducerBodySimpleTest.java
+++
b/components/camel-elsql/src/test/java/org/apache/camel/component/elsql/ElSqlProducerBodySimpleTest.java
@@ -25,20 +25,23 @@ import org.apache.camel.BindToRegistry;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.component.sql.SqlConstants;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.After;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabase;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;
+import static org.apache.camel.test.junit5.TestSupport.assertIsInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
public class ElSqlProducerBodySimpleTest extends CamelTestSupport {
@BindToRegistry("dataSource")
private EmbeddedDatabase db = new
EmbeddedDatabaseBuilder().setType(EmbeddedDatabaseType.DERBY).addScript("sql/createAndPopulateDatabase.sql").build();
@Test
- public void testSimpleBody() throws Exception {
+ void testSimpleBody() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(1);
@@ -61,7 +64,7 @@ public class ElSqlProducerBodySimpleTest extends
CamelTestSupport {
}
@Test
- public void testBodyParameter() throws InterruptedException {
+ void testBodyParameter() throws InterruptedException {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(1);
mock.message(0).body().isInstanceOf(List.class);
@@ -79,7 +82,7 @@ public class ElSqlProducerBodySimpleTest extends
CamelTestSupport {
}
@Test
- public void testHeadersParameter() throws InterruptedException {
+ void testHeadersParameter() throws InterruptedException {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(1);
mock.message(0).body().isInstanceOf(List.class);
@@ -97,7 +100,7 @@ public class ElSqlProducerBodySimpleTest extends
CamelTestSupport {
}
@Test
- public void testUpdateHeader() throws InterruptedException {
+ void testUpdateHeader() throws InterruptedException {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(1);
mock.message(0).header(SqlConstants.SQL_UPDATE_COUNT).isEqualTo(1);
@@ -112,7 +115,7 @@ public class ElSqlProducerBodySimpleTest extends
CamelTestSupport {
}
@Override
- @After
+ @AfterEach
public void tearDown() throws Exception {
super.tearDown();
@@ -120,7 +123,7 @@ public class ElSqlProducerBodySimpleTest extends
CamelTestSupport {
}
@Override
- protected RouteBuilder createRouteBuilder() throws Exception {
+ protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
public void configure() {
from("direct:simple").to("elsql:projectsByIdBody:elsql/projects.elsql?dataSource=#dataSource").to("mock:result");
diff --git
a/components/camel-elsql/src/test/java/org/apache/camel/component/elsql/ElSqlProducerStreamListTest.java
b/components/camel-elsql/src/test/java/org/apache/camel/component/elsql/ElSqlProducerStreamListTest.java
index adc4a54..9b641af 100644
---
a/components/camel-elsql/src/test/java/org/apache/camel/component/elsql/ElSqlProducerStreamListTest.java
+++
b/components/camel-elsql/src/test/java/org/apache/camel/component/elsql/ElSqlProducerStreamListTest.java
@@ -22,14 +22,15 @@ import java.util.Map;
import org.apache.camel.BindToRegistry;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.After;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabase;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;
import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.hamcrest.MatcherAssert.assertThat;
public class ElSqlProducerStreamListTest extends CamelTestSupport {
@@ -37,7 +38,7 @@ public class ElSqlProducerStreamListTest extends
CamelTestSupport {
private EmbeddedDatabase db = new
EmbeddedDatabaseBuilder().setType(EmbeddedDatabaseType.DERBY).addScript("sql/createAndPopulateDatabase.sql").build();
@Test
- public void testReturnAnIterator() throws Exception {
+ void testReturnAnIterator() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(1);
@@ -48,7 +49,7 @@ public class ElSqlProducerStreamListTest extends
CamelTestSupport {
}
@Test
- public void testSplit() throws Exception {
+ void testSplit() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(3);
@@ -61,7 +62,7 @@ public class ElSqlProducerStreamListTest extends
CamelTestSupport {
}
@Test
- public void testSplitWithModel() throws Exception {
+ void testSplitWithModel() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(3);
@@ -78,7 +79,7 @@ public class ElSqlProducerStreamListTest extends
CamelTestSupport {
}
@Override
- @After
+ @AfterEach
public void tearDown() throws Exception {
super.tearDown();
@@ -86,7 +87,7 @@ public class ElSqlProducerStreamListTest extends
CamelTestSupport {
}
@Override
- protected RouteBuilder createRouteBuilder() throws Exception {
+ protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
public void configure() {
getContext().getComponent("elsql",
ElsqlComponent.class).setDataSource(db);