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 2013/05/11 12:21:29 UTC
git commit: CAMEL-6351: blueprint also supports placeholder namespace
Updated Branches:
refs/heads/master fd7687b2a -> e8b4e9632
CAMEL-6351: blueprint also supports placeholder namespace
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/e8b4e963
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/e8b4e963
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/e8b4e963
Branch: refs/heads/master
Commit: e8b4e96323ba9e768c6cf6d02ae79f6c30a2d4a6
Parents: fd7687b
Author: Claus Ibsen <da...@apache.org>
Authored: Sat May 11 12:21:18 2013 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Sat May 11 12:21:18 2013 +0200
----------------------------------------------------------------------
.../blueprint/handler/CamelNamespaceHandler.java | 3 +-
.../OSGI-INF/blueprint/camel-blueprint.xml | 10 ++-
.../BlueprintOptionalPropertiesDslTest.java | 43 +++++++++++++
.../BlueprintOptionalPropertiesDslTest.xml | 50 +++++++++++++++
.../camel/test/blueprint/myproperties.properties | 35 ++++++++++
5 files changed, 137 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/e8b4e963/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/handler/CamelNamespaceHandler.java
----------------------------------------------------------------------
diff --git a/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/handler/CamelNamespaceHandler.java b/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/handler/CamelNamespaceHandler.java
index 011529a..c78717e 100644
--- a/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/handler/CamelNamespaceHandler.java
+++ b/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/handler/CamelNamespaceHandler.java
@@ -101,8 +101,9 @@ public class CamelNamespaceHandler implements NamespaceHandler {
private static final String SECURE_RANDOM_PARAMETERS = "secureRandomParameters";
private static final String SSL_CONTEXT_PARAMETERS = "sslContextParameters";
- private static final String SPRING_NS = "http://camel.apache.org/schema/spring";
private static final String BLUEPRINT_NS = "http://camel.apache.org/schema/blueprint";
+ private static final String PLACEHOLDER_NS = "http://camel.apache.org/schema/placeholder";
+ private static final String SPRING_NS = "http://camel.apache.org/schema/spring";
private static final transient Logger LOG = LoggerFactory.getLogger(CamelNamespaceHandler.class);
http://git-wip-us.apache.org/repos/asf/camel/blob/e8b4e963/components/camel-blueprint/src/main/resources/OSGI-INF/blueprint/camel-blueprint.xml
----------------------------------------------------------------------
diff --git a/components/camel-blueprint/src/main/resources/OSGI-INF/blueprint/camel-blueprint.xml b/components/camel-blueprint/src/main/resources/OSGI-INF/blueprint/camel-blueprint.xml
index dad4cb4..8da82c4 100644
--- a/components/camel-blueprint/src/main/resources/OSGI-INF/blueprint/camel-blueprint.xml
+++ b/components/camel-blueprint/src/main/resources/OSGI-INF/blueprint/camel-blueprint.xml
@@ -21,10 +21,14 @@
<service interface="org.apache.aries.blueprint.NamespaceHandler">
<service-properties>
- <entry key="osgi.service.blueprint.namespace" value="http://camel.apache.org/schema/blueprint"/>
+ <entry key="osgi.service.blueprint.namespace">
+ <array value-type="java.lang.String">
+ <value>http://camel.apache.org/schema/blueprint</value>
+ <value>http://camel.apache.org/schema/placeholder</value>
+ </array>
+ </entry>
</service-properties>
- <bean class="org.apache.camel.blueprint.handler.CamelNamespaceHandler">
- </bean>
+ <bean class="org.apache.camel.blueprint.handler.CamelNamespaceHandler"/>
</service>
</blueprint>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/e8b4e963/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/BlueprintOptionalPropertiesDslTest.java
----------------------------------------------------------------------
diff --git a/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/BlueprintOptionalPropertiesDslTest.java b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/BlueprintOptionalPropertiesDslTest.java
new file mode 100644
index 0000000..1e4f75f
--- /dev/null
+++ b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/BlueprintOptionalPropertiesDslTest.java
@@ -0,0 +1,43 @@
+/**
+ * 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.test.blueprint;
+
+import org.junit.Test;
+
+public class BlueprintOptionalPropertiesDslTest extends CamelBlueprintTestSupport {
+
+ @Override
+ protected String getBlueprintDescriptor() {
+ return "org/apache/camel/test/blueprint/BlueprintOptionalPropertiesDslTest.xml";
+ }
+
+ @Test
+ public void testPlaceholderDslTest() throws Exception {
+ getMockEndpoint("mock:a").expectedMessageCount(1);
+ getMockEndpoint("mock:b").expectedMessageCount(0);
+
+ try {
+ template.sendBody("direct:start", "Hello World");
+ fail("Should have thrown an exception");
+ } catch (Exception e) {
+ // expected
+ }
+
+ assertMockEndpointsSatisfied();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/e8b4e963/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/BlueprintOptionalPropertiesDslTest.xml
----------------------------------------------------------------------
diff --git a/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/BlueprintOptionalPropertiesDslTest.xml b/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/BlueprintOptionalPropertiesDslTest.xml
new file mode 100644
index 0000000..93b95e9
--- /dev/null
+++ b/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/BlueprintOptionalPropertiesDslTest.xml
@@ -0,0 +1,50 @@
+<?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.
+-->
+<!-- START SNIPPET: example -->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:prop="http://camel.apache.org/schema/placeholder"
+ xsi:schemaLocation="
+ http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
+
+ <!-- Notice in the declaration above, we have defined the prop prefix as the Camel placeholder namespace -->
+
+ <bean id="damn" class="java.lang.IllegalArgumentException">
+ <argument index="0" value="Damn"/>
+ </bean>
+
+ <camelContext xmlns="http://camel.apache.org/schema/blueprint">
+
+ <propertyPlaceholder id="properties"
+ location="classpath:org/apache/camel/test/blueprint/myproperties.properties"/>
+
+ <route>
+ <from uri="direct:start"/>
+ <!-- use prop namespace, to define a property placeholder, which maps to
+ option stopOnException={{stop}} -->
+ <multicast prop:stopOnException="stop">
+ <to uri="mock:a"/>
+ <throwException ref="damn"/>
+ <to uri="mock:b"/>
+ </multicast>
+ </route>
+
+ </camelContext>
+
+</blueprint>
+<!-- END SNIPPET: example -->
http://git-wip-us.apache.org/repos/asf/camel/blob/e8b4e963/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/myproperties.properties
----------------------------------------------------------------------
diff --git a/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/myproperties.properties b/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/myproperties.properties
new file mode 100644
index 0000000..1bc02cc
--- /dev/null
+++ b/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/myproperties.properties
@@ -0,0 +1,35 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
+cool.end=mock:result
+cool.result=result
+cool.concat=mock:{{cool.result}}
+cool.start=direct:cool
+cool.showid=true
+cool.name=Camel
+
+# circular reference test
+cool.a={{cool.b}}
+cool.b={{cool.c}}
+cool.c={{cool.a}}
+
+cool.mock=mock
+
+myCoolCharset=iso-8859-1
+slipDelimiter=##
+
+stop=true