This is an automated email from the ASF dual-hosted git repository. gnodet pushed a commit to branch mesquite-planet in repository https://gitbox.apache.org/repos/asf/camel.git
commit 8711c20315ca962281101071d64c6fd186c506b2 Author: Guillaume Nodet <[email protected]> AuthorDate: Fri Mar 27 23:14:46 2026 +0100 Add createSingletonService() to 32 test-infra service factories Add singleton service support to all test-infra service factories that previously only had createService(). Each follows the established pattern (inner SingletonXxxService, lazy holder, factory method). Co-Authored-By: Claude Opus 4.6 <[email protected]> --- .../infra/services/RabbitMQServiceFactory.java | 4 + .../services/AzureStorageBlobServiceFactory.java | 50 ++++++++++++ .../AzureStorageDataLakeServiceFactory.java | 47 ++++++++++++ .../services/AzureStorageQueueServiceFactory.java | 50 ++++++++++++ .../services/CassandraServiceFactory.java | 43 +++++++++++ .../services/ChatScriptServiceFactory.java | 28 +++++++ .../test/infra/cli/services/CliServiceFactory.java | 88 ++++++++++++++++++++++ .../infra/common/services/SingletonService.java | 3 +- .../consul/services/ConsulServiceFactory.java | 37 +++++++++ .../docling/services/DoclingServiceFactory.java | 27 +++++++ .../services/GooglePubSubServiceFactory.java | 29 +++++++ .../vault/services/HashicorpServiceFactory.java | 38 ++++++++++ .../services/HazelcastServiceFactory.java | 27 +++++++ .../infra/ibmmq/services/IbmMQServiceFactory.java | 36 +++++++++ .../infra/iggy/services/IggyServiceFactory.java | 43 +++++++++++ .../ignite/services/IgniteServiceFactory.java | 27 +++++++ .../keycloak/services/KeycloakServiceFactory.java | 48 ++++++++++++ .../services/McpEverythingServiceFactory.java | 32 ++++++++ .../services/McpEverythingSseServiceFactory.java | 34 +++++++++ .../services/MicroprofileLRAServiceFactory.java | 41 ++++++++++ .../infra/minio/services/MinioServiceFactory.java | 58 ++++++++++++++ .../services/MosquittoServiceFactory.java | 27 +++++++ .../infra/nats/services/NatsServiceFactory.java | 28 +++++++ .../openldap/services/OpenldapServiceFactory.java | 38 ++++++++++ .../postgres/services/PostgresServiceFactory.java | 47 ++++++++++++ .../services/PostgresVectorServiceFactory.java | 47 ++++++++++++ .../rabbitmq/services/RabbitMQServiceFactory.java | 48 ++++++++++++ .../infra/redis/services/RedisServiceFactory.java | 33 ++++++++ .../infra/solr/services/SolrServiceFactory.java | 33 ++++++++ .../services/TensorFlowServingServiceFactory.java | 36 +++++++++ .../triton/services/TritonServiceFactory.java | 38 ++++++++++ .../infra/xmpp/services/XmppServiceFactory.java | 38 ++++++++++ .../services/ZooKeeperServiceFactory.java | 15 ++++ 33 files changed, 1216 insertions(+), 2 deletions(-) diff --git a/components/camel-spring-parent/camel-spring-rabbitmq/src/test/java/org/apache/camel/component/springrabbit/test/infra/services/RabbitMQServiceFactory.java b/components/camel-spring-parent/camel-spring-rabbitmq/src/test/java/org/apache/camel/component/springrabbit/test/infra/services/RabbitMQServiceFactory.java index c602ced47349..cbdcad9c8e0e 100644 --- a/components/camel-spring-parent/camel-spring-rabbitmq/src/test/java/org/apache/camel/component/springrabbit/test/infra/services/RabbitMQServiceFactory.java +++ b/components/camel-spring-parent/camel-spring-rabbitmq/src/test/java/org/apache/camel/component/springrabbit/test/infra/services/RabbitMQServiceFactory.java @@ -26,4 +26,8 @@ public final class RabbitMQServiceFactory { public static RabbitMQService createService() { return org.apache.camel.test.infra.rabbitmq.services.RabbitMQServiceFactory.createService(); } + + public static RabbitMQService createSingletonService() { + return org.apache.camel.test.infra.rabbitmq.services.RabbitMQServiceFactory.createSingletonService(); + } } diff --git a/test-infra/camel-test-infra-azure-storage-blob/src/main/java/org/apache/camel/test/infra/azure/storage/blob/services/AzureStorageBlobServiceFactory.java b/test-infra/camel-test-infra-azure-storage-blob/src/main/java/org/apache/camel/test/infra/azure/storage/blob/services/AzureStorageBlobServiceFactory.java index 01180df23be9..ed1b91978e46 100644 --- a/test-infra/camel-test-infra-azure-storage-blob/src/main/java/org/apache/camel/test/infra/azure/storage/blob/services/AzureStorageBlobServiceFactory.java +++ b/test-infra/camel-test-infra-azure-storage-blob/src/main/java/org/apache/camel/test/infra/azure/storage/blob/services/AzureStorageBlobServiceFactory.java @@ -17,10 +17,45 @@ package org.apache.camel.test.infra.azure.storage.blob.services; +import org.apache.camel.test.infra.azure.common.AzureCredentialsHolder; import org.apache.camel.test.infra.azure.common.services.AzureService; import org.apache.camel.test.infra.common.services.SimpleTestServiceBuilder; +import org.apache.camel.test.infra.common.services.SingletonService; public final class AzureStorageBlobServiceFactory { + + private static class SingletonAzureStorageBlobService extends SingletonService<AzureService> + implements AzureService { + public SingletonAzureStorageBlobService(AzureService service, String name) { + super(service, name); + } + + @Override + public AzureCredentialsHolder azureCredentials() { + return getService().azureCredentials(); + } + + @Override + public String accountName() { + return getService().accountName(); + } + + @Override + public String accessKey() { + return getService().accessKey(); + } + + @Override + public String host() { + return getService().host(); + } + + @Override + public int port() { + return getService().port(); + } + } + private AzureStorageBlobServiceFactory() { } @@ -36,6 +71,21 @@ public final class AzureStorageBlobServiceFactory { .build(); } + public static AzureService createSingletonService() { + return SingletonServiceHolder.INSTANCE; + } + + private static class SingletonServiceHolder { + static final AzureService INSTANCE; + static { + SimpleTestServiceBuilder<AzureService> instance = builder(); + instance.addLocalMapping( + () -> new SingletonAzureStorageBlobService(new AzureStorageBlobLocalContainerService(), "azure")) + .addRemoteMapping(AzureStorageBlobRemoteService::new); + INSTANCE = instance.build(); + } + } + static class AzureStorageBlobLocalContainerService extends AzureStorageBlobLocalContainerInfraService implements AzureService { } diff --git a/test-infra/camel-test-infra-azure-storage-datalake/src/main/java/org/apache/camel/test/infra/azure/storage/datalake/services/AzureStorageDataLakeServiceFactory.java b/test-infra/camel-test-infra-azure-storage-datalake/src/main/java/org/apache/camel/test/infra/azure/storage/datalake/services/AzureStorageDataLakeServiceFactory.java index 953576f653ea..95449de430d1 100644 --- a/test-infra/camel-test-infra-azure-storage-datalake/src/main/java/org/apache/camel/test/infra/azure/storage/datalake/services/AzureStorageDataLakeServiceFactory.java +++ b/test-infra/camel-test-infra-azure-storage-datalake/src/main/java/org/apache/camel/test/infra/azure/storage/datalake/services/AzureStorageDataLakeServiceFactory.java @@ -17,11 +17,45 @@ package org.apache.camel.test.infra.azure.storage.datalake.services; +import org.apache.camel.test.infra.azure.common.AzureCredentialsHolder; import org.apache.camel.test.infra.azure.common.services.AzureService; import org.apache.camel.test.infra.common.services.SimpleTestServiceBuilder; +import org.apache.camel.test.infra.common.services.SingletonService; public final class AzureStorageDataLakeServiceFactory { + private static class SingletonAzureStorageDataLakeService extends SingletonService<AzureService> + implements AzureService { + public SingletonAzureStorageDataLakeService(AzureService service, String name) { + super(service, name); + } + + @Override + public AzureCredentialsHolder azureCredentials() { + return getService().azureCredentials(); + } + + @Override + public String accountName() { + return getService().accountName(); + } + + @Override + public String accessKey() { + return getService().accessKey(); + } + + @Override + public String host() { + return getService().host(); + } + + @Override + public int port() { + return getService().port(); + } + } + private AzureStorageDataLakeServiceFactory() { } @@ -36,6 +70,19 @@ public final class AzureStorageDataLakeServiceFactory { .build(); } + public static AzureService createSingletonService() { + return SingletonServiceHolder.INSTANCE; + } + + private static class SingletonServiceHolder { + static final AzureService INSTANCE; + static { + SimpleTestServiceBuilder<AzureService> instance = builder(); + instance.addRemoteMapping(AzureStorageDataLakeRemoteService::new); + INSTANCE = instance.build(); + } + } + static class AzureStorageDataLakeRemoteService extends AzureStorageDataLakeRemoteInfraService implements AzureService { } } diff --git a/test-infra/camel-test-infra-azure-storage-queue/src/main/java/org/apache/camel/test/infra/azure/storage/queue/services/AzureStorageQueueServiceFactory.java b/test-infra/camel-test-infra-azure-storage-queue/src/main/java/org/apache/camel/test/infra/azure/storage/queue/services/AzureStorageQueueServiceFactory.java index 6761ca364789..9109f568581c 100644 --- a/test-infra/camel-test-infra-azure-storage-queue/src/main/java/org/apache/camel/test/infra/azure/storage/queue/services/AzureStorageQueueServiceFactory.java +++ b/test-infra/camel-test-infra-azure-storage-queue/src/main/java/org/apache/camel/test/infra/azure/storage/queue/services/AzureStorageQueueServiceFactory.java @@ -17,10 +17,45 @@ package org.apache.camel.test.infra.azure.storage.queue.services; +import org.apache.camel.test.infra.azure.common.AzureCredentialsHolder; import org.apache.camel.test.infra.azure.common.services.AzureService; import org.apache.camel.test.infra.common.services.SimpleTestServiceBuilder; +import org.apache.camel.test.infra.common.services.SingletonService; public final class AzureStorageQueueServiceFactory { + + private static class SingletonAzureStorageQueueService extends SingletonService<AzureService> + implements AzureService { + public SingletonAzureStorageQueueService(AzureService service, String name) { + super(service, name); + } + + @Override + public AzureCredentialsHolder azureCredentials() { + return getService().azureCredentials(); + } + + @Override + public String accountName() { + return getService().accountName(); + } + + @Override + public String accessKey() { + return getService().accessKey(); + } + + @Override + public String host() { + return getService().host(); + } + + @Override + public int port() { + return getService().port(); + } + } + private AzureStorageQueueServiceFactory() { } @@ -36,6 +71,21 @@ public final class AzureStorageQueueServiceFactory { .build(); } + public static AzureService createSingletonService() { + return SingletonServiceHolder.INSTANCE; + } + + private static class SingletonServiceHolder { + static final AzureService INSTANCE; + static { + SimpleTestServiceBuilder<AzureService> instance = builder(); + instance.addLocalMapping( + () -> new SingletonAzureStorageQueueService(new AzureStorageQueueLocalContainerService(), "azure")) + .addRemoteMapping(AzureStorageQueueRemoteService::new); + INSTANCE = instance.build(); + } + } + public static class AzureStorageQueueLocalContainerService extends AzureStorageQueueLocalContainerInfraService implements AzureService { } diff --git a/test-infra/camel-test-infra-cassandra/src/main/java/org/apache/camel/test/infra/cassandra/services/CassandraServiceFactory.java b/test-infra/camel-test-infra-cassandra/src/main/java/org/apache/camel/test/infra/cassandra/services/CassandraServiceFactory.java index 2cdf79679e7f..9418a9bba8ee 100644 --- a/test-infra/camel-test-infra-cassandra/src/main/java/org/apache/camel/test/infra/cassandra/services/CassandraServiceFactory.java +++ b/test-infra/camel-test-infra-cassandra/src/main/java/org/apache/camel/test/infra/cassandra/services/CassandraServiceFactory.java @@ -17,8 +17,36 @@ package org.apache.camel.test.infra.cassandra.services; import org.apache.camel.test.infra.common.services.SimpleTestServiceBuilder; +import org.apache.camel.test.infra.common.services.SingletonService; public final class CassandraServiceFactory { + + private static class SingletonCassandraService extends SingletonService<CassandraService> implements CassandraService { + public SingletonCassandraService(CassandraService service, String name) { + super(service, name); + } + + @Override + public int getCQL3Port() { + return getService().getCQL3Port(); + } + + @Override + public String getCassandraHost() { + return getService().getCassandraHost(); + } + + @Override + public String hosts() { + return getService().hosts(); + } + + @Override + public int port() { + return getService().port(); + } + } + private CassandraServiceFactory() { } @@ -43,6 +71,21 @@ public final class CassandraServiceFactory { .build(); } + public static CassandraService createSingletonService() { + return SingletonServiceHolder.INSTANCE; + } + + private static class SingletonServiceHolder { + static final CassandraService INSTANCE; + static { + SimpleTestServiceBuilder<CassandraService> instance = builder(); + instance.addLocalMapping( + () -> new SingletonCassandraService(new CassandraLocalContainerService(), "cassandra")) + .addRemoteMapping(RemoteCassandraService::new); + INSTANCE = instance.build(); + } + } + public static class RemoteCassandraService extends RemoteCassandraInfraService implements CassandraService { } } diff --git a/test-infra/camel-test-infra-chatscript/src/main/java/org/apache/camel/test/infra/chatscript/services/ChatScriptServiceFactory.java b/test-infra/camel-test-infra-chatscript/src/main/java/org/apache/camel/test/infra/chatscript/services/ChatScriptServiceFactory.java index c5b1689e1626..dfb1594f24e4 100644 --- a/test-infra/camel-test-infra-chatscript/src/main/java/org/apache/camel/test/infra/chatscript/services/ChatScriptServiceFactory.java +++ b/test-infra/camel-test-infra-chatscript/src/main/java/org/apache/camel/test/infra/chatscript/services/ChatScriptServiceFactory.java @@ -17,9 +17,22 @@ package org.apache.camel.test.infra.chatscript.services; import org.apache.camel.test.infra.common.services.SimpleTestServiceBuilder; +import org.apache.camel.test.infra.common.services.SingletonService; public final class ChatScriptServiceFactory { + private static class SingletonChatScriptService extends SingletonService<ChatScriptService> + implements ChatScriptService { + public SingletonChatScriptService(ChatScriptService service, String name) { + super(service, name); + } + + @Override + public String serviceAddress() { + return getService().serviceAddress(); + } + } + private ChatScriptServiceFactory() { } @@ -35,6 +48,21 @@ public final class ChatScriptServiceFactory { .build(); } + public static ChatScriptService createSingletonService() { + return SingletonServiceHolder.INSTANCE; + } + + private static class SingletonServiceHolder { + static final ChatScriptService INSTANCE; + static { + SimpleTestServiceBuilder<ChatScriptService> instance = builder(); + instance.addLocalMapping( + () -> new SingletonChatScriptService(new ChatScriptLocalContainerTestService(), "chatscript")) + .addRemoteMapping(ChatScriptRemoteTestService::new); + INSTANCE = instance.build(); + } + } + public static class ChatScriptLocalContainerTestService extends ChatScriptLocalContainerInfraService implements ChatScriptService { } diff --git a/test-infra/camel-test-infra-cli/src/main/java/org/apache/camel/test/infra/cli/services/CliServiceFactory.java b/test-infra/camel-test-infra-cli/src/main/java/org/apache/camel/test/infra/cli/services/CliServiceFactory.java index bad418ff5cad..200f942c34b1 100644 --- a/test-infra/camel-test-infra-cli/src/main/java/org/apache/camel/test/infra/cli/services/CliServiceFactory.java +++ b/test-infra/camel-test-infra-cli/src/main/java/org/apache/camel/test/infra/cli/services/CliServiceFactory.java @@ -16,9 +16,79 @@ */ package org.apache.camel.test.infra.cli.services; +import java.util.stream.Stream; + import org.apache.camel.test.infra.common.services.SimpleTestServiceBuilder; +import org.apache.camel.test.infra.common.services.SingletonService; public final class CliServiceFactory { + + private static class SingletonCliService extends SingletonService<CliService> implements CliService { + public SingletonCliService(CliService service, String name) { + super(service, name); + } + + @Override + public String execute(String command) { + return getService().execute(command); + } + + @Override + public String executeBackground(String command) { + return getService().executeBackground(command); + } + + @Override + public String executeGenericCommand(String command) { + return getService().executeGenericCommand(command); + } + + @Override + public void copyFileInternally(String source, String destination) { + getService().copyFileInternally(source, destination); + } + + @Override + public String getMountPoint() { + return getService().getMountPoint(); + } + + @Override + public String getContainerLogs() { + return getService().getContainerLogs(); + } + + @Override + public int getDevConsolePort() { + return getService().getDevConsolePort(); + } + + @Override + public Stream<String> listDirectory(String directoryPath) { + return getService().listDirectory(directoryPath); + } + + @Override + public String id() { + return getService().id(); + } + + @Override + public String version() { + return getService().version(); + } + + @Override + public int getSshPort() { + return getService().getSshPort(); + } + + @Override + public String getSshPassword() { + return getService().getSshPassword(); + } + } + private CliServiceFactory() { } @@ -33,4 +103,22 @@ public final class CliServiceFactory { .addMapping("local-camel-cli-process", CliLocalProcessService::new) .build(); } + + public static CliService createSingletonService() { + return SingletonServiceHolder.INSTANCE; + } + + private static class SingletonServiceHolder { + static final CliService INSTANCE; + static { + SimpleTestServiceBuilder<CliService> instance = builder(); + instance.addLocalMapping( + () -> new SingletonCliService(new CliLocalContainerService(), CliLocalContainerService.CONTAINER_NAME)) + .addMapping("local-camel-cli-process", + () -> new SingletonCliService( + new CliLocalProcessService(), + CliLocalContainerService.CONTAINER_NAME)); + INSTANCE = instance.build(); + } + } } diff --git a/test-infra/camel-test-infra-common/src/main/java/org/apache/camel/test/infra/common/services/SingletonService.java b/test-infra/camel-test-infra-common/src/main/java/org/apache/camel/test/infra/common/services/SingletonService.java index 127f562258e0..9e2fc8501e67 100644 --- a/test-infra/camel-test-infra-common/src/main/java/org/apache/camel/test/infra/common/services/SingletonService.java +++ b/test-infra/camel-test-infra-common/src/main/java/org/apache/camel/test/infra/common/services/SingletonService.java @@ -78,8 +78,7 @@ public class SingletonService<T extends InfrastructureService> @Override public final void shutdown() { - LOG.error("Singleton services must not be shutdown manually"); - throw new IllegalArgumentException("Singleton services must not be shutdown manually"); + LOG.debug("Ignoring shutdown request for singleton service {}: will be shutdown via JVM shutdown hook", name); } @Override diff --git a/test-infra/camel-test-infra-consul/src/main/java/org/apache/camel/test/infra/consul/services/ConsulServiceFactory.java b/test-infra/camel-test-infra-consul/src/main/java/org/apache/camel/test/infra/consul/services/ConsulServiceFactory.java index ae9a9ac1d0bb..81f1241577ad 100644 --- a/test-infra/camel-test-infra-consul/src/main/java/org/apache/camel/test/infra/consul/services/ConsulServiceFactory.java +++ b/test-infra/camel-test-infra-consul/src/main/java/org/apache/camel/test/infra/consul/services/ConsulServiceFactory.java @@ -17,9 +17,31 @@ package org.apache.camel.test.infra.consul.services; import org.apache.camel.test.infra.common.services.SimpleTestServiceBuilder; +import org.apache.camel.test.infra.common.services.SingletonService; public final class ConsulServiceFactory { + private static class SingletonConsulService extends SingletonService<ConsulService> implements ConsulService { + public SingletonConsulService(ConsulService service, String name) { + super(service, name); + } + + @Override + public String getConsulUrl() { + return getService().getConsulUrl(); + } + + @Override + public String host() { + return getService().host(); + } + + @Override + public int port() { + return getService().port(); + } + } + private ConsulServiceFactory() { } @@ -34,6 +56,21 @@ public final class ConsulServiceFactory { .build(); } + public static ConsulService createSingletonService() { + return SingletonServiceHolder.INSTANCE; + } + + private static class SingletonServiceHolder { + static final ConsulService INSTANCE; + static { + SimpleTestServiceBuilder<ConsulService> instance = builder(); + instance.addLocalMapping( + () -> new SingletonConsulService(new ConsulLocalContainerTestService(), "consul")) + .addRemoteMapping(ConsulRemoteTestService::new); + INSTANCE = instance.build(); + } + } + public static class ConsulLocalContainerTestService extends ConsulLocalContainerInfraService implements ConsulService { } diff --git a/test-infra/camel-test-infra-docling/src/main/java/org/apache/camel/test/infra/docling/services/DoclingServiceFactory.java b/test-infra/camel-test-infra-docling/src/main/java/org/apache/camel/test/infra/docling/services/DoclingServiceFactory.java index 6e38bdc21760..798f55be973c 100644 --- a/test-infra/camel-test-infra-docling/src/main/java/org/apache/camel/test/infra/docling/services/DoclingServiceFactory.java +++ b/test-infra/camel-test-infra-docling/src/main/java/org/apache/camel/test/infra/docling/services/DoclingServiceFactory.java @@ -17,8 +17,21 @@ package org.apache.camel.test.infra.docling.services; import org.apache.camel.test.infra.common.services.SimpleTestServiceBuilder; +import org.apache.camel.test.infra.common.services.SingletonService; public final class DoclingServiceFactory { + + private static class SingletonDoclingService extends SingletonService<DoclingService> implements DoclingService { + public SingletonDoclingService(DoclingService service, String name) { + super(service, name); + } + + @Override + public String doclingServerUrl() { + return getService().doclingServerUrl(); + } + } + private DoclingServiceFactory() { } @@ -33,6 +46,20 @@ public final class DoclingServiceFactory { .build(); } + public static DoclingService createSingletonService() { + return SingletonServiceHolder.INSTANCE; + } + + private static class SingletonServiceHolder { + static final DoclingService INSTANCE; + static { + SimpleTestServiceBuilder<DoclingService> instance = builder(); + instance.addLocalMapping( + () -> new SingletonDoclingService(new DoclingLocalContainerService(), "docling")); + INSTANCE = instance.build(); + } + } + public static class DoclingLocalContainerService extends DoclingLocalContainerInfraService implements DoclingService { } diff --git a/test-infra/camel-test-infra-google-pubsub/src/main/java/org/apache/camel/test/infra/google/pubsub/services/GooglePubSubServiceFactory.java b/test-infra/camel-test-infra-google-pubsub/src/main/java/org/apache/camel/test/infra/google/pubsub/services/GooglePubSubServiceFactory.java index a729c3047a51..dcaf73615029 100644 --- a/test-infra/camel-test-infra-google-pubsub/src/main/java/org/apache/camel/test/infra/google/pubsub/services/GooglePubSubServiceFactory.java +++ b/test-infra/camel-test-infra-google-pubsub/src/main/java/org/apache/camel/test/infra/google/pubsub/services/GooglePubSubServiceFactory.java @@ -17,8 +17,22 @@ package org.apache.camel.test.infra.google.pubsub.services; import org.apache.camel.test.infra.common.services.SimpleTestServiceBuilder; +import org.apache.camel.test.infra.common.services.SingletonService; public final class GooglePubSubServiceFactory { + + private static class SingletonGooglePubSubService extends SingletonService<GooglePubSubService> + implements GooglePubSubService { + public SingletonGooglePubSubService(GooglePubSubService service, String name) { + super(service, name); + } + + @Override + public String getServiceAddress() { + return getService().getServiceAddress(); + } + } + private GooglePubSubServiceFactory() { } @@ -34,6 +48,21 @@ public final class GooglePubSubServiceFactory { .build(); } + public static GooglePubSubService createSingletonService() { + return SingletonServiceHolder.INSTANCE; + } + + private static class SingletonServiceHolder { + static final GooglePubSubService INSTANCE; + static { + SimpleTestServiceBuilder<GooglePubSubService> instance = builder(); + instance.addLocalMapping( + () -> new SingletonGooglePubSubService(new GooglePubSubLocalContainerService(), "google")) + .addRemoteMapping(GooglePubSubRemoteService::new); + INSTANCE = instance.build(); + } + } + public static class GooglePubSubLocalContainerService extends GooglePubSubLocalContainerInfraService implements GooglePubSubService { } diff --git a/test-infra/camel-test-infra-hashicorp-vault/src/main/java/org/apache/camel/test/infra/hashicorp/vault/services/HashicorpServiceFactory.java b/test-infra/camel-test-infra-hashicorp-vault/src/main/java/org/apache/camel/test/infra/hashicorp/vault/services/HashicorpServiceFactory.java index 55a44f2194dc..7e6133e5445e 100644 --- a/test-infra/camel-test-infra-hashicorp-vault/src/main/java/org/apache/camel/test/infra/hashicorp/vault/services/HashicorpServiceFactory.java +++ b/test-infra/camel-test-infra-hashicorp-vault/src/main/java/org/apache/camel/test/infra/hashicorp/vault/services/HashicorpServiceFactory.java @@ -17,8 +17,32 @@ package org.apache.camel.test.infra.hashicorp.vault.services; import org.apache.camel.test.infra.common.services.SimpleTestServiceBuilder; +import org.apache.camel.test.infra.common.services.SingletonService; public final class HashicorpServiceFactory { + + private static class SingletonHashicorpVaultService extends SingletonService<HashicorpVaultService> + implements HashicorpVaultService { + public SingletonHashicorpVaultService(HashicorpVaultService service, String name) { + super(service, name); + } + + @Override + public String token() { + return getService().token(); + } + + @Override + public int port() { + return getService().port(); + } + + @Override + public String host() { + return getService().host(); + } + } + private HashicorpServiceFactory() { } @@ -33,6 +57,20 @@ public final class HashicorpServiceFactory { .build(); } + public static HashicorpVaultService createSingletonService() { + return SingletonServiceHolder.INSTANCE; + } + + private static class SingletonServiceHolder { + static final HashicorpVaultService INSTANCE; + static { + SimpleTestServiceBuilder<HashicorpVaultService> instance = builder(); + instance.addLocalMapping( + () -> new SingletonHashicorpVaultService(new HashicorpVaultLocalContainerService(), "hashicorp-vault")); + INSTANCE = instance.build(); + } + } + public static class HashicorpVaultLocalContainerService extends HashicorpVaultLocalContainerInfraService implements HashicorpVaultService { } diff --git a/test-infra/camel-test-infra-hazelcast/src/main/java/org/apache/camel/test/infra/hazelcast/services/HazelcastServiceFactory.java b/test-infra/camel-test-infra-hazelcast/src/main/java/org/apache/camel/test/infra/hazelcast/services/HazelcastServiceFactory.java index d1b9eab87135..45bfb5a37e92 100644 --- a/test-infra/camel-test-infra-hazelcast/src/main/java/org/apache/camel/test/infra/hazelcast/services/HazelcastServiceFactory.java +++ b/test-infra/camel-test-infra-hazelcast/src/main/java/org/apache/camel/test/infra/hazelcast/services/HazelcastServiceFactory.java @@ -16,10 +16,23 @@ */ package org.apache.camel.test.infra.hazelcast.services; +import com.hazelcast.config.Config; import org.apache.camel.test.infra.common.services.SimpleTestServiceBuilder; +import org.apache.camel.test.infra.common.services.SingletonService; public final class HazelcastServiceFactory { + private static class SingletonHazelcastService extends SingletonService<HazelcastService> implements HazelcastService { + public SingletonHazelcastService(HazelcastService service, String name) { + super(service, name); + } + + @Override + public Config createConfiguration(String name, int port, String instanceName, String componentName) { + return getService().createConfiguration(name, port, instanceName, componentName); + } + } + private HazelcastServiceFactory() { } @@ -34,6 +47,20 @@ public final class HazelcastServiceFactory { .build(); } + public static HazelcastService createSingletonService() { + return SingletonServiceHolder.INSTANCE; + } + + private static class SingletonServiceHolder { + static final HazelcastService INSTANCE; + static { + SimpleTestServiceBuilder<HazelcastService> instance = builder(); + instance.addLocalMapping( + () -> new SingletonHazelcastService(new HazelcastEmbeddedService(), "hazelcast")); + INSTANCE = instance.build(); + } + } + public static class HazelcastEmbeddedService extends HazelcastEmbeddedInfraService implements HazelcastService { } } diff --git a/test-infra/camel-test-infra-ibmmq/src/main/java/org/apache/camel/test/infra/ibmmq/services/IbmMQServiceFactory.java b/test-infra/camel-test-infra-ibmmq/src/main/java/org/apache/camel/test/infra/ibmmq/services/IbmMQServiceFactory.java index f3043328dfd9..5010039b1b1e 100644 --- a/test-infra/camel-test-infra-ibmmq/src/main/java/org/apache/camel/test/infra/ibmmq/services/IbmMQServiceFactory.java +++ b/test-infra/camel-test-infra-ibmmq/src/main/java/org/apache/camel/test/infra/ibmmq/services/IbmMQServiceFactory.java @@ -17,9 +17,31 @@ package org.apache.camel.test.infra.ibmmq.services; import org.apache.camel.test.infra.common.services.SimpleTestServiceBuilder; +import org.apache.camel.test.infra.common.services.SingletonService; public class IbmMQServiceFactory { + private static class SingletonIbmMQService extends SingletonService<IbmMQService> implements IbmMQService { + public SingletonIbmMQService(IbmMQService service, String name) { + super(service, name); + } + + @Override + public String channel() { + return getService().channel(); + } + + @Override + public String queueManager() { + return getService().queueManager(); + } + + @Override + public int listenerPort() { + return getService().listenerPort(); + } + } + private IbmMQServiceFactory() { } @@ -34,6 +56,20 @@ public class IbmMQServiceFactory { .build(); } + public static IbmMQService createSingletonService() { + return SingletonServiceHolder.INSTANCE; + } + + private static class SingletonServiceHolder { + static final IbmMQService INSTANCE; + static { + SimpleTestServiceBuilder<IbmMQService> instance = builder(); + instance.addLocalMapping( + () -> new SingletonIbmMQService(new IbmMQLocalContainerService(), "ibm-mq")); + INSTANCE = instance.build(); + } + } + public static class IbmMQLocalContainerService extends IbmMQLocalContainerInfraService implements IbmMQService { } diff --git a/test-infra/camel-test-infra-iggy/src/main/java/org/apache/camel/test/infra/iggy/services/IggyServiceFactory.java b/test-infra/camel-test-infra-iggy/src/main/java/org/apache/camel/test/infra/iggy/services/IggyServiceFactory.java index d093337a8695..74ae73f13e70 100644 --- a/test-infra/camel-test-infra-iggy/src/main/java/org/apache/camel/test/infra/iggy/services/IggyServiceFactory.java +++ b/test-infra/camel-test-infra-iggy/src/main/java/org/apache/camel/test/infra/iggy/services/IggyServiceFactory.java @@ -17,8 +17,36 @@ package org.apache.camel.test.infra.iggy.services; import org.apache.camel.test.infra.common.services.SimpleTestServiceBuilder; +import org.apache.camel.test.infra.common.services.SingletonService; public final class IggyServiceFactory { + + private static class SingletonIggyService extends SingletonService<IggyService> implements IggyService { + public SingletonIggyService(IggyService service, String name) { + super(service, name); + } + + @Override + public String host() { + return getService().host(); + } + + @Override + public int port() { + return getService().port(); + } + + @Override + public String username() { + return getService().username(); + } + + @Override + public String password() { + return getService().password(); + } + } + private IggyServiceFactory() { } @@ -34,6 +62,21 @@ public final class IggyServiceFactory { .build(); } + public static IggyService createSingletonService() { + return SingletonServiceHolder.INSTANCE; + } + + private static class SingletonServiceHolder { + static final IggyService INSTANCE; + static { + SimpleTestServiceBuilder<IggyService> instance = builder(); + instance.addLocalMapping( + () -> new SingletonIggyService(new IggyLocalContainerService(), "iggy")) + .addRemoteMapping(IggyRemoteService::new); + INSTANCE = instance.build(); + } + } + public static class IggyRemoteService extends IggyRemoteInfraService implements IggyService { } diff --git a/test-infra/camel-test-infra-ignite/src/main/java/org/apache/camel/test/infra/ignite/services/IgniteServiceFactory.java b/test-infra/camel-test-infra-ignite/src/main/java/org/apache/camel/test/infra/ignite/services/IgniteServiceFactory.java index 68addd52e597..04f3d6eb85a6 100644 --- a/test-infra/camel-test-infra-ignite/src/main/java/org/apache/camel/test/infra/ignite/services/IgniteServiceFactory.java +++ b/test-infra/camel-test-infra-ignite/src/main/java/org/apache/camel/test/infra/ignite/services/IgniteServiceFactory.java @@ -17,9 +17,22 @@ package org.apache.camel.test.infra.ignite.services; import org.apache.camel.test.infra.common.services.SimpleTestServiceBuilder; +import org.apache.camel.test.infra.common.services.SingletonService; +import org.apache.ignite.configuration.IgniteConfiguration; public final class IgniteServiceFactory { + private static class SingletonIgniteService extends SingletonService<IgniteService> implements IgniteService { + public SingletonIgniteService(IgniteService service, String name) { + super(service, name); + } + + @Override + public IgniteConfiguration createConfiguration() { + return getService().createConfiguration(); + } + } + private IgniteServiceFactory() { } @@ -34,6 +47,20 @@ public final class IgniteServiceFactory { .build(); } + public static IgniteService createSingletonService() { + return SingletonServiceHolder.INSTANCE; + } + + private static class SingletonServiceHolder { + static final IgniteService INSTANCE; + static { + SimpleTestServiceBuilder<IgniteService> instance = builder(); + instance.addLocalMapping( + () -> new SingletonIgniteService(new IgniteEmbeddedService(), "ignite")); + INSTANCE = instance.build(); + } + } + public static class IgniteEmbeddedService extends IgniteEmbeddedInfraService implements IgniteService { } } diff --git a/test-infra/camel-test-infra-keycloak/src/main/java/org/apache/camel/test/infra/keycloak/services/KeycloakServiceFactory.java b/test-infra/camel-test-infra-keycloak/src/main/java/org/apache/camel/test/infra/keycloak/services/KeycloakServiceFactory.java index 526c5e5f61de..d97224e56f0d 100644 --- a/test-infra/camel-test-infra-keycloak/src/main/java/org/apache/camel/test/infra/keycloak/services/KeycloakServiceFactory.java +++ b/test-infra/camel-test-infra-keycloak/src/main/java/org/apache/camel/test/infra/keycloak/services/KeycloakServiceFactory.java @@ -17,8 +17,42 @@ package org.apache.camel.test.infra.keycloak.services; import org.apache.camel.test.infra.common.services.SimpleTestServiceBuilder; +import org.apache.camel.test.infra.common.services.SingletonService; +import org.keycloak.admin.client.Keycloak; public final class KeycloakServiceFactory { + + private static class SingletonKeycloakService extends SingletonService<KeycloakService> implements KeycloakService { + public SingletonKeycloakService(KeycloakService service, String name) { + super(service, name); + } + + @Override + public String getKeycloakServerUrl() { + return getService().getKeycloakServerUrl(); + } + + @Override + public String getKeycloakRealm() { + return getService().getKeycloakRealm(); + } + + @Override + public String getKeycloakUsername() { + return getService().getKeycloakUsername(); + } + + @Override + public String getKeycloakPassword() { + return getService().getKeycloakPassword(); + } + + @Override + public Keycloak getKeycloakAdminClient() { + return getService().getKeycloakAdminClient(); + } + } + private KeycloakServiceFactory() { } @@ -33,6 +67,20 @@ public final class KeycloakServiceFactory { .build(); } + public static KeycloakService createSingletonService() { + return SingletonServiceHolder.INSTANCE; + } + + private static class SingletonServiceHolder { + static final KeycloakService INSTANCE; + static { + SimpleTestServiceBuilder<KeycloakService> instance = builder(); + instance.addLocalMapping( + () -> new SingletonKeycloakService(new KeycloakLocalContainerService(), "keycloak")); + INSTANCE = instance.build(); + } + } + public static class KeycloakLocalContainerService extends KeycloakLocalContainerInfraService implements KeycloakService { } diff --git a/test-infra/camel-test-infra-mcp-everything/src/main/java/org/apache/camel/test/infra/mcp/everything/services/McpEverythingServiceFactory.java b/test-infra/camel-test-infra-mcp-everything/src/main/java/org/apache/camel/test/infra/mcp/everything/services/McpEverythingServiceFactory.java index 597b46d53c20..254039c45583 100644 --- a/test-infra/camel-test-infra-mcp-everything/src/main/java/org/apache/camel/test/infra/mcp/everything/services/McpEverythingServiceFactory.java +++ b/test-infra/camel-test-infra-mcp-everything/src/main/java/org/apache/camel/test/infra/mcp/everything/services/McpEverythingServiceFactory.java @@ -17,9 +17,27 @@ package org.apache.camel.test.infra.mcp.everything.services; import org.apache.camel.test.infra.common.services.SimpleTestServiceBuilder; +import org.apache.camel.test.infra.common.services.SingletonService; public final class McpEverythingServiceFactory { + private static class SingletonMcpEverythingService extends SingletonService<McpEverythingService> + implements McpEverythingService { + public SingletonMcpEverythingService(McpEverythingService service, String name) { + super(service, name); + } + + @Override + public String host() { + return getService().host(); + } + + @Override + public int port() { + return getService().port(); + } + } + private McpEverythingServiceFactory() { } @@ -33,6 +51,20 @@ public final class McpEverythingServiceFactory { .build(); } + public static McpEverythingService createSingletonService() { + return SingletonServiceHolder.INSTANCE; + } + + private static class SingletonServiceHolder { + static final McpEverythingService INSTANCE; + static { + SimpleTestServiceBuilder<McpEverythingService> instance = builder(); + instance.addLocalMapping( + () -> new SingletonMcpEverythingService(new McpEverythingLocalContainerService(), "mcp-everything")); + INSTANCE = instance.build(); + } + } + public static class McpEverythingLocalContainerService extends McpEverythingLocalContainerInfraService implements McpEverythingService { } diff --git a/test-infra/camel-test-infra-mcp-everything/src/main/java/org/apache/camel/test/infra/mcp/everything/services/McpEverythingSseServiceFactory.java b/test-infra/camel-test-infra-mcp-everything/src/main/java/org/apache/camel/test/infra/mcp/everything/services/McpEverythingSseServiceFactory.java index a8bca0e5e018..c3bdd07628f9 100644 --- a/test-infra/camel-test-infra-mcp-everything/src/main/java/org/apache/camel/test/infra/mcp/everything/services/McpEverythingSseServiceFactory.java +++ b/test-infra/camel-test-infra-mcp-everything/src/main/java/org/apache/camel/test/infra/mcp/everything/services/McpEverythingSseServiceFactory.java @@ -17,9 +17,27 @@ package org.apache.camel.test.infra.mcp.everything.services; import org.apache.camel.test.infra.common.services.SimpleTestServiceBuilder; +import org.apache.camel.test.infra.common.services.SingletonService; public final class McpEverythingSseServiceFactory { + private static class SingletonMcpEverythingSseService extends SingletonService<McpEverythingSseService> + implements McpEverythingSseService { + public SingletonMcpEverythingSseService(McpEverythingSseService service, String name) { + super(service, name); + } + + @Override + public String host() { + return getService().host(); + } + + @Override + public int port() { + return getService().port(); + } + } + private McpEverythingSseServiceFactory() { } @@ -33,6 +51,22 @@ public final class McpEverythingSseServiceFactory { .build(); } + public static McpEverythingSseService createSingletonService() { + return SingletonServiceHolder.INSTANCE; + } + + private static class SingletonServiceHolder { + static final McpEverythingSseService INSTANCE; + static { + SimpleTestServiceBuilder<McpEverythingSseService> instance = builder(); + instance.addLocalMapping( + () -> new SingletonMcpEverythingSseService( + new McpEverythingSseLocalContainerService(), + "mcp-everything-sse")); + INSTANCE = instance.build(); + } + } + public static class McpEverythingSseLocalContainerService extends McpEverythingSseLocalContainerInfraService implements McpEverythingSseService { } diff --git a/test-infra/camel-test-infra-microprofile-lra/src/main/java/org/apache/camel/test/infra/microprofile/lra/services/MicroprofileLRAServiceFactory.java b/test-infra/camel-test-infra-microprofile-lra/src/main/java/org/apache/camel/test/infra/microprofile/lra/services/MicroprofileLRAServiceFactory.java index dce1211eccd3..4d808fccfaf7 100644 --- a/test-infra/camel-test-infra-microprofile-lra/src/main/java/org/apache/camel/test/infra/microprofile/lra/services/MicroprofileLRAServiceFactory.java +++ b/test-infra/camel-test-infra-microprofile-lra/src/main/java/org/apache/camel/test/infra/microprofile/lra/services/MicroprofileLRAServiceFactory.java @@ -17,8 +17,32 @@ package org.apache.camel.test.infra.microprofile.lra.services; import org.apache.camel.test.infra.common.services.SimpleTestServiceBuilder; +import org.apache.camel.test.infra.common.services.SingletonService; public final class MicroprofileLRAServiceFactory { + + private static class SingletonMicroprofileLRAService extends SingletonService<MicroprofileLRAService> + implements MicroprofileLRAService { + public SingletonMicroprofileLRAService(MicroprofileLRAService service, String name) { + super(service, name); + } + + @Override + public String host() { + return getService().host(); + } + + @Override + public int port() { + return getService().port(); + } + + @Override + public String callbackHost() { + return getService().callbackHost(); + } + } + private MicroprofileLRAServiceFactory() { } @@ -34,6 +58,23 @@ public final class MicroprofileLRAServiceFactory { .build(); } + public static MicroprofileLRAService createSingletonService() { + return SingletonServiceHolder.INSTANCE; + } + + private static class SingletonServiceHolder { + static final MicroprofileLRAService INSTANCE; + static { + SimpleTestServiceBuilder<MicroprofileLRAService> instance = builder(); + instance.addLocalMapping( + () -> new SingletonMicroprofileLRAService( + new MicroprofileLRALocalContainerService(), + "microprofile-lra")) + .addRemoteMapping(MicroprofileLRARemoteService::new); + INSTANCE = instance.build(); + } + } + public static class MicroprofileLRALocalContainerService extends MicroprofileLRALocalContainerInfraService implements MicroprofileLRAService { } diff --git a/test-infra/camel-test-infra-minio/src/main/java/org/apache/camel/test/infra/minio/services/MinioServiceFactory.java b/test-infra/camel-test-infra-minio/src/main/java/org/apache/camel/test/infra/minio/services/MinioServiceFactory.java index ed25e600c9e8..1ed85dc0c28d 100644 --- a/test-infra/camel-test-infra-minio/src/main/java/org/apache/camel/test/infra/minio/services/MinioServiceFactory.java +++ b/test-infra/camel-test-infra-minio/src/main/java/org/apache/camel/test/infra/minio/services/MinioServiceFactory.java @@ -17,8 +17,51 @@ package org.apache.camel.test.infra.minio.services; import org.apache.camel.test.infra.common.services.SimpleTestServiceBuilder; +import org.apache.camel.test.infra.common.services.SingletonService; public final class MinioServiceFactory { + + private static class SingletonMinioService extends SingletonService<MinioService> implements MinioService { + public SingletonMinioService(MinioService service, String name) { + super(service, name); + } + + @Override + public String secretKey() { + return getService().secretKey(); + } + + @Override + public String accessKey() { + return getService().accessKey(); + } + + @Override + public int port() { + return getService().port(); + } + + @Override + public String host() { + return getService().host(); + } + + @Override + public int consolePort() { + return getService().consolePort(); + } + + @Override + public String consoleUsername() { + return getService().consoleUsername(); + } + + @Override + public String consolePassword() { + return getService().consolePassword(); + } + } + private MinioServiceFactory() { } @@ -34,6 +77,21 @@ public final class MinioServiceFactory { .build(); } + public static MinioService createSingletonService() { + return SingletonServiceHolder.INSTANCE; + } + + private static class SingletonServiceHolder { + static final MinioService INSTANCE; + static { + SimpleTestServiceBuilder<MinioService> instance = builder(); + instance.addLocalMapping( + () -> new SingletonMinioService(new MinioLocalContainerService(), "minio")) + .addRemoteMapping(MinioRemoteService::new); + INSTANCE = instance.build(); + } + } + public static class MinioLocalContainerService extends MinioLocalContainerInfraService implements MinioService { } diff --git a/test-infra/camel-test-infra-mosquitto/src/main/java/org/apache/camel/test/infra/mosquitto/services/MosquittoServiceFactory.java b/test-infra/camel-test-infra-mosquitto/src/main/java/org/apache/camel/test/infra/mosquitto/services/MosquittoServiceFactory.java index d8d85c9190b2..0e51be0dda13 100644 --- a/test-infra/camel-test-infra-mosquitto/src/main/java/org/apache/camel/test/infra/mosquitto/services/MosquittoServiceFactory.java +++ b/test-infra/camel-test-infra-mosquitto/src/main/java/org/apache/camel/test/infra/mosquitto/services/MosquittoServiceFactory.java @@ -17,8 +17,21 @@ package org.apache.camel.test.infra.mosquitto.services; import org.apache.camel.test.infra.common.services.SimpleTestServiceBuilder; +import org.apache.camel.test.infra.common.services.SingletonService; public final class MosquittoServiceFactory { + + private static class SingletonMosquittoService extends SingletonService<MosquittoService> implements MosquittoService { + public SingletonMosquittoService(MosquittoService service, String name) { + super(service, name); + } + + @Override + public Integer getPort() { + return getService().getPort(); + } + } + private MosquittoServiceFactory() { } @@ -34,4 +47,18 @@ public final class MosquittoServiceFactory { .build(); } + public static MosquittoService createSingletonService() { + return SingletonServiceHolder.INSTANCE; + } + + private static class SingletonServiceHolder { + static final MosquittoService INSTANCE; + static { + SimpleTestServiceBuilder<MosquittoService> instance = builder(); + instance.addLocalMapping( + () -> new SingletonMosquittoService(new MosquittoLocalContainerService(), "mosquitto")) + .addRemoteMapping(MosquittoRemoteService::new); + INSTANCE = instance.build(); + } + } } diff --git a/test-infra/camel-test-infra-nats/src/main/java/org/apache/camel/test/infra/nats/services/NatsServiceFactory.java b/test-infra/camel-test-infra-nats/src/main/java/org/apache/camel/test/infra/nats/services/NatsServiceFactory.java index ae2ea32d1005..29c445b60c93 100644 --- a/test-infra/camel-test-infra-nats/src/main/java/org/apache/camel/test/infra/nats/services/NatsServiceFactory.java +++ b/test-infra/camel-test-infra-nats/src/main/java/org/apache/camel/test/infra/nats/services/NatsServiceFactory.java @@ -17,8 +17,21 @@ package org.apache.camel.test.infra.nats.services; import org.apache.camel.test.infra.common.services.SimpleTestServiceBuilder; +import org.apache.camel.test.infra.common.services.SingletonService; public final class NatsServiceFactory { + + private static class SingletonNatsService extends SingletonService<NatsService> implements NatsService { + public SingletonNatsService(NatsService service, String name) { + super(service, name); + } + + @Override + public String getServiceAddress() { + return getService().getServiceAddress(); + } + } + private NatsServiceFactory() { } @@ -33,6 +46,21 @@ public final class NatsServiceFactory { .build(); } + public static NatsService createSingletonService() { + return SingletonServiceHolder.INSTANCE; + } + + private static class SingletonServiceHolder { + static final NatsService INSTANCE; + static { + SimpleTestServiceBuilder<NatsService> instance = builder(); + instance.addLocalMapping( + () -> new SingletonNatsService(new NatsLocalContainerService(), "nats")) + .addRemoteMapping(NatsRemoteService::new); + INSTANCE = instance.build(); + } + } + public static class NatsRemoteService extends NatsRemoteInfraService implements NatsService { } } diff --git a/test-infra/camel-test-infra-openldap/src/main/java/org/apache/camel/test/infra/openldap/services/OpenldapServiceFactory.java b/test-infra/camel-test-infra-openldap/src/main/java/org/apache/camel/test/infra/openldap/services/OpenldapServiceFactory.java index 1938b40548fa..65f58acf505b 100644 --- a/test-infra/camel-test-infra-openldap/src/main/java/org/apache/camel/test/infra/openldap/services/OpenldapServiceFactory.java +++ b/test-infra/camel-test-infra-openldap/src/main/java/org/apache/camel/test/infra/openldap/services/OpenldapServiceFactory.java @@ -17,8 +17,31 @@ package org.apache.camel.test.infra.openldap.services; import org.apache.camel.test.infra.common.services.SimpleTestServiceBuilder; +import org.apache.camel.test.infra.common.services.SingletonService; public final class OpenldapServiceFactory { + + private static class SingletonOpenldapService extends SingletonService<OpenldapService> implements OpenldapService { + public SingletonOpenldapService(OpenldapService service, String name) { + super(service, name); + } + + @Override + public Integer getPort() { + return getService().getPort(); + } + + @Override + public Integer getSslPort() { + return getService().getSslPort(); + } + + @Override + public String getHost() { + return getService().getHost(); + } + } + private OpenldapServiceFactory() { } @@ -34,6 +57,21 @@ public final class OpenldapServiceFactory { .build(); } + public static OpenldapService createSingletonService() { + return SingletonServiceHolder.INSTANCE; + } + + private static class SingletonServiceHolder { + static final OpenldapService INSTANCE; + static { + SimpleTestServiceBuilder<OpenldapService> instance = builder(); + instance.addLocalMapping( + () -> new SingletonOpenldapService(new OpenldapLocalContainerService(), "openldap")) + .addRemoteMapping(OpenldapRemoteService::new); + INSTANCE = instance.build(); + } + } + public static class OpenldapLocalContainerService extends OpenldapLocalContainerInfraService implements OpenldapService { } diff --git a/test-infra/camel-test-infra-postgres/src/main/java/org/apache/camel/test/infra/postgres/services/PostgresServiceFactory.java b/test-infra/camel-test-infra-postgres/src/main/java/org/apache/camel/test/infra/postgres/services/PostgresServiceFactory.java index e442ab10cc58..3d636efe84db 100644 --- a/test-infra/camel-test-infra-postgres/src/main/java/org/apache/camel/test/infra/postgres/services/PostgresServiceFactory.java +++ b/test-infra/camel-test-infra-postgres/src/main/java/org/apache/camel/test/infra/postgres/services/PostgresServiceFactory.java @@ -17,9 +17,41 @@ package org.apache.camel.test.infra.postgres.services; import org.apache.camel.test.infra.common.services.SimpleTestServiceBuilder; +import org.apache.camel.test.infra.common.services.SingletonService; public final class PostgresServiceFactory { + private static class SingletonPostgresService extends SingletonService<PostgresService> implements PostgresService { + public SingletonPostgresService(PostgresService service, String name) { + super(service, name); + } + + @Override + public String host() { + return getService().host(); + } + + @Override + public int port() { + return getService().port(); + } + + @Override + public String userName() { + return getService().userName(); + } + + @Override + public String password() { + return getService().password(); + } + + @Override + public String getServiceAddress() { + return getService().getServiceAddress(); + } + } + private PostgresServiceFactory() { } @@ -33,6 +65,21 @@ public final class PostgresServiceFactory { .build(); } + public static PostgresService createSingletonService() { + return SingletonServiceHolder.INSTANCE; + } + + private static class SingletonServiceHolder { + static final PostgresService INSTANCE; + static { + SimpleTestServiceBuilder<PostgresService> instance = builder(); + instance.addLocalMapping( + () -> new SingletonPostgresService(new PostgresLocalContainerService(), "postgres")) + .addRemoteMapping(PostgresRemoteService::new); + INSTANCE = instance.build(); + } + } + public static class PostgresRemoteService extends PostgresRemoteInfraService implements PostgresService { } } diff --git a/test-infra/camel-test-infra-postgres/src/main/java/org/apache/camel/test/infra/postgres/services/PostgresVectorServiceFactory.java b/test-infra/camel-test-infra-postgres/src/main/java/org/apache/camel/test/infra/postgres/services/PostgresVectorServiceFactory.java index d0084ea87924..0cc8f47f062a 100644 --- a/test-infra/camel-test-infra-postgres/src/main/java/org/apache/camel/test/infra/postgres/services/PostgresVectorServiceFactory.java +++ b/test-infra/camel-test-infra-postgres/src/main/java/org/apache/camel/test/infra/postgres/services/PostgresVectorServiceFactory.java @@ -17,9 +17,41 @@ package org.apache.camel.test.infra.postgres.services; import org.apache.camel.test.infra.common.services.SimpleTestServiceBuilder; +import org.apache.camel.test.infra.common.services.SingletonService; public final class PostgresVectorServiceFactory { + private static class SingletonPostgresVectorService extends SingletonService<PostgresService> implements PostgresService { + public SingletonPostgresVectorService(PostgresService service, String name) { + super(service, name); + } + + @Override + public String host() { + return getService().host(); + } + + @Override + public int port() { + return getService().port(); + } + + @Override + public String userName() { + return getService().userName(); + } + + @Override + public String password() { + return getService().password(); + } + + @Override + public String getServiceAddress() { + return getService().getServiceAddress(); + } + } + private PostgresVectorServiceFactory() { } @@ -32,4 +64,19 @@ public final class PostgresVectorServiceFactory { .addRemoteMapping(PostgresServiceFactory.PostgresRemoteService::new) .build(); } + + public static PostgresService createSingletonService() { + return SingletonServiceHolder.INSTANCE; + } + + private static class SingletonServiceHolder { + static final PostgresService INSTANCE; + static { + SimpleTestServiceBuilder<PostgresService> instance = builder(); + instance.addLocalMapping( + () -> new SingletonPostgresVectorService(new PostgresVectorLocalContainerService(), "postgres-vector")) + .addRemoteMapping(PostgresServiceFactory.PostgresRemoteService::new); + INSTANCE = instance.build(); + } + } } diff --git a/test-infra/camel-test-infra-rabbitmq/src/main/java/org/apache/camel/test/infra/rabbitmq/services/RabbitMQServiceFactory.java b/test-infra/camel-test-infra-rabbitmq/src/main/java/org/apache/camel/test/infra/rabbitmq/services/RabbitMQServiceFactory.java index 97a6ad9da886..77e73c7f8b8b 100644 --- a/test-infra/camel-test-infra-rabbitmq/src/main/java/org/apache/camel/test/infra/rabbitmq/services/RabbitMQServiceFactory.java +++ b/test-infra/camel-test-infra-rabbitmq/src/main/java/org/apache/camel/test/infra/rabbitmq/services/RabbitMQServiceFactory.java @@ -18,8 +18,41 @@ package org.apache.camel.test.infra.rabbitmq.services; import org.apache.camel.test.infra.common.services.SimpleTestServiceBuilder; +import org.apache.camel.test.infra.common.services.SingletonService; public final class RabbitMQServiceFactory { + + private static class SingletonRabbitMQService extends SingletonService<RabbitMQService> implements RabbitMQService { + public SingletonRabbitMQService(RabbitMQService service, String name) { + super(service, name); + } + + @Override + public ConnectionProperties connectionProperties() { + return getService().connectionProperties(); + } + + @Override + public int getHttpPort() { + return getService().getHttpPort(); + } + + @Override + public String managementUsername() { + return getService().managementUsername(); + } + + @Override + public String managementPassword() { + return getService().managementPassword(); + } + + @Override + public String managementUri() { + return getService().managementUri(); + } + } + private RabbitMQServiceFactory() { } @@ -35,6 +68,21 @@ public final class RabbitMQServiceFactory { .build(); } + public static RabbitMQService createSingletonService() { + return SingletonServiceHolder.INSTANCE; + } + + private static class SingletonServiceHolder { + static final RabbitMQService INSTANCE; + static { + SimpleTestServiceBuilder<RabbitMQService> instance = builder(); + instance.addLocalMapping( + () -> new SingletonRabbitMQService(new RabbitMQLocalContainerService(), "rabbitmq")) + .addRemoteMapping(RabbitMQRemoteService::new); + INSTANCE = instance.build(); + } + } + public static class RabbitMQLocalContainerService extends RabbitMQLocalContainerInfraService implements RabbitMQService { } diff --git a/test-infra/camel-test-infra-redis/src/main/java/org/apache/camel/test/infra/redis/services/RedisServiceFactory.java b/test-infra/camel-test-infra-redis/src/main/java/org/apache/camel/test/infra/redis/services/RedisServiceFactory.java index e27c3842d4f7..e6b90e3469f9 100644 --- a/test-infra/camel-test-infra-redis/src/main/java/org/apache/camel/test/infra/redis/services/RedisServiceFactory.java +++ b/test-infra/camel-test-infra-redis/src/main/java/org/apache/camel/test/infra/redis/services/RedisServiceFactory.java @@ -17,8 +17,26 @@ package org.apache.camel.test.infra.redis.services; import org.apache.camel.test.infra.common.services.SimpleTestServiceBuilder; +import org.apache.camel.test.infra.common.services.SingletonService; public final class RedisServiceFactory { + + private static class SingletonRedisService extends SingletonService<RedisService> implements RedisService { + public SingletonRedisService(RedisService service, String name) { + super(service, name); + } + + @Override + public String host() { + return getService().host(); + } + + @Override + public int port() { + return getService().port(); + } + } + private RedisServiceFactory() { } @@ -34,6 +52,21 @@ public final class RedisServiceFactory { .build(); } + public static RedisService createSingletonService() { + return SingletonServiceHolder.INSTANCE; + } + + private static class SingletonServiceHolder { + static final RedisService INSTANCE; + static { + SimpleTestServiceBuilder<RedisService> instance = builder(); + instance.addLocalMapping( + () -> new SingletonRedisService(new RedisLocalContainerService(), "redis")) + .addRemoteMapping(RedisRemoteService::new); + INSTANCE = instance.build(); + } + } + public static class RedisRemoteService extends RedisRemoteInfraService implements RedisService { } diff --git a/test-infra/camel-test-infra-solr/src/main/java/org/apache/camel/test/infra/solr/services/SolrServiceFactory.java b/test-infra/camel-test-infra-solr/src/main/java/org/apache/camel/test/infra/solr/services/SolrServiceFactory.java index d79388ea0c2f..0e29c8e2846f 100644 --- a/test-infra/camel-test-infra-solr/src/main/java/org/apache/camel/test/infra/solr/services/SolrServiceFactory.java +++ b/test-infra/camel-test-infra-solr/src/main/java/org/apache/camel/test/infra/solr/services/SolrServiceFactory.java @@ -17,8 +17,26 @@ package org.apache.camel.test.infra.solr.services; import org.apache.camel.test.infra.common.services.SimpleTestServiceBuilder; +import org.apache.camel.test.infra.common.services.SingletonService; public final class SolrServiceFactory { + + private static class SingletonSolrService extends SingletonService<SolrService> implements SolrService { + public SingletonSolrService(SolrService service, String name) { + super(service, name); + } + + @Override + public int getPort() { + return getService().getPort(); + } + + @Override + public String getSolrHost() { + return getService().getSolrHost(); + } + } + private SolrServiceFactory() { } @@ -34,6 +52,21 @@ public final class SolrServiceFactory { .build(); } + public static SolrService createSingletonService() { + return SingletonServiceHolder.INSTANCE; + } + + private static class SingletonServiceHolder { + static final SolrService INSTANCE; + static { + SimpleTestServiceBuilder<SolrService> instance = builder(); + instance.addLocalMapping( + () -> new SingletonSolrService(new SolrLocalContainerService(), SolrContainer.CONTAINER_NAME)) + .addRemoteMapping(SolrRemoteService::new); + INSTANCE = instance.build(); + } + } + public static class SolrRemoteService extends SolrRemoteInfraService implements SolrService { } diff --git a/test-infra/camel-test-infra-tensorflow-serving/src/main/java/org/apache/camel/test/infra/tensorflow/serving/services/TensorFlowServingServiceFactory.java b/test-infra/camel-test-infra-tensorflow-serving/src/main/java/org/apache/camel/test/infra/tensorflow/serving/services/TensorFlowServingServiceFactory.java index b1689e835ab6..0dfd8f1fff54 100644 --- a/test-infra/camel-test-infra-tensorflow-serving/src/main/java/org/apache/camel/test/infra/tensorflow/serving/services/TensorFlowServingServiceFactory.java +++ b/test-infra/camel-test-infra-tensorflow-serving/src/main/java/org/apache/camel/test/infra/tensorflow/serving/services/TensorFlowServingServiceFactory.java @@ -17,8 +17,27 @@ package org.apache.camel.test.infra.tensorflow.serving.services; import org.apache.camel.test.infra.common.services.SimpleTestServiceBuilder; +import org.apache.camel.test.infra.common.services.SingletonService; public final class TensorFlowServingServiceFactory { + + private static class SingletonTensorFlowServingService extends SingletonService<TensorFlowServingService> + implements TensorFlowServingService { + public SingletonTensorFlowServingService(TensorFlowServingService service, String name) { + super(service, name); + } + + @Override + public int grpcPort() { + return getService().grpcPort(); + } + + @Override + public int restPort() { + return getService().restPort(); + } + } + private TensorFlowServingServiceFactory() { } @@ -32,4 +51,21 @@ public final class TensorFlowServingServiceFactory { .addRemoteMapping(TensorFlowServingRemoteService::new) .build(); } + + public static TensorFlowServingService createSingletonService() { + return SingletonServiceHolder.INSTANCE; + } + + private static class SingletonServiceHolder { + static final TensorFlowServingService INSTANCE; + static { + SimpleTestServiceBuilder<TensorFlowServingService> instance = builder(); + instance.addLocalMapping( + () -> new SingletonTensorFlowServingService( + new TensorFlowServingLocalContainerService(), + "tensorflow-serving")) + .addRemoteMapping(TensorFlowServingRemoteService::new); + INSTANCE = instance.build(); + } + } } diff --git a/test-infra/camel-test-infra-triton/src/main/java/org/apache/camel/test/infra/triton/services/TritonServiceFactory.java b/test-infra/camel-test-infra-triton/src/main/java/org/apache/camel/test/infra/triton/services/TritonServiceFactory.java index 9544f9176574..c2fced13be8c 100644 --- a/test-infra/camel-test-infra-triton/src/main/java/org/apache/camel/test/infra/triton/services/TritonServiceFactory.java +++ b/test-infra/camel-test-infra-triton/src/main/java/org/apache/camel/test/infra/triton/services/TritonServiceFactory.java @@ -17,8 +17,31 @@ package org.apache.camel.test.infra.triton.services; import org.apache.camel.test.infra.common.services.SimpleTestServiceBuilder; +import org.apache.camel.test.infra.common.services.SingletonService; public final class TritonServiceFactory { + + private static class SingletonTritonService extends SingletonService<TritonService> implements TritonService { + public SingletonTritonService(TritonService service, String name) { + super(service, name); + } + + @Override + public int httpPort() { + return getService().httpPort(); + } + + @Override + public int grpcPort() { + return getService().grpcPort(); + } + + @Override + public int metricsPort() { + return getService().metricsPort(); + } + } + private TritonServiceFactory() { } @@ -33,6 +56,21 @@ public final class TritonServiceFactory { .build(); } + public static TritonService createSingletonService() { + return SingletonServiceHolder.INSTANCE; + } + + private static class SingletonServiceHolder { + static final TritonService INSTANCE; + static { + SimpleTestServiceBuilder<TritonService> instance = builder(); + instance.addLocalMapping( + () -> new SingletonTritonService(new TritonLocalContainerService(), "triton")) + .addRemoteMapping(TritonRemoteService::new); + INSTANCE = instance.build(); + } + } + public static class TritonLocalContainerService extends TritonLocalContainerInfraService implements TritonService { } diff --git a/test-infra/camel-test-infra-xmpp/src/main/java/org/apache/camel/test/infra/xmpp/services/XmppServiceFactory.java b/test-infra/camel-test-infra-xmpp/src/main/java/org/apache/camel/test/infra/xmpp/services/XmppServiceFactory.java index 89339aeda594..d62a23f46056 100644 --- a/test-infra/camel-test-infra-xmpp/src/main/java/org/apache/camel/test/infra/xmpp/services/XmppServiceFactory.java +++ b/test-infra/camel-test-infra-xmpp/src/main/java/org/apache/camel/test/infra/xmpp/services/XmppServiceFactory.java @@ -17,8 +17,31 @@ package org.apache.camel.test.infra.xmpp.services; import org.apache.camel.test.infra.common.services.SimpleTestServiceBuilder; +import org.apache.camel.test.infra.common.services.SingletonService; public final class XmppServiceFactory { + + private static class SingletonXmppService extends SingletonService<XmppService> implements XmppService { + public SingletonXmppService(XmppService service, String name) { + super(service, name); + } + + @Override + public String host() { + return getService().host(); + } + + @Override + public int port() { + return getService().port(); + } + + @Override + public String getUrl() { + return getService().getUrl(); + } + } + private XmppServiceFactory() { } @@ -34,6 +57,21 @@ public final class XmppServiceFactory { .build(); } + public static XmppService createSingletonService() { + return SingletonServiceHolder.INSTANCE; + } + + private static class SingletonServiceHolder { + static final XmppService INSTANCE; + static { + SimpleTestServiceBuilder<XmppService> instance = builder(); + instance.addLocalMapping( + () -> new SingletonXmppService(new XmppLocalContainerService(), "xmpp")) + .addRemoteMapping(XmppRemoteService::new); + INSTANCE = instance.build(); + } + } + public static class XmppLocalContainerService extends XmppLocalContainerInfraService implements XmppService { } diff --git a/test-infra/camel-test-infra-zookeeper/src/main/java/org/apache/camel/test/infra/zookeeper/services/ZooKeeperServiceFactory.java b/test-infra/camel-test-infra-zookeeper/src/main/java/org/apache/camel/test/infra/zookeeper/services/ZooKeeperServiceFactory.java index 16c1084060f9..e1714ded9e4e 100644 --- a/test-infra/camel-test-infra-zookeeper/src/main/java/org/apache/camel/test/infra/zookeeper/services/ZooKeeperServiceFactory.java +++ b/test-infra/camel-test-infra-zookeeper/src/main/java/org/apache/camel/test/infra/zookeeper/services/ZooKeeperServiceFactory.java @@ -47,6 +47,21 @@ public final class ZooKeeperServiceFactory { .addRemoteMapping(ZooKeeperRemoteService::new) .build(); } + + public static ZooKeeperService createSingletonService() { + return SingletonServiceHolder.INSTANCE; + } + + private static class SingletonServiceHolder { + static final ZooKeeperService INSTANCE; + static { + SimpleTestServiceBuilder<ZooKeeperService> instance = builder(); + instance.addLocalMapping( + () -> new SingletonZooKeeperService(new ZooKeeperLocalContainerService(), "zookeeper")) + .addRemoteMapping(ZooKeeperRemoteService::new); + INSTANCE = instance.build(); + } + } } class ZooKeeperLocalContainerService extends ZooKeeperLocalContainerInfraService
