TAMAYA-300 Unified props and manifest entry style.

Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/commit/8215ad66
Tree: 
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/tree/8215ad66
Diff: 
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/diff/8215ad66

Branch: refs/heads/master
Commit: 8215ad66c94c56b99820a2942c409b9defaa27cb
Parents: b813e7b
Author: Anatole Tresch <anat...@apache.org>
Authored: Sun Oct 1 23:01:31 2017 +0200
Committer: Anatole Tresch <anat...@apache.org>
Committed: Sun Oct 1 23:05:25 2017 +0200

----------------------------------------------------------------------
 .../org/apache/tamaya/osgi/ConfigChanger.java   |  25 ++-
 .../org/apache/tamaya/osgi/OperationMode.java   |  31 ----
 .../java/org/apache/tamaya/osgi/Policy.java     |  31 ++++
 .../apache/tamaya/osgi/TamayaConfigPlugin.java  |  84 +++++----
 .../tamaya/osgi/commands/ConfigCommands.java    |  20 +--
 .../tamaya/osgi/commands/HistoryCommands.java   |   2 +-
 .../org/apache/tamaya/osgi/OSGIBasicTests.java  | 102 -----------
 .../java/org/apache/tamaya/osgi/OSGITest.java   | 135 --------------
 .../tamaya/osgi/TamayaConfigPluginTest.java     | 175 +++++++++++++++++--
 .../osgi/commands/ConfigCommandsTest.java       |  16 +-
 .../META-INF/javaconfiguration.properties       |   3 +-
 11 files changed, 282 insertions(+), 342 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/8215ad66/osgi/common/src/main/java/org/apache/tamaya/osgi/ConfigChanger.java
----------------------------------------------------------------------
diff --git 
a/osgi/common/src/main/java/org/apache/tamaya/osgi/ConfigChanger.java 
b/osgi/common/src/main/java/org/apache/tamaya/osgi/ConfigChanger.java
index 3c5826a..0969a59 100644
--- a/osgi/common/src/main/java/org/apache/tamaya/osgi/ConfigChanger.java
+++ b/osgi/common/src/main/java/org/apache/tamaya/osgi/ConfigChanger.java
@@ -43,8 +43,6 @@ import java.util.logging.Logger;
 final class ConfigChanger {
 
     private static final Logger LOG = 
Logger.getLogger(TamayaConfigPlugin.class.getName());
-    private static final String TAMAYA_OPERATION_MODE = "tamaya-operationmode";
-    private static final String TAMAYA_ROOT = "tamaya-root";
 
     private BundleContext context;
     private ConfigurationAdmin cm;
@@ -63,21 +61,21 @@ final class ConfigChanger {
         return cm;
     }
 
-    public Dictionary<String, Object> configure(String pid, Bundle bundle, 
OperationMode operationMode, boolean opModeExplicit, boolean dryRun) {
+    public Dictionary<String, Object> configure(String pid, Bundle bundle, 
Policy policy, boolean opModeExplicit, boolean dryRun) {
         try {
             String root = '[' + pid + ']';
             // TODO Check for Bundle.getLocation() usage here...
             Configuration osgiConfig = cm.getConfiguration(pid, 
bundle!=null?bundle.getLocation():null);
-            OperationMode opMode = Objects.requireNonNull(operationMode);
+            Policy opMode = Objects.requireNonNull(policy);
             // Check manifest config
             if(bundle!=null) {
                 if(!opModeExplicit) {
-                    String opVal = 
bundle.getHeaders().get(TAMAYA_OPERATION_MODE);
+                    String opVal = 
bundle.getHeaders().get(TamayaConfigPlugin.TAMAYA_POLICY_MANIFEST);
                     if (opVal != null) {
-                        opMode = OperationMode.valueOf(opVal.toUpperCase());
+                        opMode = Policy.valueOf(opVal.toUpperCase());
                     }
                 }
-                String customRoot = bundle.getHeaders().get(TAMAYA_ROOT);
+                String customRoot = 
bundle.getHeaders().get(TamayaConfigPlugin.TAMAYA_CUSTOM_ROOT_MANIFEST);
                 if(customRoot!=null){
                     root = customRoot;
                 }
@@ -87,12 +85,12 @@ final class ConfigChanger {
                 Dictionary<String,Object> props = osgiConfig.getProperties();
                 if(props!=null){
                     if(!opModeExplicit) {
-                        String opVal = (String) 
props.get(TAMAYA_OPERATION_MODE);
+                        String opVal = (String) 
props.get(TamayaConfigPlugin.TAMAYA_POLICY_PROP);
                         if (opVal != null) {
-                            opMode = 
OperationMode.valueOf(opVal.toUpperCase());
+                            opMode = Policy.valueOf(opVal.toUpperCase());
                         }
                     }
-                    String customRoot = (String)props.get(TAMAYA_ROOT);
+                    String customRoot = 
(String)props.get(TamayaConfigPlugin.TAMAYA_CUSTOM_ROOT_PROP);
                     if(customRoot!=null){
                         root = customRoot;
                     }
@@ -101,6 +99,7 @@ final class ConfigChanger {
                 }
                 if(!dryRun && !Backups.contains(pid)){
                     Backups.set(pid, props);
+                    LOG.finest("Stored OSGI configuration backup for PID: " + 
pid);
                 }
                 LOG.finest("Evaluating Tamaya Config for PID: " + pid);
                 org.apache.tamaya.Configuration tamayaConfig = 
getTamayaConfiguration(root);
@@ -137,7 +136,7 @@ final class ConfigChanger {
         }
     }
 
-    public void modifyConfiguration(String pid, 
org.apache.tamaya.Configuration config, Dictionary<String, Object> dictionary, 
OperationMode opMode) {
+    public void modifyConfiguration(String pid, 
org.apache.tamaya.Configuration config, Dictionary<String, Object> dictionary, 
Policy opMode) {
         LOG.info(() -> "Updating configuration for PID: " + pid + "...");
         dictionary.put("tamaya.modified.at", new Date().toString());
 
@@ -171,7 +170,7 @@ final class ConfigChanger {
         }
         for (Map.Entry<String, String> configEntry : 
config.getProperties().entrySet()) {
             Object dictValue = dictionary.get(configEntry.getKey());
-            if(dictValue.equals(configEntry.getValue())){
+            if(dictValue!=null && dictValue.equals(configEntry.getValue())){
                 continue;
             }
             switch (opMode) {
@@ -209,7 +208,7 @@ final class ConfigChanger {
     public void restoreBackup(String pid, Dictionary<String, Object> 
config)throws IOException{
         Configuration osgiConfig = cm.getConfiguration(pid);
         if(osgiConfig!=null){
-            config.put(TamayaConfigPlugin.TAMAYA_ENABLED, "false");
+            config.put(TamayaConfigPlugin.TAMAYA_ENABLED_PROP, "false");
             osgiConfig.update(Objects.requireNonNull(config));
         }
     }

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/8215ad66/osgi/common/src/main/java/org/apache/tamaya/osgi/OperationMode.java
----------------------------------------------------------------------
diff --git 
a/osgi/common/src/main/java/org/apache/tamaya/osgi/OperationMode.java 
b/osgi/common/src/main/java/org/apache/tamaya/osgi/OperationMode.java
deleted file mode 100644
index 67c85e1..0000000
--- a/osgi/common/src/main/java/org/apache/tamaya/osgi/OperationMode.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * 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.tamaya.osgi;
-
-/**
- * Operation mode applied to the getConfig read.
- */
-public enum OperationMode{
-    /** Only add properties not existing in the getConfig. */
-    EXTEND,
-    /** Override existing properties and add new properties. */
-    OVERRIDE,
-    /** Override existing properties only. */
-    UPDATE_ONLY
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/8215ad66/osgi/common/src/main/java/org/apache/tamaya/osgi/Policy.java
----------------------------------------------------------------------
diff --git a/osgi/common/src/main/java/org/apache/tamaya/osgi/Policy.java 
b/osgi/common/src/main/java/org/apache/tamaya/osgi/Policy.java
new file mode 100644
index 0000000..f19c2d1
--- /dev/null
+++ b/osgi/common/src/main/java/org/apache/tamaya/osgi/Policy.java
@@ -0,0 +1,31 @@
+/*
+ * 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.tamaya.osgi;
+
+/**
+ * Operation mode applied to the getConfig read.
+ */
+public enum Policy {
+    /** Only add properties not existing in the getConfig. */
+    EXTEND,
+    /** Override existing properties and add new properties. */
+    OVERRIDE,
+    /** Override existing properties only. */
+    UPDATE_ONLY
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/8215ad66/osgi/common/src/main/java/org/apache/tamaya/osgi/TamayaConfigPlugin.java
----------------------------------------------------------------------
diff --git 
a/osgi/common/src/main/java/org/apache/tamaya/osgi/TamayaConfigPlugin.java 
b/osgi/common/src/main/java/org/apache/tamaya/osgi/TamayaConfigPlugin.java
index d986f0e..ebafa3c 100644
--- a/osgi/common/src/main/java/org/apache/tamaya/osgi/TamayaConfigPlugin.java
+++ b/osgi/common/src/main/java/org/apache/tamaya/osgi/TamayaConfigPlugin.java
@@ -32,17 +32,24 @@ import java.util.logging.Logger;
 
 /**
  * Tamaya plugin that updates/extends the component configurations managed
- * by {@link ConfigurationAdmin}, based on the configured {@link 
OperationMode}.
+ * by {@link ConfigurationAdmin}, based on the configured {@link Policy}.
  */
 public class TamayaConfigPlugin implements BundleListener, ServiceListener{
     static final String COMPONENTID = "TamayaConfigPlugin";
     /** the logger. */
     private static final Logger LOG = 
Logger.getLogger(TamayaConfigPlugin.class.getName());
-    public static final String TAMAYA_ENABLED = "tamaya-enabled";
-    public static final String TAMAYA_AUTO_UPDATE_ENABLED = 
"tamaya.autoUpdateEnabled";
-    public static final String TAMAYA_ROOT_KEY = "tamaya-root";
+
+    public static final String TAMAYA_POLICY_PROP = "tamaya-policy";
+    public static final String TAMAYA_POLICY_MANIFEST = "Tamaya-Policy";
+    public static final String TAMAYA_CUSTOM_ROOT_PROP = "tamaya-config-root";
+    public static final String TAMAYA_CUSTOM_ROOT_MANIFEST = 
"Tamaya-Config-Root";
+    public static final String TAMAYA_ENABLED_PROP = "tamaya-enabled";
+    public static final String TAMAYA_ENABLED_MANIFEST = "Tamaya-Enabled";
+    public static final String TAMAYA_AUTO_UPDATE_ENABLED_PROP = 
"tamaya-update-enabled";
+    public static final String TAMAYA_AUTO_UPDATE_ENABLED_MANIFEST = 
"Tamaya-Update-Enabled";
     private boolean enabledByDefault = false;
-    private OperationMode defaultOpMode = OperationMode.OVERRIDE;
+
+    private Policy defaultPolicy = Policy.OVERRIDE;
 
     private ConfigChanger configChanger;
     private boolean autoUpdateEnabled;
@@ -78,25 +85,25 @@ public class TamayaConfigPlugin implements BundleListener, 
ServiceListener{
 
     public void setAutoUpdateEnabled(boolean enabled){
         this.autoUpdateEnabled = enabled;
-        setConfigValue(TAMAYA_AUTO_UPDATE_ENABLED, enabled);
+        setConfigValue(TAMAYA_AUTO_UPDATE_ENABLED_PROP, enabled);
     }
 
     public void setTamayaEnabledByDefault(boolean enabledByDefault){
         this.enabledByDefault = enabledByDefault;
-        setConfigValue(TAMAYA_ENABLED, enabledByDefault);
+        setConfigValue(TAMAYA_ENABLED_PROP, enabledByDefault);
     }
 
     public boolean isTamayaEnabledByDefault(){
         return enabledByDefault;
     }
 
-    public OperationMode getDefaultOperationMode(){
-        return defaultOpMode;
+    public Policy getDefaultOperationMode(){
+        return defaultPolicy;
     }
 
-    public void setDefaultOperationMode(OperationMode mode){
-        this.defaultOpMode = Objects.requireNonNull(mode);
-        setConfigValue(OperationMode.class.getSimpleName(), 
defaultOpMode.toString());
+    public void setDefaultOperationMode(Policy mode){
+        this.defaultPolicy = Objects.requireNonNull(mode);
+        setConfigValue(Policy.class.getSimpleName(), defaultPolicy.toString());
     }
 
     @Override
@@ -131,7 +138,7 @@ public class TamayaConfigPlugin implements BundleListener, 
ServiceListener{
             LOG.finest("No service pid for: " + event.getServiceReference());
             return;
         }
-        configChanger.configure(pid, event.getServiceReference().getBundle(), 
defaultOpMode, false, false);
+        configChanger.configure(pid, event.getServiceReference().getBundle(), 
defaultPolicy, false, false);
         Dictionary<String,Object> props = getPluginConfig();
         Backups.save(props);
         ConfigHistory.save(props);
@@ -139,14 +146,14 @@ public class TamayaConfigPlugin implements 
BundleListener, ServiceListener{
     }
 
     public Dictionary<String,Object> updateConfig(String pid) {
-        return updateConfig(pid, defaultOpMode, false, false);
+        return updateConfig(pid, defaultPolicy, false, false);
     }
 
     public Dictionary<String,Object> updateConfig(String pid, boolean dryRun) {
-        return updateConfig(pid, defaultOpMode, false, dryRun);
+        return updateConfig(pid, defaultPolicy, false, dryRun);
     }
 
-    public Dictionary<String,Object> updateConfig(String pid, OperationMode 
opMode, boolean explicitMode, boolean dryRun) {
+    public Dictionary<String,Object> updateConfig(String pid, Policy opMode, 
boolean explicitMode, boolean dryRun) {
         if(dryRun){
             return configChanger.configure(pid, null, opMode, explicitMode, 
true);
         }else {
@@ -164,7 +171,7 @@ public class TamayaConfigPlugin implements BundleListener, 
ServiceListener{
         if(!isBundleEnabled(bundle)){
             return;
         }
-        String tamayaPid = bundle.getHeaders().get(TAMAYA_ROOT_KEY);
+        String tamayaPid = 
bundle.getHeaders().get(TAMAYA_CUSTOM_ROOT_MANIFEST);
         String pid = tamayaPid!=null?tamayaPid:bundle.getSymbolicName();
         if(pid==null){
             pid = bundle.getLocation();
@@ -173,7 +180,7 @@ public class TamayaConfigPlugin implements BundleListener, 
ServiceListener{
             LOG.finest(() -> "No PID/location for bundle " + 
bundle.getSymbolicName() + '('+bundle.getBundleId()+')');
             return;
         }
-        configChanger.configure(pid, bundle, defaultOpMode, false, false);
+        configChanger.configure(pid, bundle, defaultPolicy, false, false);
         Dictionary<String,Object> props = getPluginConfig();
         Backups.save(props);
         ConfigHistory.save(props);
@@ -182,7 +189,7 @@ public class TamayaConfigPlugin implements BundleListener, 
ServiceListener{
 
     public boolean isBundleEnabled(Bundle bundle){
         // Optional MANIFEST entries
-        String bundleEnabledVal = bundle.getHeaders().get(TAMAYA_ENABLED);
+        String bundleEnabledVal = 
bundle.getHeaders().get(TAMAYA_ENABLED_MANIFEST);
         if(bundleEnabledVal==null && !enabledByDefault){
             LOG.finest("tamaya.enabled=false: not configuring bundle: " + 
bundle.getSymbolicName());
             return false;
@@ -198,25 +205,42 @@ public class TamayaConfigPlugin implements 
BundleListener, ServiceListener{
         return true;
     }
 
+    private boolean isAutoUpdateEnabled(Bundle bundle, 
Dictionary<String,Object> props) {
+        Object enabledVal = props.get(TAMAYA_AUTO_UPDATE_ENABLED_PROP);
+        if(enabledVal!=null){
+            return Boolean.parseBoolean(enabledVal.toString());
+        }
+        if(bundle!=null){
+            enabledVal = 
bundle.getHeaders().get(TAMAYA_AUTO_UPDATE_ENABLED_MANIFEST);
+            if(enabledVal!=null){
+                return Boolean.parseBoolean(enabledVal.toString());
+            }
+        }
+        return this.autoUpdateEnabled;
+    }
+
     private void initAutoUpdateEnabled(Dictionary<String,Object> props) {
-        Object enabledVal = props.get(TAMAYA_AUTO_UPDATE_ENABLED);
+        Object enabledVal = props.get(TAMAYA_AUTO_UPDATE_ENABLED_PROP);
+        if(enabledVal==null && 
System.getProperty(TAMAYA_AUTO_UPDATE_ENABLED_PROP)!=null){
+            enabledVal = 
Boolean.parseBoolean(System.getProperty(TAMAYA_AUTO_UPDATE_ENABLED_PROP));
+        }
         if(enabledVal!=null){
             this.autoUpdateEnabled = 
Boolean.parseBoolean(enabledVal.toString());
         }
         if(this.autoUpdateEnabled) {
-            LOG.info("Tamaya Automatic Config Updating is enabled.");
+            LOG.info("Tamaya Automatic Config Update is enabled by default.");
         }else{
-            LOG.info("Tamaya Automatic Config Updating is enabledByDefault.");
+            LOG.info("Tamaya Automatic Config Update is disabled by default.");
         }
     }
 
     private void initDefaultEnabled(Dictionary<String,Object> props) {
-        Object disabledVal = props.get(TAMAYA_ENABLED);
-        if(disabledVal==null && System.getProperty(TAMAYA_ENABLED)!=null){
-            disabledVal = 
Boolean.parseBoolean(System.getProperty(TAMAYA_ENABLED));
+        Object enabledVal = props.get(TAMAYA_ENABLED_PROP);
+        if(enabledVal==null && System.getProperty(TAMAYA_ENABLED_PROP)!=null){
+            enabledVal = 
Boolean.parseBoolean(System.getProperty(TAMAYA_ENABLED_PROP));
         }
-        if(disabledVal!=null){
-            this.enabledByDefault = 
Boolean.parseBoolean(disabledVal.toString());
+        if(enabledVal!=null){
+            this.enabledByDefault = 
Boolean.parseBoolean(enabledVal.toString());
         }
         if(this.enabledByDefault) {
             LOG.info("Tamaya Config is enabledByDefault by default. Add 
Tamaya-Enabled to your bundle manifests to enable it.");
@@ -226,12 +250,12 @@ public class TamayaConfigPlugin implements 
BundleListener, ServiceListener{
     }
 
     private void initDefaultOpMode(Dictionary<String,Object> props) {
-        String opVal = (String)props.get(OperationMode.class.getSimpleName());
+        String opVal = (String)props.get(Policy.class.getSimpleName());
         if(opVal!=null){
             try{
-                defaultOpMode = OperationMode.valueOf(opVal);
+                defaultPolicy = Policy.valueOf(opVal);
             }catch(Exception e){
-                LOG.warning("Invalid OperationMode: " + opVal +", using 
default: " + defaultOpMode);
+                LOG.warning("Invalid Policy: " + opVal +", using default: " + 
defaultPolicy);
             }
         }
     }

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/8215ad66/osgi/common/src/main/java/org/apache/tamaya/osgi/commands/ConfigCommands.java
----------------------------------------------------------------------
diff --git 
a/osgi/common/src/main/java/org/apache/tamaya/osgi/commands/ConfigCommands.java 
b/osgi/common/src/main/java/org/apache/tamaya/osgi/commands/ConfigCommands.java
index ec24308..a10b3b8 100644
--- 
a/osgi/common/src/main/java/org/apache/tamaya/osgi/commands/ConfigCommands.java
+++ 
b/osgi/common/src/main/java/org/apache/tamaya/osgi/commands/ConfigCommands.java
@@ -21,7 +21,7 @@ package org.apache.tamaya.osgi.commands;
 import org.apache.tamaya.Configuration;
 import org.apache.tamaya.ConfigurationProvider;
 import org.apache.tamaya.functions.ConfigurationFunctions;
-import org.apache.tamaya.osgi.OperationMode;
+import org.apache.tamaya.osgi.Policy;
 import org.apache.tamaya.osgi.TamayaConfigPlugin;
 import org.apache.tamaya.spi.PropertySource;
 import org.apache.tamaya.spi.PropertyValue;
@@ -42,8 +42,8 @@ public final class ConfigCommands {
     public static String getInfo(TamayaConfigPlugin configPlugin) throws 
IOException {
         Configuration config = ConfigurationProvider.getConfiguration();
         return config.toString() + "\n\n"
-                + StringUtil.format("Default OperationMode:", 30) + 
configPlugin.getDefaultOperationMode() + '\n'
-                + StringUtil.format("Default Disabled: ", 30) + 
configPlugin.isTamayaEnabledByDefault();
+                + StringUtil.format("Default Policy:", 30) + 
configPlugin.getDefaultOperationMode() + '\n'
+                + StringUtil.format("Default Enabled: ", 30) + 
configPlugin.isTamayaEnabledByDefault();
     }
 
     public static String readTamayaConfig(String section, String filter) {
@@ -69,11 +69,11 @@ public final class ConfigCommands {
     public static String applyTamayaConfiguration(TamayaConfigPlugin 
configPlugin, String pid, String operationMode, boolean dryRun){
         Dictionary<String,Object> config = null;
         if(operationMode!=null){
-            config = configPlugin.updateConfig(pid, 
OperationMode.valueOf(operationMode), true, dryRun);
+            config = configPlugin.updateConfig(pid, 
Policy.valueOf(operationMode), true, dryRun);
             return  "Full configuration\n" +
                     "------------------\n" +
                     "PID           : " + pid + "\n" +
-                    "OperationMode : "+ operationMode + "\n" +
+                    "Policy : "+ operationMode + "\n" +
                     "Applied       : " + !dryRun + "\n" +
                     printOSGIConfig(pid, config);
         }else{
@@ -81,7 +81,7 @@ public final class ConfigCommands {
             return  "Full configuration\n" +
                     "------------------\n" +
                     "PID           : " + pid + "\n" +
-                    "OperationMode : "+ configPlugin.getDefaultOperationMode() 
+ "\n" +
+                    "Policy : "+ configPlugin.getDefaultOperationMode() + "\n" 
+
                     "Applied       : " + !dryRun + "\n" +
                     printOSGIConfig(pid, config);
         }
@@ -118,9 +118,9 @@ public final class ConfigCommands {
     }
 
     public static String setDefaultOpPolicy(TamayaConfigPlugin configPlugin, 
String policy) throws IOException {
-        OperationMode opMode = OperationMode.valueOf(policy);
+        Policy opMode = Policy.valueOf(policy);
         configPlugin.setDefaultOperationMode(opMode);
-        return "OperationMode="+opMode.toString();
+        return "Policy="+opMode.toString();
     }
 
     public static String getProperty(String propertysource, String key, 
boolean extended) throws IOException {
@@ -227,7 +227,7 @@ public final class ConfigCommands {
 
     public static String setDefaultEnabled(TamayaConfigPlugin configPlugin, 
boolean enabled) throws IOException {
         configPlugin.setTamayaEnabledByDefault(enabled);
-        return "tamaya.default-enabled="+enabled;
+        return TamayaConfigPlugin.TAMAYA_ENABLED_PROP+"d="+enabled;
     }
 
     public static String getDefaultEnabled(TamayaConfigPlugin configPlugin) {
@@ -236,7 +236,7 @@ public final class ConfigCommands {
 
     public static String setAutoUpdateEnabled(TamayaConfigPlugin configPlugin, 
boolean enabled) {
         configPlugin.setAutoUpdateEnabled(enabled);
-        return "tamaya.auto-update="+enabled;
+        return TamayaConfigPlugin.TAMAYA_AUTO_UPDATE_ENABLED_PROP+"="+enabled;
     }
 
     public static String getAutoUpdateEnabled(TamayaConfigPlugin configPlugin) 
{

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/8215ad66/osgi/common/src/main/java/org/apache/tamaya/osgi/commands/HistoryCommands.java
----------------------------------------------------------------------
diff --git 
a/osgi/common/src/main/java/org/apache/tamaya/osgi/commands/HistoryCommands.java
 
b/osgi/common/src/main/java/org/apache/tamaya/osgi/commands/HistoryCommands.java
index 6b282f5..7a372fe 100644
--- 
a/osgi/common/src/main/java/org/apache/tamaya/osgi/commands/HistoryCommands.java
+++ 
b/osgi/common/src/main/java/org/apache/tamaya/osgi/commands/HistoryCommands.java
@@ -72,7 +72,7 @@ public final class HistoryCommands{
 
     public static String setMaxHistorySize(int maxSize){
         ConfigHistory.setMaxHistory(maxSize);
-        return "tamaya.max-history-size="+maxSize;
+        return "tamaya-max-history-size="+maxSize;
     }
 
     private static List<ConfigHistory> filterTypes(List<ConfigHistory> 
history, String... eventTypes) {

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/8215ad66/osgi/common/src/test/java/org/apache/tamaya/osgi/OSGIBasicTests.java
----------------------------------------------------------------------
diff --git 
a/osgi/common/src/test/java/org/apache/tamaya/osgi/OSGIBasicTests.java 
b/osgi/common/src/test/java/org/apache/tamaya/osgi/OSGIBasicTests.java
deleted file mode 100644
index 95317b0..0000000
--- a/osgi/common/src/test/java/org/apache/tamaya/osgi/OSGIBasicTests.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * 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.tamaya.osgi;
-
-import static org.junit.Assert.*;
-import static org.ops4j.pax.exam.CoreOptions.*;
-
-import org.apache.tamaya.osgi.commands.BackupCommands;
-import org.apache.tamaya.osgi.commands.ConfigCommands;
-import org.apache.tamaya.osgi.commands.HistoryCommands;
-import org.apache.tamaya.osgi.commands.StringUtil;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.ConfigurationManager;
-import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.ProbeBuilder;
-import org.ops4j.pax.exam.TestProbeBuilder;
-import org.ops4j.pax.exam.junit.PaxExam;
-import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
-import org.ops4j.pax.exam.spi.reactors.PerClass;
-import org.ops4j.pax.exam.spi.reactors.PerMethod;
-import org.ops4j.pax.tinybundles.core.TinyBundles;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Constants;
-
-import javax.inject.Inject;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-
-@RunWith(PaxExam.class)
-@ExamReactorStrategy(PerMethod.class)
-@Ignore
-public class OSGIBasicTests {
-
-    @Inject
-    private BundleContext bundleContext;
-
-    @ProbeBuilder
-    public TestProbeBuilder probeConfiguration(TestProbeBuilder probe) {
-        probe.setHeader( Constants.IMPORT_PACKAGE,
-                        
"org.apache.tamaya.osgi,org.apache.tamaya.osgi.commands" );
-        return probe;
-    }
-
-    @org.ops4j.pax.exam.Configuration
-    public Option[] config() throws FileNotFoundException {
-        return new Option[] {
-                cleanCaches(true),
-                junitBundles(),
-                mavenBundle("org.apache.felix","org.apache.felix.configadmin"),
-                mavenBundle("org.apache.geronimo.specs", 
"geronimo-annotation_1.2_spec", "1.0"),
-                mavenBundle("org.apache.tamaya", "tamaya-api"),
-                mavenBundle("org.apache.tamaya", "tamaya-core"),
-                mavenBundle("org.apache.tamaya.ext", "tamaya-spisupport"),
-                mavenBundle("org.apache.tamaya.ext", "tamaya-functions"),
-                streamBundle(TinyBundles.bundle()
-                        .set( Constants.BUNDLE_VERSION, "0.4.0")
-                        .set( Constants.BUNDLE_NAME, "org.apache.tamaya.osgi" )
-                        .set( Constants.BUNDLE_SYMBOLICNAME, 
"org.apache.tamaya.osgi" )
-                        .set( Constants.EXPORT_PACKAGE, 
"org.apache.tamaya.osgi,org.apache.tamaya.osgi.commands" )
-                        .set( Constants.IMPORT_PACKAGE, 
"org.osgi.framework,org.osgi.service.cm,org.apache.tamaya," +
-                                
"org.apache.tamaya.spi,org.apache.tamaya.functions,org.apache.tamaya.spisupport"
 )
-                        .set( Constants.BUNDLE_ACTIVATOR, 
Activator.class.getName() )
-                        .set( Constants.BUNDLE_MANIFESTVERSION, "2")
-                        .set("Export-Service", 
"org.apache.tamaya.osgi.TamayaConfigPlugin")
-                        .add(Activator.class)
-                        .add(Backups.class)
-                        .add(ConfigChanger.class)
-                        .add(ConfigHistory.class)
-                        .add(OperationMode.class)
-                        .add(TamayaConfigPlugin.class)
-                        .add(BackupCommands.class)
-                        .add(ConfigCommands.class)
-                        .add(HistoryCommands.class)
-                        .add(StringUtil.class)
-                        .add("META-INF/javaconfiguration.properties", new 
FileInputStream("src/test/resources/META-INF/javaconfiguration.properties"))
-                        .add(OSGIBasicTests.class)
-                        .build()),
-        };
-    }
-
-    @Test
-    public void hello(){}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/8215ad66/osgi/common/src/test/java/org/apache/tamaya/osgi/OSGITest.java
----------------------------------------------------------------------
diff --git a/osgi/common/src/test/java/org/apache/tamaya/osgi/OSGITest.java 
b/osgi/common/src/test/java/org/apache/tamaya/osgi/OSGITest.java
deleted file mode 100644
index b214689..0000000
--- a/osgi/common/src/test/java/org/apache/tamaya/osgi/OSGITest.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * 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.tamaya.osgi;
-
-import org.apache.tamaya.spi.ConfigurationProviderSpi;
-import org.apache.tamaya.spi.ServiceContextManager;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.Configuration;
-import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.junit.PaxExam;
-import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
-import org.ops4j.pax.exam.spi.reactors.PerMethod;
-import org.osgi.framework.BundleContext;
-import org.osgi.service.cm.ConfigurationAdmin;
-
-import javax.inject.Inject;
-import java.io.IOException;
-import java.net.URL;
-import java.util.Arrays;
-import java.util.Enumeration;
-
-import static org.junit.Assert.*;
-import static org.ops4j.pax.exam.CoreOptions.*;
-
-@Ignore("TAMAYA-276: Does not work on Jenkins - 
org.apache.tamaya.osgi.Activator not found by 
PAXEXAM-PROBE-0d47b84d-95ee-4136-96af-3c82380444da")
-@RunWith(PaxExam.class)
-@ExamReactorStrategy(PerMethod.class)
-public class OSGITest {
- 
-    @Inject
-    private BundleContext bundleContext;
-
-    @Inject
-    private ConfigurationAdmin configAdmin;
-
-    private Activator activator = new Activator();
-
-    @Before
-    public void setup()throws Exception{
-        activator.start(bundleContext);
-    }
-
-    @After
-    public void tearDown()throws Exception{
-        activator.stop(bundleContext);
-    }
-
-    @Configuration
-    public Option[] config() {
-        return options(
-                cleanCaches(),
-                junitBundles(),
-                mavenBundle("org.apache.felix", 
"org.apache.felix.configadmin"),
-                mavenBundle("org.apache.geronimo.specs", 
"geronimo-annotation_1.2_spec", "1.0"),
-                mavenBundle("org.apache.tamaya", "tamaya-api"),
-                mavenBundle("org.apache.tamaya", "tamaya-core"),
-                mavenBundle("org.apache.tamaya.ext", "tamaya-spisupport"),
-                mavenBundle("org.apache.tamaya.ext", "tamaya-functions"),
-                bundle("reference:file:target/classes")
-        );
-    }
-
-
-    @Test
-    public void testConfiguration() throws Exception {
-        assertNotNull(configAdmin);
-        org.osgi.service.cm.Configuration config = 
configAdmin.getConfiguration("tamaya");
-        assertNotNull(config);
-        assertNotNull(config.getProperties());
-        assertFalse(config.getProperties().isEmpty());
-        assertEquals(config.getProperties().size(), 4);
-        assertEquals(config.getProperties().get("my.testProperty1"), 
"success1");
-        assertEquals(config.getProperties().get("my.testProperty2"), 
"success2");
-        assertEquals(config.getProperties().get("my.testProperty3"), 
"success3");
-        assertEquals(config.getProperties().get("my.testProperty4"), 
"success4");
-        StringBuilder b = new StringBuilder();
-        b.append("Print all configs....\n\n");
-        org.osgi.service.cm.Configuration[] configs = 
configAdmin.listConfigurations(null);
-        for (org.osgi.service.cm.Configuration cfg : configs) {
-            b.append("\nConfiguration found in OSGI Container: " + cfg);
-            b.append("\n-------------------------------------------------");
-        }
-        System.out.println(b.toString());
-    }
-
-    @Test
-    public void ensureEnvironmentIsWorkingAndTamayaIsActive()throws Exception {
-        assertNotNull(configAdmin);
-        assertEquals("Tamaya ConfigAdmin is not installed.",
-                "TamayaConfigAdminImpl", 
configAdmin.getClass().getSimpleName());
-        System.out.println("ConfigAdmin found in OSGI Container: " + 
configAdmin);
-    }
-
-    @Test
-    public void testResourceIsVisible(){
-        assertNotNull(ServiceContextManager.getServiceContext()
-        .getResource("META-INF/javaconfiguration.properties", null));
-    }
-
-    @Test
-    public void testResourcesAreVisible() throws IOException {
-        Enumeration<URL> urls = ServiceContextManager.getServiceContext()
-                .getResources("META-INF/javaconfiguration.properties", null);
-        assertNotNull(urls);
-        assertTrue(urls.hasMoreElements());
-        URL url = urls.nextElement();
-        assertNotNull(url);
-    }
-
-    @Test
-    public void testServices() {
-        assertNotNull("ConfigurationProviderSpi service missing.", 
bundleContext.getService(bundleContext.getServiceReference(ConfigurationProviderSpi.class)));
-        assertNotNull("ConfigurationAdmin service missing.", 
bundleContext.getService(bundleContext.getServiceReference(ConfigurationAdmin.class)));
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/8215ad66/osgi/common/src/test/java/org/apache/tamaya/osgi/TamayaConfigPluginTest.java
----------------------------------------------------------------------
diff --git 
a/osgi/common/src/test/java/org/apache/tamaya/osgi/TamayaConfigPluginTest.java 
b/osgi/common/src/test/java/org/apache/tamaya/osgi/TamayaConfigPluginTest.java
index 712ed3b..9758c08 100644
--- 
a/osgi/common/src/test/java/org/apache/tamaya/osgi/TamayaConfigPluginTest.java
+++ 
b/osgi/common/src/test/java/org/apache/tamaya/osgi/TamayaConfigPluginTest.java
@@ -40,10 +40,10 @@ public class TamayaConfigPluginTest extends  
AbstractOSGITest{
 
     @Test
     public void testOperationMode() throws Exception {
-        OperationMode om = tamayaConfigPlugin.getDefaultOperationMode();
-        tamayaConfigPlugin.setDefaultOperationMode(OperationMode.EXTEND);
-        assertEquals(OperationMode.EXTEND, 
tamayaConfigPlugin.getDefaultOperationMode());
-        tamayaConfigPlugin.setDefaultOperationMode(OperationMode.OVERRIDE);
+        Policy om = tamayaConfigPlugin.getDefaultOperationMode();
+        tamayaConfigPlugin.setDefaultOperationMode(Policy.EXTEND);
+        assertEquals(Policy.EXTEND, 
tamayaConfigPlugin.getDefaultOperationMode());
+        tamayaConfigPlugin.setDefaultOperationMode(Policy.OVERRIDE);
     }
 
     @Test
@@ -103,7 +103,7 @@ public class TamayaConfigPluginTest extends  
AbstractOSGITest{
 
     @Test
     public void getUpdateConfig_Explicit_DryRun() throws Exception {
-        Dictionary<String, Object> config = 
tamayaConfigPlugin.updateConfig(TamayaConfigPlugin.COMPONENTID, 
OperationMode.EXTEND, true, true);
+        Dictionary<String, Object> config = 
tamayaConfigPlugin.updateConfig(TamayaConfigPlugin.COMPONENTID, Policy.EXTEND, 
true, true);
         assertNotNull(config);
         assertEquals(config.get("java.home"), System.getProperty("java.home"));
     }
@@ -117,19 +117,174 @@ public class TamayaConfigPluginTest extends  
AbstractOSGITest{
 
     @Test
     public void getDefaultOperationMode() throws Exception {
-        OperationMode om = tamayaConfigPlugin.getDefaultOperationMode();
+        Policy om = tamayaConfigPlugin.getDefaultOperationMode();
         assertNotNull(om);
         Dictionary<String,Object> pluginConfig = 
super.getProperties(TamayaConfigPlugin.COMPONENTID);
-        pluginConfig.put(OperationMode.class.getSimpleName(), 
OperationMode.UPDATE_ONLY.toString());
+        pluginConfig.put(Policy.class.getSimpleName(), 
Policy.UPDATE_ONLY.toString());
         TamayaConfigPlugin plugin = new TamayaConfigPlugin(bundleContext);
         om = plugin.getDefaultOperationMode();
         assertNotNull(om);
-        assertEquals(om, OperationMode.UPDATE_ONLY);
-        pluginConfig.put(OperationMode.class.getSimpleName(), 
OperationMode.OVERRIDE.toString());
+        assertEquals(om, Policy.UPDATE_ONLY);
+        pluginConfig.put(Policy.class.getSimpleName(), 
Policy.OVERRIDE.toString());
         plugin = new TamayaConfigPlugin(bundleContext);
         om = plugin.getDefaultOperationMode();
         assertNotNull(om);
-        assertEquals(om, OperationMode.OVERRIDE);
+        assertEquals(om, Policy.OVERRIDE);
+    }
+
+    @Test
+    public void testConfiguration_Override() throws Exception {
+        assertNotNull(cm);
+        tamayaConfigPlugin.updateConfig("tamaya", Policy.OVERRIDE, true, 
false);
+        org.osgi.service.cm.Configuration config = 
cm.getConfiguration("tamaya");
+        assertNotNull(config);
+        assertNotNull(config.getProperties());
+        assertFalse(config.getProperties().isEmpty());
+        assertTrue(config.getProperties().size() > 4);
+        // Override should add additional values
+        assertEquals(config.getProperties().get("my.testProperty1"), 
"success1");
+        assertEquals(config.getProperties().get("my.testProperty2"), 
"success2");
+        assertEquals(config.getProperties().get("my.testProperty3"), 
"success3");
+        assertEquals(config.getProperties().get("my.testProperty4"), 
"success4");
+        // Extend should also update any existing values...
+        assertEquals(config.getProperties().get("java.version"), "Java2000");
+        tamayaConfigPlugin.restoreBackup("tamaya");
+    }
+
+    @Test
+    public void testConfiguration_Override_ImplicitlyConfigured() throws 
Exception {
+        assertNotNull(cm);
+        org.osgi.service.cm.Configuration config = 
cm.getConfiguration("tamaya");
+        Dictionary<String,Object> props = config.getProperties();
+        props.put(TamayaConfigPlugin.TAMAYA_POLICY_PROP, "OVERRIDE");
+        config.update(props);
+        tamayaConfigPlugin.updateConfig("tamaya", Policy.UPDATE_ONLY, false, 
false);
+        config = cm.getConfiguration("tamaya");
+        assertNotNull(config);
+        assertNotNull(config.getProperties());
+        assertFalse(config.getProperties().isEmpty());
+        assertTrue(config.getProperties().size() > 4);
+        // Override should add additional values
+        assertEquals(config.getProperties().get("my.testProperty1"), 
"success1");
+        assertEquals(config.getProperties().get("my.testProperty2"), 
"success2");
+        assertEquals(config.getProperties().get("my.testProperty3"), 
"success3");
+        assertEquals(config.getProperties().get("my.testProperty4"), 
"success4");
+        // Extend should also update any existing values...
+        assertEquals(config.getProperties().get("java.version"), "Java2000");
+        tamayaConfigPlugin.restoreBackup("tamaya");
+    }
+
+    @Test
+    public void testConfiguration_Extend() throws Exception {
+        assertNotNull(cm);
+        tamayaConfigPlugin.updateConfig("tamaya", Policy.EXTEND, true, false);
+        org.osgi.service.cm.Configuration config = 
cm.getConfiguration("tamaya");
+        assertNotNull(config);
+        assertNotNull(config.getProperties());
+        assertFalse(config.getProperties().isEmpty());
+        assertTrue(config.getProperties().size() > 4);
+        assertEquals(config.getProperties().get("my.testProperty1"), 
"success1");
+        assertEquals(config.getProperties().get("my.testProperty2"), 
"success2");
+        assertEquals(config.getProperties().get("my.testProperty3"), 
"success3");
+        assertEquals(config.getProperties().get("my.testProperty4"), 
"success4");
+        // Extend should not update any existing values...
+        assertEquals(config.getProperties().get("java.version"), 
System.getProperty("java.version"));
+        tamayaConfigPlugin.restoreBackup("tamaya");
+    }
+
+    @Test
+    public void testConfiguration_Update_Only() throws Exception {
+        assertNotNull(cm);
+        tamayaConfigPlugin.updateConfig("tamaya", Policy.UPDATE_ONLY, true, 
false);
+        org.osgi.service.cm.Configuration config = 
cm.getConfiguration("tamaya");
+        assertNotNull(config);
+        assertNotNull(config.getProperties());
+        assertFalse(config.getProperties().isEmpty());
+        assertTrue(config.getProperties().size() > 4);
+        assertEquals(config.getProperties().get("my.testProperty1"), null);
+        assertEquals(config.getProperties().get("my.testProperty2"), null);
+        assertEquals(config.getProperties().get("my.testProperty3"), null);
+        assertEquals(config.getProperties().get("my.testProperty4"), null);
+        // Update only should update any existing values...
+        assertEquals(config.getProperties().get("java.version"), "Java2000");
+        tamayaConfigPlugin.restoreBackup("tamaya");
+    }
+
+    @Test
+    public void testConfiguration_Override_Dryrun() throws Exception {
+        assertNotNull(cm);
+        Dictionary<String,Object> result = 
tamayaConfigPlugin.updateConfig("tamaya", Policy.OVERRIDE, true, true);
+        assertNotNull(result);
+        // Override should add additional values
+        assertEquals(result.get("my.testProperty1"), "success1");
+        assertEquals(result.get("my.testProperty2"), "success2");
+        assertEquals(result.get("my.testProperty3"), "success3");
+        assertEquals(result.get("my.testProperty4"), "success4");
+        // Extend should also update any existing values...
+        assertEquals(result.get("java.version"), "Java2000");
+
+        // DryRun: should not have been changged anything on OSGI level...
+        org.osgi.service.cm.Configuration config = 
cm.getConfiguration("tamaya");
+        assertNotNull(config);
+        assertNotNull(config.getProperties());
+        assertFalse(config.getProperties().isEmpty());
+        assertTrue(config.getProperties().size() > 4);
+        assertEquals(config.getProperties().get("my.testProperty1"), null);
+        assertEquals(config.getProperties().get("my.testProperty2"), null);
+        assertEquals(config.getProperties().get("my.testProperty3"), null);
+        assertEquals(config.getProperties().get("my.testProperty4"), null);
+        assertEquals(config.getProperties().get("java.version"), 
System.getProperty("java.version"));
+    }
+
+    @Test
+    public void testConfiguration_Extend_Dryrun() throws Exception {
+        assertNotNull(cm);
+        Dictionary<String,Object> result = 
tamayaConfigPlugin.updateConfig("tamaya", Policy.EXTEND, true, true);
+        assertNotNull(result);
+        assertEquals(result.get("my.testProperty1"), "success1");
+        assertEquals(result.get("my.testProperty2"), "success2");
+        assertEquals(result.get("my.testProperty3"), "success3");
+        assertEquals(result.get("my.testProperty4"), "success4");
+        // Extend should not update any existing values...
+        assertEquals(result.get("java.version"), 
System.getProperty("java.version"));
+
+        // DryRun: should not have been changged anything on OSGI level...
+        org.osgi.service.cm.Configuration config = 
cm.getConfiguration("tamaya");
+        assertNotNull(config);
+        assertNotNull(config.getProperties());
+        assertFalse(config.getProperties().isEmpty());
+        assertTrue(config.getProperties().size() > 4);
+        assertEquals(config.getProperties().get("my.testProperty1"), null);
+        assertEquals(config.getProperties().get("my.testProperty2"), null);
+        assertEquals(config.getProperties().get("my.testProperty3"), null);
+        assertEquals(config.getProperties().get("my.testProperty4"), null);
+        assertEquals(config.getProperties().get("java.version"), 
System.getProperty("java.version"));
+    }
+
+    @Test
+    public void testConfiguration_Update_Only_Dryrun() throws Exception {
+        assertNotNull(cm);
+        Dictionary<String,Object> result = 
tamayaConfigPlugin.updateConfig("tamaya", Policy.UPDATE_ONLY, true, true);
+        assertNotNull(result);
+        assertTrue(result.size() > 4);
+        assertEquals(result.get("my.testProperty1"), null);
+        assertEquals(result.get("my.testProperty2"), null);
+        assertEquals(result.get("my.testProperty3"), null);
+        assertEquals(result.get("my.testProperty4"), null);
+        // Update only should update any existing values...
+        assertEquals(result.get("java.version"), "Java2000");
+
+        // DryRun: should not have been changged anything on OSGI level...
+        org.osgi.service.cm.Configuration config = 
cm.getConfiguration("tamaya");
+        assertNotNull(config);
+        assertNotNull(config.getProperties());
+        assertFalse(config.getProperties().isEmpty());
+        assertTrue(config.getProperties().size() > 4);
+        assertEquals(config.getProperties().get("my.testProperty1"), null);
+        assertEquals(config.getProperties().get("my.testProperty2"), null);
+        assertEquals(config.getProperties().get("my.testProperty3"), null);
+        assertEquals(config.getProperties().get("my.testProperty4"), null);
+        assertEquals(config.getProperties().get("java.version"), 
System.getProperty("java.version"));
     }
 
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/8215ad66/osgi/common/src/test/java/org/apache/tamaya/osgi/commands/ConfigCommandsTest.java
----------------------------------------------------------------------
diff --git 
a/osgi/common/src/test/java/org/apache/tamaya/osgi/commands/ConfigCommandsTest.java
 
b/osgi/common/src/test/java/org/apache/tamaya/osgi/commands/ConfigCommandsTest.java
index 3d180e7..a3020d7 100644
--- 
a/osgi/common/src/test/java/org/apache/tamaya/osgi/commands/ConfigCommandsTest.java
+++ 
b/osgi/common/src/test/java/org/apache/tamaya/osgi/commands/ConfigCommandsTest.java
@@ -18,10 +18,8 @@
  */
 package org.apache.tamaya.osgi.commands;
 
-import org.apache.tamaya.ConfigurationProvider;
 import org.apache.tamaya.osgi.AbstractOSGITest;
-import org.apache.tamaya.osgi.OperationMode;
-import org.apache.tamaya.osgi.TamayaConfigPlugin;
+import org.apache.tamaya.osgi.Policy;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.runners.MockitoJUnitRunner;
@@ -75,7 +73,7 @@ public class ConfigCommandsTest extends AbstractOSGITest{
 
     @Test
     public void applyTamayaConfiguration() throws Exception {
-        String result = 
ConfigCommands.applyTamayaConfiguration(tamayaConfigPlugin, 
"applyTamayaConfiguration", OperationMode.OVERRIDE.toString(), true);
+        String result = 
ConfigCommands.applyTamayaConfiguration(tamayaConfigPlugin, 
"applyTamayaConfiguration", Policy.OVERRIDE.toString(), true);
         assertNotNull(result);
         System.out.println(result);
         assertTrue(result.contains("OSGI Configuration for PID"));
@@ -97,7 +95,7 @@ public class ConfigCommandsTest extends AbstractOSGITest{
 
     @Test
     public void getDefaultOpPolicy() throws Exception {
-        OperationMode mode = tamayaConfigPlugin.getDefaultOperationMode();
+        Policy mode = tamayaConfigPlugin.getDefaultOperationMode();
         String result = ConfigCommands.getDefaultOpPolicy(tamayaConfigPlugin);
         assertNotNull(result);
         assertTrue(result.contains(mode.toString()));
@@ -105,14 +103,14 @@ public class ConfigCommandsTest extends AbstractOSGITest{
 
     @Test
     public void setDefaultOpPolicy() throws Exception {
-        String result = ConfigCommands.setDefaultOpPolicy(tamayaConfigPlugin, 
OperationMode.EXTEND.toString());
+        String result = ConfigCommands.setDefaultOpPolicy(tamayaConfigPlugin, 
Policy.EXTEND.toString());
         assertNotNull(result);
         assertTrue(result.contains("EXTEND"));
-        assertEquals(tamayaConfigPlugin.getDefaultOperationMode(), 
OperationMode.EXTEND);
-        result = ConfigCommands.setDefaultOpPolicy(tamayaConfigPlugin, 
OperationMode.UPDATE_ONLY.toString());
+        assertEquals(tamayaConfigPlugin.getDefaultOperationMode(), 
Policy.EXTEND);
+        result = ConfigCommands.setDefaultOpPolicy(tamayaConfigPlugin, 
Policy.UPDATE_ONLY.toString());
         assertNotNull(result);
         assertTrue(result.contains("UPDATE_ONLY"));
-        assertEquals(tamayaConfigPlugin.getDefaultOperationMode(), 
OperationMode.UPDATE_ONLY);
+        assertEquals(tamayaConfigPlugin.getDefaultOperationMode(), 
Policy.UPDATE_ONLY);
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/8215ad66/osgi/common/src/test/resources/META-INF/javaconfiguration.properties
----------------------------------------------------------------------
diff --git 
a/osgi/common/src/test/resources/META-INF/javaconfiguration.properties 
b/osgi/common/src/test/resources/META-INF/javaconfiguration.properties
index f2879a0..d0b0cb8 100644
--- a/osgi/common/src/test/resources/META-INF/javaconfiguration.properties
+++ b/osgi/common/src/test/resources/META-INF/javaconfiguration.properties
@@ -18,4 +18,5 @@
 [tamaya]my.testProperty1=success1
 [tamaya]my.testProperty2=success2
 [tamaya]my.testProperty3=success3
-[tamaya]my.testProperty4=success4
\ No newline at end of file
+[tamaya]my.testProperty4=success4
+[tamaya]java.version=Java2000
\ No newline at end of file

Reply via email to