This is an automated email from the ASF dual-hosted git repository. orpiske pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel.git
commit d19a62947a715e88cbe6085247feb07ec52ce212 Author: Otavio Rodolfo Piske <angusyo...@gmail.com> AuthorDate: Thu May 23 11:29:07 2024 +0200 CAMEL-20785: mark createCamelRegistry as deprecated and cleanup abuses of the API --- .../google/calendar/CalendarConfigurationTest.java | 4 ++-- .../integration/PulsarConcurrentConsumerInIT.java | 20 +++----------------- .../integration/PulsarConcurrentProducerInIT.java | 20 +++----------------- .../integration/PulsarConsumerAcknowledgementIT.java | 19 +++---------------- .../PulsarConsumerDeadLetterPolicyIT.java | 18 +++--------------- .../integration/PulsarConsumerInAsynchronousIT.java | 20 +++----------------- .../pulsar/integration/PulsarConsumerInIT.java | 19 +++---------------- .../PulsarConsumerNegativeAcknowledgementIT.java | 9 ++------- .../PulsarConsumerNoAcknowledgementIT.java | 9 ++------- .../integration/PulsarConsumerPatternInIT.java | 19 +++---------------- .../integration/PulsarConsumerReadCompactedIT.java | 19 +++---------------- .../integration/PulsarCustomMessageReceiptIT.java | 9 ++------- .../pulsar/integration/PulsarITSupport.java | 15 +++++++++++++++ .../integration/PulsarProducerHeadersInIT.java | 19 +++---------------- .../pulsar/integration/PulsarProducerInIT.java | 19 +++---------------- .../PulsarProducerUndefinedProducerNameInIT.java | 16 ++-------------- ...ulsarSharedSubscriptionMessageDistributionIT.java | 19 +++---------------- .../pulsar/integration/PulsarSuspendRouteIT.java | 17 +++-------------- .../spring/batch/SpringBatchEndpointTest.java | 4 +--- .../apache/camel/component/redis/RedisHashTest.java | 5 +---- .../apache/camel/component/redis/RedisListTest.java | 5 +---- .../component/redis/RedisRemoveEndpointTest.java | 5 +---- .../camel/component/redis/RedisRemoveRouteTest.java | 5 +---- .../apache/camel/component/redis/RedisSetTest.java | 5 +---- .../camel/component/redis/RedisSortedSetTest.java | 5 +---- .../camel/component/redis/RedisStringTest.java | 5 +---- .../redis/integration/RedisConsumerManualIT.java | 6 +----- .../redis/integration/RedisProducerManualIT.java | 5 +---- .../RedisStringIdempotentRepositoryManualIT.java | 5 +---- .../spring/ws/ConsumerBreadcrumbIdTest.java | 5 +---- .../ws/ConsumerExceptionPropagationRouteTest.java | 5 +---- .../spring/ws/ConsumerMarshallingRouteTest.java | 5 +---- .../apache/camel/spring/SpringMDCTransactedTest.java | 9 ++++----- .../camel/component/sql/SqlDataSourceRefTest.java | 8 ++------ .../camel/component/sql/SqlDataSourceTest.java | 8 ++------ .../camel/component/sql/SqlEndpointLikeTest.java | 7 ++----- .../camel/component/sql/SqlTransactedRouteTest.java | 13 ++++--------- .../sql/stored/SqlStoredDataSourceTest.java | 9 ++------- .../apache/camel/component/stomp/StompBaseTest.java | 6 +----- .../apache/camel/test/junit5/CamelTestSupport.java | 1 + .../component/thrift/ThriftConsumerSecurityTest.java | 7 ++----- .../component/thrift/ThriftProducerSecurityTest.java | 7 ++----- .../apache/camel/component/tika/TikaParseTest.java | 7 ++----- .../component/xmlsecurity/ECDSASignatureTest.java | 7 +------ .../xmlsecurity/SignatureAlgorithmTest.java | 7 +------ .../xmlsecurity/SignatureDigestMethodTest.java | 7 +------ .../xmlsecurity/XAdESSignaturePropertiesTest.java | 6 +----- .../component/xmlsecurity/XmlSignatureTest.java | 7 +------ .../camel/component/xmpp/XmppBaseContainerTest.java | 6 +----- .../camel/component/xmpp/integration/XmppBaseIT.java | 6 +----- 50 files changed, 106 insertions(+), 382 deletions(-) diff --git a/components/camel-google/camel-google-calendar/src/test/java/org/apache/camel/component/google/calendar/CalendarConfigurationTest.java b/components/camel-google/camel-google-calendar/src/test/java/org/apache/camel/component/google/calendar/CalendarConfigurationTest.java index 456bb19a228..e112f3f01f6 100644 --- a/components/camel-google/camel-google-calendar/src/test/java/org/apache/camel/component/google/calendar/CalendarConfigurationTest.java +++ b/components/camel-google/camel-google-calendar/src/test/java/org/apache/camel/component/google/calendar/CalendarConfigurationTest.java @@ -49,8 +49,8 @@ public class CalendarConfigurationTest extends AbstractGoogleCalendarTestSupport } @Override - protected CamelContext createCamelContext() throws Exception { - final CamelContext context = new DefaultCamelContext(createCamelRegistry()); + protected CamelContext createCamelContext() { + final CamelContext context = new DefaultCamelContext(); // add GoogleCalendarComponent to Camel context but don't set up configuration final GoogleCalendarComponent component = new GoogleCalendarComponent(context); diff --git a/components/camel-pulsar/src/test/java/org/apache/camel/component/pulsar/integration/PulsarConcurrentConsumerInIT.java b/components/camel-pulsar/src/test/java/org/apache/camel/component/pulsar/integration/PulsarConcurrentConsumerInIT.java index d9d95682473..ff56234a6ab 100644 --- a/components/camel-pulsar/src/test/java/org/apache/camel/component/pulsar/integration/PulsarConcurrentConsumerInIT.java +++ b/components/camel-pulsar/src/test/java/org/apache/camel/component/pulsar/integration/PulsarConcurrentConsumerInIT.java @@ -24,10 +24,7 @@ import org.apache.camel.Exchange; import org.apache.camel.Processor; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; -import org.apache.camel.component.pulsar.PulsarComponent; -import org.apache.camel.component.pulsar.utils.AutoConfiguration; import org.apache.camel.spi.Registry; -import org.apache.camel.support.SimpleRegistry; import org.apache.pulsar.client.api.Producer; import org.apache.pulsar.client.api.PulsarClient; import org.apache.pulsar.client.api.PulsarClientException; @@ -71,24 +68,13 @@ public class PulsarConcurrentConsumerInIT extends PulsarITSupport { } @Override - protected Registry createCamelRegistry() throws Exception { - SimpleRegistry registry = new SimpleRegistry(); - + protected void bindToRegistry(Registry registry) throws Exception { registerPulsarBeans(registry); - - return registry; } - private void registerPulsarBeans(SimpleRegistry registry) throws PulsarClientException { + private void registerPulsarBeans(Registry registry) throws PulsarClientException { PulsarClient pulsarClient = concurrentPulsarClient(); - AutoConfiguration autoConfiguration = new AutoConfiguration(null, null); - - registry.bind("pulsarClient", pulsarClient); - PulsarComponent comp = new PulsarComponent(context); - comp.setAutoConfiguration(autoConfiguration); - comp.setPulsarClient(pulsarClient); - registry.bind("pulsar", comp); - + registerPulsarBeans(registry, pulsarClient, context); } private PulsarClient concurrentPulsarClient() throws PulsarClientException { diff --git a/components/camel-pulsar/src/test/java/org/apache/camel/component/pulsar/integration/PulsarConcurrentProducerInIT.java b/components/camel-pulsar/src/test/java/org/apache/camel/component/pulsar/integration/PulsarConcurrentProducerInIT.java index d03caf635da..2d34ab8e286 100644 --- a/components/camel-pulsar/src/test/java/org/apache/camel/component/pulsar/integration/PulsarConcurrentProducerInIT.java +++ b/components/camel-pulsar/src/test/java/org/apache/camel/component/pulsar/integration/PulsarConcurrentProducerInIT.java @@ -26,10 +26,7 @@ import org.apache.camel.Produce; import org.apache.camel.ProducerTemplate; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; -import org.apache.camel.component.pulsar.PulsarComponent; -import org.apache.camel.component.pulsar.utils.AutoConfiguration; import org.apache.camel.spi.Registry; -import org.apache.camel.support.SimpleRegistry; import org.apache.pulsar.client.api.PulsarClient; import org.apache.pulsar.client.api.PulsarClientException; import org.apache.pulsar.client.impl.ClientBuilderImpl; @@ -64,24 +61,13 @@ public class PulsarConcurrentProducerInIT extends PulsarITSupport { } @Override - protected Registry createCamelRegistry() throws Exception { - SimpleRegistry registry = new SimpleRegistry(); - + protected void bindToRegistry(Registry registry) throws Exception { registerPulsarBeans(registry); - - return registry; } - private void registerPulsarBeans(SimpleRegistry registry) throws PulsarClientException { + private void registerPulsarBeans(Registry registry) throws PulsarClientException { PulsarClient pulsarClient = givenPulsarClient(); - AutoConfiguration autoConfiguration = new AutoConfiguration(null, null); - - registry.bind("pulsarClient", pulsarClient); - PulsarComponent comp = new PulsarComponent(context); - comp.setAutoConfiguration(autoConfiguration); - comp.setPulsarClient(pulsarClient); - registry.bind("pulsar", comp); - + registerPulsarBeans(registry, pulsarClient, context); } private PulsarClient givenPulsarClient() throws PulsarClientException { diff --git a/components/camel-pulsar/src/test/java/org/apache/camel/component/pulsar/integration/PulsarConsumerAcknowledgementIT.java b/components/camel-pulsar/src/test/java/org/apache/camel/component/pulsar/integration/PulsarConsumerAcknowledgementIT.java index 43489d21a66..cf276f887d8 100644 --- a/components/camel-pulsar/src/test/java/org/apache/camel/component/pulsar/integration/PulsarConsumerAcknowledgementIT.java +++ b/components/camel-pulsar/src/test/java/org/apache/camel/component/pulsar/integration/PulsarConsumerAcknowledgementIT.java @@ -23,12 +23,9 @@ import java.util.concurrent.atomic.AtomicBoolean; import org.apache.camel.Endpoint; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; -import org.apache.camel.component.pulsar.PulsarComponent; import org.apache.camel.component.pulsar.PulsarMessageReceipt; -import org.apache.camel.component.pulsar.utils.AutoConfiguration; import org.apache.camel.component.pulsar.utils.message.PulsarMessageHeaders; import org.apache.camel.spi.Registry; -import org.apache.camel.support.SimpleRegistry; import org.apache.camel.test.infra.common.TestUtils; import org.apache.pulsar.client.api.Producer; import org.apache.pulsar.client.api.PulsarClient; @@ -80,23 +77,13 @@ public class PulsarConsumerAcknowledgementIT extends PulsarITSupport { } @Override - protected Registry createCamelRegistry() throws Exception { - Registry registry = new SimpleRegistry(); - + protected void bindToRegistry(Registry registry) throws Exception { registerPulsarBeans(registry); - - return registry; } - private void registerPulsarBeans(final Registry registry) throws PulsarClientException { + private void registerPulsarBeans(Registry registry) throws PulsarClientException { PulsarClient pulsarClient = givenPulsarClient(); - AutoConfiguration autoConfiguration = new AutoConfiguration(null, null); - - registry.bind("pulsarClient", pulsarClient); - PulsarComponent comp = new PulsarComponent(context); - comp.setAutoConfiguration(autoConfiguration); - comp.setPulsarClient(pulsarClient); - registry.bind("pulsar", comp); + registerPulsarBeans(registry, pulsarClient, context); } private PulsarClient givenPulsarClient() throws PulsarClientException { diff --git a/components/camel-pulsar/src/test/java/org/apache/camel/component/pulsar/integration/PulsarConsumerDeadLetterPolicyIT.java b/components/camel-pulsar/src/test/java/org/apache/camel/component/pulsar/integration/PulsarConsumerDeadLetterPolicyIT.java index 6e5e24f9e47..914dcf3068b 100644 --- a/components/camel-pulsar/src/test/java/org/apache/camel/component/pulsar/integration/PulsarConsumerDeadLetterPolicyIT.java +++ b/components/camel-pulsar/src/test/java/org/apache/camel/component/pulsar/integration/PulsarConsumerDeadLetterPolicyIT.java @@ -24,10 +24,8 @@ import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.component.pulsar.PulsarComponent; import org.apache.camel.component.pulsar.PulsarEndpoint; import org.apache.camel.component.pulsar.PulsarMessageReceipt; -import org.apache.camel.component.pulsar.utils.AutoConfiguration; import org.apache.camel.component.pulsar.utils.message.PulsarMessageHeaders; import org.apache.camel.spi.Registry; -import org.apache.camel.support.SimpleRegistry; import org.apache.camel.test.infra.common.TestUtils; import org.apache.pulsar.client.api.Producer; import org.apache.pulsar.client.api.PulsarClient; @@ -58,23 +56,13 @@ public class PulsarConsumerDeadLetterPolicyIT extends PulsarITSupport { private String topicUri; @Override - protected Registry createCamelRegistry() throws Exception { - Registry registry = new SimpleRegistry(); - + protected void bindToRegistry(Registry registry) throws Exception { registerPulsarBeans(registry); - - return registry; } - private void registerPulsarBeans(final Registry registry) throws PulsarClientException { + private void registerPulsarBeans(Registry registry) throws PulsarClientException { PulsarClient pulsarClient = givenPulsarClient(); - AutoConfiguration autoConfiguration = new AutoConfiguration(null, null); - - registry.bind("pulsarClient", pulsarClient); - PulsarComponent comp = new PulsarComponent(context); - comp.setAutoConfiguration(autoConfiguration); - comp.setPulsarClient(pulsarClient); - registry.bind("pulsar", comp); + registerPulsarBeans(registry, pulsarClient, context); } @BeforeEach diff --git a/components/camel-pulsar/src/test/java/org/apache/camel/component/pulsar/integration/PulsarConsumerInAsynchronousIT.java b/components/camel-pulsar/src/test/java/org/apache/camel/component/pulsar/integration/PulsarConsumerInAsynchronousIT.java index f28573298e0..c48b2315cc0 100644 --- a/components/camel-pulsar/src/test/java/org/apache/camel/component/pulsar/integration/PulsarConsumerInAsynchronousIT.java +++ b/components/camel-pulsar/src/test/java/org/apache/camel/component/pulsar/integration/PulsarConsumerInAsynchronousIT.java @@ -26,12 +26,9 @@ import org.apache.camel.Processor; import org.apache.camel.RuntimeCamelException; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; -import org.apache.camel.component.pulsar.PulsarComponent; import org.apache.camel.component.pulsar.PulsarMessageReceipt; -import org.apache.camel.component.pulsar.utils.AutoConfiguration; import org.apache.camel.component.pulsar.utils.message.PulsarMessageHeaders; import org.apache.camel.spi.Registry; -import org.apache.camel.support.SimpleRegistry; import org.apache.pulsar.client.api.Producer; import org.apache.pulsar.client.api.PulsarClient; import org.apache.pulsar.client.api.PulsarClientException; @@ -123,24 +120,13 @@ public class PulsarConsumerInAsynchronousIT extends PulsarITSupport { } @Override - protected Registry createCamelRegistry() throws Exception { - SimpleRegistry registry = new SimpleRegistry(); - + protected void bindToRegistry(Registry registry) throws Exception { registerPulsarBeans(registry); - - return registry; } - private void registerPulsarBeans(SimpleRegistry registry) throws PulsarClientException { + private void registerPulsarBeans(Registry registry) throws PulsarClientException { PulsarClient pulsarClient = givenPulsarClient(); - AutoConfiguration autoConfiguration = new AutoConfiguration(null, null); - - registry.bind("pulsarClient", pulsarClient); - PulsarComponent comp = new PulsarComponent(context); - comp.setAutoConfiguration(autoConfiguration); - comp.setPulsarClient(pulsarClient); - registry.bind("pulsar", comp); - + registerPulsarBeans(registry, pulsarClient, context); } private PulsarClient givenPulsarClient() throws PulsarClientException { diff --git a/components/camel-pulsar/src/test/java/org/apache/camel/component/pulsar/integration/PulsarConsumerInIT.java b/components/camel-pulsar/src/test/java/org/apache/camel/component/pulsar/integration/PulsarConsumerInIT.java index 9233d98c994..55350638699 100644 --- a/components/camel-pulsar/src/test/java/org/apache/camel/component/pulsar/integration/PulsarConsumerInIT.java +++ b/components/camel-pulsar/src/test/java/org/apache/camel/component/pulsar/integration/PulsarConsumerInIT.java @@ -24,10 +24,7 @@ import org.apache.camel.Exchange; import org.apache.camel.Processor; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; -import org.apache.camel.component.pulsar.PulsarComponent; -import org.apache.camel.component.pulsar.utils.AutoConfiguration; import org.apache.camel.spi.Registry; -import org.apache.camel.support.SimpleRegistry; import org.apache.pulsar.client.api.Producer; import org.apache.pulsar.client.api.PulsarClient; import org.apache.pulsar.client.api.PulsarClientException; @@ -70,24 +67,14 @@ public class PulsarConsumerInIT extends PulsarITSupport { } @Override - protected Registry createCamelRegistry() throws Exception { - SimpleRegistry registry = new SimpleRegistry(); - + protected void bindToRegistry(Registry registry) throws Exception { registerPulsarBeans(registry); - - return registry; } - private void registerPulsarBeans(SimpleRegistry registry) throws PulsarClientException { + private void registerPulsarBeans(Registry registry) throws PulsarClientException { PulsarClient pulsarClient = givenPulsarClient(); - AutoConfiguration autoConfiguration = new AutoConfiguration(null, null); - - registry.bind("pulsarClient", pulsarClient); - PulsarComponent comp = new PulsarComponent(context); - comp.setAutoConfiguration(autoConfiguration); - comp.setPulsarClient(pulsarClient); - registry.bind("pulsar", comp); + registerPulsarBeans(registry, pulsarClient, context); } private PulsarClient givenPulsarClient() throws PulsarClientException { diff --git a/components/camel-pulsar/src/test/java/org/apache/camel/component/pulsar/integration/PulsarConsumerNegativeAcknowledgementIT.java b/components/camel-pulsar/src/test/java/org/apache/camel/component/pulsar/integration/PulsarConsumerNegativeAcknowledgementIT.java index f5bb919fe0b..703ae9b2993 100644 --- a/components/camel-pulsar/src/test/java/org/apache/camel/component/pulsar/integration/PulsarConsumerNegativeAcknowledgementIT.java +++ b/components/camel-pulsar/src/test/java/org/apache/camel/component/pulsar/integration/PulsarConsumerNegativeAcknowledgementIT.java @@ -27,7 +27,6 @@ import org.apache.camel.component.pulsar.PulsarMessageReceipt; import org.apache.camel.component.pulsar.utils.AutoConfiguration; import org.apache.camel.component.pulsar.utils.message.PulsarMessageHeaders; import org.apache.camel.spi.Registry; -import org.apache.camel.support.SimpleRegistry; import org.apache.pulsar.client.api.Producer; import org.apache.pulsar.client.api.PulsarClient; import org.apache.pulsar.client.api.PulsarClientException; @@ -64,15 +63,11 @@ public class PulsarConsumerNegativeAcknowledgementIT extends PulsarITSupport { } @Override - protected Registry createCamelRegistry() throws Exception { - Registry registry = new SimpleRegistry(); - + protected void bindToRegistry(Registry registry) throws Exception { registerPulsarBeans(registry); - - return registry; } - private void registerPulsarBeans(final Registry registry) throws PulsarClientException { + private void registerPulsarBeans(Registry registry) throws PulsarClientException { PulsarClient pulsarClient = givenPulsarClient(); AutoConfiguration autoConfiguration = new AutoConfiguration(null, null); diff --git a/components/camel-pulsar/src/test/java/org/apache/camel/component/pulsar/integration/PulsarConsumerNoAcknowledgementIT.java b/components/camel-pulsar/src/test/java/org/apache/camel/component/pulsar/integration/PulsarConsumerNoAcknowledgementIT.java index aed3a199f77..9f3f2092abb 100644 --- a/components/camel-pulsar/src/test/java/org/apache/camel/component/pulsar/integration/PulsarConsumerNoAcknowledgementIT.java +++ b/components/camel-pulsar/src/test/java/org/apache/camel/component/pulsar/integration/PulsarConsumerNoAcknowledgementIT.java @@ -25,7 +25,6 @@ import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.component.pulsar.PulsarComponent; import org.apache.camel.component.pulsar.utils.AutoConfiguration; import org.apache.camel.spi.Registry; -import org.apache.camel.support.SimpleRegistry; import org.apache.pulsar.client.api.Producer; import org.apache.pulsar.client.api.PulsarClient; import org.apache.pulsar.client.api.PulsarClientException; @@ -58,15 +57,11 @@ public class PulsarConsumerNoAcknowledgementIT extends PulsarITSupport { } @Override - protected Registry createCamelRegistry() throws Exception { - Registry registry = new SimpleRegistry(); - + protected void bindToRegistry(Registry registry) throws Exception { registerPulsarBeans(registry); - - return registry; } - private void registerPulsarBeans(final Registry registry) throws PulsarClientException { + private void registerPulsarBeans(Registry registry) throws PulsarClientException { PulsarClient pulsarClient = givenPulsarClient(); AutoConfiguration autoConfiguration = new AutoConfiguration(null, null); diff --git a/components/camel-pulsar/src/test/java/org/apache/camel/component/pulsar/integration/PulsarConsumerPatternInIT.java b/components/camel-pulsar/src/test/java/org/apache/camel/component/pulsar/integration/PulsarConsumerPatternInIT.java index 9f298cd2835..b564d868b1b 100644 --- a/components/camel-pulsar/src/test/java/org/apache/camel/component/pulsar/integration/PulsarConsumerPatternInIT.java +++ b/components/camel-pulsar/src/test/java/org/apache/camel/component/pulsar/integration/PulsarConsumerPatternInIT.java @@ -22,10 +22,7 @@ import org.apache.camel.Endpoint; import org.apache.camel.EndpointInject; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; -import org.apache.camel.component.pulsar.PulsarComponent; -import org.apache.camel.component.pulsar.utils.AutoConfiguration; import org.apache.camel.spi.Registry; -import org.apache.camel.support.SimpleRegistry; import org.apache.pulsar.client.admin.PulsarAdmin; import org.apache.pulsar.client.admin.internal.PulsarAdminBuilderImpl; import org.apache.pulsar.client.api.Producer; @@ -67,23 +64,13 @@ public class PulsarConsumerPatternInIT extends PulsarITSupport { } @Override - protected Registry createCamelRegistry() throws Exception { - SimpleRegistry registry = new SimpleRegistry(); - + protected void bindToRegistry(Registry registry) throws Exception { registerPulsarBeans(registry); - - return registry; } - private void registerPulsarBeans(SimpleRegistry registry) throws PulsarClientException { + private void registerPulsarBeans(Registry registry) throws PulsarClientException { PulsarClient pulsarClient = givenPulsarClient(); - AutoConfiguration autoConfiguration = new AutoConfiguration(null, null); - - registry.bind("pulsarClient", pulsarClient); - PulsarComponent comp = new PulsarComponent(context); - comp.setAutoConfiguration(autoConfiguration); - comp.setPulsarClient(pulsarClient); - registry.bind("pulsar", comp); + registerPulsarBeans(registry, pulsarClient, context); } private PulsarClient givenPulsarClient() throws PulsarClientException { diff --git a/components/camel-pulsar/src/test/java/org/apache/camel/component/pulsar/integration/PulsarConsumerReadCompactedIT.java b/components/camel-pulsar/src/test/java/org/apache/camel/component/pulsar/integration/PulsarConsumerReadCompactedIT.java index bed5c4faea0..69362795aa0 100644 --- a/components/camel-pulsar/src/test/java/org/apache/camel/component/pulsar/integration/PulsarConsumerReadCompactedIT.java +++ b/components/camel-pulsar/src/test/java/org/apache/camel/component/pulsar/integration/PulsarConsumerReadCompactedIT.java @@ -23,12 +23,9 @@ import org.apache.camel.Endpoint; import org.apache.camel.EndpointInject; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; -import org.apache.camel.component.pulsar.PulsarComponent; import org.apache.camel.component.pulsar.PulsarMessageReceipt; -import org.apache.camel.component.pulsar.utils.AutoConfiguration; import org.apache.camel.component.pulsar.utils.message.PulsarMessageHeaders; import org.apache.camel.spi.Registry; -import org.apache.camel.support.SimpleRegistry; import org.apache.camel.test.infra.common.TestUtils; import org.apache.pulsar.client.admin.LongRunningProcessStatus; import org.apache.pulsar.client.admin.PulsarAdmin; @@ -81,23 +78,13 @@ public class PulsarConsumerReadCompactedIT extends PulsarITSupport { } @Override - protected Registry createCamelRegistry() throws Exception { - Registry registry = new SimpleRegistry(); - + protected void bindToRegistry(Registry registry) throws Exception { registerPulsarBeans(registry); - - return registry; } - private void registerPulsarBeans(final Registry registry) throws PulsarClientException { + private void registerPulsarBeans(Registry registry) throws PulsarClientException { PulsarClient pulsarClient = givenPulsarClient(); - AutoConfiguration autoConfiguration = new AutoConfiguration(null, null); - - registry.bind("pulsarClient", pulsarClient); - PulsarComponent comp = new PulsarComponent(context); - comp.setAutoConfiguration(autoConfiguration); - comp.setPulsarClient(pulsarClient); - registry.bind("pulsar", comp); + registerPulsarBeans(registry, pulsarClient, context); } private PulsarClient givenPulsarClient() throws PulsarClientException { diff --git a/components/camel-pulsar/src/test/java/org/apache/camel/component/pulsar/integration/PulsarCustomMessageReceiptIT.java b/components/camel-pulsar/src/test/java/org/apache/camel/component/pulsar/integration/PulsarCustomMessageReceiptIT.java index 410a1c62300..3d4a8d66112 100644 --- a/components/camel-pulsar/src/test/java/org/apache/camel/component/pulsar/integration/PulsarCustomMessageReceiptIT.java +++ b/components/camel-pulsar/src/test/java/org/apache/camel/component/pulsar/integration/PulsarCustomMessageReceiptIT.java @@ -28,7 +28,6 @@ import org.apache.camel.component.pulsar.PulsarMessageReceiptFactory; import org.apache.camel.component.pulsar.utils.AutoConfiguration; import org.apache.camel.component.pulsar.utils.message.PulsarMessageHeaders; import org.apache.camel.spi.Registry; -import org.apache.camel.support.SimpleRegistry; import org.apache.pulsar.client.api.Producer; import org.apache.pulsar.client.api.PulsarClient; import org.apache.pulsar.client.api.PulsarClientException; @@ -73,15 +72,11 @@ public class PulsarCustomMessageReceiptIT extends PulsarITSupport { } @Override - protected Registry createCamelRegistry() throws Exception { - Registry registry = new SimpleRegistry(); - + protected void bindToRegistry(Registry registry) throws Exception { registerPulsarBeans(registry); - - return registry; } - private void registerPulsarBeans(final Registry registry) throws PulsarClientException { + private void registerPulsarBeans(Registry registry) throws PulsarClientException { PulsarClient pulsarClient = givenPulsarClient(); AutoConfiguration autoConfiguration = new AutoConfiguration(null, null); diff --git a/components/camel-pulsar/src/test/java/org/apache/camel/component/pulsar/integration/PulsarITSupport.java b/components/camel-pulsar/src/test/java/org/apache/camel/component/pulsar/integration/PulsarITSupport.java index 1187d1a83cb..ae2656dc5d1 100644 --- a/components/camel-pulsar/src/test/java/org/apache/camel/component/pulsar/integration/PulsarITSupport.java +++ b/components/camel-pulsar/src/test/java/org/apache/camel/component/pulsar/integration/PulsarITSupport.java @@ -16,9 +16,14 @@ */ package org.apache.camel.component.pulsar.integration; +import org.apache.camel.CamelContext; +import org.apache.camel.component.pulsar.PulsarComponent; +import org.apache.camel.component.pulsar.utils.AutoConfiguration; +import org.apache.camel.spi.Registry; import org.apache.camel.test.infra.pulsar.services.PulsarService; import org.apache.camel.test.infra.pulsar.services.PulsarServiceFactory; import org.apache.camel.test.junit5.CamelTestSupport; +import org.apache.pulsar.client.api.PulsarClient; import org.junit.jupiter.api.extension.RegisterExtension; public class PulsarITSupport extends CamelTestSupport { @@ -32,4 +37,14 @@ public class PulsarITSupport extends CamelTestSupport { public String getPulsarAdminUrl() { return service.getPulsarAdminUrl(); } + + protected static void registerPulsarBeans(Registry registry, PulsarClient pulsarClient, CamelContext context) { + AutoConfiguration autoConfiguration = new AutoConfiguration(null, null); + + registry.bind("pulsarClient", pulsarClient); + PulsarComponent comp = new PulsarComponent(context); + comp.setAutoConfiguration(autoConfiguration); + comp.setPulsarClient(pulsarClient); + registry.bind("pulsar", comp); + } } diff --git a/components/camel-pulsar/src/test/java/org/apache/camel/component/pulsar/integration/PulsarProducerHeadersInIT.java b/components/camel-pulsar/src/test/java/org/apache/camel/component/pulsar/integration/PulsarProducerHeadersInIT.java index 1046b1d5ef7..cd553600084 100644 --- a/components/camel-pulsar/src/test/java/org/apache/camel/component/pulsar/integration/PulsarProducerHeadersInIT.java +++ b/components/camel-pulsar/src/test/java/org/apache/camel/component/pulsar/integration/PulsarProducerHeadersInIT.java @@ -26,11 +26,8 @@ import org.apache.camel.Produce; import org.apache.camel.ProducerTemplate; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; -import org.apache.camel.component.pulsar.PulsarComponent; -import org.apache.camel.component.pulsar.utils.AutoConfiguration; import org.apache.camel.component.pulsar.utils.message.PulsarMessageHeaders; import org.apache.camel.spi.Registry; -import org.apache.camel.support.SimpleRegistry; import org.apache.pulsar.client.api.PulsarClient; import org.apache.pulsar.client.api.PulsarClientException; import org.apache.pulsar.client.impl.ClientBuilderImpl; @@ -68,23 +65,13 @@ public class PulsarProducerHeadersInIT extends PulsarITSupport { } @Override - protected Registry createCamelRegistry() throws Exception { - Registry registry = new SimpleRegistry(); - + protected void bindToRegistry(Registry registry) throws Exception { registerPulsarBeans(registry); - - return registry; } - private void registerPulsarBeans(final Registry registry) throws PulsarClientException { + private void registerPulsarBeans(Registry registry) throws PulsarClientException { PulsarClient pulsarClient = givenPulsarClient(); - AutoConfiguration autoConfiguration = new AutoConfiguration(null, null); - - registry.bind("pulsarClient", pulsarClient); - PulsarComponent comp = new PulsarComponent(context); - comp.setAutoConfiguration(autoConfiguration); - comp.setPulsarClient(pulsarClient); - registry.bind("pulsar", comp); + registerPulsarBeans(registry, pulsarClient, context); } private PulsarClient givenPulsarClient() throws PulsarClientException { diff --git a/components/camel-pulsar/src/test/java/org/apache/camel/component/pulsar/integration/PulsarProducerInIT.java b/components/camel-pulsar/src/test/java/org/apache/camel/component/pulsar/integration/PulsarProducerInIT.java index 29bc8f83b28..678606bd5f2 100644 --- a/components/camel-pulsar/src/test/java/org/apache/camel/component/pulsar/integration/PulsarProducerInIT.java +++ b/components/camel-pulsar/src/test/java/org/apache/camel/component/pulsar/integration/PulsarProducerInIT.java @@ -25,10 +25,7 @@ import org.apache.camel.Produce; import org.apache.camel.ProducerTemplate; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; -import org.apache.camel.component.pulsar.PulsarComponent; -import org.apache.camel.component.pulsar.utils.AutoConfiguration; import org.apache.camel.spi.Registry; -import org.apache.camel.support.SimpleRegistry; import org.apache.commons.lang3.exception.ExceptionUtils; import org.apache.pulsar.client.api.PulsarClient; import org.apache.pulsar.client.api.PulsarClientException; @@ -82,24 +79,14 @@ public class PulsarProducerInIT extends PulsarITSupport { } @Override - protected Registry createCamelRegistry() throws Exception { - SimpleRegistry registry = new SimpleRegistry(); - + protected void bindToRegistry(Registry registry) throws Exception { registerPulsarBeans(registry); - - return registry; } - private void registerPulsarBeans(SimpleRegistry registry) throws PulsarClientException { + private void registerPulsarBeans(Registry registry) throws PulsarClientException { PulsarClient pulsarClient = givenPulsarClient(); - AutoConfiguration autoConfiguration = new AutoConfiguration(null, null); - - registry.bind("pulsarClient", pulsarClient); - PulsarComponent comp = new PulsarComponent(context); - comp.setAutoConfiguration(autoConfiguration); - comp.setPulsarClient(pulsarClient); - registry.bind("pulsar", comp); + registerPulsarBeans(registry, pulsarClient, context); } private PulsarClient givenPulsarClient() throws PulsarClientException { diff --git a/components/camel-pulsar/src/test/java/org/apache/camel/component/pulsar/integration/PulsarProducerUndefinedProducerNameInIT.java b/components/camel-pulsar/src/test/java/org/apache/camel/component/pulsar/integration/PulsarProducerUndefinedProducerNameInIT.java index ceef570a080..867ebb366b3 100644 --- a/components/camel-pulsar/src/test/java/org/apache/camel/component/pulsar/integration/PulsarProducerUndefinedProducerNameInIT.java +++ b/components/camel-pulsar/src/test/java/org/apache/camel/component/pulsar/integration/PulsarProducerUndefinedProducerNameInIT.java @@ -24,10 +24,7 @@ import org.apache.camel.Produce; import org.apache.camel.ProducerTemplate; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; -import org.apache.camel.component.pulsar.PulsarComponent; -import org.apache.camel.component.pulsar.utils.AutoConfiguration; import org.apache.camel.spi.Registry; -import org.apache.camel.support.SimpleRegistry; import org.apache.pulsar.client.api.PulsarClient; import org.apache.pulsar.client.api.PulsarClientException; import org.apache.pulsar.client.impl.ClientBuilderImpl; @@ -72,23 +69,14 @@ public class PulsarProducerUndefinedProducerNameInIT extends PulsarITSupport { } @Override - protected Registry createCamelRegistry() throws Exception { - Registry registry = new SimpleRegistry(); - + protected void bindToRegistry(Registry registry) throws Exception { registerPulsarBeans(registry); - - return registry; } private void registerPulsarBeans(Registry registry) throws PulsarClientException { PulsarClient pulsarClient = givenPulsarClient(); - AutoConfiguration autoConfiguration = new AutoConfiguration(null, null); - registry.bind("pulsarClient", pulsarClient); - PulsarComponent comp = new PulsarComponent(context); - comp.setAutoConfiguration(autoConfiguration); - comp.setPulsarClient(pulsarClient); - registry.bind("pulsar", comp); + registerPulsarBeans(registry, pulsarClient, context); } private PulsarClient givenPulsarClient() throws PulsarClientException { diff --git a/components/camel-pulsar/src/test/java/org/apache/camel/component/pulsar/integration/PulsarSharedSubscriptionMessageDistributionIT.java b/components/camel-pulsar/src/test/java/org/apache/camel/component/pulsar/integration/PulsarSharedSubscriptionMessageDistributionIT.java index 4ce5ed680e6..5b9dc15af74 100644 --- a/components/camel-pulsar/src/test/java/org/apache/camel/component/pulsar/integration/PulsarSharedSubscriptionMessageDistributionIT.java +++ b/components/camel-pulsar/src/test/java/org/apache/camel/component/pulsar/integration/PulsarSharedSubscriptionMessageDistributionIT.java @@ -24,10 +24,7 @@ import org.apache.camel.Exchange; import org.apache.camel.Processor; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; -import org.apache.camel.component.pulsar.PulsarComponent; -import org.apache.camel.component.pulsar.utils.AutoConfiguration; import org.apache.camel.spi.Registry; -import org.apache.camel.support.SimpleRegistry; import org.apache.pulsar.client.api.Producer; import org.apache.pulsar.client.api.PulsarClient; import org.apache.pulsar.client.api.PulsarClientException; @@ -89,23 +86,13 @@ public class PulsarSharedSubscriptionMessageDistributionIT extends PulsarITSuppo } @Override - protected Registry createCamelRegistry() throws Exception { - SimpleRegistry registry = new SimpleRegistry(); - + protected void bindToRegistry(Registry registry) throws Exception { registerPulsarBeans(registry); - - return registry; } - private void registerPulsarBeans(SimpleRegistry registry) throws PulsarClientException { + private void registerPulsarBeans(Registry registry) throws PulsarClientException { PulsarClient pulsarClient = concurrentPulsarClient(); - AutoConfiguration autoConfiguration = new AutoConfiguration(null, null); - - registry.bind("pulsarClient", pulsarClient); - PulsarComponent comp = new PulsarComponent(context); - comp.setAutoConfiguration(autoConfiguration); - comp.setPulsarClient(pulsarClient); - registry.bind("pulsar", comp); + registerPulsarBeans(registry, pulsarClient, context); } diff --git a/components/camel-pulsar/src/test/java/org/apache/camel/component/pulsar/integration/PulsarSuspendRouteIT.java b/components/camel-pulsar/src/test/java/org/apache/camel/component/pulsar/integration/PulsarSuspendRouteIT.java index f466e7bdde2..db810d9e69a 100644 --- a/components/camel-pulsar/src/test/java/org/apache/camel/component/pulsar/integration/PulsarSuspendRouteIT.java +++ b/components/camel-pulsar/src/test/java/org/apache/camel/component/pulsar/integration/PulsarSuspendRouteIT.java @@ -26,12 +26,9 @@ import org.apache.camel.Endpoint; import org.apache.camel.EndpointInject; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; -import org.apache.camel.component.pulsar.PulsarComponent; import org.apache.camel.component.pulsar.PulsarMessageReceipt; -import org.apache.camel.component.pulsar.utils.AutoConfiguration; import org.apache.camel.component.pulsar.utils.message.PulsarMessageHeaders; import org.apache.camel.spi.Registry; -import org.apache.camel.support.SimpleRegistry; import org.apache.pulsar.client.api.MessageId; import org.apache.pulsar.client.api.Producer; import org.apache.pulsar.client.api.PulsarClient; @@ -81,21 +78,13 @@ public class PulsarSuspendRouteIT extends PulsarITSupport { } @Override - protected Registry createCamelRegistry() throws Exception { - SimpleRegistry registry = new SimpleRegistry(); + protected void bindToRegistry(Registry registry) throws Exception { registerPulsarBeans(registry); - return registry; } - private void registerPulsarBeans(SimpleRegistry registry) throws PulsarClientException { + private void registerPulsarBeans(Registry registry) throws PulsarClientException { PulsarClient pulsarClient = setUpPulsarClient(); - AutoConfiguration autoConfiguration = new AutoConfiguration(null, null); - - registry.bind("pulsarClient", pulsarClient); - PulsarComponent comp = new PulsarComponent(context); - comp.setAutoConfiguration(autoConfiguration); - comp.setPulsarClient(pulsarClient); - registry.bind("pulsar", comp); + registerPulsarBeans(registry, pulsarClient, context); } private PulsarClient setUpPulsarClient() throws PulsarClientException { diff --git a/components/camel-spring-batch/src/test/java/org/apache/camel/component/spring/batch/SpringBatchEndpointTest.java b/components/camel-spring-batch/src/test/java/org/apache/camel/component/spring/batch/SpringBatchEndpointTest.java index 7ffed647595..52508a003bf 100644 --- a/components/camel-spring-batch/src/test/java/org/apache/camel/component/spring/batch/SpringBatchEndpointTest.java +++ b/components/camel-spring-batch/src/test/java/org/apache/camel/component/spring/batch/SpringBatchEndpointTest.java @@ -94,14 +94,12 @@ public class SpringBatchEndpointTest extends CamelTestSupport { } @Override - public Registry createCamelRegistry() throws Exception { - SimpleRegistry registry = new SimpleRegistry(); + protected void bindToRegistry(Registry registry) { registry.bind("jobLauncher", jobLauncher); registry.bind("alternativeJobLauncher", alternativeJobLauncher); registry.bind("mockJob", job); registry.bind("dynamicMockjob", dynamicMockjob); registry.bind("jobRegistry", jobRegistry); - return registry; } // Tests diff --git a/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/RedisHashTest.java b/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/RedisHashTest.java index f817aca610b..023c0cd8af0 100644 --- a/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/RedisHashTest.java +++ b/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/RedisHashTest.java @@ -25,7 +25,6 @@ import java.util.Map; import java.util.Set; import org.apache.camel.spi.Registry; -import org.apache.camel.support.SimpleRegistry; import org.junit.jupiter.api.Test; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoSettings; @@ -48,12 +47,10 @@ public class RedisHashTest extends RedisTestSupport { private HashOperations<String, String, String> hashOperations; @Override - protected Registry createCamelRegistry() throws Exception { + protected void bindToRegistry(Registry registry) { when(redisTemplate.<String, String> opsForHash()).thenReturn(hashOperations); - Registry registry = new SimpleRegistry(); registry.bind("redisTemplate", redisTemplate); - return registry; } @Test diff --git a/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/RedisListTest.java b/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/RedisListTest.java index a30eea869df..4795479ed56 100644 --- a/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/RedisListTest.java +++ b/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/RedisListTest.java @@ -21,7 +21,6 @@ import java.util.List; import java.util.concurrent.TimeUnit; import org.apache.camel.spi.Registry; -import org.apache.camel.support.SimpleRegistry; import org.junit.jupiter.api.Test; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoSettings; @@ -44,12 +43,10 @@ public class RedisListTest extends RedisTestSupport { private ListOperations<String, String> listOperations; @Override - protected Registry createCamelRegistry() throws Exception { + protected void bindToRegistry(Registry registry) throws Exception { when(redisTemplate.opsForList()).thenReturn(listOperations); - Registry registry = new SimpleRegistry(); registry.bind("redisTemplate", redisTemplate); - return registry; } @Test diff --git a/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/RedisRemoveEndpointTest.java b/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/RedisRemoveEndpointTest.java index 79b0414c987..ceb4f20afd6 100644 --- a/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/RedisRemoveEndpointTest.java +++ b/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/RedisRemoveEndpointTest.java @@ -18,7 +18,6 @@ package org.apache.camel.component.redis; import org.apache.camel.Endpoint; import org.apache.camel.spi.Registry; -import org.apache.camel.support.SimpleRegistry; import org.apache.camel.test.junit5.CamelTestSupport; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; @@ -28,11 +27,9 @@ import org.springframework.data.redis.core.RedisTemplate; public class RedisRemoveEndpointTest extends CamelTestSupport { @Override - protected Registry createCamelRegistry() throws Exception { - Registry registry = new SimpleRegistry(); + protected void bindToRegistry(Registry registry) throws Exception { redisTemplate = new RedisTemplate<>(); registry.bind("redisTemplate", redisTemplate); - return registry; } @Mock diff --git a/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/RedisRemoveRouteTest.java b/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/RedisRemoveRouteTest.java index ccc4d417aec..98f8e3aad71 100644 --- a/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/RedisRemoveRouteTest.java +++ b/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/RedisRemoveRouteTest.java @@ -18,7 +18,6 @@ package org.apache.camel.component.redis; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.spi.Registry; -import org.apache.camel.support.SimpleRegistry; import org.apache.camel.test.junit5.CamelTestSupport; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; @@ -28,12 +27,10 @@ import org.springframework.data.redis.core.RedisTemplate; public class RedisRemoveRouteTest extends CamelTestSupport { @Override - protected Registry createCamelRegistry() throws Exception { - Registry registry = new SimpleRegistry(); + protected void bindToRegistry(Registry registry) throws Exception { redisTemplate = new RedisTemplate<>(); registry.bind("redisTemplate", redisTemplate); - return registry; } @Mock diff --git a/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/RedisSetTest.java b/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/RedisSetTest.java index 7bc5d8c319c..6ae46df2605 100644 --- a/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/RedisSetTest.java +++ b/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/RedisSetTest.java @@ -20,7 +20,6 @@ import java.util.HashSet; import java.util.Set; import org.apache.camel.spi.Registry; -import org.apache.camel.support.SimpleRegistry; import org.junit.jupiter.api.Test; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoSettings; @@ -43,12 +42,10 @@ public class RedisSetTest extends RedisTestSupport { private SetOperations<String, String> setOperations; @Override - protected Registry createCamelRegistry() throws Exception { + protected void bindToRegistry(Registry registry) throws Exception { when(redisTemplate.opsForSet()).thenReturn(setOperations); - Registry registry = new SimpleRegistry(); registry.bind("redisTemplate", redisTemplate); - return registry; } @Test diff --git a/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/RedisSortedSetTest.java b/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/RedisSortedSetTest.java index 2d76bf7c9f0..c49be16f826 100644 --- a/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/RedisSortedSetTest.java +++ b/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/RedisSortedSetTest.java @@ -20,7 +20,6 @@ import java.util.HashSet; import java.util.Set; import org.apache.camel.spi.Registry; -import org.apache.camel.support.SimpleRegistry; import org.junit.jupiter.api.Test; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoSettings; @@ -45,12 +44,10 @@ public class RedisSortedSetTest extends RedisTestSupport { private ZSetOperations<String, String> zSetOperations; @Override - protected Registry createCamelRegistry() throws Exception { + protected void bindToRegistry(Registry registry) throws Exception { when(redisTemplate.opsForZSet()).thenReturn(zSetOperations); - Registry registry = new SimpleRegistry(); registry.bind("redisTemplate", redisTemplate); - return registry; } @Test diff --git a/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/RedisStringTest.java b/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/RedisStringTest.java index 8ac68226189..e9d7767b633 100644 --- a/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/RedisStringTest.java +++ b/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/RedisStringTest.java @@ -23,7 +23,6 @@ import java.util.Map; import java.util.concurrent.TimeUnit; import org.apache.camel.spi.Registry; -import org.apache.camel.support.SimpleRegistry; import org.junit.jupiter.api.Test; import org.mockito.ArgumentMatchers; import org.mockito.Mock; @@ -45,12 +44,10 @@ public class RedisStringTest extends RedisTestSupport { private ValueOperations<String, String> valueOperations; @Override - protected Registry createCamelRegistry() throws Exception { + protected void bindToRegistry(Registry registry) throws Exception { when(redisTemplate.opsForValue()).thenReturn(valueOperations); - Registry registry = new SimpleRegistry(); registry.bind("redisTemplate", redisTemplate); - return registry; } @Test diff --git a/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/integration/RedisConsumerManualIT.java b/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/integration/RedisConsumerManualIT.java index 31cec615360..521bddbbbf5 100644 --- a/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/integration/RedisConsumerManualIT.java +++ b/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/integration/RedisConsumerManualIT.java @@ -21,7 +21,6 @@ import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.component.redis.RedisConstants; import org.apache.camel.component.redis.RedisTestSupport; import org.apache.camel.spi.Registry; -import org.apache.camel.support.SimpleRegistry; import org.apache.camel.test.infra.redis.services.RedisService; import org.apache.camel.test.infra.redis.services.RedisServiceFactory; import org.junit.jupiter.api.BeforeAll; @@ -54,16 +53,13 @@ public class RedisConsumerManualIT extends RedisTestSupport { } @Override - protected Registry createCamelRegistry() throws Exception { - Registry registry = new SimpleRegistry(); - + protected void bindToRegistry(Registry registry) throws Exception { redisTemplate = new RedisTemplate<>(); redisTemplate.setConnectionFactory(jedisConnectionFactory); redisTemplate.afterPropertiesSet(); registry.bind("redisTemplate", redisTemplate); registry.bind("listenerContainer", LISTENER_CONTAINER); - return registry; } @Override diff --git a/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/integration/RedisProducerManualIT.java b/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/integration/RedisProducerManualIT.java index f66d5c6c392..6a15d127b7c 100644 --- a/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/integration/RedisProducerManualIT.java +++ b/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/integration/RedisProducerManualIT.java @@ -19,7 +19,6 @@ package org.apache.camel.component.redis.integration; import org.apache.camel.component.redis.RedisConstants; import org.apache.camel.component.redis.RedisTestSupport; import org.apache.camel.spi.Registry; -import org.apache.camel.support.SimpleRegistry; import org.apache.camel.test.infra.redis.services.RedisService; import org.apache.camel.test.infra.redis.services.RedisServiceFactory; import org.junit.jupiter.api.BeforeAll; @@ -48,14 +47,12 @@ public class RedisProducerManualIT extends RedisTestSupport { } @Override - protected Registry createCamelRegistry() throws Exception { - Registry registry = new SimpleRegistry(); + protected void bindToRegistry(Registry registry) throws Exception { redisTemplate = new RedisTemplate<>(); redisTemplate.setConnectionFactory(connectionFactory); redisTemplate.afterPropertiesSet(); registry.bind("redisTemplate", redisTemplate); - return registry; } @Test diff --git a/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/processor/idempotent/RedisStringIdempotentRepositoryManualIT.java b/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/processor/idempotent/RedisStringIdempotentRepositoryManualIT.java index e007ba287f0..7faa27efdd0 100644 --- a/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/processor/idempotent/RedisStringIdempotentRepositoryManualIT.java +++ b/components/camel-spring-redis/src/test/java/org/apache/camel/component/redis/processor/idempotent/RedisStringIdempotentRepositoryManualIT.java @@ -25,7 +25,6 @@ import org.apache.camel.ProducerTemplate; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.spi.Registry; -import org.apache.camel.support.SimpleRegistry; import org.apache.camel.test.junit5.CamelTestSupport; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @@ -57,14 +56,12 @@ public class RedisStringIdempotentRepositoryManualIT extends CamelTestSupport { } @Override - protected Registry createCamelRegistry() throws Exception { - SimpleRegistry registry = new SimpleRegistry(); + protected void bindToRegistry(Registry registry) throws Exception { redisTemplate = new RedisTemplate<>(); redisTemplate.setConnectionFactory(CONNECTION_FACTORY); redisTemplate.afterPropertiesSet(); registry.bind("redisTemplate", redisTemplate); - return registry; } @Override diff --git a/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/ConsumerBreadcrumbIdTest.java b/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/ConsumerBreadcrumbIdTest.java index 73d66504e88..f99a099e030 100644 --- a/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/ConsumerBreadcrumbIdTest.java +++ b/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/ConsumerBreadcrumbIdTest.java @@ -23,7 +23,6 @@ import org.apache.camel.component.spring.ws.bean.CamelEndpointMapping; import org.apache.camel.component.spring.ws.jaxb.QuoteRequest; import org.apache.camel.model.dataformat.JaxbDataFormat; import org.apache.camel.spi.Registry; -import org.apache.camel.support.SimpleRegistry; import org.apache.camel.test.junit5.CamelTestSupport; import org.apache.camel.test.spring.junit5.CamelSpringTest; import org.junit.jupiter.api.BeforeEach; @@ -55,11 +54,9 @@ public class ConsumerBreadcrumbIdTest extends CamelTestSupport { } @Override - protected Registry createCamelRegistry() throws Exception { - Registry registry = new SimpleRegistry(); + protected void bindToRegistry(Registry registry) throws Exception { registry.bind("endpointMapping", this.endpointMapping); registry.bind("webServiceTemplate", this.webServiceTemplate); - return registry; } @Test diff --git a/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/ConsumerExceptionPropagationRouteTest.java b/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/ConsumerExceptionPropagationRouteTest.java index 22dfbd7e82e..f1e3f16b60f 100644 --- a/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/ConsumerExceptionPropagationRouteTest.java +++ b/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/ConsumerExceptionPropagationRouteTest.java @@ -25,7 +25,6 @@ import org.apache.camel.Endpoint; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.spring.ws.bean.CamelEndpointMapping; import org.apache.camel.spi.Registry; -import org.apache.camel.support.SimpleRegistry; import org.apache.camel.test.junit5.CamelTestSupport; import org.apache.camel.test.spring.junit5.CamelSpringTest; import org.junit.jupiter.api.BeforeEach; @@ -69,10 +68,8 @@ public class ConsumerExceptionPropagationRouteTest extends CamelTestSupport { } @Override - protected Registry createCamelRegistry() throws Exception { - Registry registry = new SimpleRegistry(); + protected void bindToRegistry(Registry registry) throws Exception { registry.bind("endpointMapping", this.endpointMapping); - return registry; } @Disabled("For now getEndpointUri does not return the initial uri. Info like the endpoint scheme is lost") diff --git a/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/ConsumerMarshallingRouteTest.java b/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/ConsumerMarshallingRouteTest.java index 3fed7dcb71a..fcfa65fcc23 100644 --- a/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/ConsumerMarshallingRouteTest.java +++ b/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/ConsumerMarshallingRouteTest.java @@ -23,7 +23,6 @@ import org.apache.camel.component.spring.ws.jaxb.QuoteRequest; import org.apache.camel.component.spring.ws.jaxb.QuoteResponse; import org.apache.camel.model.dataformat.JaxbDataFormat; import org.apache.camel.spi.Registry; -import org.apache.camel.support.SimpleRegistry; import org.apache.camel.test.junit5.CamelTestSupport; import org.apache.camel.test.spring.junit5.CamelSpringTest; import org.junit.jupiter.api.BeforeEach; @@ -56,11 +55,9 @@ public class ConsumerMarshallingRouteTest extends CamelTestSupport { } @Override - protected Registry createCamelRegistry() throws Exception { - Registry registry = new SimpleRegistry(); + protected void bindToRegistry(Registry registry) throws Exception { registry.bind("endpointMapping", this.endpointMapping); registry.bind("webServiceTemplate", this.webServiceTemplate); - return registry; } @Test diff --git a/components/camel-spring-xml/src/test/java/org/apache/camel/spring/SpringMDCTransactedTest.java b/components/camel-spring-xml/src/test/java/org/apache/camel/spring/SpringMDCTransactedTest.java index 3e7759ea95b..a7d46980294 100644 --- a/components/camel-spring-xml/src/test/java/org/apache/camel/spring/SpringMDCTransactedTest.java +++ b/components/camel-spring-xml/src/test/java/org/apache/camel/spring/SpringMDCTransactedTest.java @@ -21,7 +21,6 @@ import org.apache.camel.Processor; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.spi.Registry; -import org.apache.camel.support.SimpleRegistry; import org.apache.camel.test.junit5.CamelTestSupport; import org.junit.jupiter.api.Test; import org.slf4j.MDC; @@ -31,10 +30,10 @@ import static org.junit.jupiter.api.Assertions.assertEquals; public class SpringMDCTransactedTest extends CamelTestSupport { @Override - protected Registry createCamelRegistry() throws Exception { - Registry result = new SimpleRegistry(); - result.bind("NOOP-TX", new NoopPlatformTransactionManager()); - return result; + protected void bindToRegistry(Registry registry) throws Exception { + super.bindToRegistry(registry); + + registry.bind("NOOP-TX", new NoopPlatformTransactionManager()); } @Test diff --git a/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlDataSourceRefTest.java b/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlDataSourceRefTest.java index 8b9923594da..584466b6bf7 100644 --- a/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlDataSourceRefTest.java +++ b/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlDataSourceRefTest.java @@ -22,7 +22,6 @@ import java.util.Map; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.spi.Registry; -import org.apache.camel.support.SimpleRegistry; import org.apache.camel.test.junit5.CamelTestSupport; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Test; @@ -38,8 +37,7 @@ public class SqlDataSourceRefTest extends CamelTestSupport { private EmbeddedDatabase db; @Override - protected Registry createCamelRegistry() { - SimpleRegistry reg = new SimpleRegistry(); + protected void bindToRegistry(Registry registry) throws Exception { // START SNIPPET: e2 // this is the database we create with some initial data for our unit test @@ -49,9 +47,7 @@ public class SqlDataSourceRefTest extends CamelTestSupport { .addScript("sql/createAndPopulateDatabase.sql").build(); // END SNIPPET: e2 - reg.bind("jdbc/myDataSource", db); - - return reg; + registry.bind("jdbc/myDataSource", db); } @Test diff --git a/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlDataSourceTest.java b/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlDataSourceTest.java index 2cab1ffba3f..fd2713d9575 100644 --- a/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlDataSourceTest.java +++ b/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlDataSourceTest.java @@ -22,7 +22,6 @@ import java.util.Map; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.spi.Registry; -import org.apache.camel.support.SimpleRegistry; import org.apache.camel.test.junit5.CamelTestSupport; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Test; @@ -38,8 +37,7 @@ public class SqlDataSourceTest extends CamelTestSupport { private EmbeddedDatabase db; @Override - protected Registry createCamelRegistry() { - Registry reg = new SimpleRegistry(); + protected void bindToRegistry(Registry registry) throws Exception { // this is the database we create with some initial data for our unit test db = new EmbeddedDatabaseBuilder() @@ -47,9 +45,7 @@ public class SqlDataSourceTest extends CamelTestSupport { .setType(EmbeddedDatabaseType.H2) .addScript("sql/createAndPopulateDatabase.sql").build(); - reg.bind("dataSource", db); - - return reg; + registry.bind("dataSource", db); } @Test diff --git a/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlEndpointLikeTest.java b/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlEndpointLikeTest.java index cdd8ef766dc..f0f8fa68a13 100644 --- a/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlEndpointLikeTest.java +++ b/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlEndpointLikeTest.java @@ -19,7 +19,6 @@ package org.apache.camel.component.sql; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.spi.Registry; -import org.apache.camel.support.SimpleRegistry; import org.apache.camel.test.junit5.CamelTestSupport; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Test; @@ -42,15 +41,13 @@ public class SqlEndpointLikeTest extends CamelTestSupport { } @Override - protected Registry createCamelRegistry() { - Registry reg = new SimpleRegistry(); + protected void bindToRegistry(Registry registry) throws Exception { // this is the database we create with some initial data for our unit test db = new EmbeddedDatabaseBuilder() .setName(getClass().getSimpleName()) .setType(EmbeddedDatabaseType.H2) .addScript("sql/createAndPopulateDatabase.sql").build(); - reg.bind("jdbc/myDataSource", db); - return reg; + registry.bind("jdbc/myDataSource", db); } @Override diff --git a/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlTransactedRouteTest.java b/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlTransactedRouteTest.java index 17f91600599..bf3ade1e568 100644 --- a/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlTransactedRouteTest.java +++ b/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlTransactedRouteTest.java @@ -23,7 +23,6 @@ import org.apache.camel.Processor; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.spi.Registry; import org.apache.camel.spring.spi.SpringTransactionPolicy; -import org.apache.camel.support.SimpleRegistry; import org.apache.camel.test.junit5.CamelTestSupport; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; @@ -56,24 +55,20 @@ public class SqlTransactedRouteTest extends CamelTestSupport { } @Override - protected Registry createCamelRegistry() { - Registry reg = new SimpleRegistry(); - + protected void bindToRegistry(Registry registry) throws Exception { db = new EmbeddedDatabaseBuilder() .setName(getClass().getSimpleName()) .setType(EmbeddedDatabaseType.H2).build(); - reg.bind("testdb", db); + registry.bind("testdb", db); DataSourceTransactionManager txMgr = new DataSourceTransactionManager(); txMgr.setDataSource(db); - reg.bind("txManager", txMgr); + registry.bind("txManager", txMgr); SpringTransactionPolicy txPolicy = new SpringTransactionPolicy(); txPolicy.setTransactionManager(txMgr); txPolicy.setPropagationBehaviorName("PROPAGATION_REQUIRED"); - reg.bind("required", txPolicy); - - return reg; + registry.bind("required", txPolicy); } @Override diff --git a/components/camel-sql/src/test/java/org/apache/camel/component/sql/stored/SqlStoredDataSourceTest.java b/components/camel-sql/src/test/java/org/apache/camel/component/sql/stored/SqlStoredDataSourceTest.java index 2cb4fc8bde0..642f8d7694f 100644 --- a/components/camel-sql/src/test/java/org/apache/camel/component/sql/stored/SqlStoredDataSourceTest.java +++ b/components/camel-sql/src/test/java/org/apache/camel/component/sql/stored/SqlStoredDataSourceTest.java @@ -20,7 +20,6 @@ import org.apache.camel.Exchange; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.spi.Registry; -import org.apache.camel.support.SimpleRegistry; import org.apache.camel.test.junit5.CamelTestSupport; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Test; @@ -35,9 +34,7 @@ public class SqlStoredDataSourceTest extends CamelTestSupport { private EmbeddedDatabase db; @Override - protected Registry createCamelRegistry() { - Registry reg = new SimpleRegistry(); - + protected void bindToRegistry(Registry registry) throws Exception { // START SNIPPET: e2 // this is the database we create with some initial data for our unit test db = new EmbeddedDatabaseBuilder() @@ -46,9 +43,7 @@ public class SqlStoredDataSourceTest extends CamelTestSupport { .addScript("sql/storedProcedureTest.sql").build(); // END SNIPPET: e2 - reg.bind("jdbc/myDataSource", db); - - return reg; + registry.bind("jdbc/myDataSource", db); } @Override diff --git a/components/camel-stomp/src/test/java/org/apache/camel/component/stomp/StompBaseTest.java b/components/camel-stomp/src/test/java/org/apache/camel/component/stomp/StompBaseTest.java index fe079daacb3..31ac1f59149 100644 --- a/components/camel-stomp/src/test/java/org/apache/camel/component/stomp/StompBaseTest.java +++ b/components/camel-stomp/src/test/java/org/apache/camel/component/stomp/StompBaseTest.java @@ -21,7 +21,6 @@ import javax.net.ssl.SSLContext; import org.apache.camel.CamelContext; import org.apache.camel.impl.DefaultCamelContext; import org.apache.camel.spi.Registry; -import org.apache.camel.support.SimpleRegistry; import org.apache.camel.support.jsse.KeyManagersParameters; import org.apache.camel.support.jsse.KeyStoreParameters; import org.apache.camel.support.jsse.SSLContextParameters; @@ -75,13 +74,10 @@ public abstract class StompBaseTest extends CamelTestSupport { } @Override - protected Registry createCamelRegistry() { - SimpleRegistry registry = new SimpleRegistry(); + protected void bindToRegistry(Registry registry) { if (isUseSsl()) { registry.bind("sslContextParameters", getClientSSLContextParameters()); } - - return registry; } protected Stomp createStompClient() throws Exception { diff --git a/components/camel-test/camel-test-junit5/src/main/java/org/apache/camel/test/junit5/CamelTestSupport.java b/components/camel-test/camel-test-junit5/src/main/java/org/apache/camel/test/junit5/CamelTestSupport.java index 61c134b9240..6e50639aca8 100644 --- a/components/camel-test/camel-test-junit5/src/main/java/org/apache/camel/test/junit5/CamelTestSupport.java +++ b/components/camel-test/camel-test-junit5/src/main/java/org/apache/camel/test/junit5/CamelTestSupport.java @@ -706,6 +706,7 @@ public abstract class CamelTestSupport * However if you need to bind beans to the registry then this is possible already with the bind method on registry, * and there is no need to override this method. */ + @Deprecated(since = "4.7.0") protected Registry createCamelRegistry() throws Exception { return null; } diff --git a/components/camel-thrift/src/test/java/org/apache/camel/component/thrift/ThriftConsumerSecurityTest.java b/components/camel-thrift/src/test/java/org/apache/camel/component/thrift/ThriftConsumerSecurityTest.java index 302373b361e..1d109491a7c 100644 --- a/components/camel-thrift/src/test/java/org/apache/camel/component/thrift/ThriftConsumerSecurityTest.java +++ b/components/camel-thrift/src/test/java/org/apache/camel/component/thrift/ThriftConsumerSecurityTest.java @@ -22,7 +22,6 @@ import org.apache.camel.component.thrift.generated.Calculator; import org.apache.camel.component.thrift.generated.Operation; import org.apache.camel.component.thrift.generated.Work; import org.apache.camel.spi.Registry; -import org.apache.camel.support.SimpleRegistry; import org.apache.camel.support.jsse.KeyManagersParameters; import org.apache.camel.support.jsse.KeyStoreParameters; import org.apache.camel.support.jsse.SSLContextParameters; @@ -84,8 +83,7 @@ public class ThriftConsumerSecurityTest extends CamelTestSupport { } @Override - protected Registry createCamelRegistry() { - Registry reg = new SimpleRegistry(); + protected void bindToRegistry(Registry registry) { SSLContextParameters sslParameters = new SSLContextParameters(); KeyStoreParameters keyStoreParams = new KeyStoreParameters(); @@ -97,8 +95,7 @@ public class ThriftConsumerSecurityTest extends CamelTestSupport { sslParameters.setKeyManagers(keyManagerParams); - reg.bind("sslParams", sslParameters); - return reg; + registry.bind("sslParams", sslParameters); } @Test diff --git a/components/camel-thrift/src/test/java/org/apache/camel/component/thrift/ThriftProducerSecurityTest.java b/components/camel-thrift/src/test/java/org/apache/camel/component/thrift/ThriftProducerSecurityTest.java index 19892fe264c..c0da4a6b2af 100644 --- a/components/camel-thrift/src/test/java/org/apache/camel/component/thrift/ThriftProducerSecurityTest.java +++ b/components/camel-thrift/src/test/java/org/apache/camel/component/thrift/ThriftProducerSecurityTest.java @@ -31,7 +31,6 @@ import org.apache.camel.component.thrift.generated.Operation; import org.apache.camel.component.thrift.generated.Work; import org.apache.camel.component.thrift.impl.CalculatorSyncServerImpl; import org.apache.camel.spi.Registry; -import org.apache.camel.support.SimpleRegistry; import org.apache.camel.support.jsse.KeyStoreParameters; import org.apache.camel.support.jsse.SSLContextParameters; import org.apache.camel.support.jsse.TrustManagersParameters; @@ -103,8 +102,7 @@ public class ThriftProducerSecurityTest extends CamelTestSupport { } @Override - protected Registry createCamelRegistry() { - Registry reg = new SimpleRegistry(); + protected void bindToRegistry(Registry registry) { SSLContextParameters sslParameters = new SSLContextParameters(); KeyStoreParameters keyStoreParams = new KeyStoreParameters(); @@ -116,8 +114,7 @@ public class ThriftProducerSecurityTest extends CamelTestSupport { sslParameters.setTrustManagers(trustManagerParams); - reg.bind("sslParams", sslParameters); - return reg; + registry.bind("sslParams", sslParameters); } @Test diff --git a/components/camel-tika/src/test/java/org/apache/camel/component/tika/TikaParseTest.java b/components/camel-tika/src/test/java/org/apache/camel/component/tika/TikaParseTest.java index 0f752bfaa9e..d84ae1a91fc 100644 --- a/components/camel-tika/src/test/java/org/apache/camel/component/tika/TikaParseTest.java +++ b/components/camel-tika/src/test/java/org/apache/camel/component/tika/TikaParseTest.java @@ -30,7 +30,6 @@ import org.apache.camel.Predicate; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.spi.Registry; -import org.apache.camel.support.SimpleRegistry; import org.apache.camel.test.junit5.CamelTestSupport; import org.apache.tika.metadata.Metadata; import org.apache.tika.parser.txt.UniversalEncodingDetector; @@ -193,9 +192,7 @@ public class TikaParseTest extends CamelTestSupport { } @Override - protected Registry createCamelRegistry() throws Exception { - Registry reg = new SimpleRegistry(); - reg.bind("testConfig", new TikaEmptyConfig()); - return reg; + protected void bindToRegistry(Registry registry) throws Exception { + registry.bind("testConfig", new TikaEmptyConfig()); } } diff --git a/components/camel-xmlsecurity/src/test/java/org/apache/camel/component/xmlsecurity/ECDSASignatureTest.java b/components/camel-xmlsecurity/src/test/java/org/apache/camel/component/xmlsecurity/ECDSASignatureTest.java index 0dd23538587..932527a517f 100644 --- a/components/camel-xmlsecurity/src/test/java/org/apache/camel/component/xmlsecurity/ECDSASignatureTest.java +++ b/components/camel-xmlsecurity/src/test/java/org/apache/camel/component/xmlsecurity/ECDSASignatureTest.java @@ -37,7 +37,6 @@ import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.component.xmlsecurity.api.KeyAccessor; import org.apache.camel.component.xmlsecurity.util.SameDocumentUriDereferencer; import org.apache.camel.spi.Registry; -import org.apache.camel.support.SimpleRegistry; import org.apache.camel.test.junit5.CamelTestSupport; import org.apache.camel.test.junit5.TestSupport; import org.junit.jupiter.api.BeforeEach; @@ -93,17 +92,13 @@ public class ECDSASignatureTest extends CamelTestSupport { } @Override - protected Registry createCamelRegistry() throws Exception { - Registry registry = new SimpleRegistry(); - + protected void bindToRegistry(Registry registry) throws Exception { // This test fails with the IBM JDK if (canTest) { registry.bind("accessor", getKeyAccessor()); registry.bind("selector", KeySelector.singletonKeySelector(getCertificateFromKeyStore().getPublicKey())); registry.bind("uriDereferencer", getSameDocumentUriDereferencer()); } - - return registry; } @Override diff --git a/components/camel-xmlsecurity/src/test/java/org/apache/camel/component/xmlsecurity/SignatureAlgorithmTest.java b/components/camel-xmlsecurity/src/test/java/org/apache/camel/component/xmlsecurity/SignatureAlgorithmTest.java index 82af6955779..a71bc539ae6 100644 --- a/components/camel-xmlsecurity/src/test/java/org/apache/camel/component/xmlsecurity/SignatureAlgorithmTest.java +++ b/components/camel-xmlsecurity/src/test/java/org/apache/camel/component/xmlsecurity/SignatureAlgorithmTest.java @@ -73,7 +73,6 @@ import org.apache.camel.component.xmlsecurity.util.ValidationFailedHandlerIgnore import org.apache.camel.component.xmlsecurity.util.XmlSignature2Message2MessageWithTimestampProperty; import org.apache.camel.impl.DefaultCamelContext; import org.apache.camel.spi.Registry; -import org.apache.camel.support.SimpleRegistry; import org.apache.camel.test.junit5.CamelTestSupport; import org.apache.camel.test.junit5.TestSupport; import org.junit.jupiter.api.BeforeEach; @@ -110,9 +109,7 @@ public class SignatureAlgorithmTest extends CamelTestSupport { } @Override - protected Registry createCamelRegistry() throws Exception { - Registry registry = new SimpleRegistry(); - + protected void bindToRegistry(Registry registry) throws Exception { Key secretKey = getSecretKey("testkey".getBytes("ASCII")); registry.bind("accessor", getKeyAccessor(keyPair.getPrivate())); @@ -137,8 +134,6 @@ public class SignatureAlgorithmTest extends CamelTestSupport { registry.bind("xpathsToIdAttributes", xpaths); registry.bind("parentXpathBean", getParentXPathBean()); - - return registry; } @Override diff --git a/components/camel-xmlsecurity/src/test/java/org/apache/camel/component/xmlsecurity/SignatureDigestMethodTest.java b/components/camel-xmlsecurity/src/test/java/org/apache/camel/component/xmlsecurity/SignatureDigestMethodTest.java index b926e50b0fe..ee8fb5ab3ee 100644 --- a/components/camel-xmlsecurity/src/test/java/org/apache/camel/component/xmlsecurity/SignatureDigestMethodTest.java +++ b/components/camel-xmlsecurity/src/test/java/org/apache/camel/component/xmlsecurity/SignatureDigestMethodTest.java @@ -72,7 +72,6 @@ import org.apache.camel.component.xmlsecurity.util.ValidationFailedHandlerIgnore import org.apache.camel.component.xmlsecurity.util.XmlSignature2Message2MessageWithTimestampProperty; import org.apache.camel.impl.DefaultCamelContext; import org.apache.camel.spi.Registry; -import org.apache.camel.support.SimpleRegistry; import org.apache.camel.test.junit5.CamelTestSupport; import org.apache.camel.test.junit5.TestSupport; import org.junit.jupiter.api.BeforeEach; @@ -109,9 +108,7 @@ public class SignatureDigestMethodTest extends CamelTestSupport { } @Override - protected Registry createCamelRegistry() throws Exception { - Registry registry = new SimpleRegistry(); - + protected void bindToRegistry(Registry registry) throws Exception { registry.bind("accessor", getKeyAccessor(keyPair.getPrivate())); registry.bind("canonicalizationMethod1", getCanonicalizationMethod()); registry.bind("selector", KeySelector.singletonKeySelector(keyPair.getPublic())); @@ -132,8 +129,6 @@ public class SignatureDigestMethodTest extends CamelTestSupport { registry.bind("xpathsToIdAttributes", xpaths); registry.bind("parentXpathBean", getParentXPathBean()); - - return registry; } @Override diff --git a/components/camel-xmlsecurity/src/test/java/org/apache/camel/component/xmlsecurity/XAdESSignaturePropertiesTest.java b/components/camel-xmlsecurity/src/test/java/org/apache/camel/component/xmlsecurity/XAdESSignaturePropertiesTest.java index d74abe097b4..59d2cc33ba5 100644 --- a/components/camel-xmlsecurity/src/test/java/org/apache/camel/component/xmlsecurity/XAdESSignaturePropertiesTest.java +++ b/components/camel-xmlsecurity/src/test/java/org/apache/camel/component/xmlsecurity/XAdESSignaturePropertiesTest.java @@ -63,7 +63,6 @@ import org.apache.camel.component.xmlsecurity.api.XmlSignatureHelper; import org.apache.camel.component.xmlsecurity.api.XmlSignatureProperties; import org.apache.camel.component.xmlsecurity.util.TestKeystore; import org.apache.camel.spi.Registry; -import org.apache.camel.support.SimpleRegistry; import org.apache.camel.test.junit5.CamelTestSupport; import org.apache.camel.test.junit5.TestSupport; import org.junit.jupiter.api.BeforeEach; @@ -100,8 +99,7 @@ public class XAdESSignaturePropertiesTest extends CamelTestSupport { } @Override - protected Registry createCamelRegistry() throws Exception { - Registry registry = new SimpleRegistry(); + protected void bindToRegistry(Registry registry) throws Exception { registry.bind("keyAccessorDefault", TestKeystore.getKeyAccessor("bob")); registry.bind("xmlSignatureProperties", getXmlSignatureProperties("bob")); @@ -109,8 +107,6 @@ public class XAdESSignaturePropertiesTest extends CamelTestSupport { List<XPathFilterParameterSpec> xpaths = Collections .singletonList(XmlSignatureHelper.getXpathFilter("/ns:root/a/@ID", namespaceMap)); registry.bind("xpathsToIdAttributes", xpaths); - - return registry; } @Override diff --git a/components/camel-xmlsecurity/src/test/java/org/apache/camel/component/xmlsecurity/XmlSignatureTest.java b/components/camel-xmlsecurity/src/test/java/org/apache/camel/component/xmlsecurity/XmlSignatureTest.java index 9b89187c141..0ea4aea17d1 100644 --- a/components/camel-xmlsecurity/src/test/java/org/apache/camel/component/xmlsecurity/XmlSignatureTest.java +++ b/components/camel-xmlsecurity/src/test/java/org/apache/camel/component/xmlsecurity/XmlSignatureTest.java @@ -99,7 +99,6 @@ import org.apache.camel.component.xmlsecurity.util.ValidationFailedHandlerIgnore import org.apache.camel.component.xmlsecurity.util.XmlSignature2Message2MessageWithTimestampProperty; import org.apache.camel.impl.DefaultCamelContext; import org.apache.camel.spi.Registry; -import org.apache.camel.support.SimpleRegistry; import org.apache.camel.support.processor.validation.SchemaValidationException; import org.apache.camel.test.junit5.CamelTestSupport; import org.junit.jupiter.api.BeforeEach; @@ -125,9 +124,7 @@ public class XmlSignatureTest extends CamelTestSupport { } @Override - protected Registry createCamelRegistry() throws Exception { - Registry registry = new SimpleRegistry(); - + protected void bindToRegistry(Registry registry) throws Exception { registry.bind("accessor", getKeyAccessor(keyPair.getPrivate())); registry.bind("canonicalizationMethod1", getCanonicalizationMethod()); registry.bind("selector", KeySelector.singletonKeySelector(keyPair.getPublic())); @@ -150,8 +147,6 @@ public class XmlSignatureTest extends CamelTestSupport { registry.bind("xpathsToIdAttributes", xpaths); registry.bind("parentXpathBean", getParentXPathBean()); - - return registry; } @Override diff --git a/components/camel-xmpp/src/test/java/org/apache/camel/component/xmpp/XmppBaseContainerTest.java b/components/camel-xmpp/src/test/java/org/apache/camel/component/xmpp/XmppBaseContainerTest.java index 42adbeec05f..49a40ead86c 100644 --- a/components/camel-xmpp/src/test/java/org/apache/camel/component/xmpp/XmppBaseContainerTest.java +++ b/components/camel-xmpp/src/test/java/org/apache/camel/component/xmpp/XmppBaseContainerTest.java @@ -22,7 +22,6 @@ import java.io.InputStream; import java.util.logging.LogManager; import org.apache.camel.spi.Registry; -import org.apache.camel.support.SimpleRegistry; import org.apache.camel.test.infra.xmpp.services.XmppServerContainer; import org.apache.camel.test.junit5.CamelTestSupport; import org.slf4j.Logger; @@ -44,10 +43,7 @@ public abstract class XmppBaseContainerTest extends CamelTestSupport { } @Override - protected Registry createCamelRegistry() throws Exception { - Registry registry = new SimpleRegistry(); - + protected void bindToRegistry(Registry registry) throws Exception { XmppTestUtil.bindSSLContextTo(registry, xmppServer.getHost(), xmppServer.getPortDefault()); - return registry; } } diff --git a/components/camel-xmpp/src/test/java/org/apache/camel/component/xmpp/integration/XmppBaseIT.java b/components/camel-xmpp/src/test/java/org/apache/camel/component/xmpp/integration/XmppBaseIT.java index ae59a76001e..0b869108452 100644 --- a/components/camel-xmpp/src/test/java/org/apache/camel/component/xmpp/integration/XmppBaseIT.java +++ b/components/camel-xmpp/src/test/java/org/apache/camel/component/xmpp/integration/XmppBaseIT.java @@ -22,7 +22,6 @@ import java.util.logging.LogManager; import org.apache.camel.component.xmpp.XmppTestUtil; import org.apache.camel.spi.Registry; -import org.apache.camel.support.SimpleRegistry; import org.apache.camel.test.infra.xmpp.services.XmppService; import org.apache.camel.test.infra.xmpp.services.XmppServiceFactory; import org.apache.camel.test.junit5.CamelTestSupport; @@ -51,11 +50,8 @@ public class XmppBaseIT extends CamelTestSupport { } @Override - protected Registry createCamelRegistry() throws Exception { - Registry registry = new SimpleRegistry(); - + protected void bindToRegistry(Registry registry) throws Exception { XmppTestUtil.bindSSLContextTo(registry, service.host(), service.port()); - return registry; } protected String getUrl() {