This is an automated email from the ASF dual-hosted git repository.
ffang pushed a commit to branch camel-3.14.x
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/camel-3.14.x by this push:
new 215a545 [CAMEL-17526]camel-fhir: the serverUrl configuration on
camel-fhir endpoint shouldn't be ignored (#6796)
215a545 is described below
commit 215a545f31c1f04a551fad9ab9a5352b83b1307d
Author: Freeman(Yue) Fang <[email protected]>
AuthorDate: Fri Jan 21 01:01:56 2022 -0500
[CAMEL-17526]camel-fhir: the serverUrl configuration on camel-fhir endpoint
shouldn't be ignored (#6796)
(cherry picked from commit ddfba2e83e505fa72e0e7864b686b5853a62162f)
---
.../apache/camel/component/fhir/FhirCreateIT.java | 38 ++++++++++++++++++++--
1 file changed, 36 insertions(+), 2 deletions(-)
diff --git
a/components/camel-fhir/camel-fhir-component/src/test/java/org/apache/camel/component/fhir/FhirCreateIT.java
b/components/camel-fhir/camel-fhir-component/src/test/java/org/apache/camel/component/fhir/FhirCreateIT.java
index 0c09d5c..8ca2bf0 100644
---
a/components/camel-fhir/camel-fhir-component/src/test/java/org/apache/camel/component/fhir/FhirCreateIT.java
+++
b/components/camel-fhir/camel-fhir-component/src/test/java/org/apache/camel/component/fhir/FhirCreateIT.java
@@ -19,11 +19,16 @@ package org.apache.camel.component.fhir;
import java.util.HashMap;
import java.util.Map;
+import ca.uhn.fhir.context.FhirContext;
+import ca.uhn.fhir.context.FhirVersionEnum;
import ca.uhn.fhir.rest.api.MethodOutcome;
+import org.apache.camel.CamelContext;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.fhir.api.ExtraParameters;
import org.apache.camel.component.fhir.internal.FhirApiCollection;
import org.apache.camel.component.fhir.internal.FhirCreateApiMethod;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.spi.Registry;
import org.hl7.fhir.dstu3.model.HumanName;
import org.hl7.fhir.dstu3.model.Patient;
import org.junit.jupiter.api.Test;
@@ -42,6 +47,32 @@ public class FhirCreateIT extends AbstractFhirTestSupport {
private static final Logger LOG =
LoggerFactory.getLogger(FhirCreateIT.class);
private static final String PATH_PREFIX =
FhirApiCollection.getCollection().getApiName(FhirCreateApiMethod.class).getName();
+ @Override
+ protected CamelContext createCamelContext() throws Exception {
+ //don't set serverUrl on component, use it from endpoint configration
+ Registry registry = createCamelRegistry();
+
+ if (registry != null) {
+ context = new DefaultCamelContext(registry);
+ } else {
+ context = new DefaultCamelContext();
+ }
+
+ this.fhirContext = new FhirContext(FhirVersionEnum.DSTU3);
+ // Set proxy so that FHIR resource URLs returned by the server are
using the correct host and port
+ this.fhirContext.getRestfulClientFactory().setProxy(service.getHost(),
service.getPort());
+ this.fhirClient =
this.fhirContext.newRestfulGenericClient(service.getServiceBaseURL());
+ final FhirConfiguration configuration = new FhirConfiguration();
+
+ configuration.setFhirContext(this.fhirContext);
+
+ // add FhirComponent to Camel context
+ final FhirComponent component = new FhirComponent(context);
+ component.setConfiguration(configuration);
+ context.addComponent("fhir", component);
+ return context;
+ }
+
@Test
public void testCreateResource() throws Exception {
Patient patient = new Patient().addName(new
HumanName().addGiven("Vincent").setFamily("Freeman"));
@@ -83,12 +114,15 @@ public class FhirCreateIT extends AbstractFhirTestSupport {
return new RouteBuilder() {
public void configure() {
// test route for resource
+ String serverUrl = service.getServiceBaseURL();
from("direct://RESOURCE")
- .to("fhir://" + PATH_PREFIX +
"/resource?inBody=resource");
+ .to("fhir://" + PATH_PREFIX +
"/resource?inBody=resource&serverUrl="
+ + serverUrl);
// test route for resource
from("direct://RESOURCE_STRING")
- .to("fhir://" + PATH_PREFIX +
"/resource?inBody=resourceAsString&log=true");
+ .to("fhir://" + PATH_PREFIX +
"/resource?inBody=resourceAsString&log=true&serverUrl="
+ + serverUrl);
}
};