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/20 14:52:11 UTC
[13/14] camel git commit: [CAMEL-8948] Add synchronous
CamelBlueprintTestSupport test
[CAMEL-8948] Add synchronous CamelBlueprintTestSupport test
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/7aa3b59d
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/7aa3b59d
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/7aa3b59d
Branch: refs/heads/master
Commit: 7aa3b59dd7718a47c0f5e4417419b28772ba067b
Parents: 2e502fa
Author: Grzegorz Grzybek <gr...@gmail.com>
Authored: Mon Jul 20 11:12:30 2015 +0200
Committer: Grzegorz Grzybek <gr...@gmail.com>
Committed: Mon Jul 20 14:51:38 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/7aa3b59d/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 b517b29..ece0688 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/7aa3b59d/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 88194ec..c7581e3 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
@@ -74,9 +74,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/7aa3b59d/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();
+ }
+
+}