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/10 09:58:01 UTC

[camel-spring-boot] branch main updated: camel-fhir - tests should use standard way with the docker test service using the annotated way.

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-spring-boot.git


The following commit(s) were added to refs/heads/main by this push:
     new 23ae86f  camel-fhir - tests should use standard way with the docker test service using the annotated way.
23ae86f is described below

commit 23ae86fd3d0ff805145e6d7ad5fe5f94bab17f8b
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Thu Mar 10 10:57:43 2022 +0100

    camel-fhir - tests should use standard way with the docker test service using the annotated way.
---
 .../camel/component/fhir/AbstractFhirTestSupport.java       |  6 ++++++
 .../apache/camel/component/fhir/DefaultCamelContext.java    |  5 ++---
 .../org/apache/camel/component/fhir/FhirCreateTest.java     |  2 +-
 .../java/org/apache/camel/component/fhir/FhirServer.java    | 13 ++-----------
 .../org/apache/camel/component/fhir/FhirSimpleTest.java     |  2 +-
 5 files changed, 12 insertions(+), 16 deletions(-)

diff --git a/components-starter/camel-fhir-starter/src/test/java/org/apache/camel/component/fhir/AbstractFhirTestSupport.java b/components-starter/camel-fhir-starter/src/test/java/org/apache/camel/component/fhir/AbstractFhirTestSupport.java
index f447fb2..20b2c55 100644
--- a/components-starter/camel-fhir-starter/src/test/java/org/apache/camel/component/fhir/AbstractFhirTestSupport.java
+++ b/components-starter/camel-fhir-starter/src/test/java/org/apache/camel/component/fhir/AbstractFhirTestSupport.java
@@ -23,10 +23,13 @@ import ca.uhn.fhir.rest.server.exceptions.ResourceGoneException;
 import org.apache.camel.CamelContext;
 import org.apache.camel.CamelExecutionException;
 import org.apache.camel.ProducerTemplate;
+import org.apache.camel.test.infra.fhir.services.FhirService;
+import org.apache.camel.test.infra.fhir.services.FhirServiceFactory;
 import org.hl7.fhir.dstu3.model.Bundle;
 import org.hl7.fhir.dstu3.model.HumanName;
 import org.hl7.fhir.dstu3.model.Patient;
 import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.extension.RegisterExtension;
 import org.springframework.beans.factory.annotation.Autowired;
 
 import static org.junit.jupiter.api.Assertions.assertFalse;
@@ -34,6 +37,9 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
 
 public abstract class AbstractFhirTestSupport {
 
+    @RegisterExtension
+    public static FhirService service = FhirServiceFactory.createService();
+
     protected Patient patient;
     @Autowired
     protected FhirContext fhirContext;
diff --git a/components-starter/camel-fhir-starter/src/test/java/org/apache/camel/component/fhir/DefaultCamelContext.java b/components-starter/camel-fhir-starter/src/test/java/org/apache/camel/component/fhir/DefaultCamelContext.java
index 0a9ef53..5718c5d 100644
--- a/components-starter/camel-fhir-starter/src/test/java/org/apache/camel/component/fhir/DefaultCamelContext.java
+++ b/components-starter/camel-fhir-starter/src/test/java/org/apache/camel/component/fhir/DefaultCamelContext.java
@@ -19,11 +19,10 @@ package org.apache.camel.component.fhir;
 import ca.uhn.fhir.context.FhirContext;
 import org.apache.camel.CamelContext;
 import org.apache.camel.spring.boot.CamelContextConfiguration;
+import org.apache.camel.test.infra.fhir.services.FhirService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Bean;
 
-import static org.apache.camel.component.fhir.FhirServer.service;
-
 public class DefaultCamelContext {
 
     @Autowired
@@ -35,7 +34,7 @@ public class DefaultCamelContext {
             @Override
             public void beforeApplicationStart(CamelContext context) {
                 final FhirConfiguration configuration = new FhirConfiguration();
-                configuration.setServerUrl(service.getServiceBaseURL());
+                configuration.setServerUrl(AbstractFhirTestSupport.service.getServiceBaseURL());
                 configuration.setFhirContext(fhirContext);
 
                 // add FhirComponent to Camel context
diff --git a/components-starter/camel-fhir-starter/src/test/java/org/apache/camel/component/fhir/FhirCreateTest.java b/components-starter/camel-fhir-starter/src/test/java/org/apache/camel/component/fhir/FhirCreateTest.java
index b285b55..e444821 100644
--- a/components-starter/camel-fhir-starter/src/test/java/org/apache/camel/component/fhir/FhirCreateTest.java
+++ b/components-starter/camel-fhir-starter/src/test/java/org/apache/camel/component/fhir/FhirCreateTest.java
@@ -102,7 +102,7 @@ public class FhirCreateTest extends AbstractFhirTestSupport {
                 @Override
                 public void configure() {
                     // test route for resource
-                    String serverUrl = FhirServer.service.getServiceBaseURL();
+                    String serverUrl = service.getServiceBaseURL();
                     from("direct://RESOURCE")
                             .to("fhir://" + PATH_PREFIX + "/resource?inBody=resource&serverUrl="
                                     + serverUrl);
diff --git a/components-starter/camel-fhir-starter/src/test/java/org/apache/camel/component/fhir/FhirServer.java b/components-starter/camel-fhir-starter/src/test/java/org/apache/camel/component/fhir/FhirServer.java
index 7eb7ac0..f022e1d 100644
--- a/components-starter/camel-fhir-starter/src/test/java/org/apache/camel/component/fhir/FhirServer.java
+++ b/components-starter/camel-fhir-starter/src/test/java/org/apache/camel/component/fhir/FhirServer.java
@@ -28,25 +28,16 @@ import org.springframework.context.annotation.Bean;
  */
 public class FhirServer {
 
-    static FhirService service;
-
-    static {
-        // We don't want a new FHIR server for every test class
-        // https://www.testcontainers.org/test_framework_integration/manual_lifecycle_control/
-        service = FhirServiceFactory.createService();
-        service.initialize();
-    }
-
     @Bean
     FhirContext fhirContext(){
         FhirContext fhirContext = new FhirContext(FhirVersionEnum.DSTU3);
         // Set proxy so that FHIR resource URLs returned by the server are using the correct host and port
-        fhirContext.getRestfulClientFactory().setProxy(service.getHost(), service.getPort());
+        fhirContext.getRestfulClientFactory().setProxy(AbstractFhirTestSupport.service.getHost(), AbstractFhirTestSupport.service.getPort());
         return fhirContext;
     }
 
     @Bean
     IGenericClient fhirClient(FhirContext fc){
-        return  fc.newRestfulGenericClient(service.getServiceBaseURL());
+        return  fc.newRestfulGenericClient(AbstractFhirTestSupport.service.getServiceBaseURL());
     }
 }
diff --git a/components-starter/camel-fhir-starter/src/test/java/org/apache/camel/component/fhir/FhirSimpleTest.java b/components-starter/camel-fhir-starter/src/test/java/org/apache/camel/component/fhir/FhirSimpleTest.java
index b8b2d7e..997e278 100644
--- a/components-starter/camel-fhir-starter/src/test/java/org/apache/camel/component/fhir/FhirSimpleTest.java
+++ b/components-starter/camel-fhir-starter/src/test/java/org/apache/camel/component/fhir/FhirSimpleTest.java
@@ -78,7 +78,7 @@ public class FhirSimpleTest extends AbstractFhirTestSupport {
                 @Override
                 public void configure() {
                     from("direct://RESOURCE")
-                            .to("fhir://" + PATH_PREFIX + "/resource?inBody=resource&serverUrl=" + FhirServer.service.getServiceBaseURL()
+                            .to("fhir://" + PATH_PREFIX + "/resource?inBody=resource&serverUrl=" + service.getServiceBaseURL()
                                     + "&fhirVersion=DSTU3");
                 }
             };