This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch camel-2.24.x
in repository https://gitbox.apache.org/repos/asf/camel.git

commit ee8a129bcb66d317d99ef6ef23c9da92ee685d05
Author: Timo 'Timii' Paananen <paanane...@gmail.com>
AuthorDate: Fri Nov 1 08:03:21 2019 +0200

    Fixed CAMEL-14117
---
 .../apache/camel/component/cxf/CxfComponent.java   |   4 -
 .../component/cxf/CxfComponentEnableMtomTest.java  | 133 +++++++++++++++++++++
 2 files changed, 133 insertions(+), 4 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 1ab8b9c..42b3b12 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
@@ -127,10 +127,6 @@ public class CxfComponent extends 
HeaderFilterStrategyComponent implements SSLCo
         if (properties != null) {
             result.setProperties(properties);
         }
-        if (result.getProperties() != null) {
-            // set the properties of MTOM
-            result.setMtomEnabled(Boolean.valueOf((String) 
result.getProperties().get(Message.MTOM_ENABLED)));
-        }
 
         // use global ssl config if set
         if (result.getSslContextParameters() == null) {
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..37762f1
--- /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;
+
+        }
+    }
+}

Reply via email to