You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by gg...@apache.org on 2015/07/21 11:23:59 UTC
[01/13] camel git commit: [camel-test-blueprint] Ensure
loadConfigAdminConfigurationFile() provided file is valid
Repository: camel
Updated Branches:
refs/heads/camel-2.15.x 9ff5aadd0 -> 23fc3a530
[camel-test-blueprint] Ensure loadConfigAdminConfigurationFile() provided file is valid
(cherry picked from commit 7fba34a9a5de8ece63e0fae23eccc64090f8491a)
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/65700051
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/65700051
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/65700051
Branch: refs/heads/camel-2.15.x
Commit: 65700051482bc75e611732926c2a8efa80120c32
Parents: b6fba46
Author: Grzegorz Grzybek <gr...@gmail.com>
Authored: Fri Jul 10 15:01:24 2015 +0200
Committer: Grzegorz Grzybek <gr...@gmail.com>
Committed: Tue Jul 21 09:43:27 2015 +0200
----------------------------------------------------------------------
.../blueprint/CamelBlueprintTestSupport.java | 4 ++
...gAdminLoadConfigurationFileNotFoundTest.java | 57 ++++++++++++++++++++
2 files changed, 61 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/65700051/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 f69e157..71e5864 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
@@ -16,6 +16,7 @@
*/
package org.apache.camel.test.blueprint;
+import java.io.File;
import java.util.Dictionary;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
@@ -101,6 +102,9 @@ public abstract class CamelBlueprintTestSupport extends CamelTestSupport {
}
if (file != null) {
+ if (!new File(file[0]).exists()) {
+ throw new IllegalArgumentException("The provided file \"" + file[0] + "\" from loadConfigAdminConfigurationFile doesn't exist");
+ }
CamelBlueprintHelper.setPersistentFileForConfigAdmin(answer, file[1], file[0], props);
}
http://git-wip-us.apache.org/repos/asf/camel/blob/65700051/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/ConfigAdminLoadConfigurationFileNotFoundTest.java
----------------------------------------------------------------------
diff --git a/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/ConfigAdminLoadConfigurationFileNotFoundTest.java b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/ConfigAdminLoadConfigurationFileNotFoundTest.java
new file mode 100644
index 0000000..2f6d465
--- /dev/null
+++ b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/ConfigAdminLoadConfigurationFileNotFoundTest.java
@@ -0,0 +1,57 @@
+/**
+ * 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 org.osgi.framework.BundleContext;
+
+/**
+ *
+ */
+public class ConfigAdminLoadConfigurationFileNotFoundTest extends CamelBlueprintTestSupport {
+
+ @Override
+ protected String getBlueprintDescriptor() {
+ return "org/apache/camel/test/blueprint/configadmin-loadfile.xml";
+ }
+
+ @Override
+ public void setUp() throws Exception {
+ try {
+ super.setUp();
+ fail("Should throw IllegalArgumentException, because the config file wasn't found");
+ } catch (IllegalArgumentException e) {
+ assertTrue(e.getMessage().contains("../../src/test/resources/etc/stuff.cfg"));
+ }
+ }
+
+ // START SNIPPET: e1
+ @Override
+ protected String[] loadConfigAdminConfigurationFile() {
+ // String[0] = tell Camel the path of the .cfg file to use for OSGi ConfigAdmin in the blueprint XML file
+ // this file should exist
+ // String[1] = tell Camel the persistence-id of the cm:property-placeholder in the blueprint XML file
+ return new String[]{"../../src/test/resources/etc/stuff.cfg", "stuff"};
+ }
+ // END SNIPPET: e1
+
+ @Test
+ public void test() throws Exception {
+ // irrelevant
+ }
+
+}
[02/13] camel git commit: [CAMEL-8948] More reliable
CamelBlueprintTestSupport tests - always wait for BlueprintEvent.CREATED
Posted by gg...@apache.org.
[CAMEL-8948] More reliable CamelBlueprintTestSupport tests - always wait for BlueprintEvent.CREATED
(cherry picked from commit dc23d6a458a6abd4c633586af6048ee03c09cf71)
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/b6fba462
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/b6fba462
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/b6fba462
Branch: refs/heads/camel-2.15.x
Commit: b6fba462384593465fe6f57972b4f164db4dccb9
Parents: 9ff5aad
Author: Grzegorz Grzybek <gr...@gmail.com>
Authored: Fri Jul 10 15:00:10 2015 +0200
Committer: Grzegorz Grzybek <gr...@gmail.com>
Committed: Tue Jul 21 09:43:27 2015 +0200
----------------------------------------------------------------------
.../test/blueprint/CamelBlueprintHelper.java | 3 ++-
.../blueprint/CamelBlueprintTestSupport.java | 20 ++++++++++++++++----
2 files changed, 18 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/b6fba462/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintHelper.java
----------------------------------------------------------------------
diff --git a/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintHelper.java b/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintHelper.java
index 0c14be6..126f68a 100644
--- a/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintHelper.java
+++ b/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintHelper.java
@@ -185,7 +185,8 @@ public final class CamelBlueprintHelper {
.getOsgiService(bundleContext, ConfigurationAdmin.class);
if (configAdmin != null) {
// ensure we update
- Configuration config = configAdmin.getConfiguration(pid);
+ // we *have to* use "null" as 2nd arg to have correct bundle location for Configuration object
+ Configuration config = configAdmin.getConfiguration(pid, null);
LOG.info("Updating ConfigAdmin {} by overriding properties {}", config, props);
config.update(props);
}
http://git-wip-us.apache.org/repos/asf/camel/blob/b6fba462/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 fc88f56..f69e157 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
@@ -157,6 +157,19 @@ public abstract class CamelBlueprintTestSupport extends CamelTestSupport {
config.update(props);
latch.await(CamelBlueprintHelper.DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS);
+ } else {
+ // let's wait for BP container to start
+ final CountDownLatch latch = new CountDownLatch(1);
+ answer.registerService(BlueprintListener.class, new BlueprintListener() {
+ @Override
+ public void blueprintEvent(BlueprintEvent event) {
+ if (event.getType() == BlueprintEvent.CREATED && event.getBundle().getSymbolicName().equals(symbolicName)) {
+ latch.countDown();
+ }
+ }
+ }, null);
+
+ latch.await(CamelBlueprintHelper.DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS);
}
return answer;
@@ -182,13 +195,12 @@ public abstract class CamelBlueprintTestSupport extends CamelTestSupport {
super.setUp();
+ // we don't have to wait for BP container's OSGi service - we've already waited
+ // for BlueprintEvent.CREATED
+
// start context when we are ready
log.debug("Staring CamelContext: {}", context.getName());
context.start();
-
- // must wait for blueprint container to be published then the namespace parser is complete and we are ready for testing
- log.debug("Waiting for BlueprintContainer to be published with symbolicName: {}", symbolicName);
- getOsgiService(BlueprintContainer.class, "(osgi.blueprint.container.symbolicname=" + symbolicName + ")");
}
/**
[11/13] camel git commit: [CAMEL-8948] Add CamelBlueprintTestSupport
tests for update-strategy="none"
Posted by gg...@apache.org.
[CAMEL-8948] Add CamelBlueprintTestSupport tests for update-strategy="none"
(cherry picked from commit 2e502fa02699bc0808179a1f755ed160987d2091)
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/02855659
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/02855659
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/02855659
Branch: refs/heads/camel-2.15.x
Commit: 0285565979a465252f9c3b29a4c66dff53270c02
Parents: 35d7ab6
Author: Grzegorz Grzybek <gr...@gmail.com>
Authored: Mon Jul 20 11:05:34 2015 +0200
Committer: Grzegorz Grzybek <gr...@gmail.com>
Committed: Tue Jul 21 09:45:55 2015 +0200
----------------------------------------------------------------------
...oadLoadConfigurationFileAndOverrideTest.java | 65 ++++++++++++++++++++
...gAdminNoReloadLoadConfigurationFileTest.java | 51 +++++++++++++++
...erridePropertiesOutsideCamelContextTest.java | 57 +++++++++++++++++
.../configadmin-no-reload-loadfile.xml | 45 ++++++++++++++
.../configadmin-no-reload-loadfileoverride.xml | 54 ++++++++++++++++
.../blueprint/configadmin-no-reload-outside.xml | 50 +++++++++++++++
6 files changed, 322 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/02855659/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/ConfigAdminNoReloadLoadConfigurationFileAndOverrideTest.java
----------------------------------------------------------------------
diff --git a/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/ConfigAdminNoReloadLoadConfigurationFileAndOverrideTest.java b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/ConfigAdminNoReloadLoadConfigurationFileAndOverrideTest.java
new file mode 100644
index 0000000..9f7faaa
--- /dev/null
+++ b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/ConfigAdminNoReloadLoadConfigurationFileAndOverrideTest.java
@@ -0,0 +1,65 @@
+/**
+ * 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 java.util.Dictionary;
+
+import org.junit.Test;
+
+// START SNIPPET: e1
+
+/**
+ * This example will load a Blueprint .cfg file, and also override its property placeholders from this unit test
+ * source code directly.
+ * But having <code>update-strategy="none"</code> means that BP container won't be reloaded
+ */
+public class ConfigAdminNoReloadLoadConfigurationFileAndOverrideTest extends CamelBlueprintTestSupport {
+
+ @Override
+ protected String getBlueprintDescriptor() {
+ // which blueprint XML file to use for this test
+ return "org/apache/camel/test/blueprint/configadmin-no-reload-loadfileoverride.xml";
+ }
+
+ @Override
+ protected String[] loadConfigAdminConfigurationFile() {
+ // which .cfg file to use, and the name of the persistence-id
+ return new String[]{"src/test/resources/etc/stuff.cfg", "stuff"};
+ }
+
+ @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 {
+ // regular unit test method
+ getMockEndpoint("mock:original").expectedBodiesReceived("Hello World", "Hey Hello WorldHey Hello World");
+ getMockEndpoint("mock:extra").setExpectedMessageCount(0);
+
+ template.sendBody("direct:start", "World");
+
+ assertMockEndpointsSatisfied();
+ }
+
+}
+// END SNIPPET: e1
http://git-wip-us.apache.org/repos/asf/camel/blob/02855659/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/ConfigAdminNoReloadLoadConfigurationFileTest.java
----------------------------------------------------------------------
diff --git a/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/ConfigAdminNoReloadLoadConfigurationFileTest.java b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/ConfigAdminNoReloadLoadConfigurationFileTest.java
new file mode 100644
index 0000000..2196c93
--- /dev/null
+++ b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/ConfigAdminNoReloadLoadConfigurationFileTest.java
@@ -0,0 +1,51 @@
+/**
+ * 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 ConfigAdminNoReloadLoadConfigurationFileTest extends CamelBlueprintTestSupport {
+
+ @Override
+ protected String getBlueprintDescriptor() {
+ return "org/apache/camel/test/blueprint/configadmin-no-reload-loadfile.xml";
+ }
+
+ // START SNIPPET: e1
+ @Override
+ protected String[] loadConfigAdminConfigurationFile() {
+ // String[0] = tell Camel the path of the .cfg file to use for OSGi ConfigAdmin in the blueprint XML file
+ // String[1] = tell Camel the persistence-id of the cm:property-placeholder in the blueprint XML file
+ return new String[]{"src/test/resources/etc/stuff.cfg", "stuff"};
+ }
+ // END SNIPPET: e1
+
+ @Test
+ public void testConfigAdmin() throws Exception {
+ // Even if we update config admin configuration, update-strategy="none" won't cause reload of BP
+ // container and reinjection of bean properties
+ getMockEndpoint("mock:result").expectedBodiesReceived("${greeting} World");
+
+ template.sendBody("direct:start", "World");
+
+ assertMockEndpointsSatisfied();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/02855659/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/ConfigAdminNoReloadOverridePropertiesOutsideCamelContextTest.java
----------------------------------------------------------------------
diff --git a/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/ConfigAdminNoReloadOverridePropertiesOutsideCamelContextTest.java b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/ConfigAdminNoReloadOverridePropertiesOutsideCamelContextTest.java
new file mode 100644
index 0000000..b2ac339
--- /dev/null
+++ b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/ConfigAdminNoReloadOverridePropertiesOutsideCamelContextTest.java
@@ -0,0 +1,57 @@
+/**
+ * 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 java.util.Dictionary;
+
+import org.junit.Test;
+
+/**
+ *
+ */
+public class ConfigAdminNoReloadOverridePropertiesOutsideCamelContextTest extends CamelBlueprintTestSupport {
+
+ @Override
+ protected String getBlueprintDescriptor() {
+ return "org/apache/camel/test/blueprint/configadmin-no-reload-outside.xml";
+ }
+
+ // START SNIPPET: e1
+ @Override
+ protected String useOverridePropertiesWithConfigAdmin(Dictionary props) {
+ // add the properties we want to override
+ props.put("greeting", "Bye");
+ props.put("destination", "mock:extra");
+
+ // return the PID of the config-admin we are using in the blueprint xml file
+ return "my-placeholders";
+ }
+ // END SNIPPET: e1
+
+ @Test
+ public void testConfigAdmin() throws Exception {
+ // Even if we update config admin configuration, update-strategy="none" won't cause reload of BP
+ // container and reinjection of bean properties
+ getMockEndpoint("mock:result").expectedBodiesReceived("Hello World");
+ getMockEndpoint("mock:extra").setExpectedMessageCount(0);
+
+ template.sendBody("direct:start", "World");
+
+ assertMockEndpointsSatisfied();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/02855659/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/configadmin-no-reload-loadfile.xml
----------------------------------------------------------------------
diff --git a/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/configadmin-no-reload-loadfile.xml b/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/configadmin-no-reload-loadfile.xml
new file mode 100644
index 0000000..b6ffedd
--- /dev/null
+++ b/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/configadmin-no-reload-loadfile.xml
@@ -0,0 +1,45 @@
+<?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.
+-->
+<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 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
+
+ <!-- START SNIPPET: e1 -->
+ <!-- blueprint property placeholders, that will use etc/stuff.cfg as the properties file -->
+ <cm:property-placeholder persistent-id="stuff" update-strategy="none"/>
+
+ <!-- a bean that uses a blueprint property placeholder -->
+ <bean id="myCoolBean" class="org.apache.camel.test.blueprint.MyCoolBean">
+ <property name="say" value="${greeting}"/>
+ </bean>
+
+ <camelContext xmlns="http://camel.apache.org/schema/blueprint">
+
+ <route>
+ <from uri="direct:start"/>
+ <bean ref="myCoolBean" method="saySomething"/>
+ <to uri="mock:result"/>
+ </route>
+
+ </camelContext>
+ <!-- END SNIPPET: e1 -->
+
+</blueprint>
http://git-wip-us.apache.org/repos/asf/camel/blob/02855659/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/configadmin-no-reload-loadfileoverride.xml
----------------------------------------------------------------------
diff --git a/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/configadmin-no-reload-loadfileoverride.xml b/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/configadmin-no-reload-loadfileoverride.xml
new file mode 100644
index 0000000..1d5274d
--- /dev/null
+++ b/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/configadmin-no-reload-loadfileoverride.xml
@@ -0,0 +1,54 @@
+<?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 http://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="none">
+ <cm:default-properties>
+ <cm:property name="say" value="Hello" />
+ <cm:property name="echo" value="Hey" />
+ <cm:property name="destination" value="mock:original" />
+ </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="${say}"/>
+ <property name="echo" value="${echo}"/>
+ </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>
+
+ </camelContext>
+
+</blueprint>
+<!-- END SNIPPET: e1 -->
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/02855659/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/configadmin-no-reload-outside.xml
----------------------------------------------------------------------
diff --git a/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/configadmin-no-reload-outside.xml b/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/configadmin-no-reload-outside.xml
new file mode 100644
index 0000000..e7c8319
--- /dev/null
+++ b/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/configadmin-no-reload-outside.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.
+-->
+<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 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
+
+ <!-- START SNIPPET: e1 -->
+ <!-- blueprint property placeholders -->
+ <cm:property-placeholder persistent-id="my-placeholders" update-strategy="none">
+ <cm:default-properties>
+ <cm:property name="greeting" value="Hello"/>
+ <cm:property name="destination" value="mock:result"/>
+ </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}"/>
+ </bean>
+
+ <camelContext xmlns="http://camel.apache.org/schema/blueprint">
+
+ <route>
+ <from uri="direct:start"/>
+ <bean ref="myCoolBean" method="saySomething"/>
+ <to uri="{{destination}}"/>
+ </route>
+
+ </camelContext>
+ <!-- END SNIPPET: e1 -->
+
+</blueprint>
[08/13] camel git commit: [CAMEL-8948] CamelBlueprintTestSupport
detects if BP container will be reloaded and syncs with the reload
Posted by gg...@apache.org.
[CAMEL-8948] CamelBlueprintTestSupport detects if BP container will be reloaded and syncs with the reload
(cherry picked from commit 9b6737bd904bc2ec893060d8fe50494f0713fa27)
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/9eb4b81a
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/9eb4b81a
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/9eb4b81a
Branch: refs/heads/camel-2.15.x
Commit: 9eb4b81a10004f85fdfd813f8e505f234dc6c52c
Parents: d0586a2
Author: Grzegorz Grzybek <gr...@gmail.com>
Authored: Mon Jul 20 09:43:09 2015 +0200
Committer: Grzegorz Grzybek <gr...@gmail.com>
Committed: Tue Jul 21 09:45:50 2015 +0200
----------------------------------------------------------------------
.../test/blueprint/CamelBlueprintHelper.java | 27 ++++---
.../blueprint/CamelBlueprintTestSupport.java | 75 +++++++++++++++++---
.../org/apache/camel/test/blueprint/Main.java | 7 +-
3 files changed, 87 insertions(+), 22 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/9eb4b81a/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintHelper.java
----------------------------------------------------------------------
diff --git a/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintHelper.java b/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintHelper.java
index b920f9f..497b065 100644
--- a/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintHelper.java
+++ b/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintHelper.java
@@ -179,7 +179,8 @@ public final class CamelBlueprintHelper {
@SuppressWarnings({"unchecked", "rawtypes"})
public static void setPersistentFileForConfigAdmin(BundleContext bundleContext, String pid,
String fileName, final Dictionary props,
- String symbolicName, Set<Long> bpEvents) throws IOException, InterruptedException {
+ String symbolicName, Set<Long> bpEvents,
+ boolean expectReload) throws IOException, InterruptedException {
if (pid != null) {
if (fileName == null) {
throw new IllegalArgumentException("The persistent file should not be null");
@@ -198,18 +199,22 @@ public final class CamelBlueprintHelper {
// we *have to* use "null" as 2nd arg to have correct bundle location for Configuration object
final Configuration config = configAdmin.getConfiguration(pid, null);
LOG.info("Updating ConfigAdmin {} by overriding properties {}", config, props);
- // we will have update and in consequence, BP container reload, let's wait for it to
+ // we may have update and in consequence, BP container reload, let's wait for it to
// be CREATED again
- CamelBlueprintHelper.waitForBlueprintContainer(bpEvents, bundleContext, symbolicName, BlueprintEvent.CREATED, new Runnable() {
- @Override
- public void run() {
- try {
- config.update(props);
- } catch (IOException e) {
- throw new RuntimeException(e.getMessage(), e);
+ if (expectReload) {
+ CamelBlueprintHelper.waitForBlueprintContainer(bpEvents, bundleContext, symbolicName, BlueprintEvent.CREATED, new Runnable() {
+ @Override
+ public void run() {
+ try {
+ config.update(props);
+ } catch (IOException e) {
+ throw new RuntimeException(e.getMessage(), e);
+ }
}
- }
- });
+ });
+ } else {
+ config.update(props);
+ }
}
}
http://git-wip-us.apache.org/repos/asf/camel/blob/9eb4b81a/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 030f99e..be721e4 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
@@ -18,6 +18,8 @@ package org.apache.camel.test.blueprint;
import java.io.File;
import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Dictionary;
import java.util.HashSet;
import java.util.LinkedHashMap;
@@ -26,6 +28,10 @@ import java.util.Map;
import java.util.Properties;
import java.util.Set;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.apache.aries.blueprint.compendium.cm.CmNamespaceHandler;
import org.apache.camel.CamelContext;
import org.apache.camel.component.properties.PropertiesComponent;
import org.apache.camel.model.ModelCamelContext;
@@ -39,6 +45,10 @@ import org.osgi.framework.ServiceRegistration;
import org.osgi.service.blueprint.container.BlueprintEvent;
import org.osgi.service.cm.Configuration;
import org.osgi.service.cm.ConfigurationAdmin;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
/**
* Base class for OSGi Blueprint unit tests with Camel.
@@ -69,6 +79,8 @@ public abstract class CamelBlueprintTestSupport extends CamelTestSupport {
final BundleContext answer = CamelBlueprintHelper.createBundleContext(symbolicName, getBlueprintDescriptor(),
includeTestBundle(), getBundleFilter(), getBundleVersion(), getBundleDirectives());
+ boolean expectReload = expectBlueprintContainerReloadOnConfigAdminUpdate();
+
// must register override properties early in OSGi containers
Properties extra = useOverridePropertiesWithPropertiesComponent();
if (extra != null) {
@@ -119,7 +131,7 @@ public abstract class CamelBlueprintTestSupport extends CamelTestSupport {
if (!new File(file[0]).exists()) {
throw new IllegalArgumentException("The provided file \"" + file[0] + "\" from loadConfigAdminConfigurationFile doesn't exist");
}
- CamelBlueprintHelper.setPersistentFileForConfigAdmin(answer, file[1], file[0], props, symbolicName, bpEvents);
+ CamelBlueprintHelper.setPersistentFileForConfigAdmin(answer, file[1], file[0], props, symbolicName, bpEvents, expectReload);
}
// allow end user to override properties
@@ -135,16 +147,20 @@ public abstract class CamelBlueprintTestSupport extends CamelTestSupport {
throw new IllegalArgumentException("Cannot find configuration with pid " + pid + " in OSGi ConfigurationAdmin service.");
}
log.info("Updating ConfigAdmin {} by overriding properties {}", config, props);
- CamelBlueprintHelper.waitForBlueprintContainer(bpEvents, answer, symbolicName, BlueprintEvent.CREATED, new Runnable() {
- @Override
- public void run() {
- try {
- config.update(props);
- } catch (IOException e) {
- throw new RuntimeException(e.getMessage(), e);
+ if (expectReload) {
+ CamelBlueprintHelper.waitForBlueprintContainer(bpEvents, answer, symbolicName, BlueprintEvent.CREATED, new Runnable() {
+ @Override
+ public void run() {
+ try {
+ config.update(props);
+ } catch (IOException e) {
+ throw new RuntimeException(e.getMessage(), e);
+ }
}
- }
- });
+ });
+ } else {
+ config.update(props);
+ }
}
return answer;
@@ -189,6 +205,45 @@ public abstract class CamelBlueprintTestSupport extends CamelTestSupport {
}
/**
+ * This method may be overriden to instruct BP test support that BP container will reloaded when
+ * Config Admin configuration is updated. By default, this is expected, when blueprint XML definition
+ * contains <code><cm:property-placeholder persistent-id="PID" update-strategy="reload"></code>
+ */
+ protected boolean expectBlueprintContainerReloadOnConfigAdminUpdate() {
+ boolean expectedReload = false;
+ String descriptor = getBlueprintDescriptor();
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ dbf.setNamespaceAware(true);
+ try {
+ // cm-1.0 doesn't define update-strategy attribute
+ Set<String> cmNamesaces = new HashSet<>(Arrays.asList(
+ CmNamespaceHandler.BLUEPRINT_CM_NAMESPACE_1_1,
+ CmNamespaceHandler.BLUEPRINT_CM_NAMESPACE_1_2,
+ CmNamespaceHandler.BLUEPRINT_CM_NAMESPACE_1_3
+ ));
+ DocumentBuilder db = dbf.newDocumentBuilder();
+ Document doc = db.parse(getClass().getClassLoader().getResourceAsStream(descriptor));
+ NodeList nl = doc.getDocumentElement().getChildNodes();
+ for (int i = 0; i < nl.getLength(); i++) {
+ Node node = nl.item(i);
+ if (node instanceof Element) {
+ Element pp = (Element) node;
+ if (cmNamesaces.contains(pp.getNamespaceURI())) {
+ String us = pp.getAttribute("update-strategy");
+ if (us != null && us.equals("reload")) {
+ expectedReload = true;
+ break;
+ }
+ }
+ }
+ }
+ } catch (Exception e) {
+ throw new RuntimeException(e.getMessage(), e);
+ }
+ return expectedReload;
+ }
+
+ /**
* Creates a holder for the given service, which make it easier to use {@link #addServicesOnStartup(java.util.Map)}
*/
protected KeyValueHolder<Object, Dictionary> asService(Object service, Dictionary dict) {
http://git-wip-us.apache.org/repos/asf/camel/blob/9eb4b81a/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/Main.java
----------------------------------------------------------------------
diff --git a/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/Main.java b/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/Main.java
index cadc063..404844f 100644
--- a/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/Main.java
+++ b/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/Main.java
@@ -17,9 +17,11 @@
package org.apache.camel.test.blueprint;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map;
import java.util.Properties;
+import java.util.Set;
import javax.xml.bind.JAXBException;
@@ -28,6 +30,7 @@ import org.apache.camel.ProducerTemplate;
import org.apache.camel.main.MainSupport;
import org.apache.camel.view.ModelFileGenerator;
import org.osgi.framework.BundleContext;
+import org.osgi.service.blueprint.container.BlueprintEvent;
/**
* A command line tool for booting up a CamelContext using an OSGi Blueprint XML file
@@ -100,8 +103,10 @@ public class Main extends MainSupport {
}
LOG.debug("Starting Blueprint XML file: " + descriptors);
bundleContext = createBundleContext(bundleName);
+ Set<Long> eventHistory = new HashSet<>();
+ CamelBlueprintHelper.waitForBlueprintContainer(eventHistory, bundleContext, bundleName, BlueprintEvent.CREATED, null);
CamelBlueprintHelper.setPersistentFileForConfigAdmin(bundleContext, configAdminPid, configAdminFileName, new Properties(),
- bundleName, null);
+ bundleName, eventHistory, true);
camelContext = CamelBlueprintHelper.getOsgiService(bundleContext, CamelContext.class);
if (camelContext == null) {
throw new IllegalArgumentException("Cannot find CamelContext in blueprint XML file: " + descriptors);
[09/13] camel git commit: [CAMEL-8948] Downgrade to
aries.blueprint.cm-1.0.6. 1.0.7 has one timing issue
Posted by gg...@apache.org.
[CAMEL-8948] Downgrade to aries.blueprint.cm-1.0.6. 1.0.7 has one timing issue
(cherry picked from commit a7d325b5723d8e8116449940e86e20c689678319)
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/28548850
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/28548850
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/28548850
Branch: refs/heads/camel-2.15.x
Commit: 285488508f210ea94966dda3246230e1c9c12ea2
Parents: 9eb4b81
Author: Grzegorz Grzybek <gr...@gmail.com>
Authored: Mon Jul 20 09:44:00 2015 +0200
Committer: Grzegorz Grzybek <gr...@gmail.com>
Committed: Tue Jul 21 09:45:53 2015 +0200
----------------------------------------------------------------------
parent/pom.xml | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/28548850/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index a4b8663..84e0212 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -45,7 +45,7 @@
<apache-gora-version>0.4</apache-gora-version>
<apache-mime4j-version>0.7.2</apache-mime4j-version>
<aries-blueprint-api-version>1.0.1</aries-blueprint-api-version>
- <aries-blueprint-cm-version>1.0.7</aries-blueprint-cm-version>
+ <aries-blueprint-cm-version>1.0.6</aries-blueprint-cm-version>
<aries-blueprint-core-version>1.4.4</aries-blueprint-core-version>
<aries-blueprint-proxy-version>1.0.1</aries-blueprint-proxy-version>
<aries-blueprint-proxy-impl-version>1.0.4</aries-blueprint-proxy-impl-version>
@@ -3091,6 +3091,7 @@
</goals>
<configuration>
<strict>true</strict>
+ <skip>true</skip>
</configuration>
</execution>
</executions>
[07/13] camel git commit: [CAMEL-8948] Precise synchronization with
BP container of the test bundle
Posted by gg...@apache.org.
[CAMEL-8948] Precise synchronization with BP container of the test bundle
(cherry picked from commit 692e479b940b1198df3cec386c16aa4fd071e16c)
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/d0586a23
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/d0586a23
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/d0586a23
Branch: refs/heads/camel-2.15.x
Commit: d0586a23e54af00611aba3d72f29d945ebdb9f31
Parents: ec5a7aa
Author: Grzegorz Grzybek <gr...@gmail.com>
Authored: Fri Jul 17 21:40:16 2015 +0200
Committer: Grzegorz Grzybek <gr...@gmail.com>
Committed: Tue Jul 21 09:45:02 2015 +0200
----------------------------------------------------------------------
.../test/blueprint/CamelBlueprintHelper.java | 52 ++++++++++-
.../blueprint/CamelBlueprintTestSupport.java | 91 +++++++-------------
.../org/apache/camel/test/blueprint/Main.java | 3 +-
3 files changed, 82 insertions(+), 64 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/d0586a23/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintHelper.java
----------------------------------------------------------------------
diff --git a/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintHelper.java b/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintHelper.java
index 126f68a..b920f9f 100644
--- a/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintHelper.java
+++ b/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintHelper.java
@@ -35,6 +35,9 @@ import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
import java.util.jar.JarInputStream;
import de.kalpatec.pojosr.framework.PojoServiceRegistryFactoryImpl;
@@ -58,6 +61,9 @@ import org.osgi.framework.Filter;
import org.osgi.framework.FrameworkUtil;
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.blueprint.container.BlueprintEvent;
+import org.osgi.service.blueprint.container.BlueprintListener;
import org.osgi.service.cm.Configuration;
import org.osgi.service.cm.ConfigurationAdmin;
import org.osgi.util.tracker.ServiceTracker;
@@ -107,6 +113,9 @@ public final class CamelBlueprintHelper {
String uid = "" + System.currentTimeMillis();
String tempDir = "target/bundles/" + uid;
System.setProperty("org.osgi.framework.storage", tempDir);
+ // explicitly set this to "false" - we will not depend on the order of starting bundles,
+ // (and running their BP containers) but we will have to do more synchornization
+ System.setProperty("org.apache.aries.blueprint.synchronous", "false");
createDirectory(tempDir);
// use another directory for the jar of the bundle as it cannot be in the same directory
@@ -169,7 +178,8 @@ public final class CamelBlueprintHelper {
// pick up persistent file configuration
@SuppressWarnings({"unchecked", "rawtypes"})
public static void setPersistentFileForConfigAdmin(BundleContext bundleContext, String pid,
- String fileName, Dictionary props) throws IOException {
+ String fileName, final Dictionary props,
+ String symbolicName, Set<Long> bpEvents) throws IOException, InterruptedException {
if (pid != null) {
if (fileName == null) {
throw new IllegalArgumentException("The persistent file should not be null");
@@ -186,9 +196,20 @@ public final class CamelBlueprintHelper {
if (configAdmin != null) {
// ensure we update
// we *have to* use "null" as 2nd arg to have correct bundle location for Configuration object
- Configuration config = configAdmin.getConfiguration(pid, null);
+ final Configuration config = configAdmin.getConfiguration(pid, null);
LOG.info("Updating ConfigAdmin {} by overriding properties {}", config, props);
- config.update(props);
+ // we will have update and in consequence, BP container reload, let's wait for it to
+ // be CREATED again
+ CamelBlueprintHelper.waitForBlueprintContainer(bpEvents, bundleContext, symbolicName, BlueprintEvent.CREATED, new Runnable() {
+ @Override
+ public void run() {
+ try {
+ config.update(props);
+ } catch (IOException e) {
+ throw new RuntimeException(e.getMessage(), e);
+ }
+ }
+ });
}
}
@@ -226,6 +247,7 @@ public final class CamelBlueprintHelper {
// Note that the tracker is not closed to keep the reference
// This is buggy, as the service reference may change i think
Object svc = tracker.waitForService(timeout);
+
if (svc == null) {
Dictionary<?, ?> dic = bundleContext.getBundle().getHeaders();
LOG.warn("Test bundle headers: " + explode(dic));
@@ -248,6 +270,30 @@ public final class CamelBlueprintHelper {
}
}
+ /**
+ * Synchronization method to wait for particular state of BlueprintContainer under test.
+ */
+ public static void waitForBlueprintContainer(final Set<Long> eventHistory, BundleContext context, final String symbolicName, final int bpEvent, final Runnable runAndWait) throws InterruptedException {
+ final CountDownLatch latch = new CountDownLatch(1);
+ ServiceRegistration<BlueprintListener> registration = context.registerService(BlueprintListener.class, new BlueprintListener() {
+ @Override
+ public void blueprintEvent(BlueprintEvent event) {
+ if (event.getType() == bpEvent && event.getBundle().getSymbolicName().equals(symbolicName)) {
+ // we skip events that we've already seen
+ // it works with BP container reloads if next CREATE state is at least 1ms after previous one
+ if (eventHistory == null || eventHistory.add(event.getTimestamp())) {
+ latch.countDown();
+ }
+ }
+ }
+ }, null);
+ if (runAndWait != null) {
+ runAndWait.run();
+ }
+ latch.await(CamelBlueprintHelper.DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS);
+ registration.unregister();
+ }
+
protected static TinyBundle createTestBundle(String name, String version, String descriptors) throws FileNotFoundException, MalformedURLException {
TinyBundle bundle = TinyBundles.newBundle();
for (URL url : getBlueprintDescriptors(descriptors)) {
http://git-wip-us.apache.org/repos/asf/camel/blob/d0586a23/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 71e5864..030f99e 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
@@ -17,14 +17,14 @@
package org.apache.camel.test.blueprint;
import java.io.File;
+import java.io.IOException;
import java.util.Dictionary;
+import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
import org.apache.camel.CamelContext;
import org.apache.camel.component.properties.PropertiesComponent;
@@ -36,13 +36,9 @@ import org.junit.AfterClass;
import org.junit.Before;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
-import org.osgi.service.blueprint.container.BlueprintContainer;
import org.osgi.service.blueprint.container.BlueprintEvent;
-import org.osgi.service.blueprint.container.BlueprintListener;
import org.osgi.service.cm.Configuration;
import org.osgi.service.cm.ConfigurationAdmin;
-import org.osgi.service.cm.ConfigurationEvent;
-import org.osgi.service.cm.ConfigurationListener;
/**
* Base class for OSGi Blueprint unit tests with Camel.
@@ -93,7 +89,7 @@ public abstract class CamelBlueprintTestSupport extends CamelTestSupport {
}
// must reuse props as we can do both load from .cfg file and override afterwards
- Dictionary props = new Properties();
+ final Dictionary props = new Properties();
// load configuration file
String[] file = loadConfigAdminConfigurationFile();
@@ -101,79 +97,54 @@ public abstract class CamelBlueprintTestSupport extends CamelTestSupport {
throw new IllegalArgumentException("The returned String[] from loadConfigAdminConfigurationFile must be of length 2, was " + file.length);
}
+ // if blueprint XML uses <cm:property-placeholder> (any update-strategy and any default properties)
+ // - org.apache.aries.blueprint.compendium.cm.ManagedObjectManager.register() is called
+ // - ManagedServiceUpdate is scheduled in felix.cm
+ // - org.apache.felix.cm.impl.ConfigurationImpl.setDynamicBundleLocation() is called
+ // - CM_LOCATION_CHANGED event is fired
+ // - if BP was alredy created, it's <cm:property-placeholder> receives the event and
+ // - org.apache.aries.blueprint.compendium.cm.CmPropertyPlaceholder.updated() is called,
+ // but no BP reload occurs
+ // we will however wait for BP container of the test bundle to become CREATED for the first time
+ // each configadmin update *may* lead to reload of BP container, if it uses <cm:property-placeholder>
+ // with update-strategy="reload"
+
+ // we will gather timestamps of BP events. We don't want to be fooled but repeated events related
+ // to the same state of BP container
+ Set<Long> bpEvents = new HashSet<>();
+
+ CamelBlueprintHelper.waitForBlueprintContainer(bpEvents, answer, symbolicName, BlueprintEvent.CREATED, null);
+
if (file != null) {
if (!new File(file[0]).exists()) {
throw new IllegalArgumentException("The provided file \"" + file[0] + "\" from loadConfigAdminConfigurationFile doesn't exist");
}
- CamelBlueprintHelper.setPersistentFileForConfigAdmin(answer, file[1], file[0], props);
+ CamelBlueprintHelper.setPersistentFileForConfigAdmin(answer, file[1], file[0], props, symbolicName, bpEvents);
}
// allow end user to override properties
String pid = useOverridePropertiesWithConfigAdmin(props);
if (pid != null) {
- // we will update the configuration now. As OSGi is highly asynchronous, we need to make the tests as repeatable as possible
- // the problem is when blueprint container defines cm:property-placeholder with update-strategy="reload"
- // updating the configuration leads to (felix framework + aries blueprint):
- // 1. schedule org.apache.felix.cm.impl.ConfigurationManager.UpdateConfiguration object to run in config admin thread
- // 2. this thread calls org.apache.felix.cm.impl.ConfigurationImpl#tryBindLocation()
- // 3. org.osgi.service.cm.ConfigurationEvent#CM_LOCATION_CHANGED is send
- // 4. org.apache.aries.blueprint.compendium.cm.ManagedObjectManager.ConfigurationWatcher#updated() is invoked
- // 5. new Thread().start() is called
- // 6. org.apache.aries.blueprint.compendium.cm.ManagedObject#updated() is called
- // 7. org.apache.aries.blueprint.compendium.cm.CmPropertyPlaceholder#updated() is called
- // 8. new Thread().start() is called
- // 9. org.apache.aries.blueprint.services.ExtendedBlueprintContainer#reload() is called which destroys everything in BP container
- // 10. finally reload of BP container is scheduled (in yet another thread)
- //
- // if we start/use camel context between point 9 and 10 we may get many different errors described in https://issues.apache.org/jira/browse/ARIES-961
-
- // to synchronize this (main) thread of execution with the asynchronous series of events, we can register the following listener.
- // this way be sure that we got to point 3
- final CountDownLatch latch = new CountDownLatch(2);
- answer.registerService(ConfigurationListener.class, new ConfigurationListener() {
- @Override
- public void configurationEvent(ConfigurationEvent event) {
- if (event.getType() == ConfigurationEvent.CM_LOCATION_CHANGED) {
- latch.countDown();
- }
- // when we update the configuration, BP container will be reloaded as well
- // hoping that we get the event after *second* restart, let's register the listener
- answer.registerService(BlueprintListener.class, new BlueprintListener() {
- @Override
- public void blueprintEvent(BlueprintEvent event) {
- if (event.getType() == BlueprintEvent.CREATED && event.getBundle().getSymbolicName().equals(symbolicName)) {
- latch.countDown();
- }
- }
- }, null);
- }
- }, null);
-
+ // we will update the configuration again
ConfigurationAdmin configAdmin = CamelBlueprintHelper.getOsgiService(answer, ConfigurationAdmin.class);
// passing null as second argument ties the configuration to correct bundle.
// using single-arg method causes:
// *ERROR* Cannot use configuration xxx.properties for [org.osgi.service.cm.ManagedService, id=N, bundle=N/jar:file:xyz.jar!/]: No visibility to configuration bound to file:pojosr
- Configuration config = configAdmin.getConfiguration(pid, null);
+ final Configuration config = configAdmin.getConfiguration(pid, null);
if (config == null) {
throw new IllegalArgumentException("Cannot find configuration with pid " + pid + " in OSGi ConfigurationAdmin service.");
}
log.info("Updating ConfigAdmin {} by overriding properties {}", config, props);
- config.update(props);
-
- latch.await(CamelBlueprintHelper.DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS);
- } else {
- // let's wait for BP container to start
- final CountDownLatch latch = new CountDownLatch(1);
- answer.registerService(BlueprintListener.class, new BlueprintListener() {
+ CamelBlueprintHelper.waitForBlueprintContainer(bpEvents, answer, symbolicName, BlueprintEvent.CREATED, new Runnable() {
@Override
- public void blueprintEvent(BlueprintEvent event) {
- if (event.getType() == BlueprintEvent.CREATED && event.getBundle().getSymbolicName().equals(symbolicName)) {
- latch.countDown();
+ public void run() {
+ try {
+ config.update(props);
+ } catch (IOException e) {
+ throw new RuntimeException(e.getMessage(), e);
}
}
- }, null);
-
- latch.await(CamelBlueprintHelper.DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS);
+ });
}
return answer;
http://git-wip-us.apache.org/repos/asf/camel/blob/d0586a23/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/Main.java
----------------------------------------------------------------------
diff --git a/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/Main.java b/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/Main.java
index 3094d5e..cadc063 100644
--- a/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/Main.java
+++ b/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/Main.java
@@ -100,7 +100,8 @@ public class Main extends MainSupport {
}
LOG.debug("Starting Blueprint XML file: " + descriptors);
bundleContext = createBundleContext(bundleName);
- CamelBlueprintHelper.setPersistentFileForConfigAdmin(bundleContext, configAdminPid, configAdminFileName, new Properties());
+ CamelBlueprintHelper.setPersistentFileForConfigAdmin(bundleContext, configAdminPid, configAdminFileName, new Properties(),
+ bundleName, null);
camelContext = CamelBlueprintHelper.getOsgiService(bundleContext, CamelContext.class);
if (camelContext == null) {
throw new IllegalArgumentException("Cannot find CamelContext in blueprint XML file: " + descriptors);
[06/13] camel git commit: [CAMEL-8984] Explicitly start
OsgiCamelContextPublisher, it didn't unregister OSGi service
Posted by gg...@apache.org.
[CAMEL-8984] Explicitly start OsgiCamelContextPublisher, it didn't unregister OSGi service
(cherry picked from commit 9aa1ab935a24f210a8592e08a34fc6cc5ed10eea)
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/ec5a7aa6
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/ec5a7aa6
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/ec5a7aa6
Branch: refs/heads/camel-2.15.x
Commit: ec5a7aa661a84abede33ad6e62cb7767edfeea6a
Parents: 140b0f9
Author: Grzegorz Grzybek <gr...@gmail.com>
Authored: Mon Jul 20 10:22:21 2015 +0200
Committer: Grzegorz Grzybek <gr...@gmail.com>
Committed: Tue Jul 21 09:44:20 2015 +0200
----------------------------------------------------------------------
.../camel/blueprint/CamelContextFactoryBean.java | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/ec5a7aa6/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/CamelContextFactoryBean.java
----------------------------------------------------------------------
diff --git a/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/CamelContextFactoryBean.java b/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/CamelContextFactoryBean.java
index b8500cd..63240bb 100644
--- a/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/CamelContextFactoryBean.java
+++ b/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/CamelContextFactoryBean.java
@@ -179,6 +179,8 @@ public class CamelContextFactoryBean extends AbstractCamelContextFactoryBean<Blu
private BundleContext bundleContext;
@XmlTransient
private boolean implicitId;
+ @XmlTransient
+ private OsgiCamelContextPublisher osgiCamelContextPublisher;
public Class<BlueprintCamelContext> getObjectType() {
return BlueprintCamelContext.class;
@@ -301,7 +303,9 @@ public class CamelContextFactoryBean extends AbstractCamelContextFactoryBean<Blu
ClassLoader cl = new BundleDelegatingClassLoader(bundleContext.getBundle());
LOG.debug("Set the application context classloader to: {}", cl);
getContext().setApplicationContextClassLoader(cl);
- getContext().getManagementStrategy().addEventNotifier(new OsgiCamelContextPublisher(bundleContext));
+ osgiCamelContextPublisher = new OsgiCamelContextPublisher(bundleContext);
+ osgiCamelContextPublisher.start();
+ getContext().getManagementStrategy().addEventNotifier(osgiCamelContextPublisher);
try {
getClass().getClassLoader().loadClass("org.osgi.service.event.EventAdmin");
getContext().getManagementStrategy().addEventNotifier(new OsgiEventAdminNotifier(bundleContext));
@@ -313,6 +317,14 @@ public class CamelContextFactoryBean extends AbstractCamelContextFactoryBean<Blu
setupRoutes();
}
+ @Override
+ public void destroy() throws Exception {
+ super.destroy();
+ if (osgiCamelContextPublisher != null) {
+ osgiCamelContextPublisher.shutdown();
+ }
+ }
+
public String getDependsOn() {
return dependsOn;
}
[10/13] camel git commit: [CAMEL-8948] Use
property-placeholder/@update-strategy="reload" in tests which require reload
of BP container
Posted by gg...@apache.org.
[CAMEL-8948] Use property-placeholder/@update-strategy="reload" in tests which require reload of BP container
(cherry picked from commit 21309c048e35c8eba0d482873e14d47974189456)
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/35d7ab61
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/35d7ab61
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/35d7ab61
Branch: refs/heads/camel-2.15.x
Commit: 35d7ab61431d83163c15acfa624848f6cf87b149
Parents: 2854885
Author: Grzegorz Grzybek <gr...@gmail.com>
Authored: Mon Jul 20 09:45:43 2015 +0200
Committer: Grzegorz Grzybek <gr...@gmail.com>
Committed: Tue Jul 21 09:45:54 2015 +0200
----------------------------------------------------------------------
.../camel/test/blueprint/BlueprintPropertiesTest.java | 2 ++
.../apache/camel/test/blueprint/configadmin-loadfile.xml | 6 +++---
.../camel/test/blueprint/configadmin-loadfileoverride.xml | 10 +++++++---
.../apache/camel/test/blueprint/configadmin-outside.xml | 6 +++---
.../org/apache/camel/test/blueprint/main-loadfile.xml | 6 +++---
5 files changed, 18 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/35d7ab61/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/BlueprintPropertiesTest.java
----------------------------------------------------------------------
diff --git a/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/BlueprintPropertiesTest.java b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/BlueprintPropertiesTest.java
index 857959d..09ccc35 100644
--- a/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/BlueprintPropertiesTest.java
+++ b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/BlueprintPropertiesTest.java
@@ -19,6 +19,7 @@ package org.apache.camel.test.blueprint;
import org.junit.Test;
import org.osgi.framework.Bundle;
import org.osgi.service.blueprint.container.BlueprintContainer;
+import org.osgi.service.blueprint.container.BlueprintEvent;
/**
*
@@ -49,6 +50,7 @@ public class BlueprintPropertiesTest extends CamelBlueprintTestSupport {
}
camelCore.start();
+ CamelBlueprintHelper.waitForBlueprintContainer(null, test.getBundleContext(), getClass().getSimpleName(), BlueprintEvent.CREATED, null);
getOsgiService(BlueprintContainer.class, "(osgi.blueprint.container.symbolicname=" + getClass().getSimpleName() + ")", 500);
}
http://git-wip-us.apache.org/repos/asf/camel/blob/35d7ab61/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/configadmin-loadfile.xml
----------------------------------------------------------------------
diff --git a/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/configadmin-loadfile.xml b/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/configadmin-loadfile.xml
index b0726cd..85659d8 100644
--- a/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/configadmin-loadfile.xml
+++ b/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/configadmin-loadfile.xml
@@ -17,14 +17,14 @@
-->
<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.0.0"
+ xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
xsi:schemaLocation="
- http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0 http://aries.apache.org/schemas/blueprint-cm/blueprint-cm-1.0.0.xsd
+ 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 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
<!-- START SNIPPET: e1 -->
<!-- blueprint property placeholders, that will use etc/stuff.cfg as the properties file -->
- <cm:property-placeholder persistent-id="stuff"/>
+ <cm:property-placeholder persistent-id="stuff" update-strategy="reload"/>
<!-- a bean that uses a blueprint property placeholder -->
<bean id="myCoolBean" class="org.apache.camel.test.blueprint.MyCoolBean">
http://git-wip-us.apache.org/repos/asf/camel/blob/35d7ab61/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/configadmin-loadfileoverride.xml
----------------------------------------------------------------------
diff --git a/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/configadmin-loadfileoverride.xml b/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/configadmin-loadfileoverride.xml
index cd72116..c9e45d3 100644
--- a/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/configadmin-loadfileoverride.xml
+++ b/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/configadmin-loadfileoverride.xml
@@ -18,13 +18,17 @@
<!-- 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.0.0"
+ xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
xsi:schemaLocation="
- http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0 http://aries.apache.org/schemas/blueprint-cm/blueprint-cm-1.0.0.xsd
+ 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 http://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"/>
+ <cm:property-placeholder persistent-id="stuff" update-strategy="reload">
+ <cm:default-properties>
+ <cm:property name="destination" value="to-be-replaced" />
+ </cm:default-properties>
+ </cm:property-placeholder>
<!-- a bean that uses a blueprint property placeholder -->
<bean id="myCoolBean" class="org.apache.camel.test.blueprint.MyCoolBean">
http://git-wip-us.apache.org/repos/asf/camel/blob/35d7ab61/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/configadmin-outside.xml
----------------------------------------------------------------------
diff --git a/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/configadmin-outside.xml b/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/configadmin-outside.xml
index d0f5920..03bd18c 100644
--- a/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/configadmin-outside.xml
+++ b/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/configadmin-outside.xml
@@ -17,14 +17,14 @@
-->
<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.0.0"
+ xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
xsi:schemaLocation="
- http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0 http://aries.apache.org/schemas/blueprint-cm/blueprint-cm-1.0.0.xsd
+ 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 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
<!-- START SNIPPET: e1 -->
<!-- blueprint property placeholders -->
- <cm:property-placeholder persistent-id="my-placeholders">
+ <cm:property-placeholder persistent-id="my-placeholders" update-strategy="reload">
<cm:default-properties>
<cm:property name="greeting" value="Hello"/>
<cm:property name="destination" value="mock:result"/>
http://git-wip-us.apache.org/repos/asf/camel/blob/35d7ab61/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/main-loadfile.xml
----------------------------------------------------------------------
diff --git a/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/main-loadfile.xml b/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/main-loadfile.xml
index 1e99278..1c84522 100644
--- a/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/main-loadfile.xml
+++ b/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/main-loadfile.xml
@@ -17,13 +17,13 @@
-->
<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.0.0"
+ xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
xsi:schemaLocation="
- http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0 http://aries.apache.org/schemas/blueprint-cm/blueprint-cm-1.0.0.xsd
+ 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 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
<!-- blueprint property placeholders which we can configure from outside -->
- <cm:property-placeholder persistent-id="stuff"/>
+ <cm:property-placeholder persistent-id="stuff" update-strategy="reload"/>
<!-- a bean that uses a blueprint property placeholder -->
<bean id="myCoolBean" class="org.apache.camel.test.blueprint.MyCoolBean">
[12/13] camel git commit: [CAMEL-8948] Add synchronous
CamelBlueprintTestSupport test
Posted by gg...@apache.org.
[CAMEL-8948] Add synchronous CamelBlueprintTestSupport test
(cherry picked from commit 7aa3b59dd7718a47c0f5e4417419b28772ba067b)
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/6998e85d
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/6998e85d
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/6998e85d
Branch: refs/heads/camel-2.15.x
Commit: 6998e85d746248cf27ab1d9ad7baf576957cdba2
Parents: 0285565
Author: Grzegorz Grzybek <gr...@gmail.com>
Authored: Mon Jul 20 11:12:30 2015 +0200
Committer: Grzegorz Grzybek <gr...@gmail.com>
Committed: Tue Jul 21 09:45:56 2015 +0200
----------------------------------------------------------------------
.../test/blueprint/CamelBlueprintHelper.java | 3 --
.../blueprint/CamelBlueprintTestSupport.java | 17 +++++++-
...intWithSynchronousBlueprintCreationTest.java | 45 ++++++++++++++++++++
3 files changed, 61 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/6998e85d/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintHelper.java
----------------------------------------------------------------------
diff --git a/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintHelper.java b/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintHelper.java
index 497b065..f6f1b46 100644
--- a/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintHelper.java
+++ b/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintHelper.java
@@ -113,9 +113,6 @@ public final class CamelBlueprintHelper {
String uid = "" + System.currentTimeMillis();
String tempDir = "target/bundles/" + uid;
System.setProperty("org.osgi.framework.storage", tempDir);
- // explicitly set this to "false" - we will not depend on the order of starting bundles,
- // (and running their BP containers) but we will have to do more synchornization
- System.setProperty("org.apache.aries.blueprint.synchronous", "false");
createDirectory(tempDir);
// use another directory for the jar of the bundle as it cannot be in the same directory
http://git-wip-us.apache.org/repos/asf/camel/blob/6998e85d/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 be721e4..1839789 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
@@ -72,9 +72,24 @@ public abstract class CamelBlueprintTestSupport extends CamelTestSupport {
return true;
}
-
+ /**
+ * <p>Override this method if you want to start Blueprint containers asynchronously using the thread
+ * that starts the bundles itself.
+ * By default this method returns <code>true</code> which means Blueprint Extender will use thread pool
+ * (threads named "<code>Blueprint Extender: N</code>") to startup Blueprint containers.</p>
+ * <p>Karaf and Fuse OSGi containers use synchronous startup.</p>
+ * <p>Asynchronous startup is more in the <em>spirit</em> of OSGi and usually means that if everything works fine
+ * asynchronously, it'll work synchronously as well. This isn't always true otherwise.</p>
+ * @return
+ */
+ protected boolean useAsynchronousBlueprintStartup() {
+ return true;
+ }
+
@SuppressWarnings({"rawtypes", "unchecked"})
protected BundleContext createBundleContext() throws Exception {
+ System.setProperty("org.apache.aries.blueprint.synchronous", Boolean.toString(!useAsynchronousBlueprintStartup()));
+
final String symbolicName = getClass().getSimpleName();
final BundleContext answer = CamelBlueprintHelper.createBundleContext(symbolicName, getBlueprintDescriptor(),
includeTestBundle(), getBundleFilter(), getBundleVersion(), getBundleDirectives());
http://git-wip-us.apache.org/repos/asf/camel/blob/6998e85d/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/ConfigAdminEndpointWithSynchronousBlueprintCreationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/ConfigAdminEndpointWithSynchronousBlueprintCreationTest.java b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/ConfigAdminEndpointWithSynchronousBlueprintCreationTest.java
new file mode 100644
index 0000000..b07dc2a
--- /dev/null
+++ b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/ConfigAdminEndpointWithSynchronousBlueprintCreationTest.java
@@ -0,0 +1,45 @@
+/**
+ * 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 ConfigAdminEndpointWithSynchronousBlueprintCreationTest extends CamelBlueprintTestSupport {
+
+ @Override
+ protected boolean useAsynchronousBlueprintStartup() {
+ return false;
+ }
+
+ @Override
+ protected String getBlueprintDescriptor() {
+ return "org/apache/camel/test/blueprint/configadmin-endpoint.xml";
+ }
+
+ @Test
+ public void testConfigAdmin() throws Exception {
+ getMockEndpoint("mock:result").expectedBodiesReceived("Bye World");
+
+ template.sendBody("direct:start", "World");
+
+ assertMockEndpointsSatisfied();
+ }
+
+}
[13/13] camel git commit: Fixed CS
Posted by gg...@apache.org.
Fixed CS
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/23fc3a53
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/23fc3a53
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/23fc3a53
Branch: refs/heads/camel-2.15.x
Commit: 23fc3a53057bede363f4dd939750a49b8d239959
Parents: 6998e85
Author: Grzegorz Grzybek <gr...@gmail.com>
Authored: Tue Jul 21 11:23:33 2015 +0200
Committer: Grzegorz Grzybek <gr...@gmail.com>
Committed: Tue Jul 21 11:23:33 2015 +0200
----------------------------------------------------------------------
.../properties/DefaultPropertiesParser.java | 4 ++--
.../apache/camel/util/CamelVersionHelper.java | 3 +++
.../remote/FtpBadLoginConnectionLeakTest.java | 12 ++++++------
...FtpBadLoginInProducerConnectionLeakTest.java | 14 +++++++-------
.../FtpBadLoginMockNoopConnectionLeakTest.java | 20 ++++++++++----------
.../CamelSpringBootApplicationController.java | 4 ++--
.../test/blueprint/CamelBlueprintHelper.java | 4 +++-
.../blueprint/CamelBlueprintTestSupport.java | 14 +++++++-------
.../org/apache/camel/test/blueprint/Main.java | 2 +-
9 files changed, 41 insertions(+), 36 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/23fc3a53/camel-core/src/main/java/org/apache/camel/component/properties/DefaultPropertiesParser.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/component/properties/DefaultPropertiesParser.java b/camel-core/src/main/java/org/apache/camel/component/properties/DefaultPropertiesParser.java
index a3bbc8d..c19f165 100644
--- a/camel-core/src/main/java/org/apache/camel/component/properties/DefaultPropertiesParser.java
+++ b/camel-core/src/main/java/org/apache/camel/component/properties/DefaultPropertiesParser.java
@@ -20,12 +20,12 @@ import java.util.HashSet;
import java.util.Properties;
import java.util.Set;
+import static java.lang.String.format;
+
import org.apache.camel.util.ObjectHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import static java.lang.String.format;
-
/**
* A parser to parse a string which contains property placeholders.
*/
http://git-wip-us.apache.org/repos/asf/camel/blob/23fc3a53/camel-core/src/main/java/org/apache/camel/util/CamelVersionHelper.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/util/CamelVersionHelper.java b/camel-core/src/main/java/org/apache/camel/util/CamelVersionHelper.java
index 368b4c7..f502d03 100644
--- a/camel-core/src/main/java/org/apache/camel/util/CamelVersionHelper.java
+++ b/camel-core/src/main/java/org/apache/camel/util/CamelVersionHelper.java
@@ -21,6 +21,9 @@ package org.apache.camel.util;
*/
public final class CamelVersionHelper {
+ private CamelVersionHelper() {
+ }
+
/**
* Checks whether other >= base
*
http://git-wip-us.apache.org/repos/asf/camel/blob/23fc3a53/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpBadLoginConnectionLeakTest.java
----------------------------------------------------------------------
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpBadLoginConnectionLeakTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpBadLoginConnectionLeakTest.java
index ff430ee..7c26bd6 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpBadLoginConnectionLeakTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpBadLoginConnectionLeakTest.java
@@ -34,11 +34,11 @@ public class FtpBadLoginConnectionLeakTest extends FtpServerTestSupport {
/**
* Mapping of socket hashcode to two element tab ([connect() called, close() called])
*/
- private Map<Integer, boolean[]> socketAudits = new HashMap<>();
+ private Map<Integer, boolean[]> socketAudits = new HashMap<Integer, boolean[]>();
private String getFtpUrl() {
- return "ftp://dummy@localhost:" + getPort() + "/badlogin?password=cantremeber" +
- "&throwExceptionOnConnectFailed=false&ftpClient.socketFactory=#sf";
+ return "ftp://dummy@localhost:" + getPort() + "/badlogin?password=cantremeber"
+ + "&throwExceptionOnConnectFailed=false&ftpClient.socketFactory=#sf";
}
@Override
@@ -101,7 +101,7 @@ public class FtpBadLoginConnectionLeakTest extends FtpServerTestSupport {
@Override
public Socket createSocket() throws IOException {
AuditingSocket socket = new AuditingSocket();
- socketAudits.put(System.identityHashCode(socket), new boolean[] { false, false });
+ socketAudits.put(System.identityHashCode(socket), new boolean[] {false, false});
return socket;
}
@@ -119,13 +119,13 @@ public class FtpBadLoginConnectionLeakTest extends FtpServerTestSupport {
@Override
public void connect(SocketAddress endpoint, int timeout) throws IOException {
super.connect(endpoint, timeout);
- socketAudits.get(System.identityHashCode(this))[0] = true;
+ ((boolean[])socketAudits.get(System.identityHashCode(this)))[0] = true;
}
@Override
public synchronized void close() throws IOException {
super.close();
- socketAudits.get(System.identityHashCode(this))[1] = true;
+ ((boolean[])socketAudits.get(System.identityHashCode(this)))[1] = true;
}
}
http://git-wip-us.apache.org/repos/asf/camel/blob/23fc3a53/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpBadLoginInProducerConnectionLeakTest.java
----------------------------------------------------------------------
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpBadLoginInProducerConnectionLeakTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpBadLoginInProducerConnectionLeakTest.java
index e3314d0..0bb5e3e 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpBadLoginInProducerConnectionLeakTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpBadLoginInProducerConnectionLeakTest.java
@@ -33,11 +33,11 @@ public class FtpBadLoginInProducerConnectionLeakTest extends FtpServerTestSuppor
/**
* Mapping of socket hashcode to two element tab ([connect() called, close() called])
*/
- private Map<Integer, boolean[]> socketAudits = new HashMap<>();
+ private Map<Integer, boolean[]> socketAudits = new HashMap<Integer, boolean[]>();
private String getFtpUrl() {
- return "ftp://dummy@localhost:" + getPort() + "/badlogin?password=cantremeber&maximumReconnectAttempts=3" +
- "&throwExceptionOnConnectFailed=false&ftpClient.socketFactory=#sf";
+ return "ftp://dummy@localhost:" + getPort() + "/badlogin?password=cantremeber&maximumReconnectAttempts=3"
+ + "&throwExceptionOnConnectFailed=false&ftpClient.socketFactory=#sf";
}
@Override
@@ -51,7 +51,7 @@ public class FtpBadLoginInProducerConnectionLeakTest extends FtpServerTestSuppor
@Test
public void testConnectionLeak() throws Exception {
- for (String filename : new String[] { "claus.txt", "grzegorz.txt" }) {
+ for (String filename : new String[] {"claus.txt", "grzegorz.txt"}) {
try {
sendFile(getFtpUrl(), "Hello World", filename);
} catch (Exception ignored) {
@@ -93,7 +93,7 @@ public class FtpBadLoginInProducerConnectionLeakTest extends FtpServerTestSuppor
@Override
public Socket createSocket() throws IOException {
AuditingSocket socket = new AuditingSocket();
- socketAudits.put(System.identityHashCode(socket), new boolean[] { false, false });
+ socketAudits.put(System.identityHashCode(socket), new boolean[] {false, false});
return socket;
}
@@ -111,13 +111,13 @@ public class FtpBadLoginInProducerConnectionLeakTest extends FtpServerTestSuppor
@Override
public void connect(SocketAddress endpoint, int timeout) throws IOException {
super.connect(endpoint, timeout);
- socketAudits.get(System.identityHashCode(this))[0] = true;
+ ((boolean[])socketAudits.get(System.identityHashCode(this)))[0] = true;
}
@Override
public synchronized void close() throws IOException {
super.close();
- socketAudits.get(System.identityHashCode(this))[1] = true;
+ ((boolean[])socketAudits.get(System.identityHashCode(this)))[1] = true;
}
}
http://git-wip-us.apache.org/repos/asf/camel/blob/23fc3a53/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpBadLoginMockNoopConnectionLeakTest.java
----------------------------------------------------------------------
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpBadLoginMockNoopConnectionLeakTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpBadLoginMockNoopConnectionLeakTest.java
index 0b895f5..9c80c89 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpBadLoginMockNoopConnectionLeakTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpBadLoginMockNoopConnectionLeakTest.java
@@ -35,9 +35,14 @@ import org.junit.Test;
*/
public class FtpBadLoginMockNoopConnectionLeakTest extends FtpServerTestSupport {
+ /**
+ * Mapping of socket hashcode to two element tab ([connect() called, close() called])
+ */
+ private Map<Integer, boolean[]> socketAudits = new HashMap<Integer, boolean[]>();
+
private String getFtpUrl() {
- return "ftp://dummy@localhost:" + getPort() + "/badlogin?password=cantremeber&maximumReconnectAttempts=3" +
- "&throwExceptionOnConnectFailed=false&ftpClient.socketFactory=#sf";
+ return "ftp://dummy@localhost:" + getPort() + "/badlogin?password=cantremeber&maximumReconnectAttempts=3"
+ + "&throwExceptionOnConnectFailed=false&ftpClient.socketFactory=#sf";
}
@Override
@@ -54,11 +59,6 @@ public class FtpBadLoginMockNoopConnectionLeakTest extends FtpServerTestSupport
});
}
- /**
- * Mapping of socket hashcode to two element tab ([connect() called, close() called])
- */
- private Map<Integer, boolean[]> socketAudits = new HashMap<>();
-
@Override
protected JndiRegistry createRegistry() throws Exception {
JndiRegistry jndi = super.createRegistry();
@@ -119,7 +119,7 @@ public class FtpBadLoginMockNoopConnectionLeakTest extends FtpServerTestSupport
@Override
public Socket createSocket() throws IOException {
AuditingSocket socket = new AuditingSocket();
- socketAudits.put(System.identityHashCode(socket), new boolean[] { false, false });
+ socketAudits.put(System.identityHashCode(socket), new boolean[] {false, false});
return socket;
}
@@ -138,14 +138,14 @@ public class FtpBadLoginMockNoopConnectionLeakTest extends FtpServerTestSupport
public void connect(SocketAddress endpoint, int timeout) throws IOException {
log.info("Connecting socket {}", System.identityHashCode(this));
super.connect(endpoint, timeout);
- socketAudits.get(System.identityHashCode(this))[0] = true;
+ ((boolean[])socketAudits.get(System.identityHashCode(this)))[0] = true;
}
@Override
public synchronized void close() throws IOException {
log.info("Disconnecting socket {}", System.identityHashCode(this));
super.close();
- socketAudits.get(System.identityHashCode(this))[1] = true;
+ ((boolean[])socketAudits.get(System.identityHashCode(this)))[1] = true;
}
}
http://git-wip-us.apache.org/repos/asf/camel/blob/23fc3a53/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelSpringBootApplicationController.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelSpringBootApplicationController.java b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelSpringBootApplicationController.java
index cd516e7..067edc9 100644
--- a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelSpringBootApplicationController.java
+++ b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelSpringBootApplicationController.java
@@ -19,13 +19,13 @@ package org.apache.camel.spring.boot;
import java.util.Collections;
import java.util.Map;
+import javax.annotation.PreDestroy;
+
import org.apache.camel.CamelContext;
import org.apache.camel.ProducerTemplate;
import org.apache.camel.main.MainSupport;
import org.springframework.context.ApplicationContext;
-import javax.annotation.PreDestroy;
-
public class CamelSpringBootApplicationController {
private final MainSupport mainSupport;
http://git-wip-us.apache.org/repos/asf/camel/blob/23fc3a53/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintHelper.java
----------------------------------------------------------------------
diff --git a/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintHelper.java b/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintHelper.java
index f6f1b46..4074376 100644
--- a/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintHelper.java
+++ b/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintHelper.java
@@ -275,7 +275,9 @@ public final class CamelBlueprintHelper {
/**
* Synchronization method to wait for particular state of BlueprintContainer under test.
*/
- public static void waitForBlueprintContainer(final Set<Long> eventHistory, BundleContext context, final String symbolicName, final int bpEvent, final Runnable runAndWait) throws InterruptedException {
+ public static void waitForBlueprintContainer(final Set<Long> eventHistory, BundleContext context,
+ final String symbolicName, final int bpEvent, final Runnable runAndWait)
+ throws InterruptedException {
final CountDownLatch latch = new CountDownLatch(1);
ServiceRegistration<BlueprintListener> registration = context.registerService(BlueprintListener.class, new BlueprintListener() {
@Override
http://git-wip-us.apache.org/repos/asf/camel/blob/23fc3a53/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 1839789..0361ce8 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
@@ -18,7 +18,6 @@ package org.apache.camel.test.blueprint;
import java.io.File;
import java.io.IOException;
-import java.util.ArrayList;
import java.util.Arrays;
import java.util.Dictionary;
import java.util.HashSet;
@@ -31,6 +30,11 @@ import java.util.Set;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
import org.apache.aries.blueprint.compendium.cm.CmNamespaceHandler;
import org.apache.camel.CamelContext;
import org.apache.camel.component.properties.PropertiesComponent;
@@ -45,10 +49,6 @@ import org.osgi.framework.ServiceRegistration;
import org.osgi.service.blueprint.container.BlueprintEvent;
import org.osgi.service.cm.Configuration;
import org.osgi.service.cm.ConfigurationAdmin;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
/**
* Base class for OSGi Blueprint unit tests with Camel.
@@ -138,7 +138,7 @@ public abstract class CamelBlueprintTestSupport extends CamelTestSupport {
// we will gather timestamps of BP events. We don't want to be fooled but repeated events related
// to the same state of BP container
- Set<Long> bpEvents = new HashSet<>();
+ Set<Long> bpEvents = new HashSet<Long>();
CamelBlueprintHelper.waitForBlueprintContainer(bpEvents, answer, symbolicName, BlueprintEvent.CREATED, null);
@@ -231,7 +231,7 @@ public abstract class CamelBlueprintTestSupport extends CamelTestSupport {
dbf.setNamespaceAware(true);
try {
// cm-1.0 doesn't define update-strategy attribute
- Set<String> cmNamesaces = new HashSet<>(Arrays.asList(
+ Set<String> cmNamesaces = new HashSet<String>(Arrays.asList(
CmNamespaceHandler.BLUEPRINT_CM_NAMESPACE_1_1,
CmNamespaceHandler.BLUEPRINT_CM_NAMESPACE_1_2,
CmNamespaceHandler.BLUEPRINT_CM_NAMESPACE_1_3
http://git-wip-us.apache.org/repos/asf/camel/blob/23fc3a53/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/Main.java
----------------------------------------------------------------------
diff --git a/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/Main.java b/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/Main.java
index 404844f..49e64b5 100644
--- a/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/Main.java
+++ b/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/Main.java
@@ -103,7 +103,7 @@ public class Main extends MainSupport {
}
LOG.debug("Starting Blueprint XML file: " + descriptors);
bundleContext = createBundleContext(bundleName);
- Set<Long> eventHistory = new HashSet<>();
+ Set<Long> eventHistory = new HashSet<Long>();
CamelBlueprintHelper.waitForBlueprintContainer(eventHistory, bundleContext, bundleName, BlueprintEvent.CREATED, null);
CamelBlueprintHelper.setPersistentFileForConfigAdmin(bundleContext, configAdminPid, configAdminFileName, new Properties(),
bundleName, eventHistory, true);
[03/13] camel git commit: [CAMEL-8948] Replace old aggregate Aries BP
bundle with correct bundles (api, core, cm)
Posted by gg...@apache.org.
[CAMEL-8948] Replace old aggregate Aries BP bundle with correct bundles (api, core, cm)
(cherry picked from commit c52c9196afe80f333f2be384463466c7ddf2272f)
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/118b605a
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/118b605a
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/118b605a
Branch: refs/heads/camel-2.15.x
Commit: 118b605a9d30f4da055e1f19df93f68839eac71a
Parents: 6570005
Author: Grzegorz Grzybek <gr...@gmail.com>
Authored: Fri Jul 10 15:02:37 2015 +0200
Committer: Grzegorz Grzybek <gr...@gmail.com>
Committed: Tue Jul 21 09:43:28 2015 +0200
----------------------------------------------------------------------
components/camel-cxf/pom.xml | 2 +-
components/camel-test-blueprint/pom.xml | 11 +++++++++--
parent/pom.xml | 18 ++++++++++++------
platforms/karaf/features/pom.xml | 7 ++++++-
4 files changed, 28 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/118b605a/components/camel-cxf/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-cxf/pom.xml b/components/camel-cxf/pom.xml
index 7bb599a..d3bd296 100644
--- a/components/camel-cxf/pom.xml
+++ b/components/camel-cxf/pom.xml
@@ -146,7 +146,7 @@
</dependency>
<dependency>
<groupId>org.apache.aries.blueprint</groupId>
- <artifactId>org.apache.aries.blueprint</artifactId>
+ <artifactId>org.apache.aries.blueprint.core</artifactId>
<scope>provided</scope>
</dependency>
http://git-wip-us.apache.org/repos/asf/camel/blob/118b605a/components/camel-test-blueprint/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-test-blueprint/pom.xml b/components/camel-test-blueprint/pom.xml
index 4674ae6..f6b43c5 100644
--- a/components/camel-test-blueprint/pom.xml
+++ b/components/camel-test-blueprint/pom.xml
@@ -63,10 +63,17 @@
<!-- the ordering of the dependencies can matter as we load the dependencies from the classpath
with pojosr, and you may get a weird error if wrong order -->
- <!-- yes this is correct to use aries.blueprint as dependency (as it has all the pieces needed by pojosr) and use the core-version -->
<dependency>
<groupId>org.apache.aries.blueprint</groupId>
- <artifactId>org.apache.aries.blueprint</artifactId>
+ <artifactId>org.apache.aries.blueprint.api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.aries.blueprint</groupId>
+ <artifactId>org.apache.aries.blueprint.core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.aries.blueprint</groupId>
+ <artifactId>org.apache.aries.blueprint.cm</artifactId>
</dependency>
<dependency>
<groupId>org.apache.aries</groupId>
http://git-wip-us.apache.org/repos/asf/camel/blob/118b605a/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index f43c900..cf19b88 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -44,10 +44,11 @@
<apacheds-version>2.0.0-M19</apacheds-version>
<apache-gora-version>0.4</apache-gora-version>
<apache-mime4j-version>0.7.2</apache-mime4j-version>
- <aries-blueprint-api-version>1.0.0</aries-blueprint-api-version>
- <aries-blueprint-core-version>1.1.0</aries-blueprint-core-version>
- <aries-blueprint-proxy-version>1.0.0</aries-blueprint-proxy-version>
- <aries-blueprint-proxy-impl-version>1.0.1</aries-blueprint-proxy-impl-version>
+ <aries-blueprint-api-version>1.0.1</aries-blueprint-api-version>
+ <aries-blueprint-cm-version>1.0.6</aries-blueprint-cm-version>
+ <aries-blueprint-core-version>1.4.3</aries-blueprint-core-version>
+ <aries-blueprint-proxy-version>1.0.1</aries-blueprint-proxy-version>
+ <aries-blueprint-proxy-impl-version>1.0.4</aries-blueprint-proxy-impl-version>
<aries-util-version>1.1.0</aries-util-version>
<arquillian-junit-container-version>1.0.0.CR7</arquillian-junit-container-version>
<arquillian-weld-ee-embedded-version>1.0.0.CR3</arquillian-weld-ee-embedded-version>
@@ -2560,14 +2561,19 @@
<!-- blueprint -->
<dependency>
<groupId>org.apache.aries.blueprint</groupId>
- <artifactId>org.apache.aries.blueprint</artifactId>
- <version>${aries-blueprint-core-version}</version>
+ <artifactId>org.apache.aries.blueprint.api</artifactId>
+ <version>${aries-blueprint-api-version}</version>
</dependency>
<dependency>
<groupId>org.apache.aries.blueprint</groupId>
<artifactId>org.apache.aries.blueprint.core</artifactId>
<version>${aries-blueprint-core-version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.aries.blueprint</groupId>
+ <artifactId>org.apache.aries.blueprint.cm</artifactId>
+ <version>${aries-blueprint-cm-version}</version>
+ </dependency>
<!-- OSGi ConfigAdmin service -->
<dependency>
http://git-wip-us.apache.org/repos/asf/camel/blob/118b605a/platforms/karaf/features/pom.xml
----------------------------------------------------------------------
diff --git a/platforms/karaf/features/pom.xml b/platforms/karaf/features/pom.xml
index bffab4c..0fc7102 100644
--- a/platforms/karaf/features/pom.xml
+++ b/platforms/karaf/features/pom.xml
@@ -66,7 +66,12 @@
</dependency>
<dependency>
<groupId>org.apache.aries.blueprint</groupId>
- <artifactId>org.apache.aries.blueprint</artifactId>
+ <artifactId>org.apache.aries.blueprint.api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.aries.blueprint</groupId>
+ <artifactId>org.apache.aries.blueprint.core</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
[04/13] camel git commit: [CAMEL-8948] Upgrade to
blueprint-core-1.4.4 with fixed NS handler registration
Posted by gg...@apache.org.
[CAMEL-8948] Upgrade to blueprint-core-1.4.4 with fixed NS handler registration
(cherry picked from commit aa3793121b6778a5053650c355fe2bdb0644f4a1)
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/474c69d4
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/474c69d4
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/474c69d4
Branch: refs/heads/camel-2.15.x
Commit: 474c69d4918cc38ca419ecb228b44d2d1baafdf1
Parents: 118b605
Author: Grzegorz Grzybek <gr...@gmail.com>
Authored: Fri Jul 17 08:09:29 2015 +0200
Committer: Grzegorz Grzybek <gr...@gmail.com>
Committed: Tue Jul 21 09:43:29 2015 +0200
----------------------------------------------------------------------
parent/pom.xml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/474c69d4/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index cf19b88..a4b8663 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -45,8 +45,8 @@
<apache-gora-version>0.4</apache-gora-version>
<apache-mime4j-version>0.7.2</apache-mime4j-version>
<aries-blueprint-api-version>1.0.1</aries-blueprint-api-version>
- <aries-blueprint-cm-version>1.0.6</aries-blueprint-cm-version>
- <aries-blueprint-core-version>1.4.3</aries-blueprint-core-version>
+ <aries-blueprint-cm-version>1.0.7</aries-blueprint-cm-version>
+ <aries-blueprint-core-version>1.4.4</aries-blueprint-core-version>
<aries-blueprint-proxy-version>1.0.1</aries-blueprint-proxy-version>
<aries-blueprint-proxy-impl-version>1.0.4</aries-blueprint-proxy-impl-version>
<aries-util-version>1.1.0</aries-util-version>
[05/13] camel git commit: [CAMEL-8948] Move aries.proxy before
aries.blueprint bundles for correct ordering
Posted by gg...@apache.org.
[CAMEL-8948] Move aries.proxy before aries.blueprint bundles for correct ordering
(cherry picked from commit ab845909b0daac83509eaf5c38aca3f774c73a5d)
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/140b0f91
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/140b0f91
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/140b0f91
Branch: refs/heads/camel-2.15.x
Commit: 140b0f9102e3888ad187b1e2690bd9f0f064f3e5
Parents: 474c69d
Author: Grzegorz Grzybek <gr...@gmail.com>
Authored: Fri Jul 17 21:20:10 2015 +0200
Committer: Grzegorz Grzybek <gr...@gmail.com>
Committed: Tue Jul 21 09:44:16 2015 +0200
----------------------------------------------------------------------
components/camel-test-blueprint/pom.xml | 10 ++++++++++
tests/camel-itest-osgi/pom.xml | 12 +++++++++++-
2 files changed, 21 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/140b0f91/components/camel-test-blueprint/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-test-blueprint/pom.xml b/components/camel-test-blueprint/pom.xml
index f6b43c5..af5323f 100644
--- a/components/camel-test-blueprint/pom.xml
+++ b/components/camel-test-blueprint/pom.xml
@@ -64,6 +64,16 @@
<!-- the ordering of the dependencies can matter as we load the dependencies from the classpath
with pojosr, and you may get a weird error if wrong order -->
<dependency>
+ <groupId>org.apache.aries.proxy</groupId>
+ <artifactId>org.apache.aries.proxy.api</artifactId>
+ <version>${aries-blueprint-proxy-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.aries.proxy</groupId>
+ <artifactId>org.apache.aries.proxy.impl</artifactId>
+ <version>${aries-blueprint-proxy-impl-version}</version>
+ </dependency>
+ <dependency>
<groupId>org.apache.aries.blueprint</groupId>
<artifactId>org.apache.aries.blueprint.api</artifactId>
</dependency>
http://git-wip-us.apache.org/repos/asf/camel/blob/140b0f91/tests/camel-itest-osgi/pom.xml
----------------------------------------------------------------------
diff --git a/tests/camel-itest-osgi/pom.xml b/tests/camel-itest-osgi/pom.xml
index 7671768..a74b2e7 100644
--- a/tests/camel-itest-osgi/pom.xml
+++ b/tests/camel-itest-osgi/pom.xml
@@ -43,7 +43,17 @@
<!-- blueprint -->
<dependency>
<groupId>org.apache.aries.blueprint</groupId>
- <artifactId>org.apache.aries.blueprint</artifactId>
+ <artifactId>org.apache.aries.blueprint.api</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.aries.blueprint</groupId>
+ <artifactId>org.apache.aries.blueprint.core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.aries.blueprint</groupId>
+ <artifactId>org.apache.aries.blueprint.cm</artifactId>
<scope>test</scope>
</dependency>