Skip to content

Commit 6d7050d

Browse files
gnodetclaude
andcommitted
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 <noreply@anthropic.com>
1 parent 3a3f118 commit 6d7050d

File tree

33 files changed

+1216
-2
lines changed

33 files changed

+1216
-2
lines changed

components/camel-spring-parent/camel-spring-rabbitmq/src/test/java/org/apache/camel/component/springrabbit/test/infra/services/RabbitMQServiceFactory.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,8 @@ private RabbitMQServiceFactory() {
2626
public static RabbitMQService createService() {
2727
return org.apache.camel.test.infra.rabbitmq.services.RabbitMQServiceFactory.createService();
2828
}
29+
30+
public static RabbitMQService createSingletonService() {
31+
return org.apache.camel.test.infra.rabbitmq.services.RabbitMQServiceFactory.createSingletonService();
32+
}
2933
}

test-infra/camel-test-infra-azure-storage-blob/src/main/java/org/apache/camel/test/infra/azure/storage/blob/services/AzureStorageBlobServiceFactory.java

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,45 @@
1717

1818
package org.apache.camel.test.infra.azure.storage.blob.services;
1919

20+
import org.apache.camel.test.infra.azure.common.AzureCredentialsHolder;
2021
import org.apache.camel.test.infra.azure.common.services.AzureService;
2122
import org.apache.camel.test.infra.common.services.SimpleTestServiceBuilder;
23+
import org.apache.camel.test.infra.common.services.SingletonService;
2224

2325
public final class AzureStorageBlobServiceFactory {
26+
27+
private static class SingletonAzureStorageBlobService extends SingletonService<AzureService>
28+
implements AzureService {
29+
public SingletonAzureStorageBlobService(AzureService service, String name) {
30+
super(service, name);
31+
}
32+
33+
@Override
34+
public AzureCredentialsHolder azureCredentials() {
35+
return getService().azureCredentials();
36+
}
37+
38+
@Override
39+
public String accountName() {
40+
return getService().accountName();
41+
}
42+
43+
@Override
44+
public String accessKey() {
45+
return getService().accessKey();
46+
}
47+
48+
@Override
49+
public String host() {
50+
return getService().host();
51+
}
52+
53+
@Override
54+
public int port() {
55+
return getService().port();
56+
}
57+
}
58+
2459
private AzureStorageBlobServiceFactory() {
2560

2661
}
@@ -36,6 +71,21 @@ public static AzureService createService() {
3671
.build();
3772
}
3873

74+
public static AzureService createSingletonService() {
75+
return SingletonServiceHolder.INSTANCE;
76+
}
77+
78+
private static class SingletonServiceHolder {
79+
static final AzureService INSTANCE;
80+
static {
81+
SimpleTestServiceBuilder<AzureService> instance = builder();
82+
instance.addLocalMapping(
83+
() -> new SingletonAzureStorageBlobService(new AzureStorageBlobLocalContainerService(), "azure"))
84+
.addRemoteMapping(AzureStorageBlobRemoteService::new);
85+
INSTANCE = instance.build();
86+
}
87+
}
88+
3989
static class AzureStorageBlobLocalContainerService extends AzureStorageBlobLocalContainerInfraService
4090
implements AzureService {
4191
}

test-infra/camel-test-infra-azure-storage-datalake/src/main/java/org/apache/camel/test/infra/azure/storage/datalake/services/AzureStorageDataLakeServiceFactory.java

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,45 @@
1717

1818
package org.apache.camel.test.infra.azure.storage.datalake.services;
1919

20+
import org.apache.camel.test.infra.azure.common.AzureCredentialsHolder;
2021
import org.apache.camel.test.infra.azure.common.services.AzureService;
2122
import org.apache.camel.test.infra.common.services.SimpleTestServiceBuilder;
23+
import org.apache.camel.test.infra.common.services.SingletonService;
2224

2325
public final class AzureStorageDataLakeServiceFactory {
2426

27+
private static class SingletonAzureStorageDataLakeService extends SingletonService<AzureService>
28+
implements AzureService {
29+
public SingletonAzureStorageDataLakeService(AzureService service, String name) {
30+
super(service, name);
31+
}
32+
33+
@Override
34+
public AzureCredentialsHolder azureCredentials() {
35+
return getService().azureCredentials();
36+
}
37+
38+
@Override
39+
public String accountName() {
40+
return getService().accountName();
41+
}
42+
43+
@Override
44+
public String accessKey() {
45+
return getService().accessKey();
46+
}
47+
48+
@Override
49+
public String host() {
50+
return getService().host();
51+
}
52+
53+
@Override
54+
public int port() {
55+
return getService().port();
56+
}
57+
}
58+
2559
private AzureStorageDataLakeServiceFactory() {
2660

2761
}
@@ -36,6 +70,19 @@ public static AzureService createService() {
3670
.build();
3771
}
3872

73+
public static AzureService createSingletonService() {
74+
return SingletonServiceHolder.INSTANCE;
75+
}
76+
77+
private static class SingletonServiceHolder {
78+
static final AzureService INSTANCE;
79+
static {
80+
SimpleTestServiceBuilder<AzureService> instance = builder();
81+
instance.addRemoteMapping(AzureStorageDataLakeRemoteService::new);
82+
INSTANCE = instance.build();
83+
}
84+
}
85+
3986
static class AzureStorageDataLakeRemoteService extends AzureStorageDataLakeRemoteInfraService implements AzureService {
4087
}
4188
}

test-infra/camel-test-infra-azure-storage-queue/src/main/java/org/apache/camel/test/infra/azure/storage/queue/services/AzureStorageQueueServiceFactory.java

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,45 @@
1717

1818
package org.apache.camel.test.infra.azure.storage.queue.services;
1919

20+
import org.apache.camel.test.infra.azure.common.AzureCredentialsHolder;
2021
import org.apache.camel.test.infra.azure.common.services.AzureService;
2122
import org.apache.camel.test.infra.common.services.SimpleTestServiceBuilder;
23+
import org.apache.camel.test.infra.common.services.SingletonService;
2224

2325
public final class AzureStorageQueueServiceFactory {
26+
27+
private static class SingletonAzureStorageQueueService extends SingletonService<AzureService>
28+
implements AzureService {
29+
public SingletonAzureStorageQueueService(AzureService service, String name) {
30+
super(service, name);
31+
}
32+
33+
@Override
34+
public AzureCredentialsHolder azureCredentials() {
35+
return getService().azureCredentials();
36+
}
37+
38+
@Override
39+
public String accountName() {
40+
return getService().accountName();
41+
}
42+
43+
@Override
44+
public String accessKey() {
45+
return getService().accessKey();
46+
}
47+
48+
@Override
49+
public String host() {
50+
return getService().host();
51+
}
52+
53+
@Override
54+
public int port() {
55+
return getService().port();
56+
}
57+
}
58+
2459
private AzureStorageQueueServiceFactory() {
2560

2661
}
@@ -36,6 +71,21 @@ public static AzureService createService() {
3671
.build();
3772
}
3873

74+
public static AzureService createSingletonService() {
75+
return SingletonServiceHolder.INSTANCE;
76+
}
77+
78+
private static class SingletonServiceHolder {
79+
static final AzureService INSTANCE;
80+
static {
81+
SimpleTestServiceBuilder<AzureService> instance = builder();
82+
instance.addLocalMapping(
83+
() -> new SingletonAzureStorageQueueService(new AzureStorageQueueLocalContainerService(), "azure"))
84+
.addRemoteMapping(AzureStorageQueueRemoteService::new);
85+
INSTANCE = instance.build();
86+
}
87+
}
88+
3989
public static class AzureStorageQueueLocalContainerService extends AzureStorageQueueLocalContainerInfraService
4090
implements AzureService {
4191
}

test-infra/camel-test-infra-cassandra/src/main/java/org/apache/camel/test/infra/cassandra/services/CassandraServiceFactory.java

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,36 @@
1717
package org.apache.camel.test.infra.cassandra.services;
1818

1919
import org.apache.camel.test.infra.common.services.SimpleTestServiceBuilder;
20+
import org.apache.camel.test.infra.common.services.SingletonService;
2021

2122
public final class CassandraServiceFactory {
23+
24+
private static class SingletonCassandraService extends SingletonService<CassandraService> implements CassandraService {
25+
public SingletonCassandraService(CassandraService service, String name) {
26+
super(service, name);
27+
}
28+
29+
@Override
30+
public int getCQL3Port() {
31+
return getService().getCQL3Port();
32+
}
33+
34+
@Override
35+
public String getCassandraHost() {
36+
return getService().getCassandraHost();
37+
}
38+
39+
@Override
40+
public String hosts() {
41+
return getService().hosts();
42+
}
43+
44+
@Override
45+
public int port() {
46+
return getService().port();
47+
}
48+
}
49+
2250
private CassandraServiceFactory() {
2351

2452
}
@@ -43,6 +71,21 @@ public static CassandraService createService() {
4371
.build();
4472
}
4573

74+
public static CassandraService createSingletonService() {
75+
return SingletonServiceHolder.INSTANCE;
76+
}
77+
78+
private static class SingletonServiceHolder {
79+
static final CassandraService INSTANCE;
80+
static {
81+
SimpleTestServiceBuilder<CassandraService> instance = builder();
82+
instance.addLocalMapping(
83+
() -> new SingletonCassandraService(new CassandraLocalContainerService(), "cassandra"))
84+
.addRemoteMapping(RemoteCassandraService::new);
85+
INSTANCE = instance.build();
86+
}
87+
}
88+
4689
public static class RemoteCassandraService extends RemoteCassandraInfraService implements CassandraService {
4790
}
4891
}

test-infra/camel-test-infra-chatscript/src/main/java/org/apache/camel/test/infra/chatscript/services/ChatScriptServiceFactory.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,22 @@
1717
package org.apache.camel.test.infra.chatscript.services;
1818

1919
import org.apache.camel.test.infra.common.services.SimpleTestServiceBuilder;
20+
import org.apache.camel.test.infra.common.services.SingletonService;
2021

2122
public final class ChatScriptServiceFactory {
2223

24+
private static class SingletonChatScriptService extends SingletonService<ChatScriptService>
25+
implements ChatScriptService {
26+
public SingletonChatScriptService(ChatScriptService service, String name) {
27+
super(service, name);
28+
}
29+
30+
@Override
31+
public String serviceAddress() {
32+
return getService().serviceAddress();
33+
}
34+
}
35+
2336
private ChatScriptServiceFactory() {
2437

2538
}
@@ -35,6 +48,21 @@ public static ChatScriptService createService() {
3548
.build();
3649
}
3750

51+
public static ChatScriptService createSingletonService() {
52+
return SingletonServiceHolder.INSTANCE;
53+
}
54+
55+
private static class SingletonServiceHolder {
56+
static final ChatScriptService INSTANCE;
57+
static {
58+
SimpleTestServiceBuilder<ChatScriptService> instance = builder();
59+
instance.addLocalMapping(
60+
() -> new SingletonChatScriptService(new ChatScriptLocalContainerTestService(), "chatscript"))
61+
.addRemoteMapping(ChatScriptRemoteTestService::new);
62+
INSTANCE = instance.build();
63+
}
64+
}
65+
3866
public static class ChatScriptLocalContainerTestService extends ChatScriptLocalContainerInfraService
3967
implements ChatScriptService {
4068
}

0 commit comments

Comments
 (0)