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 2016/04/22 21:22:55 UTC
[1/2] camel git commit: CAMEL-9875 CamelBlueprintTestSupport lacks
support for multiple PIDs
Repository: camel
Updated Branches:
refs/heads/master 16163aa05 -> d59125097
CAMEL-9875 CamelBlueprintTestSupport lacks support for multiple PIDs
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/c6b14ba1
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/c6b14ba1
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/c6b14ba1
Branch: refs/heads/master
Commit: c6b14ba1bb9cf0cadd5c78b11110db2f7b50a8ef
Parents: 16163aa
Author: Kevin Earls <ke...@kevinearls.com>
Authored: Fri Apr 22 11:47:28 2016 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Fri Apr 22 21:13:04 2016 +0200
----------------------------------------------------------------------
.../blueprint/CamelBlueprintTestSupport.java | 26 +++++--
...ultiConfigurationFileAndOverrideAltTest.java | 63 ++++++++++++++++
...adMultiConfigurationFileAndOverrideTest.java | 64 ++++++++++++++++
.../src/test/resources/etc/otherstuff.cfg | 20 +++++
.../configadmin-loadmultifileoverride.xml | 78 ++++++++++++++++++++
5 files changed, 244 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/c6b14ba1/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintTestSupport.java
----------------------------------------------------------------------
diff --git a/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintTestSupport.java b/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintTestSupport.java
index 35c05c4..3bbfbef 100644
--- a/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintTestSupport.java
+++ b/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintTestSupport.java
@@ -57,7 +57,7 @@ import org.osgi.service.cm.Configuration;
import org.osgi.service.cm.ConfigurationAdmin;
/**
- * Base class for OSGi Blueprint unit tests with Camel.
+ * Base class for OSGi Blueprint unit tests with Camel
*/
public abstract class CamelBlueprintTestSupport extends CamelTestSupport {
/** Name of a system property that sets camel context creation timeout. */
@@ -97,24 +97,36 @@ public abstract class CamelBlueprintTestSupport extends CamelTestSupport {
// load configuration file
String[] file = loadConfigAdminConfigurationFile();
+ String[][] configAdminPidFiles = new String[0][0];
if (file != null) {
- if (file.length != 2) {
- throw new IllegalArgumentException("The returned String[] from loadConfigAdminConfigurationFile must be of length 2, was " + file.length);
+ if (file.length % 2 !=0) { // This needs to return pairs of filename and pid
+ throw new IllegalArgumentException("The length of the String[] returned from loadConfigAdminConfigurationFile must divisible by 2, was " + file.length);
}
- if (!new File(file[0]).exists()) {
- throw new IllegalArgumentException("The provided file \"" + file[0] + "\" from loadConfigAdminConfigurationFile doesn't exist");
+ configAdminPidFiles = new String[file.length / 2 ][2];
+
+ int pair = 0;
+ for (int i=0; i < file.length; i+=2) {
+ String fileName = file[i];
+ String pid = file[i + 1];
+ if (!new File(fileName).exists()) {
+ throw new IllegalArgumentException("The provided file \"" + fileName + "\" from loadConfigAdminConfigurationFile doesn't exist");
+ }
+ configAdminPidFiles[pair][0] = fileName;
+ configAdminPidFiles[pair][1] = pid;
+ pair++;
}
}
+
// fetch initial configadmin configuration if provided programmatically
Properties initialConfiguration = new Properties();
String pid = setConfigAdminInitialConfiguration(initialConfiguration);
if (pid != null) {
- file = new String[] {prepareInitialConfigFile(initialConfiguration), pid};
+ configAdminPidFiles = new String[][] {{prepareInitialConfigFile(initialConfiguration), pid}};
}
final String symbolicName = getClass().getSimpleName();
final BundleContext answer = CamelBlueprintHelper.createBundleContext(symbolicName, getBlueprintDescriptor(),
- includeTestBundle(), getBundleFilter(), getBundleVersion(), getBundleDirectives(), file);
+ includeTestBundle(), getBundleFilter(), getBundleVersion(), getBundleDirectives(), configAdminPidFiles);
boolean expectReload = expectBlueprintContainerReloadOnConfigAdminUpdate();
http://git-wip-us.apache.org/repos/asf/camel/blob/c6b14ba1/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/ConfigAdminLoadMultiConfigurationFileAndOverrideAltTest.java
----------------------------------------------------------------------
diff --git a/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/ConfigAdminLoadMultiConfigurationFileAndOverrideAltTest.java b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/ConfigAdminLoadMultiConfigurationFileAndOverrideAltTest.java
new file mode 100644
index 0000000..c12220e
--- /dev/null
+++ b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/ConfigAdminLoadMultiConfigurationFileAndOverrideAltTest.java
@@ -0,0 +1,63 @@
+/**
+ * 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;
+
+import java.util.Dictionary;
+
+/**
+ * This test should be run in tandem with ConfigAdminLoadConfigurationFileAndOverrideTest. These examples will load a
+ * Blueprint .cfg file with multiple property placeholders defined. We need two tests to make sure we
+ * process both of them correctly
+ */
+public class ConfigAdminLoadMultiConfigurationFileAndOverrideAltTest extends CamelBlueprintTestSupport {
+ @Override
+ protected String getBlueprintDescriptor() {
+ // which blueprint XML file to use for this test
+ return "org/apache/camel/test/blueprint/configadmin-loadmultifileoverride.xml";
+ }
+
+ @Override
+ protected String[] loadConfigAdminConfigurationFile() {
+ // which .cfg files to use, and their corresponding persistence-ids
+ return new String[]{"src/test/resources/etc/stuff.cfg", "stuff", "src/test/resources/etc/otherstuff.cfg", "otherstuff"};
+ }
+
+ @Override
+ protected String useOverridePropertiesWithConfigAdmin(Dictionary props) throws Exception {
+ // override / add extra properties
+ props.put("destination", "mock:extra");
+
+ // return the persistence-id to use
+ return "stuff";
+ }
+
+ @Test
+ public void testConfigAdmin() throws Exception {
+ // mock:original comes from <cm:default-properties>/<cm:property name="destination" value="mock:original" />
+ getMockEndpoint("mock:original").setExpectedMessageCount(0);
+ // mock:result comes from loadConfigAdminConfigurationFile()
+ getMockEndpoint("mock:result").setExpectedMessageCount(0);
+ // mock:extra comes from useOverridePropertiesWithConfigAdmin()
+ getMockEndpoint("mock:extra").expectedBodiesReceived("Bye World", "Yay Bye WorldYay Bye World");
+
+ template.sendBody("direct:start", "World");
+
+ assertMockEndpointsSatisfied();
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/c6b14ba1/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/ConfigAdminLoadMultiConfigurationFileAndOverrideTest.java
----------------------------------------------------------------------
diff --git a/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/ConfigAdminLoadMultiConfigurationFileAndOverrideTest.java b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/ConfigAdminLoadMultiConfigurationFileAndOverrideTest.java
new file mode 100644
index 0000000..72943e4
--- /dev/null
+++ b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/ConfigAdminLoadMultiConfigurationFileAndOverrideTest.java
@@ -0,0 +1,64 @@
+/**
+ * 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;
+
+import java.util.Dictionary;
+
+/**
+ * This is the first of two tests which will load a Blueprint .cfg file (which will initialize configadmin), containing
+ * multiple property placeholders and also override its property placeholders directly (the change will reload blueprint
+ * container).
+ */
+public class ConfigAdminLoadMultiConfigurationFileAndOverrideTest extends CamelBlueprintTestSupport {
+
+ @Override
+ protected String getBlueprintDescriptor() {
+ // which blueprint XML file to use for this test
+ return "org/apache/camel/test/blueprint/configadmin-loadmultifileoverride.xml";
+ }
+
+ @Override
+ protected String[] loadConfigAdminConfigurationFile() {
+ // which .cfg files to use, and their corresponding persistence-ids
+ return new String[]{"src/test/resources/etc/stuff.cfg", "stuff", "src/test/resources/etc/otherstuff.cfg", "otherstuff"};
+ }
+
+ @Override
+ protected String useOverridePropertiesWithConfigAdmin(Dictionary properties) throws Exception {
+ // override / add extra properties
+ properties.put("arrive", "mock:otherExtra");
+
+ // return the persistence-id to use
+ return "otherstuff";
+ }
+
+ @Test
+ public void testConfigAdminWithMultiplePids() throws Exception {
+ // mock:otherOriginal comes from <cm:default-properties>/<cm:property name="arrive" value="mock:otherOriginal" />
+ getMockEndpoint("mock:otherOriginal").setExpectedMessageCount(0);
+ // mock:result comes from loadConfigAdminConfigurationFile()
+ getMockEndpoint("mock:otherResult").setExpectedMessageCount(0);
+ // mock:extra comes from useOverridePropertiesWithConfigAdmin()
+ getMockEndpoint("mock:otherExtra").expectedBodiesReceived("Adieu World", "tiens! Adieu Worldtiens! Adieu World");
+
+ template.sendBody("direct:otherStart", "World");
+
+ assertMockEndpointsSatisfied();
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/c6b14ba1/components/camel-test-blueprint/src/test/resources/etc/otherstuff.cfg
----------------------------------------------------------------------
diff --git a/components/camel-test-blueprint/src/test/resources/etc/otherstuff.cfg b/components/camel-test-blueprint/src/test/resources/etc/otherstuff.cfg
new file mode 100644
index 0000000..cb1d44f
--- /dev/null
+++ b/components/camel-test-blueprint/src/test/resources/etc/otherstuff.cfg
@@ -0,0 +1,20 @@
+## ------------------------------------------------------------------------
+## 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.
+## ------------------------------------------------------------------------
+
+salutation=Adieu
+resonner=tiens!
+arrive=mock:otherResult
http://git-wip-us.apache.org/repos/asf/camel/blob/c6b14ba1/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/configadmin-loadmultifileoverride.xml
----------------------------------------------------------------------
diff --git a/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/configadmin-loadmultifileoverride.xml b/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/configadmin-loadmultifileoverride.xml
new file mode 100644
index 0000000..dd3f5d9
--- /dev/null
+++ b/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/configadmin-loadmultifileoverride.xml
@@ -0,0 +1,78 @@
+<?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: e1 -->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
+ xsi:schemaLocation="
+ http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0 http://aries.apache.org/schemas/blueprint-cm/blueprint-cm-1.1.0.xsd
+ http://www.osgi.org/xmlns/blueprint/v1.0.0 https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
+
+ <!-- blueprint property placeholders, that will use etc/stuff.cfg as the properties file -->
+ <cm:property-placeholder persistent-id="stuff" update-strategy="reload" >
+ <cm:default-properties>
+ <cm:property name="greeting" value="Hello" />
+ <cm:property name="echo" value="Hey" />
+ <cm:property name="destination" value="mock:original" />
+ </cm:default-properties>
+ </cm:property-placeholder>
+
+ <!-- blueprint property placeholders, that will use etc/otherstuff.cfg as the properties file -->
+ <cm:property-placeholder persistent-id="otherstuff" update-strategy="reload" placeholder-prefix="[" placeholder-suffix="]">
+ <cm:default-properties>
+ <cm:property name="salutation" value="Salut" />
+ <cm:property name="resonner" value="Hep" />
+ <cm:property name="arrive" value="mock:otherOriginal" />
+ </cm:default-properties>
+ </cm:property-placeholder>
+
+ <!-- a bean that uses a blueprint property placeholder -->
+ <bean id="myCoolBean" class="org.apache.camel.test.blueprint.MyCoolBean">
+ <property name="say" value="${greeting}"/>
+ <property name="echo" value="${echo}"/>
+ </bean>
+
+ <!-- a bean that uses a different blueprint property placeholder -->
+ <bean id="myOtherCoolBean" class="org.apache.camel.test.blueprint.MyCoolBean">
+ <property name="say" value="[salutation]"/>
+ <property name="echo" value="[resonner]"/>
+ </bean>
+
+
+ <camelContext xmlns="http://camel.apache.org/schema/blueprint">
+
+ <route>
+ <from uri="direct:start"/>
+ <bean ref="myCoolBean" method="saySomething"/>
+ <to uri="{{destination}}"/>
+ <bean ref="myCoolBean" method="echoSomething"/>
+ <to uri="{{destination}}"/>
+ </route>
+
+ <route>
+ <from uri="direct:otherStart"/>
+ <bean ref="myOtherCoolBean" method="saySomething"/>
+ <to uri="{{arrive}}"/>
+ <bean ref="myOtherCoolBean" method="echoSomething"/>
+ <to uri="{{arrive}}"/>
+ </route>
+
+ </camelContext>
+
+</blueprint>
+<!-- END SNIPPET: e1 -->
\ No newline at end of file
[2/2] camel git commit: Fixed CS. This closes #955
Posted by da...@apache.org.
Fixed CS. This closes #955
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/d5912509
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/d5912509
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/d5912509
Branch: refs/heads/master
Commit: d5912509742afcc8075150a6bdc5710c6de3f73c
Parents: c6b14ba
Author: Claus Ibsen <da...@apache.org>
Authored: Fri Apr 22 21:22:48 2016 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Fri Apr 22 21:22:48 2016 +0200
----------------------------------------------------------------------
.../camel/test/blueprint/CamelBlueprintTestSupport.java | 7 +++----
...nfigAdminLoadMultiConfigurationFileAndOverrideAltTest.java | 5 +++--
.../ConfigAdminLoadMultiConfigurationFileAndOverrideTest.java | 4 ++--
3 files changed, 8 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/d5912509/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintTestSupport.java
----------------------------------------------------------------------
diff --git a/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintTestSupport.java b/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintTestSupport.java
index 3bbfbef..60348f6 100644
--- a/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintTestSupport.java
+++ b/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintTestSupport.java
@@ -32,7 +32,6 @@ import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
-
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
@@ -99,13 +98,13 @@ public abstract class CamelBlueprintTestSupport extends CamelTestSupport {
String[] file = loadConfigAdminConfigurationFile();
String[][] configAdminPidFiles = new String[0][0];
if (file != null) {
- if (file.length % 2 !=0) { // This needs to return pairs of filename and pid
+ if (file.length % 2 != 0) { // This needs to return pairs of filename and pid
throw new IllegalArgumentException("The length of the String[] returned from loadConfigAdminConfigurationFile must divisible by 2, was " + file.length);
}
- configAdminPidFiles = new String[file.length / 2 ][2];
+ configAdminPidFiles = new String[file.length / 2][2];
int pair = 0;
- for (int i=0; i < file.length; i+=2) {
+ for (int i = 0; i < file.length; i += 2) {
String fileName = file[i];
String pid = file[i + 1];
if (!new File(fileName).exists()) {
http://git-wip-us.apache.org/repos/asf/camel/blob/d5912509/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/ConfigAdminLoadMultiConfigurationFileAndOverrideAltTest.java
----------------------------------------------------------------------
diff --git a/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/ConfigAdminLoadMultiConfigurationFileAndOverrideAltTest.java b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/ConfigAdminLoadMultiConfigurationFileAndOverrideAltTest.java
index c12220e..099357d 100644
--- a/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/ConfigAdminLoadMultiConfigurationFileAndOverrideAltTest.java
+++ b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/ConfigAdminLoadMultiConfigurationFileAndOverrideAltTest.java
@@ -16,16 +16,17 @@
*/
package org.apache.camel.test.blueprint;
-import org.junit.Test;
-
import java.util.Dictionary;
+import org.junit.Test;
+
/**
* This test should be run in tandem with ConfigAdminLoadConfigurationFileAndOverrideTest. These examples will load a
* Blueprint .cfg file with multiple property placeholders defined. We need two tests to make sure we
* process both of them correctly
*/
public class ConfigAdminLoadMultiConfigurationFileAndOverrideAltTest extends CamelBlueprintTestSupport {
+
@Override
protected String getBlueprintDescriptor() {
// which blueprint XML file to use for this test
http://git-wip-us.apache.org/repos/asf/camel/blob/d5912509/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/ConfigAdminLoadMultiConfigurationFileAndOverrideTest.java
----------------------------------------------------------------------
diff --git a/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/ConfigAdminLoadMultiConfigurationFileAndOverrideTest.java b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/ConfigAdminLoadMultiConfigurationFileAndOverrideTest.java
index 72943e4..40fdc83 100644
--- a/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/ConfigAdminLoadMultiConfigurationFileAndOverrideTest.java
+++ b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/ConfigAdminLoadMultiConfigurationFileAndOverrideTest.java
@@ -16,10 +16,10 @@
*/
package org.apache.camel.test.blueprint;
-import org.junit.Test;
-
import java.util.Dictionary;
+import org.junit.Test;
+
/**
* This is the first of two tests which will load a Blueprint .cfg file (which will initialize configadmin), containing
* multiple property placeholders and also override its property placeholders directly (the change will reload blueprint