camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggrzy...@apache.org
Subject [03/14] camel git commit: [CAMEL-8948] More reliable CamelBlueprintTestSupport tests - always wait for BlueprintEvent.CREATED
Date Mon, 20 Jul 2015 12:52:01 GMT
[CAMEL-8948] More reliable CamelBlueprintTestSupport tests - always wait for BlueprintEvent.CREATED


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/dc23d6a4
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/dc23d6a4
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/dc23d6a4

Branch: refs/heads/master
Commit: dc23d6a458a6abd4c633586af6048ee03c09cf71
Parents: d2ea9b5
Author: Grzegorz Grzybek <gr.grzybek@gmail.com>
Authored: Fri Jul 10 15:00:10 2015 +0200
Committer: Grzegorz Grzybek <gr.grzybek@gmail.com>
Committed: Mon Jul 20 14:51:37 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/dc23d6a4/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 88f4d4a..2eea106 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/dc23d6a4/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 a6b861c..d707370 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
@@ -167,6 +167,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;
@@ -192,13 +205,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 + ")");
     }
 
     /**


Mime
View raw message