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:51:59 UTC

[01/14] camel git commit: [CAMEL-8948] CamelBlueprintTestSupport detects if BP container will be reloaded and syncs with the reload

Repository: camel
Updated Branches:
  refs/heads/master d2ea9b510 -> 14a7dd791


[CAMEL-8948] CamelBlueprintTestSupport detects if BP container will be reloaded and syncs with the reload


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

Branch: refs/heads/master
Commit: 9b6737bd904bc2ec893060d8fe50494f0713fa27
Parents: 692e479
Author: Grzegorz Grzybek <gr...@gmail.com>
Authored: Mon Jul 20 09:43:09 2015 +0200
Committer: Grzegorz Grzybek <gr...@gmail.com>
Committed: Mon Jul 20 14:51:37 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/9b6737bd/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 4e84211..b517b29 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/9b6737bd/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 87f7256..88194ec 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;
@@ -28,6 +30,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;
@@ -41,6 +47,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.
@@ -71,6 +81,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) {
@@ -129,7 +141,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
@@ -145,16 +157,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;
@@ -199,6 +215,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>&lt;cm:property-placeholder persistent-id="PID" update-strategy="reload"&gt;</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;
+    }
+
+    /**
      * Override this method to add services to be registered on startup.
      * <p/>
      * You can use the builder methods {@link #asKeyValueService(String, Object, Dictionary)}

http://git-wip-us.apache.org/repos/asf/camel/blob/9b6737bd/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 338ad7a..3092d2e 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,14 +17,17 @@
 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 org.apache.camel.CamelContext;
 import org.apache.camel.ProducerTemplate;
 import org.apache.camel.main.MainSupport;
 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
@@ -97,8 +100,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);


[07/14] 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


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

Branch: refs/heads/master
Commit: 9aa1ab935a24f210a8592e08a34fc6cc5ed10eea
Parents: ab84590
Author: Grzegorz Grzybek <gr...@gmail.com>
Authored: Mon Jul 20 10:22:21 2015 +0200
Committer: Grzegorz Grzybek <gr...@gmail.com>
Committed: Mon Jul 20 14:51:37 2015 +0200

----------------------------------------------------------------------
 .../camel/blueprint/CamelContextFactoryBean.java      | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/9aa1ab93/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 2ae5729..1cdcf19 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;
     }


[04/14] 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)


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

Branch: refs/heads/master
Commit: c52c9196afe80f333f2be384463466c7ddf2272f
Parents: 7fba34a
Author: Grzegorz Grzybek <gr...@gmail.com>
Authored: Fri Jul 10 15:02:37 2015 +0200
Committer: Grzegorz Grzybek <gr...@gmail.com>
Committed: Mon Jul 20 14:51:37 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/c52c9196/components/camel-cxf/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-cxf/pom.xml b/components/camel-cxf/pom.xml
index ae34eee..fab4458 100644
--- a/components/camel-cxf/pom.xml
+++ b/components/camel-cxf/pom.xml
@@ -145,7 +145,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/c52c9196/components/camel-test-blueprint/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-test-blueprint/pom.xml b/components/camel-test-blueprint/pom.xml
index e80a759..e555777 100644
--- a/components/camel-test-blueprint/pom.xml
+++ b/components/camel-test-blueprint/pom.xml
@@ -57,10 +57,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/c52c9196/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index e39986b..367d2d7 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -44,10 +44,11 @@
     <apacheds-version>2.0.0-M20</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.1.8.Final</arquillian-junit-container-version>
     <arquillian-weld-se-embedded-version>1.0.0.CR8</arquillian-weld-se-embedded-version>
@@ -2614,14 +2615,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/c52c9196/platforms/karaf/features/pom.xml
----------------------------------------------------------------------
diff --git a/platforms/karaf/features/pom.xml b/platforms/karaf/features/pom.xml
index e82d17c..b076ef3 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>


[05/14] camel git commit: [camel-test-blueprint] Ensure loadConfigAdminConfigurationFile() provided file is valid

Posted by gg...@apache.org.
[camel-test-blueprint] Ensure loadConfigAdminConfigurationFile() provided file is valid


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

Branch: refs/heads/master
Commit: 7fba34a9a5de8ece63e0fae23eccc64090f8491a
Parents: dc23d6a
Author: Grzegorz Grzybek <gr...@gmail.com>
Authored: Fri Jul 10 15:01:24 2015 +0200
Committer: Grzegorz Grzybek <gr...@gmail.com>
Committed: Mon Jul 20 14:51:37 2015 +0200

----------------------------------------------------------------------
 .../blueprint/CamelBlueprintTestSupport.java    |  4 ++
 ...gAdminLoadConfigurationFileNotFoundTest.java | 57 ++++++++++++++++++++
 2 files changed, 61 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/7fba34a9/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 d707370..a49b848 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;
@@ -111,6 +112,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/7fba34a9/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
+    }
+
+}


[08/14] camel git commit: Remove references to PojoSR

Posted by gg...@apache.org.
Remove references to PojoSR


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

Branch: refs/heads/master
Commit: 3db84387a1a0f2d4620603abbd91f183a8754a2a
Parents: aa37931
Author: Grzegorz Grzybek <gr...@gmail.com>
Authored: Fri Jul 17 21:11:25 2015 +0200
Committer: Grzegorz Grzybek <gr...@gmail.com>
Committed: Mon Jul 20 14:51:37 2015 +0200

----------------------------------------------------------------------
 components/camel-test-blueprint/pom.xml                          | 2 +-
 .../org/apache/camel/test/blueprint/CamelBlueprintHelper.java    | 4 ++--
 .../apache/camel/test/blueprint/CamelBlueprintTestSupport.java   | 2 +-
 .../camel-test-blueprint/src/test/resources/log4j.properties     | 2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/3db84387/components/camel-test-blueprint/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-test-blueprint/pom.xml b/components/camel-test-blueprint/pom.xml
index e555777..7588375 100644
--- a/components/camel-test-blueprint/pom.xml
+++ b/components/camel-test-blueprint/pom.xml
@@ -56,7 +56,7 @@
         </dependency>
 
         <!-- 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 -->
+             with felix-connect, and you may get a weird error if wrong order -->
         <dependency>
             <groupId>org.apache.aries.blueprint</groupId>
             <artifactId>org.apache.aries.blueprint.api</artifactId>

http://git-wip-us.apache.org/repos/asf/camel/blob/3db84387/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 2eea106..42592c3 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
@@ -103,7 +103,7 @@ public final class CamelBlueprintHelper {
     }
 
     public static BundleContext createBundleContext(String name, String bundleFilter, TinyBundle bundle) throws Exception {
-        // ensure pojosr stores bundles in an unique target directory
+        // ensure felix-connect stores bundles in an unique target directory
         String uid = "" + System.currentTimeMillis();
         String tempDir = "target/bundles/" + uid;
         System.setProperty("org.osgi.framework.storage", tempDir);
@@ -129,7 +129,7 @@ public final class CamelBlueprintHelper {
             }
         }
 
-        // setup pojosr to use our bundles
+        // setup felix-connect to use our bundles
         Map<String, Object> config = new HashMap<String, Object>();
         config.put(PojoServiceRegistryFactory.BUNDLE_DESCRIPTORS, bundles);
 

http://git-wip-us.apache.org/repos/asf/camel/blob/3db84387/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 a49b848..1bc22a5 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
@@ -162,7 +162,7 @@ public abstract class CamelBlueprintTestSupport extends CamelTestSupport {
             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
+            // *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 felix-connect
             Configuration config = configAdmin.getConfiguration(pid, null);
             if (config == null) {
                 throw new IllegalArgumentException("Cannot find configuration with pid " + pid + " in OSGi ConfigurationAdmin service.");

http://git-wip-us.apache.org/repos/asf/camel/blob/3db84387/components/camel-test-blueprint/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/components/camel-test-blueprint/src/test/resources/log4j.properties b/components/camel-test-blueprint/src/test/resources/log4j.properties
index 39dbf51..22dcbfe 100644
--- a/components/camel-test-blueprint/src/test/resources/log4j.properties
+++ b/components/camel-test-blueprint/src/test/resources/log4j.properties
@@ -20,7 +20,7 @@
 #
 log4j.rootLogger=INFO, file
 
-#log4j.logger.de.kalpatec.pojosr=DEBUG
+#log4j.logger.org.apache.felix.connect=DEBUG
 #log4j.logger.org.apache.camel.test.blueprint=DEBUG
 #log4j.logger.org.apache.camel=DEBUG
 #log4j.logger.org.apache.camel.management=DEBUG


[06/14] 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


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

Branch: refs/heads/master
Commit: aa3793121b6778a5053650c355fe2bdb0644f4a1
Parents: c52c919
Author: Grzegorz Grzybek <gr...@gmail.com>
Authored: Fri Jul 17 08:09:29 2015 +0200
Committer: Grzegorz Grzybek <gr...@gmail.com>
Committed: Mon Jul 20 14:51:37 2015 +0200

----------------------------------------------------------------------
 parent/pom.xml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/aa379312/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index 367d2d7..0e52ca5 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>


[09/14] 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


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

Branch: refs/heads/master
Commit: ab845909b0daac83509eaf5c38aca3f774c73a5d
Parents: 3db8438
Author: Grzegorz Grzybek <gr...@gmail.com>
Authored: Fri Jul 17 21:20:10 2015 +0200
Committer: Grzegorz Grzybek <gr...@gmail.com>
Committed: Mon Jul 20 14:51:37 2015 +0200

----------------------------------------------------------------------
 components/camel-test-blueprint/pom.xml | 20 ++++++++++----------
 tests/camel-itest-osgi/pom.xml          | 12 +++++++++++-
 2 files changed, 21 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/ab845909/components/camel-test-blueprint/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-test-blueprint/pom.xml b/components/camel-test-blueprint/pom.xml
index 7588375..0da9002 100644
--- a/components/camel-test-blueprint/pom.xml
+++ b/components/camel-test-blueprint/pom.xml
@@ -58,6 +58,16 @@
         <!-- the ordering of the dependencies can matter as we load the dependencies from the classpath
              with felix-connect, 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>
@@ -75,16 +85,6 @@
             <version>${aries-util-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.proxy</groupId>
-            <artifactId>org.apache.aries.proxy.api</artifactId>
-            <version>${aries-blueprint-proxy-version}</version>
-        </dependency>
-        <dependency>
             <groupId>org.apache.felix</groupId>
             <artifactId>org.apache.felix.connect</artifactId>
             <version>${felix-connect-version}</version>

http://git-wip-us.apache.org/repos/asf/camel/blob/ab845909/tests/camel-itest-osgi/pom.xml
----------------------------------------------------------------------
diff --git a/tests/camel-itest-osgi/pom.xml b/tests/camel-itest-osgi/pom.xml
index db8c104..2ec17bb 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>
 


[11/14] 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"


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

Branch: refs/heads/master
Commit: 2e502fa02699bc0808179a1f755ed160987d2091
Parents: 21309c0
Author: Grzegorz Grzybek <gr...@gmail.com>
Authored: Mon Jul 20 11:05:34 2015 +0200
Committer: Grzegorz Grzybek <gr...@gmail.com>
Committed: Mon Jul 20 14:51:38 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/2e502fa0/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/2e502fa0/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/2e502fa0/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/2e502fa0/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/2e502fa0/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/2e502fa0/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>


[13/14] camel git commit: [CAMEL-8948] Add synchronous CamelBlueprintTestSupport test

Posted by gg...@apache.org.
[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();
+    }
+
+}


[02/14] 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


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

Branch: refs/heads/master
Commit: 692e479b940b1198df3cec386c16aa4fd071e16c
Parents: 9aa1ab9
Author: Grzegorz Grzybek <gr...@gmail.com>
Authored: Fri Jul 17 21:40:16 2015 +0200
Committer: Grzegorz Grzybek <gr...@gmail.com>
Committed: Mon Jul 20 14:51:37 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/692e479b/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 42592c3..4e84211 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 org.apache.camel.impl.DefaultClassResolver;
@@ -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/692e479b/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 1bc22a5..87f7256 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,7 +17,9 @@
 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.LinkedList;
@@ -25,8 +27,6 @@ import java.util.List;
 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;
@@ -38,13 +38,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.
@@ -103,7 +99,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();
@@ -111,79 +107,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 felix-connect
-            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/692e479b/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 ba6bcf3..338ad7a 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
@@ -97,7 +97,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);


[03/14] 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


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...@gmail.com>
Authored: Fri Jul 10 15:00:10 2015 +0200
Committer: Grzegorz Grzybek <gr...@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 + ")");
     }
 
     /**


[12/14] 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


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

Branch: refs/heads/master
Commit: a7d325b5723d8e8116449940e86e20c689678319
Parents: 9b6737b
Author: Grzegorz Grzybek <gr...@gmail.com>
Authored: Mon Jul 20 09:44:00 2015 +0200
Committer: Grzegorz Grzybek <gr...@gmail.com>
Committed: Mon Jul 20 14:51:38 2015 +0200

----------------------------------------------------------------------
 parent/pom.xml | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/a7d325b5/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index 0e52ca5..9f7455b 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>
@@ -3145,6 +3145,7 @@
             </goals>
             <configuration>
               <strict>true</strict>
+              <skip>true</skip>
             </configuration>
           </execution>
         </executions>


[14/14] 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


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

Branch: refs/heads/master
Commit: 21309c048e35c8eba0d482873e14d47974189456
Parents: a7d325b
Author: Grzegorz Grzybek <gr...@gmail.com>
Authored: Mon Jul 20 09:45:43 2015 +0200
Committer: Grzegorz Grzybek <gr...@gmail.com>
Committed: Mon Jul 20 14:51:38 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/21309c04/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/21309c04/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/21309c04/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/21309c04/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/21309c04/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">


[10/14] 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/14a7dd79
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/14a7dd79
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/14a7dd79

Branch: refs/heads/master
Commit: 14a7dd79148f9306dcd2f748b56fd6550e9406ab
Parents: 7aa3b59
Author: Grzegorz Grzybek <gr...@gmail.com>
Authored: Mon Jul 20 14:51:28 2015 +0200
Committer: Grzegorz Grzybek <gr...@gmail.com>
Committed: Mon Jul 20 14:51:38 2015 +0200

----------------------------------------------------------------------
 .../apache/camel/cdi/CdiBeanManagerHelper.java  |  3 +
 .../http/HttpGetHeadersNotCopiedTest.java       |  5 +-
 .../http4/HttpCamelHeadersNotCopiedTest.java    | 10 +--
 .../CamelSpringBootApplicationController.java   |  4 +-
 .../test/blueprint/CamelBlueprintHelper.java    |  4 +-
 .../blueprint/CamelBlueprintTestSupport.java    | 10 +--
 .../component/undertow/UndertowProducer.java    |  3 +-
 .../maven/packaging/PackageDataFormatMojo.java  | 64 +++++++++++---------
 .../maven/packaging/PackageLanguageMojo.java    | 64 +++++++++++---------
 9 files changed, 92 insertions(+), 75 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/14a7dd79/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiBeanManagerHelper.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiBeanManagerHelper.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiBeanManagerHelper.java
index 312e90a..91ecbd3 100644
--- a/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiBeanManagerHelper.java
+++ b/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiBeanManagerHelper.java
@@ -26,6 +26,9 @@ import javax.enterprise.inject.spi.BeanManager;
  */
 public final class CdiBeanManagerHelper {
 
+    private CdiBeanManagerHelper() {
+    }
+
     /**
      * To lookup a bean by a type
      */

http://git-wip-us.apache.org/repos/asf/camel/blob/14a7dd79/components/camel-http/src/test/java/org/apache/camel/component/http/HttpGetHeadersNotCopiedTest.java
----------------------------------------------------------------------
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpGetHeadersNotCopiedTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpGetHeadersNotCopiedTest.java
index cf24c4d..aae01db 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpGetHeadersNotCopiedTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpGetHeadersNotCopiedTest.java
@@ -16,11 +16,10 @@
  */
 package org.apache.camel.component.http;
 
-import org.apache.camel.builder.RouteBuilder;
-import org.junit.Before;
-
 import java.util.Map;
 
+import org.apache.camel.builder.RouteBuilder;
+
 public class HttpGetHeadersNotCopiedTest extends HttpGetWithHeadersTest {
 
     @Override

http://git-wip-us.apache.org/repos/asf/camel/blob/14a7dd79/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpCamelHeadersNotCopiedTest.java
----------------------------------------------------------------------
diff --git a/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpCamelHeadersNotCopiedTest.java b/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpCamelHeadersNotCopiedTest.java
index fa80631..4268767 100644
--- a/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpCamelHeadersNotCopiedTest.java
+++ b/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpCamelHeadersNotCopiedTest.java
@@ -5,9 +5,9 @@
  * 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
- * <p/>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p/>
+ *
+ *      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.
@@ -16,11 +16,11 @@
  */
 package org.apache.camel.component.http4;
 
+import java.util.Map;
+
 import org.apache.camel.Exchange;
 import org.apache.http.HttpStatus;
 
-import java.util.Map;
-
 public class HttpCamelHeadersNotCopiedTest extends HttpCamelHeadersTest {
 
     @Override

http://git-wip-us.apache.org/repos/asf/camel/blob/14a7dd79/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/14a7dd79/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 ece0688..a48f104 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/14a7dd79/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 c7581e3..958da58 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;
@@ -33,6 +32,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;
@@ -47,10 +51,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.

http://git-wip-us.apache.org/repos/asf/camel/blob/14a7dd79/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowProducer.java b/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowProducer.java
index d139ce4..fac4d8d 100644
--- a/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowProducer.java
+++ b/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowProducer.java
@@ -68,7 +68,8 @@ public class UndertowProducer extends DefaultAsyncProducer {
             final UndertowClient client = UndertowClient.getInstance();
             XnioWorker worker = Xnio.getInstance().createWorker(OptionMap.EMPTY);
 
-            IoFuture<ClientConnection> connect = client.connect(endpoint.getHttpURI(), worker, new ByteBufferSlicePool(BufferAllocator.DIRECT_BYTE_BUFFER_ALLOCATOR, 8192, 8192 * 8192), OptionMap.EMPTY);
+            IoFuture<ClientConnection> connect = client.connect(endpoint.getHttpURI(), worker,
+                    new ByteBufferSlicePool(BufferAllocator.DIRECT_BYTE_BUFFER_ALLOCATOR, 8192, 8192 * 8192), OptionMap.EMPTY);
 
             ClientRequest request = new ClientRequest();
             request.setProtocol(Protocols.HTTP_1_1);

http://git-wip-us.apache.org/repos/asf/camel/blob/14a7dd79/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageDataFormatMojo.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageDataFormatMojo.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageDataFormatMojo.java
index 88d7057..ca61d3e 100644
--- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageDataFormatMojo.java
+++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageDataFormatMojo.java
@@ -132,37 +132,12 @@ public class PackageDataFormatMojo extends AbstractMojo {
                 File[] files = f.listFiles();
                 if (files != null) {
                     for (File file : files) {
-                        // skip directories as there may be a sub .resolver directory
-                        if (file.isDirectory()) {
-                            continue;
-                        }
-                        String name = file.getName();
-                        if (name.charAt(0) != '.') {
+                        String javaType = readClassFromCamelResource(file, buffer, buildContext);
+                        if (!file.isDirectory() && file.getName().charAt(0) != '.') {
                             count++;
-                            if (buffer.length() > 0) {
-                                buffer.append(" ");
-                            }
-                            buffer.append(name);
-                        }
-
-                        if (!buildContext.hasDelta(file)) {
-                            // if this file has not changed,
-                            // then no need to store the javatype
-                            // for the json file to be generated again
-                            // (but we do need the name above!)
-                            continue;
                         }
-
-                        // find out the javaType for each data format
-                        try {
-                            String text = loadText(new FileInputStream(file));
-                            Map<String, String> map = parseAsMap(text);
-                            String javaType = map.get("class");
-                            if (javaType != null) {
-                                javaTypes.put(name, javaType);
-                            }
-                        } catch (IOException e) {
-                            throw new MojoExecutionException("Failed to read file " + file + ". Reason: " + e, e);
+                        if (javaType != null) {
+                            javaTypes.put(file.getName(), javaType);
                         }
                     }
                 }
@@ -300,6 +275,37 @@ public class PackageDataFormatMojo extends AbstractMojo {
         }
     }
 
+    private static String readClassFromCamelResource(File file, StringBuilder buffer, BuildContext buildContext) throws MojoExecutionException {
+        // skip directories as there may be a sub .resolver directory
+        if (file.isDirectory()) {
+            return null;
+        }
+        String name = file.getName();
+        if (name.charAt(0) != '.') {
+            if (buffer.length() > 0) {
+                buffer.append(" ");
+            }
+            buffer.append(name);
+        }
+
+        if (!buildContext.hasDelta(file)) {
+            // if this file has not changed,
+            // then no need to store the javatype
+            // for the json file to be generated again
+            // (but we do need the name above!)
+            return null;
+        }
+
+        // find out the javaType for each data format
+        try {
+            String text = loadText(new FileInputStream(file));
+            Map<String, String> map = parseAsMap(text);
+            return map.get("class");
+        } catch (IOException e) {
+            throw new MojoExecutionException("Failed to read file " + file + ". Reason: " + e, e);
+        }
+    }
+
     private static String asModelName(String name) {
         // special for some data formats
         if ("json-gson".equals(name) || "json-jackson".equals(name) || "json-xstream".equals(name)) {

http://git-wip-us.apache.org/repos/asf/camel/blob/14a7dd79/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageLanguageMojo.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageLanguageMojo.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageLanguageMojo.java
index d6596db..fda5af3 100644
--- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageLanguageMojo.java
+++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageLanguageMojo.java
@@ -132,37 +132,12 @@ public class PackageLanguageMojo extends AbstractMojo {
                 File[] files = f.listFiles();
                 if (files != null) {
                     for (File file : files) {
-                        // skip directories as there may be a sub .resolver directory such as in camel-script
-                        if (file.isDirectory()) {
-                            continue;
-                        }
-                        String name = file.getName();
-                        if (name.charAt(0) != '.') {
+                        String javaType = readClassFromCamelResource(file, buffer, buildContext);
+                        if (!file.isDirectory() && file.getName().charAt(0) != '.') {
                             count++;
-                            if (buffer.length() > 0) {
-                                buffer.append(" ");
-                            }
-                            buffer.append(name);
-                        }
-
-                        if (!buildContext.hasDelta(file)) {
-                            // if this file has not changed,
-                            // then no need to store the javatype
-                            // for the json file to be generated again
-                            // (but we do need the name above!)
-                            continue;
                         }
-
-                        // find out the javaType for each data format
-                        try {
-                            String text = loadText(new FileInputStream(file));
-                            Map<String, String> map = parseAsMap(text);
-                            String javaType = map.get("class");
-                            if (javaType != null) {
-                                javaTypes.put(name, javaType);
-                            }
-                        } catch (IOException e) {
-                            throw new MojoExecutionException("Failed to read file " + file + ". Reason: " + e, e);
+                        if (javaType != null) {
+                            javaTypes.put(file.getName(), javaType);
                         }
                     }
                 }
@@ -298,6 +273,37 @@ public class PackageLanguageMojo extends AbstractMojo {
         }
     }
 
+    private static String readClassFromCamelResource(File file, StringBuilder buffer, BuildContext buildContext) throws MojoExecutionException {
+        // skip directories as there may be a sub .resolver directory such as in camel-script
+        if (file.isDirectory()) {
+            return null;
+        }
+        String name = file.getName();
+        if (name.charAt(0) != '.') {
+            if (buffer.length() > 0) {
+                buffer.append(" ");
+            }
+            buffer.append(name);
+        }
+
+        if (!buildContext.hasDelta(file)) {
+            // if this file has not changed,
+            // then no need to store the javatype
+            // for the json file to be generated again
+            // (but we do need the name above!)
+            return null;
+        }
+
+        // find out the javaType for each data format
+        try {
+            String text = loadText(new FileInputStream(file));
+            Map<String, String> map = parseAsMap(text);
+            return map.get("class");
+        } catch (IOException e) {
+            throw new MojoExecutionException("Failed to read file " + file + ". Reason: " + e, e);
+        }
+    }
+
     private static String asModelName(String name) {
         // special for some languages
         if ("bean".equals(name)) {