You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2022/03/22 12:55:38 UTC
[camel] branch main updated: [CAMEL-17838] create single FHIR sever when running IT (#7246)
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 27122f8 [CAMEL-17838] create single FHIR sever when running IT (#7246)
27122f8 is described below
commit 27122f82f5d7da0a0a5c75137a908fdcff4446ff
Author: John Poth <po...@gmail.com>
AuthorDate: Tue Mar 22 13:54:57 2022 +0100
[CAMEL-17838] create single FHIR sever when running IT (#7246)
---
.../component/fhir/AbstractFhirTestSupport.java | 2 +-
...ava => FhirLocalSingletonContainerService.java} | 32 +++++++++++++---------
.../infra/fhir/services/FhirServiceFactory.java | 7 +++++
3 files changed, 27 insertions(+), 14 deletions(-)
diff --git a/components/camel-fhir/camel-fhir-component/src/test/java/org/apache/camel/component/fhir/AbstractFhirTestSupport.java b/components/camel-fhir/camel-fhir-component/src/test/java/org/apache/camel/component/fhir/AbstractFhirTestSupport.java
index 233ec0d..18f6d52 100644
--- a/components/camel-fhir/camel-fhir-component/src/test/java/org/apache/camel/component/fhir/AbstractFhirTestSupport.java
+++ b/components/camel-fhir/camel-fhir-component/src/test/java/org/apache/camel/component/fhir/AbstractFhirTestSupport.java
@@ -44,7 +44,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
public abstract class AbstractFhirTestSupport extends CamelTestSupport {
@RegisterExtension
- public static FhirService service = FhirServiceFactory.createService();
+ public static FhirService service = FhirServiceFactory.createSingletonService();
protected Patient patient;
FhirContext fhirContext;
diff --git a/test-infra/camel-test-infra-fhir/src/test/java/org/apache/camel/test/infra/fhir/services/FhirServiceFactory.java b/test-infra/camel-test-infra-fhir/src/test/java/org/apache/camel/test/infra/fhir/services/FhirLocalSingletonContainerService.java
similarity index 51%
copy from test-infra/camel-test-infra-fhir/src/test/java/org/apache/camel/test/infra/fhir/services/FhirServiceFactory.java
copy to test-infra/camel-test-infra-fhir/src/test/java/org/apache/camel/test/infra/fhir/services/FhirLocalSingletonContainerService.java
index 2ebb748..6860473 100644
--- a/test-infra/camel-test-infra-fhir/src/test/java/org/apache/camel/test/infra/fhir/services/FhirServiceFactory.java
+++ b/test-infra/camel-test-infra-fhir/src/test/java/org/apache/camel/test/infra/fhir/services/FhirLocalSingletonContainerService.java
@@ -16,25 +16,31 @@
*/
package org.apache.camel.test.infra.fhir.services;
-import org.apache.camel.test.infra.common.services.SimpleTestServiceBuilder;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.junit.jupiter.api.extension.ExtensionContext;
-public final class FhirServiceFactory {
- private static final Logger LOG = LoggerFactory.getLogger(FhirServiceFactory.class);
+public class FhirLocalSingletonContainerService extends FhirLocalContainerService
+ implements ExtensionContext.Store.CloseableResource {
- private FhirServiceFactory() {
+ private static boolean started;
+ @Override
+ public void beforeAll(ExtensionContext extensionContext) {
+ if (!started) {
+ started = true;
+ // Your "before all tests" startup logic goes here
+ // The following line registers a callback hook when the root test context is shut down
+ extensionContext.getRoot().getStore(ExtensionContext.Namespace.GLOBAL).put("fhir", this);
+ super.initialize();
+ }
}
- public static SimpleTestServiceBuilder<FhirService> builder() {
- return new SimpleTestServiceBuilder<>("fhir");
+ @Override
+ public void afterAll(ExtensionContext extensionContext) {
+ // no op
}
- public static FhirService createService() {
- return builder()
- .addLocalMapping(FhirLocalContainerService::new)
- .addRemoteMapping(FhirRemoteService::new)
- .build();
+ @Override
+ public void close() {
+ super.shutdown();
}
}
diff --git a/test-infra/camel-test-infra-fhir/src/test/java/org/apache/camel/test/infra/fhir/services/FhirServiceFactory.java b/test-infra/camel-test-infra-fhir/src/test/java/org/apache/camel/test/infra/fhir/services/FhirServiceFactory.java
index 2ebb748..1eaf60f 100644
--- a/test-infra/camel-test-infra-fhir/src/test/java/org/apache/camel/test/infra/fhir/services/FhirServiceFactory.java
+++ b/test-infra/camel-test-infra-fhir/src/test/java/org/apache/camel/test/infra/fhir/services/FhirServiceFactory.java
@@ -37,4 +37,11 @@ public final class FhirServiceFactory {
.addRemoteMapping(FhirRemoteService::new)
.build();
}
+
+ public static FhirService createSingletonService() {
+ return builder()
+ .addLocalMapping(() -> new FhirLocalSingletonContainerService())
+ .addRemoteMapping(FhirRemoteService::new)
+ .build();
+ }
}