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 2019/11/01 07:40:02 UTC
[camel] branch master updated: Fixed CAMEL-14117
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/master by this push:
new 1edd65e Fixed CAMEL-14117
1edd65e is described below
commit 1edd65eb4baf3d7b3631a214c70aa7734a0a80ca
Author: Timo 'Timii' Paananen <pa...@gmail.com>
AuthorDate: Fri Nov 1 08:03:21 2019 +0200
Fixed CAMEL-14117
---
.../apache/camel/component/cxf/CxfComponent.java | 5 -
.../component/cxf/CxfComponentEnableMtomTest.java | 133 +++++++++++++++++++++
2 files changed, 133 insertions(+), 5 deletions(-)
diff --git a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfComponent.java b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfComponent.java
index 31a679b..4bbd7f2 100644
--- a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfComponent.java
+++ b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfComponent.java
@@ -123,11 +123,6 @@ public class CxfComponent extends HeaderFilterStrategyComponent implements SSLCo
Map<String, Object> properties = PropertiesHelper.extractProperties(parameters, "properties.");
result.setProperties(properties);
- if (result.getProperties() != null) {
- // set the properties of MTOM
- result.setMtomEnabled(Boolean.parseBoolean((String) result.getProperties().get(Message.MTOM_ENABLED)));
- }
-
// use global ssl config if set
if (result.getSslContextParameters() == null) {
result.setSslContextParameters(retrieveGlobalSslContextParameters());
diff --git a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfComponentEnableMtomTest.java b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfComponentEnableMtomTest.java
new file mode 100644
index 0000000..0b65584
--- /dev/null
+++ b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfComponentEnableMtomTest.java
@@ -0,0 +1,133 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.cxf;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.Endpoint;
+import org.apache.camel.spring.SpringCamelContext;
+import org.apache.camel.test.spring.CamelSpringRunner;
+import org.apache.camel.test.spring.MockEndpoints;
+import org.apache.cxf.message.Message;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.test.context.ContextConfiguration;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+@RunWith(CamelSpringRunner.class)
+@ContextConfiguration(classes = CxfComponentEnableMtomTest.TestConfig.class)
+@MockEndpoints
+public class CxfComponentEnableMtomTest {
+
+ @Autowired
+ private CamelContext context;
+
+ @Test
+ public void testIsMtomEnabled_EnabledThroughBeanSetter() throws InterruptedException {
+ Endpoint endpoint = context.getEndpoint("cxf:bean:mtomByBeanSetter");
+
+ if (endpoint instanceof CxfEndpoint) {
+ CxfEndpoint cxfEndpoint = (CxfEndpoint) endpoint;
+ assertTrue("Mtom should be enabled", cxfEndpoint.isMtomEnabled());
+ } else {
+ fail("CXF Endpoint not found");
+ }
+ }
+
+ @Test
+ public void testIsMtomEnabled_EnabledThroughBeanProperties() throws InterruptedException {
+ Endpoint endpoint = context.getEndpoint("cxf:bean:mtomByBeanProperties");
+
+ if (endpoint instanceof CxfEndpoint) {
+ CxfEndpoint cxfEndpoint = (CxfEndpoint) endpoint;
+ assertTrue("Mtom should be enabled", cxfEndpoint.isMtomEnabled());
+ } else {
+ fail("CXF Endpoint not found");
+ }
+ }
+
+ @Test
+ public void testIsMtomEnabled_EnabledThroughURIProperties() throws InterruptedException {
+ Endpoint endpoint = context.getEndpoint("cxf:bean:mtomByURIProperties?properties.mtom-enabled=true");
+
+ if (endpoint instanceof CxfEndpoint) {
+ CxfEndpoint cxfEndpoint = (CxfEndpoint) endpoint;
+ assertTrue("Mtom should be enabled", cxfEndpoint.isMtomEnabled());
+ } else {
+ fail("CXF Endpoint not found");
+ }
+ }
+
+ @Test
+ public void testIsMtomEnabled_EnabledThroughQueryParameters() throws InterruptedException {
+ Endpoint endpoint = context.getEndpoint("cxf:bean:mtomByQueryParameters?mtomEnabled=true");
+
+ if (endpoint instanceof CxfEndpoint) {
+ CxfEndpoint cxfEndpoint = (CxfEndpoint) endpoint;
+ assertTrue("Mtom should be enabled", cxfEndpoint.isMtomEnabled());
+ } else {
+ fail("CXF Endpoint not found");
+ }
+ }
+
+ @Configuration
+ static class TestConfig {
+
+ @Bean
+ public CamelContext context() {
+ return new SpringCamelContext();
+ }
+
+ @Bean("mtomByQueryParameters")
+ public CxfEndpoint mtomByQueryParameters(CamelContext context) {
+ CxfEndpoint endpoint = new CxfEndpoint();
+ endpoint.setCamelContext(context);
+ return endpoint;
+ }
+
+ @Bean("mtomByURIProperties")
+ public CxfEndpoint mtomByURIProperties() {
+ return new CxfEndpoint();
+ }
+
+ @Bean("mtomByBeanProperties")
+ public CxfEndpoint mtomByBeanProperties() {
+ CxfEndpoint endpoint = new CxfEndpoint();
+ Map<String, Object> properties = new HashMap<>();
+ properties.put(Message.MTOM_ENABLED, true);
+
+ endpoint.setProperties(properties);
+ return endpoint;
+
+ }
+
+ @Bean("mtomByBeanSetter")
+ public CxfEndpoint mtomByBeanSetter() {
+ CxfEndpoint endpoint = new CxfEndpoint();
+ endpoint.setMtomEnabled(true);
+ return endpoint;
+
+ }
+ }
+}