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 2017/01/22 18:51:48 UTC
[02/11] camel git commit: CAMEL-10546: Completed with a spring xml
test
CAMEL-10546: Completed with a spring xml test
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/3c012b04
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/3c012b04
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/3c012b04
Branch: refs/heads/master
Commit: 3c012b041f2ff1412f185bfb89897c33077c13a7
Parents: 628ceee
Author: aldettinger <al...@gmail.com>
Authored: Sat Jan 21 12:55:49 2017 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Sun Jan 22 18:06:43 2017 +0100
----------------------------------------------------------------------
.../xml/AbstractCamelContextFactoryBean.java | 1 +
.../spring/handler/CamelNamespaceHandler.java | 1 +
.../camel/spring/CamelContextAwareTest.java | 4 +--
.../camel/spring/CamelGlobalOptionsTest.java | 36 ++++++++++++++++++++
.../apache/camel/spring/camelGlobalOptions.xml | 36 ++++++++++++++++++++
5 files changed, 76 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/3c012b04/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java
----------------------------------------------------------------------
diff --git a/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java b/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java
index fb2dd93..e2c1892 100644
--- a/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java
+++ b/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java
@@ -175,6 +175,7 @@ public abstract class AbstractCamelContextFactoryBean<T extends ModelCamelContex
if (getGlobalOptions() != null) {
mergedOptions.putAll(getGlobalOptions().asMap());
}
+
getContext().setGlobalOptions(mergedOptions);
// and enable lazy loading of type converters if applicable
http://git-wip-us.apache.org/repos/asf/camel/blob/3c012b04/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java b/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java
index 12cc996..ff17b4d 100644
--- a/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java
+++ b/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java
@@ -390,6 +390,7 @@ public class CamelNamespaceHandler extends NamespaceHandlerSupport {
builder.addPropertyValue("routeRefs", factoryBean.getRouteRefs());
builder.addPropertyValue("restRefs", factoryBean.getRestRefs());
builder.addPropertyValue("properties", factoryBean.getProperties());
+ builder.addPropertyValue("globalOptions", factoryBean.getGlobalOptions());
builder.addPropertyValue("packageScan", factoryBean.getPackageScan());
builder.addPropertyValue("contextScan", factoryBean.getContextScan());
if (factoryBean.getPackages().length > 0) {
http://git-wip-us.apache.org/repos/asf/camel/blob/3c012b04/components/camel-spring/src/test/java/org/apache/camel/spring/CamelContextAwareTest.java
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/CamelContextAwareTest.java b/components/camel-spring/src/test/java/org/apache/camel/spring/CamelContextAwareTest.java
index 338aefa..bad0a6c 100644
--- a/components/camel-spring/src/test/java/org/apache/camel/spring/CamelContextAwareTest.java
+++ b/components/camel-spring/src/test/java/org/apache/camel/spring/CamelContextAwareTest.java
@@ -33,8 +33,8 @@ public class CamelContextAwareTest extends SpringTestSupport {
public void testInjectionPoints() throws Exception {
assertNotNull("No CamelContext injected!", bean1.getCamelContext());
Map<String, String> globalOptions = bean1.getCamelContext().getGlobalOptions();
- assertNotNull("the properties should not been null", globalOptions);
- assertEquals("No properties injected", globalOptions.size(), 1);
+ assertNotNull("The global options reference should not be null", globalOptions);
+ assertEquals("No global options injected", globalOptions.size(), 1);
assertEquals("Should get the value of org.apache.camel.test", globalOptions.get("org.apache.camel.test"), "this is a test first");
}
http://git-wip-us.apache.org/repos/asf/camel/blob/3c012b04/components/camel-spring/src/test/java/org/apache/camel/spring/CamelGlobalOptionsTest.java
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/CamelGlobalOptionsTest.java b/components/camel-spring/src/test/java/org/apache/camel/spring/CamelGlobalOptionsTest.java
new file mode 100644
index 0000000..c9bf29c
--- /dev/null
+++ b/components/camel-spring/src/test/java/org/apache/camel/spring/CamelGlobalOptionsTest.java
@@ -0,0 +1,36 @@
+/**
+ * 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.spring;
+
+import org.springframework.context.support.AbstractXmlApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class CamelGlobalOptionsTest extends SpringTestSupport {
+
+ public void testGlobalOptionsOverrideProperties() {
+ assertEquals(3, context.getGlobalOptions().size());
+ assertEquals("VALUE_1", context.getGlobalOptions().get("KEY_1"));
+ assertEquals("VALUE_2_OVERIDDEN", context.getGlobalOptions().get("KEY_2"));
+ assertEquals("VALUE_3", context.getGlobalOptions().get("KEY_3"));
+ }
+
+ @Override
+ protected AbstractXmlApplicationContext createApplicationContext() {
+ return new ClassPathXmlApplicationContext("org/apache/camel/spring/camelGlobalOptions.xml");
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/3c012b04/components/camel-spring/src/test/resources/org/apache/camel/spring/camelGlobalOptions.xml
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/resources/org/apache/camel/spring/camelGlobalOptions.xml b/components/camel-spring/src/test/resources/org/apache/camel/spring/camelGlobalOptions.xml
new file mode 100644
index 0000000..c6cf335
--- /dev/null
+++ b/components/camel-spring/src/test/resources/org/apache/camel/spring/camelGlobalOptions.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- 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. -->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
+ ">
+
+ <camelContext xmlns="http://camel.apache.org/schema/spring">
+ <properties>
+ <property key="KEY_1" value="VALUE_1" />
+ <property key="KEY_2" value="VALUE_2" />
+ </properties>
+
+ <globalOptions>
+ <globalOption key="KEY_2" value="VALUE_2_OVERIDDEN" />
+ <globalOption key="KEY_3" value="VALUE_3" />
+ </globalOptions>
+
+ <route>
+ <from uri="direct:start" />
+ <to uri="log:TEST" />
+ </route>
+
+ </camelContext>
+</beans>