Author: davsclaus Date: Fri Feb 8 14:59:24 2013 New Revision: 1444039 URL: http://svn.apache.org/r1444039 Log: CAMEL-6053: Added example for both load .cfg file and override properties for testing with camel-test-blueprint.
Added: camel/branches/camel-2.10.x/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/ConfigAdminLoadConfigurationFileAndOverrideTest.java - copied unchanged from r1444034, camel/trunk/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/ConfigAdminLoadConfigurationFileAndOverrideTest.java camel/branches/camel-2.10.x/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/configadmin-loadfileoverride.xml - copied unchanged from r1444034, camel/trunk/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/configadmin-loadfileoverride.xml Modified: camel/branches/camel-2.10.x/ (props changed) camel/branches/camel-2.10.x/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintTestSupport.java camel/branches/camel-2.10.x/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/MyCoolBean.java camel/branches/camel-2.10.x/components/camel-test-blueprint/src/test/resources/etc/stuff.cfg Propchange: camel/branches/camel-2.10.x/ ------------------------------------------------------------------------------ Merged /camel/trunk:r1444034 Propchange: camel/branches/camel-2.10.x/ ------------------------------------------------------------------------------ Binary property 'svnmerge-integrated' - no diff available. Modified: camel/branches/camel-2.10.x/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintTestSupport.java URL: http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintTestSupport.java?rev=1444039&r1=1444038&r2=1444039&view=diff ============================================================================== --- camel/branches/camel-2.10.x/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintTestSupport.java (original) +++ camel/branches/camel-2.10.x/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintTestSupport.java Fri Feb 8 14:59:24 2013 @@ -53,15 +53,20 @@ public abstract class CamelBlueprintTest bundleContext.registerService(PropertiesComponent.OVERRIDE_PROPERTIES, extra, null); } + // must reuse props as we can do both load from .cfg file and override afterwards + Dictionary props = new Properties(); + // load configuration file String[] file = loadConfigAdminConfigurationFile(); if (file != null && file.length != 2) { throw new IllegalArgumentException("The returned String[] from loadConfigAdminConfigurationFile must be of length 2, was " + file.length); } - if (file != null && file[0] != null) { - Dictionary props = new Properties(); - File load = new File(file[0]); + if (file != null) { + String fileName = file[0]; + String pid = file[1]; + + File load = new File(fileName); log.debug("Loading properties from OSGi config admin file: {}", load); org.apache.felix.utils.properties.Properties cfg = new org.apache.felix.utils.properties.Properties(load); for (Map.Entry entry : cfg.entrySet()) { @@ -71,7 +76,7 @@ public abstract class CamelBlueprintTest ConfigurationAdmin configAdmin = getOsgiService(ConfigurationAdmin.class); if (configAdmin != null) { // ensure we update - Configuration config = configAdmin.getConfiguration(file[1]); + Configuration config = configAdmin.getConfiguration(pid); // NOTE: setting bundle location to null is only needed for Camel 2.10.x to avoid ugly ERROR logging by pojosr/blueprint config.setBundleLocation(null); log.info("Updating ConfigAdmin {} by overriding properties {}", config, props); @@ -80,7 +85,6 @@ public abstract class CamelBlueprintTest } // allow end user to override properties - Dictionary props = new Properties(); String pid = useOverridePropertiesWithConfigAdmin(props); if (pid != null) { ConfigurationAdmin configAdmin = getOsgiService(ConfigurationAdmin.class); Modified: camel/branches/camel-2.10.x/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/MyCoolBean.java URL: http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/MyCoolBean.java?rev=1444039&r1=1444038&r2=1444039&view=diff ============================================================================== --- camel/branches/camel-2.10.x/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/MyCoolBean.java (original) +++ camel/branches/camel-2.10.x/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/MyCoolBean.java Fri Feb 8 14:59:24 2013 @@ -22,6 +22,7 @@ package org.apache.camel.test.blueprint; public class MyCoolBean { private String say; + private String echo; public String getSay() { return say; @@ -31,7 +32,21 @@ public class MyCoolBean { this.say = say; } + public String getEcho() { + return echo; + } + + public void setEcho(String echo) { + this.echo = echo; + } + public String saySomething(String s) { return say + " " + s; } + + public String echoSomething(String s) { + return echo + " " + s + echo + " " + s; + } + + } Modified: camel/branches/camel-2.10.x/components/camel-test-blueprint/src/test/resources/etc/stuff.cfg URL: http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/components/camel-test-blueprint/src/test/resources/etc/stuff.cfg?rev=1444039&r1=1444038&r2=1444039&view=diff ============================================================================== --- camel/branches/camel-2.10.x/components/camel-test-blueprint/src/test/resources/etc/stuff.cfg (original) +++ camel/branches/camel-2.10.x/components/camel-test-blueprint/src/test/resources/etc/stuff.cfg Fri Feb 8 14:59:24 2013 @@ -15,4 +15,6 @@ ## limitations under the License. ## ------------------------------------------------------------------------ -greeting=Bye \ No newline at end of file +greeting=Bye +echo=Yay +destination=mock:result \ No newline at end of file