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:24:00 UTC

[02/13] camel git commit: [CAMEL-8948] More reliable CamelBlueprintTestSupport tests - always wait for BlueprintEvent.CREATED

[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 + ")");
     }
 
     /**