tamaya-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anat...@apache.org
Subject [4/7] incubator-tamaya-extensions git commit: TAMAYA-300 Added tests to improve mutation coverage. Movewd OSGI and MP to extensions.
Date Mon, 16 Oct 2017 23:03:20 GMT
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/a1cd433a/modules/osgi/common/src/test/java/org/apache/tamaya/osgi/commands/ConfigCommandsTest.java
----------------------------------------------------------------------
diff --git a/modules/osgi/common/src/test/java/org/apache/tamaya/osgi/commands/ConfigCommandsTest.java b/modules/osgi/common/src/test/java/org/apache/tamaya/osgi/commands/ConfigCommandsTest.java
new file mode 100644
index 0000000..a2c273b
--- /dev/null
+++ b/modules/osgi/common/src/test/java/org/apache/tamaya/osgi/commands/ConfigCommandsTest.java
@@ -0,0 +1,204 @@
+/*
+ * 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.commands;
+
+import org.apache.tamaya.osgi.AbstractOSGITest;
+import org.apache.tamaya.osgi.Policy;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.runners.MockitoJUnitRunner;
+
+import static org.junit.Assert.*;
+
+/**
+ * Created by atsti on 30.09.2017.
+ */
+@RunWith(MockitoJUnitRunner.class)
+public class ConfigCommandsTest extends AbstractOSGITest{
+    @Test
+    public void getInfo() throws Exception {
+        String result = ConfigCommands.getInfo(tamayaConfigPlugin);
+        assertNotNull(result);
+        System.out.println(result);
+        assertTrue(result.contains("Property Sources"));
+        assertTrue(result.contains("Property Converter"));
+        assertTrue(result.contains("Property Filter"));
+        assertTrue(result.contains("ConfigurationContext"));
+        assertTrue(result.contains("Configuration"));
+    }
+
+    @Test
+    public void readTamayaConfig() throws Exception {
+        String result = ConfigCommands.readTamayaConfig("java", null);
+        assertNotNull(result);
+        System.out.println(result);
+        assertTrue(result.contains(".version"));
+        assertTrue(result.contains("Section"));
+        assertTrue(result.contains("java"));
+        result = ConfigCommands.readTamayaConfig("java", "version");
+        assertNotNull(result);
+        assertFalse(result.contains(".version"));
+        assertTrue(result.contains("Section"));
+        assertTrue(result.contains("java"));
+        assertTrue(result.contains("Filter"));
+        assertTrue(result.contains("version"));
+        assertFalse(result.contains("java.vendor"));
+        System.out.println("readTamayaConfig: " + result);
+    }
+
+    @Test
+    public void readTamayaConfig4PID() throws Exception {
+        String result = ConfigCommands.readTamayaConfig4PID("test", null);
+        assertNotNull(result);
+        System.out.println(result);
+        assertTrue(result.contains("Configuration"));
+        assertTrue(result.contains("test"));
+    }
+
+    @Test
+    public void applyTamayaConfiguration() throws Exception {
+        String result = ConfigCommands.applyTamayaConfiguration(tamayaConfigPlugin, "applyTamayaConfiguration", Policy.OVERRIDE.toString(), true);
+        assertNotNull(result);
+        System.out.println(result);
+        assertTrue(result.contains("OSGI Configuration for PID"));
+        assertTrue(result.contains("applyTamayaConfiguration"));
+        assertTrue(result.contains("OVERRIDE"));
+        assertTrue(result.contains("Applied"));
+        assertTrue(result.contains("false"));
+    }
+
+    @Test
+    public void readOSGIConfiguration() throws Exception {
+        String result = ConfigCommands.readOSGIConfiguration(tamayaConfigPlugin, "readOSGIConfiguration", "java");
+        assertNotNull(result);
+        System.out.println(result);
+        assertTrue(result.contains("OSGI Configuration for PID"));
+        assertTrue(result.contains("readOSGIConfiguration"));
+        assertTrue(result.contains("java.home"));
+    }
+
+    @Test
+    public void getDefaultOpPolicy() throws Exception {
+        Policy mode = tamayaConfigPlugin.getDefaultPolicy();
+        String result = ConfigCommands.getDefaultOpPolicy(tamayaConfigPlugin);
+        assertNotNull(result);
+        assertTrue(result.contains(mode.toString()));
+    }
+
+    @Test
+    public void setDefaultOpPolicy() throws Exception {
+        String result = ConfigCommands.setDefaultOpPolicy(tamayaConfigPlugin, Policy.EXTEND.toString());
+        assertNotNull(result);
+        assertTrue(result.contains("EXTEND"));
+        assertEquals(tamayaConfigPlugin.getDefaultPolicy(), Policy.EXTEND);
+        result = ConfigCommands.setDefaultOpPolicy(tamayaConfigPlugin, Policy.UPDATE_ONLY.toString());
+        assertNotNull(result);
+        assertTrue(result.contains("UPDATE_ONLY"));
+        assertEquals(tamayaConfigPlugin.getDefaultPolicy(), Policy.UPDATE_ONLY);
+    }
+
+    @Test
+    public void getProperty() throws Exception {
+        String result = ConfigCommands.getProperty("system-properties", "java.version", false);
+        assertNotNull(result);
+        System.out.println(result);
+        assertEquals(result, System.getProperty("java.version"));
+        result = ConfigCommands.getProperty("system-properties", "java.version", true);
+        assertNotNull(result);
+    }
+
+    @Test
+    public void getPropertySource() throws Exception {
+        String result = ConfigCommands.getPropertySource("system-properties");
+        assertNotNull(result);
+        System.out.println(result);
+        assertTrue(result.contains("Property Source"));
+        assertTrue(result.contains("ID"));
+        assertTrue(result.contains("system-properties"));
+        assertTrue(result.contains("Ordinal"));
+        assertTrue(result.contains("java.version"));
+    }
+
+    @Test
+    public void getPropertySourceOverview() throws Exception {
+        String result = ConfigCommands.getPropertySourceOverview();
+        assertNotNull(result);
+        System.out.println(result);
+        assertTrue(result.contains("Ordinal"));
+        assertTrue(result.contains("Class"));
+        assertTrue(result.contains("Ordinal"));
+        assertTrue(result.contains("ID"));
+        assertTrue(result.contains("Ordinal"));
+        assertTrue(result.contains("system-properties"));
+        assertTrue(result.contains("environment-properties"));
+        assertTrue(result.contains("CLI"));
+    }
+
+    @Test
+    public void setDefaultEnabled() throws Exception {
+        String result = ConfigCommands.setDefaultEnabled(tamayaConfigPlugin, true);
+        assertNotNull(result);
+        System.out.println(result);
+        assertTrue(result.contains(TamayaConfigService.TAMAYA_ENABLED_PROP+"=true"));
+        assertTrue(tamayaConfigPlugin.isTamayaEnabledByDefault());
+        result = ConfigCommands.setDefaultEnabled(tamayaConfigPlugin, false);
+        assertNotNull(result);
+        assertTrue(result.contains(TamayaConfigService.TAMAYA_ENABLED_PROP+"=false"));
+        assertFalse(tamayaConfigPlugin.isTamayaEnabledByDefault());
+    }
+
+    @Test
+    public void getDefaultEnabled() throws Exception {
+        tamayaConfigPlugin.setTamayaEnabledByDefault(true);
+        String result = ConfigCommands.getDefaultEnabled(tamayaConfigPlugin);
+        System.out.println(result);
+        tamayaConfigPlugin.setTamayaEnabledByDefault(false);
+        result = ConfigCommands.getDefaultEnabled(tamayaConfigPlugin);
+        assertNotNull(result);
+        assertTrue(result.equals("false"));
+    }
+
+    @Test
+    public void setAutoUpdateEnabled() throws Exception {
+        String result = ConfigCommands.setAutoUpdateEnabled(tamayaConfigPlugin, true);
+        assertNotNull(result);
+        System.out.println(result);
+        assertTrue(result.contains("true"));
+        assertTrue(result.contains(TamayaConfigService.TAMAYA_AUTO_UPDATE_ENABLED_PROP));
+        assertTrue(tamayaConfigPlugin.isAutoUpdateEnabled());
+        result = ConfigCommands.setAutoUpdateEnabled(tamayaConfigPlugin, false);
+        assertNotNull(result);
+        assertTrue(result.contains("false"));
+        assertTrue(result.contains(TamayaConfigService.TAMAYA_AUTO_UPDATE_ENABLED_PROP));
+        assertFalse(tamayaConfigPlugin.isAutoUpdateEnabled());
+    }
+
+    @Test
+    public void getAutoUpdateEnabled() throws Exception {
+        tamayaConfigPlugin.setAutoUpdateEnabled(true);
+        String result = ConfigCommands.getAutoUpdateEnabled(tamayaConfigPlugin);
+        System.out.println(result);
+        assertTrue(result.contains("true"));
+        tamayaConfigPlugin.setAutoUpdateEnabled(false);
+        result = ConfigCommands.getAutoUpdateEnabled(tamayaConfigPlugin);
+        assertNotNull(result);
+        assertTrue(result.contains("false"));
+    }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/a1cd433a/modules/osgi/common/src/test/java/org/apache/tamaya/osgi/commands/HistoryCommandsTest.java
----------------------------------------------------------------------
diff --git a/modules/osgi/common/src/test/java/org/apache/tamaya/osgi/commands/HistoryCommandsTest.java b/modules/osgi/common/src/test/java/org/apache/tamaya/osgi/commands/HistoryCommandsTest.java
new file mode 100644
index 0000000..ad32857
--- /dev/null
+++ b/modules/osgi/common/src/test/java/org/apache/tamaya/osgi/commands/HistoryCommandsTest.java
@@ -0,0 +1,87 @@
+/*
+ * 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.commands;
+
+import org.apache.tamaya.osgi.AbstractOSGITest;
+import org.apache.tamaya.osgi.ConfigHistory;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.runners.MockitoJUnitRunner;
+
+import static org.junit.Assert.*;
+
+/**
+ * Created by atsti on 30.09.2017.
+ */
+@RunWith(MockitoJUnitRunner.class)
+public class HistoryCommandsTest extends AbstractOSGITest {
+
+    @Test
+    public void clearHistory() throws Exception {
+        ConfigHistory.configured("clearHistory1", "test");
+        ConfigHistory.configured("clearHistory2", "test");
+        assertTrue(ConfigHistory.getHistory("clearHistory1").size()==1);
+        assertTrue(ConfigHistory.getHistory("clearHistory2").size()==1);
+        assertTrue(ConfigHistory.getHistory("clearHistory3").size()==0);
+        String result = HistoryCommands.clearHistory(tamayaConfigPlugin, "clearHistory1");
+        assertTrue(result.contains("PID"));
+        assertTrue(result.contains("clearHistory1"));
+        assertTrue(ConfigHistory.getHistory("clearHistory1").size()==0);
+        assertTrue(ConfigHistory.getHistory("clearHistory2").size()==1);
+        assertTrue(ConfigHistory.getHistory("clearHistory3").size()==0);
+        ConfigHistory.configured("clearHistory1", "test");
+        result = HistoryCommands.clearHistory(tamayaConfigPlugin, "*");
+        assertTrue(result.contains("PID"));
+        assertTrue(result.contains("*"));
+        assertTrue(ConfigHistory.getHistory("clearHistory1").size()==0);
+        assertTrue(ConfigHistory.getHistory("clearHistory2").size()==0);
+        assertTrue(ConfigHistory.getHistory("clearHistory3").size()==0);
+
+    }
+
+    @Test
+    public void getHistory() throws Exception {
+        ConfigHistory.configured("getHistory", "test");
+        ConfigHistory.configuring("getHistory", "test");
+        ConfigHistory.propertySet("getHistory", "k1", "v1", null);
+        ConfigHistory.propertySet("getHistory", "k2", null, "v2");
+        String result = HistoryCommands.getHistory(tamayaConfigPlugin, "getHistory");
+        assertNotNull(result);
+        assertTrue(result.contains("k1"));
+        assertTrue(result.contains("v1"));
+        assertTrue(result.contains("test"));
+        result = HistoryCommands.getHistory(tamayaConfigPlugin, "getHistory", ConfigHistory.TaskType.BEGIN.toString());
+        assertNotNull(result);
+        assertTrue(result.contains("getHistory"));
+        assertTrue(result.contains("test"));
+        assertFalse(result.contains("k1"));
+        assertFalse(result.contains("v2"));
+    }
+
+    @Test
+    public void getSetMaxHistorySize() throws Exception {
+        String result = HistoryCommands.getMaxHistorySize(tamayaConfigPlugin);
+        assertEquals(result, String.valueOf(tamayaConfigPlugin.getMaxHistorySize()));
+        result = HistoryCommands.setMaxHistorySize(tamayaConfigPlugin, 111);
+        assertEquals(result, "tamaya-max-getHistory-size=111");
+        result = HistoryCommands.getMaxHistorySize(tamayaConfigPlugin);
+        assertEquals(result, "111");
+    }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/a1cd433a/modules/osgi/common/src/test/resources/META-INF/javaconfiguration.properties
----------------------------------------------------------------------
diff --git a/modules/osgi/common/src/test/resources/META-INF/javaconfiguration.properties b/modules/osgi/common/src/test/resources/META-INF/javaconfiguration.properties
new file mode 100644
index 0000000..d0b0cb8
--- /dev/null
+++ b/modules/osgi/common/src/test/resources/META-INF/javaconfiguration.properties
@@ -0,0 +1,22 @@
+# 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.
+#
+[tamaya]my.testProperty1=success1
+[tamaya]my.testProperty2=success2
+[tamaya]my.testProperty3=success3
+[tamaya]my.testProperty4=success4
+[tamaya]java.version=Java2000
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/a1cd433a/modules/osgi/common/src/test/resources/org.ops4j.pax.logging.cfg
----------------------------------------------------------------------
diff --git a/modules/osgi/common/src/test/resources/org.ops4j.pax.logging.cfg b/modules/osgi/common/src/test/resources/org.ops4j.pax.logging.cfg
new file mode 100644
index 0000000..6683438
--- /dev/null
+++ b/modules/osgi/common/src/test/resources/org.ops4j.pax.logging.cfg
@@ -0,0 +1,48 @@
+# 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.
+#
+#updated by pax-exam
+#Sun Nov 27 20:55:11 CET 2016
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.sift.appender.append=true
+log4j.appender.out.maxFileSize=1MB
+log4j.appender.audit.layout.ConversionPattern=%d{ISO8601} | %-5.5p | %-16.16t | %-32.32c{1} | %X{bundle.id} - %X{bundle.name} - %X{bundle.version} | %m%n
+log4j.appender.sift.appender.file=${karaf.data}/log/$\\{bundle.name\\}.log
+log4j.appender.sift.appender.layout=org.apache.log4j.PatternLayout
+log4j.appender.out.append=true
+log4j.appender.sift.appender=org.apache.log4j.FileAppender
+log4j.appender.out.layout=org.apache.log4j.PatternLayout
+log4j.appender.out=org.apache.log4j.RollingFileAppender
+log4j.appender.stdout.layout.ConversionPattern=%d{ISO8601} | %-5.5p | %-16.16t | %-32.32c{1} | %X{bundle.id} - %X{bundle.name} - %X{bundle.version} | %m%n
+log4j.throwableRenderer=org.apache.log4j.OsgiThrowableRenderer
+log4j.appender.out.file=${karaf.data}/log/karaf.log
+log4j.appender.sift=org.apache.log4j.sift.MDCSiftingAppender
+log4j.appender.audit.append=true
+log4j.appender.audit.maxBackupIndex=10
+log4j.appender.audit.layout=org.apache.log4j.PatternLayout
+log4j.appender.sift.key=bundle.name
+log4j.appender.audit.maxFileSize=1MB
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.additivity.org.apache.karaf.jaas.modules.audit=false
+log4j.logger.org.apache.karaf.jaas.modules.audit=INFO, audit
+log4j.appender.audit.file=${karaf.data}/security/audit.log
+log4j.appender.sift.default=karaf
+log4j.appender.sift.appender.layout.ConversionPattern=%d{ISO8601} | %-5.5p | %-16.16t | %-32.32c{1} | %m%n
+log4j.appender.out.maxBackupIndex=10
+log4j.appender.audit=org.apache.log4j.RollingFileAppender
+log4j.rootLogger=WARN, out, stdout, osgi\:*
+log4j.appender.out.layout.ConversionPattern=%d{ISO8601} | %-5.5p | %-16.16t | %-32.32c{1} | %X{bundle.id} - %X{bundle.name} - %X{bundle.version} | %m%n

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/a1cd433a/modules/osgi/gogo-shell/src/test/java/org/apache/tamaya/gogo/shell/AbstractOSGITest.java
----------------------------------------------------------------------
diff --git a/modules/osgi/gogo-shell/src/test/java/org/apache/tamaya/gogo/shell/AbstractOSGITest.java b/modules/osgi/gogo-shell/src/test/java/org/apache/tamaya/gogo/shell/AbstractOSGITest.java
index d33e7e0..a4bab0f 100644
--- a/modules/osgi/gogo-shell/src/test/java/org/apache/tamaya/gogo/shell/AbstractOSGITest.java
+++ b/modules/osgi/gogo-shell/src/test/java/org/apache/tamaya/gogo/shell/AbstractOSGITest.java
@@ -28,9 +28,14 @@ import org.osgi.framework.ServiceReference;
 import org.osgi.service.cm.Configuration;
 import org.osgi.service.cm.ConfigurationAdmin;
 
+import java.io.ByteArrayOutputStream;
+import java.io.PrintStream;
+import java.io.PrintWriter;
+import java.io.StringWriter;
 import java.util.Dictionary;
 import java.util.Hashtable;
 import java.util.Map;
+import java.util.concurrent.Callable;
 import java.util.concurrent.ConcurrentHashMap;
 
 import static org.mockito.Matchers.any;
@@ -61,6 +66,20 @@ public abstract class AbstractOSGITest {
         return this.properties.get(pid);
     }
 
+    String runTest(Callable<?> r) throws Exception {
+        PrintStream backup = System.out;
+        ByteArrayOutputStream bos = new ByteArrayOutputStream();
+        PrintStream pw = new PrintStream(bos);
+        System.setOut(pw);
+        try{
+            r.call();
+            return new String(bos.toByteArray());
+        }finally{
+            System.setOut(backup);
+            pw.flush();
+        }
+    }
+
     @Before
     public void setup()throws Exception{
         doAnswer(invocation -> {

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/a1cd433a/modules/osgi/gogo-shell/src/test/java/org/apache/tamaya/gogo/shell/BackupCommandsTest.java
----------------------------------------------------------------------
diff --git a/modules/osgi/gogo-shell/src/test/java/org/apache/tamaya/gogo/shell/BackupCommandsTest.java b/modules/osgi/gogo-shell/src/test/java/org/apache/tamaya/gogo/shell/BackupCommandsTest.java
index 8478cb1..0d5afd9 100644
--- a/modules/osgi/gogo-shell/src/test/java/org/apache/tamaya/gogo/shell/BackupCommandsTest.java
+++ b/modules/osgi/gogo-shell/src/test/java/org/apache/tamaya/gogo/shell/BackupCommandsTest.java
@@ -24,8 +24,15 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.runners.MockitoJUnitRunner;
 
+import java.util.Hashtable;
+import java.util.UUID;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
 import static org.mockito.Matchers.anyObject;
 import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.reset;
 import static org.mockito.Mockito.verify;
 
 /**
@@ -44,21 +51,57 @@ public class BackupCommandsTest extends AbstractOSGITest{
 
     @Test
     public void testBackup_Create() throws Exception {
-        commands.tm_backup_create("testBackup_Create1",false);
-        verify(tamayaConfigPlugin).createBackup("testBackup_Create1");
-        commands.tm_backup_create("testBackup_Create2",true);
-        verify(tamayaConfigPlugin).createBackup("testBackup_Create2");
+        String pid = UUID.randomUUID().toString();
+        doReturn(true).when(tamayaConfigPlugin).createBackup(pid);
+        String out = runTest(()-> {
+            commands.tm_backup_create(pid,false);
+            return null;
+        });
+        assertTrue(out.startsWith("Backup created, PID = " + pid));
+        assertTrue(out.contains("Key"));
+        assertTrue(out.contains("Value"));
+        assertTrue(out.contains("-------------------------------------------------------------"));
+        assertTrue(out.contains("java.home"));
+        assertTrue(out.contains(System.getProperty("java.home")));
+        verify(tamayaConfigPlugin).createBackup(pid);
+        String pid2 = UUID.randomUUID().toString();
+        doReturn(true).when(tamayaConfigPlugin).createBackup(pid2);
+        doReturn(true).when(tamayaConfigPlugin).containsBackup(pid2);
+        out = runTest(()-> {
+            commands.tm_backup_create(pid2,true);
+            return null;
+        });
+        assertTrue(out.startsWith("Backup created, PID = " + pid2));
+        assertTrue(out.contains("java.home"));
+        assertTrue(out.contains(System.getProperty("java.home")));
+        verify(tamayaConfigPlugin).createBackup(pid2);
     }
 
     @Test
     public void testBackup_Delete() throws Exception {
-        commands.tm_backup_delete("testBackup_Delete");
+        String out = runTest(()-> {
+            commands.tm_backup_delete("testBackup_Delete");
+            return null;
+        });
+        assertEquals("Backup deleted: testBackup_Delete".trim(), out.trim());
         verify(tamayaConfigPlugin).deleteBackup("testBackup_Delete");
     }
 
     @Test
     public void testBackup_Get() throws Exception {
-        commands.tm_backup_get("testBackup_Get");
+        String out = runTest(()-> {
+            commands.tm_backup_get("testBackup_Get");
+            return null;
+        });
+        assertEquals("No backup found: testBackup_Get".trim(), out.trim());
+        verify(tamayaConfigPlugin).getBackup("testBackup_Get");
+        reset(tamayaConfigPlugin);
+        doReturn(new Hashtable<>()).when(tamayaConfigPlugin).getBackup("testBackup_Get");
+        out = runTest(()-> {
+            commands.tm_backup_get("testBackup_Get");
+            return null;
+        });
+        assertTrue(out.startsWith("PID: testBackup_Get\n"));
         verify(tamayaConfigPlugin).getBackup("testBackup_Get");
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/a1cd433a/modules/osgi/gogo-shell/src/test/java/org/apache/tamaya/gogo/shell/ConfigCommandsTest.java
----------------------------------------------------------------------
diff --git a/modules/osgi/gogo-shell/src/test/java/org/apache/tamaya/gogo/shell/ConfigCommandsTest.java b/modules/osgi/gogo-shell/src/test/java/org/apache/tamaya/gogo/shell/ConfigCommandsTest.java
index 5926029..dde7b42 100644
--- a/modules/osgi/gogo-shell/src/test/java/org/apache/tamaya/gogo/shell/ConfigCommandsTest.java
+++ b/modules/osgi/gogo-shell/src/test/java/org/apache/tamaya/gogo/shell/ConfigCommandsTest.java
@@ -28,9 +28,12 @@ import org.mockito.runners.MockitoJUnitRunner;
 import java.util.Dictionary;
 import java.util.Hashtable;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
 import static org.mockito.Matchers.any;
 import static org.mockito.Matchers.anyBoolean;
 import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.reset;
 import static org.mockito.Mockito.verify;
 
 /**
@@ -49,22 +52,62 @@ public class ConfigCommandsTest extends AbstractOSGITest{
 
     @Test
     public void testPropertySources() throws Exception {
-        commands.tm_propertysources();
+        String out = runTest(() -> {
+            commands.tm_propertysources();
+            return null;
+        });
+        assertTrue(out.startsWith("Property Sources"));
+        assertTrue(out.contains(  "----------------"));
+        assertTrue(out.contains("ID"));
+        assertTrue(out.contains("Ordinal"));
+        assertTrue(out.contains("Class"));
+        assertTrue(out.contains("Size"));
+        assertTrue(out.contains("environment-properties"));
+        assertTrue(out.contains("system-properties"));
+
     }
 
     @Test
     public void testProperty_Default() throws Exception {
-        commands.tm_property("system-properties", "java.version", false);
+        String out = runTest(() -> {
+            commands.tm_property("system-properties", "java.version", false);
+            return null;
+        });
+        assertEquals(System.getProperty("java.version").trim(), out.trim());
     }
 
     @Test
     public void testProperty_Extended() throws Exception {
-        commands.tm_property("system-properties", "java.version", true);
+        String out = runTest(() -> {
+            commands.tm_property("system-properties", "java.version", true);
+            return null;
+        });
+        assertTrue(out.contains(System.getProperty("java.version")));
+        assertTrue(out.contains("Property Source"));
+        assertTrue(out.contains("Value"));
+        assertTrue(out.contains("system-properties"));
     }
 
     @Test
     public void testPropertsource() throws Exception {
-        commands.tm_propertysource("system-properties");
+        String out = runTest(() -> {
+            commands.tm_propertysource("system-properties");
+            return null;
+        });
+        assertTrue(out.startsWith("Property Source"));
+        assertTrue(out.contains("ID"));
+        assertTrue(out.contains("system-properties"));
+        assertTrue(out.contains("Ordinal"));
+        assertTrue(out.contains("1000"));
+        assertTrue(out.contains("Class"));
+        assertTrue(out.contains("SystemPropertySource"));
+        assertTrue(out.contains("Properties"));
+        assertTrue(out.contains("Key"));
+        assertTrue(out.contains("Value"));
+        assertTrue(out.contains("Source"));
+        assertTrue(out.contains("Meta"));
+        assertTrue(out.contains("java.version"));
+        assertTrue(out.contains(System.getProperty("java.version")));
     }
 
     @Test
@@ -72,8 +115,34 @@ public class ConfigCommandsTest extends AbstractOSGITest{
         Dictionary<String,Object> testConfig = new Hashtable<>();
         testConfig.put("test","testVal");
         doReturn(testConfig).when(tamayaConfigPlugin).getOSGIConfiguration(any(),any());
-        commands.tm_config(null,"testConfig");
-        commands.tm_config("java","testConfig");
+        String out = runTest(() -> {
+            commands.tm_config(null, "testConfig");
+            return null;
+        });
+        assertTrue(out.contains("Tamaya Configuration"));
+        assertTrue(out.contains("Section"));
+        assertTrue(out.contains("[testConfig]"));
+        assertTrue(out.contains("Configuration"));
+        out = runTest(() -> {
+            commands.tm_config("java", "testConfig");
+            return null;
+        });
+        assertTrue(out.contains("Tamaya Configuration"));
+        assertTrue(out.contains("Section"));
+        assertTrue(out.contains("[testConfig]"));
+        assertTrue(out.contains("Filter"));
+        assertTrue(out.contains("java"));
+        assertTrue(out.contains("Configuration"));
+        out = runTest(() -> {
+            commands.tm_config("java", "");
+            return null;
+        });
+        assertTrue(out.contains("Tamaya Configuration"));
+        assertTrue(out.contains("Section"));
+        assertTrue(out.contains("java"));
+        assertTrue(out.contains("Configuration"));
+        assertTrue(out.contains(".version"));
+        assertTrue(out.contains(System.getProperty("java.version")));
     }
 
     @Test
@@ -81,9 +150,35 @@ public class ConfigCommandsTest extends AbstractOSGITest{
         Dictionary<String,Object> testConfig = new Hashtable<>();
         testConfig.put("test","testVal");
         doReturn(testConfig).when(tamayaConfigPlugin).updateConfig(any(),any(), anyBoolean(), anyBoolean());
-        commands.tm_apply_config("testApplyConfig", Policy.EXTEND, true);
+        String out = runTest(() -> {
+            commands.tm_apply_config("testApplyConfig", Policy.EXTEND, true);
+            return null;
+        });
+        assertTrue(out.contains("Applied Configuration"));
+        assertTrue(out.contains("PID"));
+        assertTrue(out.contains("testApplyConfig"));
+        assertTrue(out.contains("Policy"));
+        assertTrue(out.contains("EXTEND"));
+        assertTrue(out.contains("Dryrun"));
+        assertTrue(out.contains("true"));
+        assertTrue(out.contains("OSGI Configuration for PID"));
+        assertTrue(out.contains("test"));
+        assertTrue(out.contains("testVal"));
         verify(tamayaConfigPlugin).updateConfig("testApplyConfig", Policy.EXTEND, true, true);
-        commands.tm_apply_config("testApplyConfig", Policy.OVERRIDE, false);
+        out = runTest(() -> {
+            commands.tm_apply_config("testApplyConfig", Policy.OVERRIDE, false);
+            return null;
+        });
+        assertTrue(out.contains("Applied Configuration"));
+        assertTrue(out.contains("PID"));
+        assertTrue(out.contains("testApplyConfig"));
+        assertTrue(out.contains("Policy"));
+        assertTrue(out.contains("OVERRIDE"));
+        assertTrue(out.contains("Dryrun"));
+        assertTrue(out.contains("false"));
+        assertTrue(out.contains("OSGI Configuration for PID"));
+        assertTrue(out.contains("test"));
+        assertTrue(out.contains("testVal"));
         verify(tamayaConfigPlugin).updateConfig("testApplyConfig", Policy.OVERRIDE, true, false);
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/a1cd433a/modules/osgi/gogo-shell/src/test/java/org/apache/tamaya/gogo/shell/HistoryCommandsTest.java
----------------------------------------------------------------------
diff --git a/modules/osgi/gogo-shell/src/test/java/org/apache/tamaya/gogo/shell/HistoryCommandsTest.java b/modules/osgi/gogo-shell/src/test/java/org/apache/tamaya/gogo/shell/HistoryCommandsTest.java
index 1d129a0..8dac595 100644
--- a/modules/osgi/gogo-shell/src/test/java/org/apache/tamaya/gogo/shell/HistoryCommandsTest.java
+++ b/modules/osgi/gogo-shell/src/test/java/org/apache/tamaya/gogo/shell/HistoryCommandsTest.java
@@ -18,12 +18,14 @@
  */
 package org.apache.tamaya.gogo.shell;
 
+import org.apache.tamaya.osgi.ConfigHistory;
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.runners.MockitoJUnitRunner;
 
+import static org.mockito.Mockito.reset;
 import static org.mockito.Mockito.verify;
 
 /**
@@ -53,9 +55,12 @@ public class HistoryCommandsTest extends AbstractOSGITest{
     }
 
     @Test
-    public void testHisatory_Get() throws Exception {
-        commands.tm_history_get("testHisatory_Get", "");
-        verify(tamayaConfigPlugin).getHistory("testHisatory_Get");
+    public void testHistory_Get() throws Exception {
+        commands.tm_history_get("testHistory_Get", "");
+        verify(tamayaConfigPlugin).getHistory("testHistory_Get");
+        reset(tamayaConfigPlugin);
+        commands.tm_history_get("testHistory_Get", "BEGIN,END");
+        verify(tamayaConfigPlugin).getHistory("testHistory_Get");
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/a1cd433a/modules/osgi/gogo-shell/src/test/java/org/apache/tamaya/gogo/shell/SettingsCommandsTest.java
----------------------------------------------------------------------
diff --git a/modules/osgi/gogo-shell/src/test/java/org/apache/tamaya/gogo/shell/SettingsCommandsTest.java b/modules/osgi/gogo-shell/src/test/java/org/apache/tamaya/gogo/shell/SettingsCommandsTest.java
index fa4e3aa..bc165e9 100644
--- a/modules/osgi/gogo-shell/src/test/java/org/apache/tamaya/gogo/shell/SettingsCommandsTest.java
+++ b/modules/osgi/gogo-shell/src/test/java/org/apache/tamaya/gogo/shell/SettingsCommandsTest.java
@@ -18,6 +18,7 @@
  */
 package org.apache.tamaya.gogo.shell;
 
+import org.apache.tamaya.osgi.Policy;
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -75,4 +76,17 @@ public class SettingsCommandsTest extends AbstractOSGITest{
         verify(tamayaConfigPlugin).setAutoUpdateEnabled(false);
     }
 
+    @Test
+    public void testPolicy() throws Exception {
+        commands.tm_policy();
+        verify(tamayaConfigPlugin).getDefaultPolicy();
+    }
+
+    @Test
+    public void testPolicySet() throws Exception {
+        commands.tm_policy_set(Policy.EXTEND);
+        verify(tamayaConfigPlugin).setDefaultPolicy(Policy.EXTEND);
+        commands.tm_policy_set(Policy.OVERRIDE);
+        verify(tamayaConfigPlugin).setDefaultPolicy(Policy.OVERRIDE);
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/a1cd433a/modules/osgi/injection/bnd.bnd
----------------------------------------------------------------------
diff --git a/modules/osgi/injection/bnd.bnd b/modules/osgi/injection/bnd.bnd
new file mode 100644
index 0000000..69e9637
--- /dev/null
+++ b/modules/osgi/injection/bnd.bnd
@@ -0,0 +1,34 @@
+-buildpath: \
+	osgi.annotation; version=6.0.0,\
+	osgi.core; version=6.0,\
+	osgi.cmpn; version=6.0
+
+-testpath: \
+	${junit}
+
+javac.source: 1.8
+javac.target: 1.8
+
+Bundle-Activator: org.apache.tamaya.osgi.injection.Activator
+Bundle-Version: ${version}.${tstamp}
+Bundle-Name: Apache Tamaya - OSGI Configuration Injection
+Bundle-SymbolicName: org.apache.tamaya.osgi.injection
+Bundle-Description: Apacha Tamaya Configuration - OSGI Service Configuration Injection
+Bundle-Category: Implementation
+Bundle-Copyright: (C) Apache Foundation
+Bundle-License: Apache Licence version 2
+Bundle-Vendor: Apache Software Foundation
+Bundle-ContactAddress: dev-tamaya@incubator.apache.org
+Bundle-DocURL: http://tamaya.apache.org
+Import-Package: \
+    org.osgi.service.cm,\
+    org.osgi.framework,\
+    org.osgi.util.tracker,\
+    org.apache.tamaya,\
+    org.apache.tamaya.spi,\
+    org.apache.tamaya.functions,\
+    org.apache.tamaya.spisupport,\
+    org.apache.tamaya.osgi,\
+    org.apache.tamaya.inject.api,\
+    org.apache.tamaya.inject.spi,\
+    org.apache.tamaya.inject

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/a1cd433a/modules/osgi/injection/pom.xml
----------------------------------------------------------------------
diff --git a/modules/osgi/injection/pom.xml b/modules/osgi/injection/pom.xml
new file mode 100644
index 0000000..692e98f
--- /dev/null
+++ b/modules/osgi/injection/pom.xml
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+    <!--
+
+        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.
+    -->
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.tamaya.ext</groupId>
+        <artifactId>tamaya-osgi-all</artifactId>
+        <version>0.4-incubating-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>tamaya-osgi-injection</artifactId>
+    <packaging>jar</packaging>
+    <name>Apache Tamaya :: OSGI :: Config Injection</name>
+    <description>Tamaya OSGI Configuration Injector</description>
+
+    <dependencies>
+
+        <dependency>
+            <groupId>org.apache.tamaya.ext</groupId>
+            <artifactId>tamaya-injection</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.tamaya.ext</groupId>
+            <artifactId>tamaya-osgi</artifactId>
+            <version>${project.parent.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.compendium</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.core</artifactId>
+        </dependency>
+
+        <!-- Testing -->
+        <dependency>
+            <groupId>org.hamcrest</groupId>
+            <artifactId>java-hamcrest</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.mockito</groupId>
+            <artifactId>mockito-core</artifactId>
+        </dependency>
+    </dependencies>
+
+</project>

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/a1cd433a/modules/osgi/injection/src/main/java/org/apache/tamaya/osgi/injection/Activator.java
----------------------------------------------------------------------
diff --git a/modules/osgi/injection/src/main/java/org/apache/tamaya/osgi/injection/Activator.java b/modules/osgi/injection/src/main/java/org/apache/tamaya/osgi/injection/Activator.java
new file mode 100644
index 0000000..b344415
--- /dev/null
+++ b/modules/osgi/injection/src/main/java/org/apache/tamaya/osgi/injection/Activator.java
@@ -0,0 +1,95 @@
+/*
+ * 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.injection;
+
+import org.osgi.framework.*;
+
+import java.util.Dictionary;
+import java.util.Hashtable;
+import java.util.Objects;
+import java.util.function.Supplier;
+import java.util.logging.Logger;
+
+/**
+ * Activator that registers the Tamaya commands for the Felix Gogo console used
+ * in Apache Felix and Equinox.
+ */
+public class Activator implements BundleActivator {
+
+    private static final Logger LOG = Logger.getLogger(Activator.class.getName());
+
+    private TamayaOSGIInjector injector;
+    private ServiceRegistration<ConfigInjectionService> serviceReg;
+
+    @Override
+    public void start(BundleContext context) throws Exception {
+        LOG.finest("Registering Tamaya OSGI Config injector...");
+        injector = new TamayaOSGIInjector(context);
+        Dictionary<String, Object> props = new Hashtable<>();
+        serviceReg = context.registerService(
+                ConfigInjectionService.class,
+                new TamayaConfigInjectionService(injector), props);
+        injector.start();
+        LOG.finest("Registered Tamaya OSGI Config injector.");
+    }
+
+    @Override
+    public void stop(BundleContext context) throws Exception {
+        LOG.finest("Unregistering Tamaya Config injector...");
+        if (serviceReg != null) {
+            injector.stop();
+            serviceReg.unregister();
+        }
+    }
+
+    private final class TamayaConfigInjectionService implements ConfigInjectionService{
+
+        private TamayaOSGIInjector injector;
+
+        TamayaConfigInjectionService(TamayaOSGIInjector injector){
+            this.injector = Objects.requireNonNull(injector);
+        }
+
+        @Override
+        public boolean isInjectionEnabled(ServiceReference reference) {
+            return injector.isInjectionEnabled(reference);
+        }
+
+        @Override
+        public boolean isInjectionEnabled(Bundle bundle) {
+            return injector.isInjectionEnabled(bundle);
+        }
+
+        @Override
+        public <T> T configure(String pid, String location, T instance) {
+            return injector.configure(pid, location, instance);
+        }
+
+        @Override
+        public <T> Supplier<T> getConfiguredSupplier(String pid, String location, Supplier<T> supplier) {
+            return injector.getConfiguredSupplier(pid, location, supplier);
+        }
+
+        @Override
+        public <T> T createTemplate(String pid, String location, Class<T> templateType) {
+            return injector.createTemplate(pid, location, templateType);
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/a1cd433a/modules/osgi/injection/src/main/java/org/apache/tamaya/osgi/injection/ConfigInjectionService.java
----------------------------------------------------------------------
diff --git a/modules/osgi/injection/src/main/java/org/apache/tamaya/osgi/injection/ConfigInjectionService.java b/modules/osgi/injection/src/main/java/org/apache/tamaya/osgi/injection/ConfigInjectionService.java
new file mode 100644
index 0000000..dce25e6
--- /dev/null
+++ b/modules/osgi/injection/src/main/java/org/apache/tamaya/osgi/injection/ConfigInjectionService.java
@@ -0,0 +1,115 @@
+/*
+ * 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.injection;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.ServiceReference;
+
+import java.util.function.Supplier;
+
+/**
+ * OSGI service interface registered by the Tamaya configuration injector plugin.
+ */
+public interface ConfigInjectionService {
+    /** The manifest entry to enable Tamaya injection. */
+    String TAMAYA_INJECTION_ENABLED_MANIFEST = "Tamaya-Config-Inject";
+    /** The OSGI config entry to enable Tamaya injection. */
+    String TAMAYA_INJECTION_ENABLED_PROP = "tamaya-config-inject";
+
+    /**
+     * Checks if injection is enabled on the given service.
+     * @param reference the service reference, not null.
+     * @return true, if enjection is enabled.
+     */
+    boolean isInjectionEnabled(ServiceReference reference);
+
+    /**
+     * Checks if injection is enabled on the given service.
+     * @param bundle the bundle, not null.
+     * @return true, if enjection is enabled.
+     */
+    boolean isInjectionEnabled(Bundle bundle);
+
+    /**
+     * Configures the passed instance.
+     * @param instance the instance, not null.
+     * @param <T> the input and return type.
+     * @param pid the target PID, not null.
+     * @param location the optional location
+     * @return the configured instance.
+     */
+    <T> T configure(String pid, String location, T instance);
+
+    /**
+     * Creates a suzpplier, which supplies events as created by the basic supplier, which are
+     * automatically configured, when supplying.
+     * @param supplier the base supplier, not null.
+     * @param pid the target PID, not null.
+     * @param location the optional location
+     * @param <T> the type
+     * @return a configuring supplier.
+     */
+    <T> Supplier<T> getConfiguredSupplier(String pid, String location, java.util.function.Supplier<T> supplier);
+
+    /**
+     * Creates a template implementing the annotated methods based on current configuration data.
+     *
+     * @param <T> the type of the template.
+     * @param templateType the type of the template to be created.
+     * @param pid the target PID, not null.
+     * @param location the optional location
+     * @return the configured template.
+     */
+    <T> T createTemplate(String pid, String location, Class<T> templateType);
+
+    /**
+     * Configures the passed instance.
+     * @param instance the instance, not null.
+     * @param <T> the input and return type.
+     * @param bundle the target bundle, not null.
+     * @return the configured instance.
+     */
+    default <T> T configure(Bundle bundle, T instance){
+        return configure(bundle.getSymbolicName(), bundle.getLocation(), instance);
+    }
+
+    /**
+     * Creates a suzpplier, which supplies events as created by the basic supplier, which are
+     * automatically configured, when supplying.
+     * @param supplier the base supplier, not null.
+     * @param bundle the target bundle, not null.
+     * @param <T> the type
+     * @return a configuring supplier.
+     */
+    default <T> Supplier<T> getConfiguredSupplier(Bundle bundle, java.util.function.Supplier<T> supplier){
+        return getConfiguredSupplier(bundle.getSymbolicName(), bundle.getLocation(), supplier);
+    }
+
+    /**
+     * Creates a template implementing the annotated methods based on current configuration data.
+     *
+     * @param <T> the type of the template.
+     * @param templateType the type of the template to be created.
+     * @param bundle the target bundle, not null.
+     * @return the configured template.
+     */
+    default <T> T createTemplate(Bundle bundle, Class<T> templateType){
+        return createTemplate(bundle.getSymbolicName(), bundle.getLocation(), templateType);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/a1cd433a/modules/osgi/injection/src/main/java/org/apache/tamaya/osgi/injection/OSGIConfigAdminPropertySource.java
----------------------------------------------------------------------
diff --git a/modules/osgi/injection/src/main/java/org/apache/tamaya/osgi/injection/OSGIConfigAdminPropertySource.java b/modules/osgi/injection/src/main/java/org/apache/tamaya/osgi/injection/OSGIConfigAdminPropertySource.java
new file mode 100644
index 0000000..529468e
--- /dev/null
+++ b/modules/osgi/injection/src/main/java/org/apache/tamaya/osgi/injection/OSGIConfigAdminPropertySource.java
@@ -0,0 +1,108 @@
+/*
+ * 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.injection;
+
+import org.apache.tamaya.spi.PropertyValue;
+import org.apache.tamaya.spisupport.BasePropertySource;
+import org.osgi.service.cm.Configuration;
+import org.osgi.service.cm.ConfigurationAdmin;
+
+import java.io.IOException;
+import java.util.*;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * This is a Tamaya PropertySource, which internally wraps the OSGI ConfigAdmin service, preconfigured
+ * for a PID and (optionally) location.
+ */
+public class OSGIConfigAdminPropertySource extends BasePropertySource{
+
+    private static final Logger LOG = Logger.getLogger(OSGIConfigAdminPropertySource.class.getName());
+    private ConfigurationAdmin configurationAdmin;
+    private String pid;
+    private String location;
+
+    public OSGIConfigAdminPropertySource(ConfigurationAdmin configurationAdmin, String pid){
+        this.configurationAdmin = Objects.requireNonNull(configurationAdmin);
+        this.pid = Objects.requireNonNull(pid);
+    }
+
+    public OSGIConfigAdminPropertySource(ConfigurationAdmin configurationAdmin, String pid, String location){
+        this.configurationAdmin = Objects.requireNonNull(configurationAdmin);
+        this.pid = Objects.requireNonNull(pid);
+        this.location = location;
+    }
+
+    /**
+     * Get the configured OSGI service PID.
+     * @return the pid, nnever null.
+     */
+    public String getPid() {
+        return pid;
+    }
+
+    /**
+     * Get the configured OSGI config location, may be null.
+     * @return the location, or null.
+     */
+    public String getLocation() {
+        return location;
+    }
+
+    @Override
+    public PropertyValue get(String key) {
+        try {
+            Configuration osgiConfig = configurationAdmin.getConfiguration(pid, location);
+            Dictionary<String,Object> props = osgiConfig.getProperties();
+            if(props!=null){
+                Object value = props.get(key);
+                if(value!=null) {
+                    return PropertyValue.of(key, String.valueOf(value), "OSGI ConfigAdmin: " + pid);
+                }
+            }
+        } catch (IOException e) {
+            LOG.log(Level.FINEST,  e, () -> "No config for PID: " + pid);
+        }
+        return null;
+    }
+
+    @Override
+    public Map<String, PropertyValue> getProperties() {
+        try {
+            Configuration osgiConfig = configurationAdmin.getConfiguration(pid);
+            Dictionary<String,Object> props = osgiConfig.getProperties();
+            if(props!=null){
+                Map<String, PropertyValue> result = new HashMap<>();
+                Enumeration<String> keys = props.keys();
+                while(keys.hasMoreElements()){
+                    String key = keys.nextElement();
+                    Object value = props.get(key);
+                    result.put(key, PropertyValue.of(key, String.valueOf(value), "OSGI ConfigAdmin: " + pid));
+                }
+                return result;
+            }
+        } catch (IOException e) {
+            LOG.log(Level.FINEST,  e, () -> "No config for PID: " + pid);
+        }
+        return Collections.emptyMap();
+    }
+}
+
+

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/a1cd433a/modules/osgi/injection/src/main/java/org/apache/tamaya/osgi/injection/OSGIConfigurationInjector.java
----------------------------------------------------------------------
diff --git a/modules/osgi/injection/src/main/java/org/apache/tamaya/osgi/injection/OSGIConfigurationInjector.java b/modules/osgi/injection/src/main/java/org/apache/tamaya/osgi/injection/OSGIConfigurationInjector.java
new file mode 100644
index 0000000..4ac520d
--- /dev/null
+++ b/modules/osgi/injection/src/main/java/org/apache/tamaya/osgi/injection/OSGIConfigurationInjector.java
@@ -0,0 +1,118 @@
+/*
+ * 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.injection;
+
+import org.apache.tamaya.Configuration;
+import org.apache.tamaya.ConfigurationProvider;
+import org.apache.tamaya.inject.ConfigurationInjection;
+import org.osgi.service.cm.ConfigurationAdmin;
+
+import java.util.Objects;
+import java.util.function.Supplier;
+
+/**
+ * This class wraps an OSGI Configuration based on PID and location and provides injection services for
+ * configuration.
+ */
+final class OSGIConfigurationInjector{
+    /** The OSGI ConfigManager. */
+    private ConfigurationAdmin cm;
+    /** The corresponding Tamaya configuration. */
+    private Configuration tamayaOSGIConfiguration;
+    /** The target PID. */
+    private String pid;
+    /** The target location. */
+    private String location;
+
+    /**
+     * Creates a new instance.
+     * @param cm the OSGI ConfigManager, not null.
+     * @param pid the target PID.
+     */
+    public OSGIConfigurationInjector(ConfigurationAdmin cm, String pid){
+        this(cm, pid, null);
+    }
+
+    /**
+     * Creates a new instance.
+     * @param cm the OSGI ConfigManager, not null.
+     * @param pid the target PID.
+     * @param location the optional location.
+     */
+    public OSGIConfigurationInjector(ConfigurationAdmin cm, String pid, String location){
+        this.cm = Objects.requireNonNull(cm);
+        tamayaOSGIConfiguration = ConfigurationProvider.createConfiguration(
+                ConfigurationProvider.getConfigurationContextBuilder()
+                .addDefaultPropertyConverters()
+                .addDefaultPropertyFilters()
+                .addPropertySources(new OSGIConfigAdminPropertySource(cm, pid, location))
+                .build());
+    }
+
+    /**
+     * Get the target PID.
+     * @return the target PID, not null.
+     */
+    public String getPid() {
+        return pid;
+    }
+
+    /**
+     * Get the location.
+     * @return the location.
+     */
+    public String getLocation() {
+        return location;
+    }
+
+    /**
+     * Configures the passed instance.
+     * @param instance the instance, not null.
+     * @param <T> the input and return type.
+     * @return the configured instance.
+     */
+    public <T> T configure(T instance){
+        return ConfigurationInjection.getConfigurationInjector()
+                .configure(instance, tamayaOSGIConfiguration);
+    }
+
+    /**
+     * Creates a suzpplier, which supplies events as created by the basic supplier, which are
+     * automatically configured, when supplying.
+     * @param supplier the base supplier, not null.
+     * @param <T> the type
+     * @return a configuring supplier.
+     */
+    public <T> Supplier<T> getConfiguredSupplier(java.util.function.Supplier<T> supplier){
+        return ConfigurationInjection.getConfigurationInjector()
+                .getConfiguredSupplier(supplier, tamayaOSGIConfiguration);
+    }
+
+    /**
+     * Creates a template implementing the annotated methods based on current configuration data.
+     *
+     * @param <T> the type of the template.
+     * @param templateType the type of the template to be created.
+     * @return the configured template.
+     */
+    public <T> T createTemplate(Class<T> templateType){
+        return ConfigurationInjection.getConfigurationInjector()
+                .createTemplate(templateType, tamayaOSGIConfiguration);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/a1cd433a/modules/osgi/injection/src/main/java/org/apache/tamaya/osgi/injection/TamayaOSGIInjector.java
----------------------------------------------------------------------
diff --git a/modules/osgi/injection/src/main/java/org/apache/tamaya/osgi/injection/TamayaOSGIInjector.java b/modules/osgi/injection/src/main/java/org/apache/tamaya/osgi/injection/TamayaOSGIInjector.java
new file mode 100644
index 0000000..2b245d3
--- /dev/null
+++ b/modules/osgi/injection/src/main/java/org/apache/tamaya/osgi/injection/TamayaOSGIInjector.java
@@ -0,0 +1,162 @@
+/*
+ * 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.injection;
+
+import org.apache.tamaya.osgi.TamayaConfigPlugin;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.cm.ConfigurationAdmin;
+import org.osgi.util.tracker.ServiceTracker;
+
+import java.util.Map;
+import java.util.Objects;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.function.Supplier;
+import java.util.logging.Logger;
+
+/**
+ * Class that monitors services and configures them if they have {@code Tamaya-Config = true} in the
+ * service settings.
+ */
+public class TamayaOSGIInjector{
+    /** The logger. */
+    private static final Logger log = Logger.getLogger(TamayaConfigPlugin.class.getName());
+    /** The bundle context. */
+    private BundleContext context;
+    /** OSGI Config manager. */
+    private ConfigurationAdmin cm;
+    /** The service tracker. */
+    private ServiceTracker<Object, Object> tracker;
+    /** The cached injectors. */
+    private static final Map<String, OSGIConfigurationInjector> INJECTORS = new ConcurrentHashMap<>();
+
+    /**
+     * Creates a new injector.
+     * @param context thge bundle contex, not null.
+     */
+    public TamayaOSGIInjector(BundleContext context) {
+        this.context = Objects.requireNonNull(context);
+    }
+
+    /**
+     * Starts the injector by registering the servidce tracker for all type of services. Injection is performed on
+     * service creation and modification.
+     */
+    public void start(){
+        tracker = new ServiceTracker<Object, Object>(context, Object.class.getName(), null) {
+            @Override
+            public Object addingService(ServiceReference reference) {
+                log.info("Checking service for configuration: " + reference);
+                Object service =  super.addingService(reference);
+                if(isInjectionEnabled(reference)) {
+                    String pid = (String)reference.getProperty(Constants.SERVICE_PID);
+                    if(pid==null){
+                        pid = reference.getBundle().getSymbolicName();
+                    }
+                    OSGIConfigurationInjector injector = getInjector(pid, reference.getBundle().getLocation());
+                    injector.configure(service);
+                }
+                return service;
+            }
+
+            @Override
+            public void modifiedService(ServiceReference<Object> reference, Object service) {
+                super.modifiedService(reference, service);
+                if(isInjectionEnabled(reference)) {
+                    String pid = (String)reference.getProperty(Constants.SERVICE_PID);
+                    if(pid==null){
+                        pid = reference.getBundle().getSymbolicName();
+                    }
+                    OSGIConfigurationInjector injector = getInjector(pid, reference.getBundle().getLocation());
+                    injector.configure(service);
+                }
+            }
+        };
+        tracker.open(true);
+    }
+
+    /**
+     * Stops the service tracker listening.
+     */
+    public void stop(){
+        if(tracker!=null){
+            tracker.close();
+            tracker = null;
+        }
+    }
+
+    /**
+     * Get or create an injector for injecting OSGI configuration using Tamaya's injection API.
+     * @param pid the PID, not nbull.
+     * @param location the optional location.
+     * @return a injector, never null.
+     */
+    private OSGIConfigurationInjector getInjector(String pid, String location){
+        String key = location==null?pid.trim():pid.trim()+"::"+location.trim();
+        OSGIConfigurationInjector injector = INJECTORS.get(key);
+        if(injector==null){
+            injector = new OSGIConfigurationInjector(cm, pid, location);
+            INJECTORS.put(key, injector);
+        }
+        return injector;
+    }
+
+    /**
+     * Checks if injection is enabled on the given service.
+     * @param reference the service reference, not null.
+     * @return true, if injection is enabled.
+     */
+    static boolean isInjectionEnabled(ServiceReference reference){
+        String enabledVal = (String)reference.getProperty(ConfigInjectionService.TAMAYA_INJECTION_ENABLED_PROP);
+        if(enabledVal!=null){
+            return Boolean.parseBoolean(enabledVal);
+        }
+        if(enabledVal!=null){
+            return Boolean.parseBoolean(enabledVal);
+        }
+        return isInjectionEnabled(reference.getBundle());
+    }
+
+    /**
+     * Checks if injection is enabled on the given bundle.
+     * @param bundle the bundle, not null.
+     * @return true, if injection is enabled.
+     */
+    static boolean isInjectionEnabled(Bundle bundle){
+        String enabledVal = (String)bundle.getHeaders().get(ConfigInjectionService.TAMAYA_INJECTION_ENABLED_MANIFEST);
+        if(enabledVal!=null){
+            return Boolean.parseBoolean(enabledVal);
+        }
+        return false;
+    }
+
+    <T> T configure(String pid, String location, T instance) {
+        return getInjector(pid, location).configure(instance);
+    }
+
+    <T> Supplier<T> getConfiguredSupplier(String pid, String location, Supplier<T> supplier) {
+        return getInjector(pid, location).getConfiguredSupplier(supplier);
+    }
+
+    <T> T createTemplate(String pid, String location, Class<T> templateType) {
+        return getInjector(pid, location).createTemplate(templateType);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/a1cd433a/modules/osgi/injection/src/test/java/org/apache/tamaya/osgi/injection/AbstractOSGITest.java
----------------------------------------------------------------------
diff --git a/modules/osgi/injection/src/test/java/org/apache/tamaya/osgi/injection/AbstractOSGITest.java b/modules/osgi/injection/src/test/java/org/apache/tamaya/osgi/injection/AbstractOSGITest.java
new file mode 100644
index 0000000..e3f73c3
--- /dev/null
+++ b/modules/osgi/injection/src/test/java/org/apache/tamaya/osgi/injection/AbstractOSGITest.java
@@ -0,0 +1,99 @@
+/*
+ * 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.injection;
+
+import org.apache.tamaya.osgi.TamayaConfigPlugin;
+import org.junit.Before;
+import org.mockito.Mock;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.cm.Configuration;
+import org.osgi.service.cm.ConfigurationAdmin;
+
+import java.util.Dictionary;
+import java.util.Hashtable;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.*;
+
+/**
+ * Created by atsticks on 27.09.17.
+ */
+public abstract class AbstractOSGITest {
+
+    private Map<String,Hashtable<String, Object>> properties = new ConcurrentHashMap<>();
+
+    @Mock
+    protected BundleContext bundleContext;
+
+    @Mock
+    protected ConfigurationAdmin cm;
+
+    @Mock
+    private ServiceReference<ConfigurationAdmin> cmRef;
+    @Mock
+    private ServiceReference<TamayaConfigPlugin> tamayaRef;
+
+    protected TamayaConfigPlugin tamayaConfigPlugin;
+
+    protected Dictionary<String,Object> getProperties(String pid){
+        return this.properties.get(pid);
+    }
+
+    @Before
+    public void setup()throws Exception{
+        doAnswer(invocation -> {
+            return initConfigurationMock((String)invocation.getArguments()[0]);
+        }).when(cm).getConfiguration(any());
+        doAnswer(invocation -> {
+            return initConfigurationMock((String)invocation.getArguments()[0]);
+        }).when(cm).getConfiguration(any(), any());
+        doReturn(new Bundle[0]).when(bundleContext).getBundles();
+        doReturn(cmRef).when(bundleContext).getServiceReference(ConfigurationAdmin.class);
+        doReturn(cm).when(bundleContext).getService(cmRef);
+        doReturn(tamayaRef).when(bundleContext).getServiceReference(TamayaConfigPlugin.class);
+        tamayaConfigPlugin = new TamayaConfigPlugin(bundleContext);
+        doReturn(tamayaConfigPlugin).when(bundleContext).getService(tamayaRef);
+    }
+
+    protected Configuration initConfigurationMock(final String pid)throws Exception{
+        Configuration config = mock(Configuration.class);
+        doAnswer(invocation -> {
+            Hashtable<String,Object> props = properties.get(pid);
+            props.clear();
+            props.putAll((Map<? extends String, ?>) invocation.getArguments()[0]);
+            return null;
+        }).when(config).update(any(Dictionary.class));
+        doAnswer(invocation -> {
+            Hashtable<String,Object> props = properties.get(pid);
+            if(props==null){
+                props = new Hashtable<>();
+                properties.put(pid, props);
+                for(Map.Entry en:System.getProperties().entrySet()){
+                    props.put(en.getKey().toString(), en.getValue());
+                }
+            }
+            return new Hashtable<>(props);
+        }).when(config).getProperties();
+        return config;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/a1cd433a/modules/osgi/injection/src/test/java/org/apache/tamaya/osgi/injection/ActivatorTest.java
----------------------------------------------------------------------
diff --git a/modules/osgi/injection/src/test/java/org/apache/tamaya/osgi/injection/ActivatorTest.java b/modules/osgi/injection/src/test/java/org/apache/tamaya/osgi/injection/ActivatorTest.java
new file mode 100644
index 0000000..9cd587f
--- /dev/null
+++ b/modules/osgi/injection/src/test/java/org/apache/tamaya/osgi/injection/ActivatorTest.java
@@ -0,0 +1,43 @@
+/*
+ * 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.injection;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.runners.MockitoJUnitRunner;
+
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.verify;
+
+/**
+ * Created by atsti on 03.10.2017.
+ */
+@RunWith(MockitoJUnitRunner.class)
+public class ActivatorTest extends AbstractOSGITest{
+
+    @Test
+    public void startStop() throws Exception {
+        Activator activator = new Activator();
+        activator.start(this.bundleContext);
+        verify(bundleContext).registerService(eq(TamayaOSGIInjector.class), anyObject(), anyObject());
+        activator.stop(this.bundleContext);
+    }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/a1cd433a/modules/osgi/injection/src/test/java/org/apache/tamaya/osgi/injection/OSGIConfigAdminPropertySourceTest.java
----------------------------------------------------------------------
diff --git a/modules/osgi/injection/src/test/java/org/apache/tamaya/osgi/injection/OSGIConfigAdminPropertySourceTest.java b/modules/osgi/injection/src/test/java/org/apache/tamaya/osgi/injection/OSGIConfigAdminPropertySourceTest.java
new file mode 100644
index 0000000..f83ac56
--- /dev/null
+++ b/modules/osgi/injection/src/test/java/org/apache/tamaya/osgi/injection/OSGIConfigAdminPropertySourceTest.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.tamaya.osgi.injection;
+
+import org.apache.tamaya.spi.PropertyValue;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.runners.MockitoJUnitRunner;
+
+import java.util.Map;
+
+import static org.junit.Assert.*;
+
+/**
+ * Created by atsti on 03.10.2017.
+ */
+@RunWith(MockitoJUnitRunner.class)
+public class OSGIConfigAdminPropertySourceTest extends AbstractOSGITest{
+
+    OSGIConfigAdminPropertySource propertySource;
+
+    @Before
+    public void init(){
+        propertySource = new OSGIConfigAdminPropertySource(cm, "tamaya");
+    }
+
+    @Test
+    public void get() throws Exception {
+        PropertyValue val = propertySource.get("java.home");
+        assertNotNull(val);
+        assertEquals(val.getKey(), "java.home");
+        assertEquals(val.getValue(), System.getProperty("java.home"));
+        val = propertySource.get("foo.bar");
+        assertNull(val);
+    }
+
+    @Test
+    public void getProperties() throws Exception {
+        Map<String,PropertyValue> props = propertySource.getProperties();
+        assertNotNull(props);
+        PropertyValue val = props.get("java.home");
+        assertEquals(val.getKey(), "java.home");
+        assertEquals(val.getValue(), System.getProperty("java.home"));
+        val = props.get("foo.bar");
+        assertNull(val);
+    }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/a1cd433a/modules/osgi/injection/src/test/java/org/apache/tamaya/osgi/injection/OSGIConfigurationInjectorTest.java
----------------------------------------------------------------------
diff --git a/modules/osgi/injection/src/test/java/org/apache/tamaya/osgi/injection/OSGIConfigurationInjectorTest.java b/modules/osgi/injection/src/test/java/org/apache/tamaya/osgi/injection/OSGIConfigurationInjectorTest.java
new file mode 100644
index 0000000..6735e7a
--- /dev/null
+++ b/modules/osgi/injection/src/test/java/org/apache/tamaya/osgi/injection/OSGIConfigurationInjectorTest.java
@@ -0,0 +1,97 @@
+/*
+ * 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.injection;
+
+import org.apache.tamaya.inject.api.Config;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.runners.MockitoJUnitRunner;
+
+import java.util.function.Supplier;
+
+import static org.junit.Assert.*;
+
+/**
+ * Created by atsti on 03.10.2017.
+ */
+@RunWith(MockitoJUnitRunner.class)
+public class OSGIConfigurationInjectorTest extends AbstractOSGITest{
+
+
+    @Test
+    public void configure() throws Exception {
+        OSGIConfigurationInjector injector = new OSGIConfigurationInjector(cm, "OSGIConfigurationInjectorTest");
+        Example example = new Example();
+        Example result = injector.configure(example);
+        assertNotNull(result);
+        assertTrue(result==example);
+        checkExampleConfig(example);
+    }
+
+    @Test
+    public void getConfiguredSupplier() throws Exception {
+        OSGIConfigurationInjector injector = new OSGIConfigurationInjector(cm, "OSGIConfigurationInjectorTest");
+        Supplier<Example> supplier = injector.getConfiguredSupplier(Example::new);
+        assertNotNull(supplier);
+        Example example = supplier.get();
+        checkExampleConfig(example);
+    }
+
+    @Test
+    public void createTemplate() throws Exception {
+        OSGIConfigurationInjector injector = new OSGIConfigurationInjector(cm, "OSGIConfigurationInjectorTest");
+        TemplateExample template = injector.createTemplate(TemplateExample.class);
+        checkExampleConfig(template);
+    }
+
+    private void checkExampleConfig(Example example) {
+        assertNotNull(example);
+        assertEquals(example.javaHome, System.getProperty("java.home"));
+        assertEquals(example.javaVersion, System.getProperty("java.version"));
+        assertEquals(example.javaUsed, true);
+    }
+
+    private void checkExampleConfig(TemplateExample template) {
+        assertNotNull(template);
+        assertEquals(template.getJavaHome(), System.getProperty("java.home"));
+        assertEquals(template.javaVersion(), System.getProperty("java.version"));
+        assertEquals(template.isJavaUsed(), true);
+    }
+
+    private static final class Example {
+        @Config("java.home")
+        String javaHome;
+        @Config("java.version")
+        String javaVersion;
+        @Config(value = "java.used", defaultValue = "true")
+        boolean javaUsed;
+    }
+
+    private interface TemplateExample {
+
+        @Config("java.home")
+        String getJavaHome();
+
+        @Config("java.version")
+        String javaVersion();
+
+        @Config(value = "java.used", defaultValue = "true")
+        boolean isJavaUsed();
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/a1cd433a/modules/osgi/karaf-features/pom.xml
----------------------------------------------------------------------
diff --git a/modules/osgi/karaf-features/pom.xml b/modules/osgi/karaf-features/pom.xml
new file mode 100644
index 0000000..8d8c2d4
--- /dev/null
+++ b/modules/osgi/karaf-features/pom.xml
@@ -0,0 +1,47 @@
+<?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.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.tamaya.ext</groupId>
+        <artifactId>tamaya-osgi-all</artifactId>
+        <version>0.4-incubating-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>tamaya-karaf-features</artifactId>
+    <packaging>feature</packaging>
+    <name>Apache Tamaya :: OSGI :: Karaf :: Features</name>
+    <description>Tamaya Karaf Feature Descriptor.</description>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.karaf.tooling</groupId>
+                <artifactId>karaf-maven-plugin</artifactId>
+                <configuration>
+                    <startLevel>80</startLevel>
+                    <aggregateFeatures>true</aggregateFeatures>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/a1cd433a/modules/osgi/karaf-features/src/main/features/features.xml
----------------------------------------------------------------------
diff --git a/modules/osgi/karaf-features/src/main/features/features.xml b/modules/osgi/karaf-features/src/main/features/features.xml
new file mode 100644
index 0000000..20c5ee3
--- /dev/null
+++ b/modules/osgi/karaf-features/src/main/features/features.xml
@@ -0,0 +1,84 @@
+<?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.
+-->
+<features xmlns="http://karaf.apache.org/xmlns/features/v1.3.0" name="org-apache-tamaya-all">
+    <features name="org-apache-tamaya-config" version="0.4-incubating">
+        <features name="org-apache-tamaya-configadmin" version="0.4-incubating">
+            <bundle>mvn:org.apache.tamaya.ext/tamaya-osgi_alpha/0.4-incubating/jar</bundle>
+            <bundle>mvn:org.apache.tamaya.ext/tamaya-functions/0.4-incubating/jar</bundle>
+            <bundle>mvn:org.apache.tamaya.ext/tamaya-spisupport/0.4-incubating/jar</bundle>
+            <bundle>mvn:org.apache.tamaya.ext/tamaya-osgi-karaf_alpha/0.4-incubating/jar</bundle>
+            <features name="org-apache-tamaya-minimal" version="0.4-incubating">
+                <feature name="org-apache-tamaya-api" version="0.4-incubating">
+                    <bundle>mvn:org.apache.tamaya/tamaya-api/0.4-incubating/jar</bundle>
+                    <bundle>mvn:org.apache.geronimo.specs/geronimo-annotation_1.2_spec/1.0-alpha-1/jar</bundle>
+                </feature>
+                <feature name="org-apache-tamaya-core" version="0.4-incubating">
+                    <bundle>mvn:org.apache.tamaya/tamaya-core/0.4-incubating/jar</bundle>
+                </feature>
+            </features>
+        </features>
+        <features name="org-apache-tamaya-config-injection" version="0.4-incubating">
+            <bundle>mvn:org.apache.tamaya.ext/tamaya-osgi-injection_alpha/0.4-incubating/jar</bundle>
+            <bundle>mvn:org.apache.tamaya.ext/tamaya-injection-api/0.4-incubating/jar</bundle>
+            <bundle>mvn:org.apache.tamaya.ext/tamaya-injection-se/0.4-incubating/jar</bundle>
+        </features>
+        <feature name="org-apache-tamaya-config-updater" version="0.4-incubating">
+            <bundle>mvn:org.apache.tamaya.ext/tamaya-events/0.4-incubating/jar</bundle>
+            <bundle>mvn:org.apache.tamaya.ext/tamaya-osgi-updater_alpha/0.4-incubating/jar</bundle>
+        </feature>
+    </features>
+    <features name="org-apache-tamaya-formats" version="0.4-incubating">
+        <bundle>mvn:org.apache.tamaya.ext/tamaya-formats/0.4-incubating/jar</bundle>
+    </features>
+    <features name="org-apache-tamaya-formats-json" version="0.4-incubating">
+        <bundle>mvn:org.apache.tamaya.ext/tamaya-formats-json/0.4-incubating/jar</bundle>
+    </features>
+    <features name="org-apache-tamaya-formats-yaml" version="0.4-incubating">
+        <bundle>mvn:org.apache.tamaya.ext/tamaya-formats-yaml/0.4-incubating/jar</bundle>
+    </features>
+    <features name="org-apache-tamaya-filter" version="0.4-incubating">
+        <bundle>mvn:org.apache.tamaya.ext/tamaya-filter/0.4-incubating/jar</bundle>
+    </features>
+    <features name="org-apache-tamaya-resources" version="0.4-incubating">
+        <bundle>mvn:org.apache.tamaya.ext/tamaya-resources/0.4-incubating/jar</bundle>
+    </features>
+    <features name="org-apache-tamaya-resolver" version="0.4-incubating">
+        <bundle>mvn:org.apache.tamaya.ext/tamaya-resolver/0.4-incubating/jar</bundle>
+    </features>
+    <features name="org-apache-tamaya-mutable-config" version="0.4-incubating">
+        <bundle>mvn:org.apache.tamaya.ext/tamaya-mutable-config/0.4-incubating/jar</bundle>
+    </features>
+    <features name="org-apache-tamaya-spring" version="0.4-incubating">
+        <bundle>mvn:org.apache.tamaya.ext/tamaya-spring/0.4-incubating/jar</bundle>
+    </features>
+    <features name="org-apache-tamaya-optional" version="0.4-incubating">
+        <bundle>mvn:org.apache.tamaya.ext/tamaya-optional/0.4-incubating/jar</bundle>
+    </features>
+    <features name="org-apache-tamaya-jndi" version="0.4-incubating">
+        <bundle>mvn:org.apache.tamaya.ext/tamaya-jndi/0.4-incubating/jar</bundle>
+    </features>
+    <features name="org-apache-tamaya-features" version="0.4-incubating">
+        <bundle>mvn:org.apache.tamaya.ext/tamaya-features/0.4-incubating/jar</bundle>
+    </features>
+    <features name="org-apache-tamaya-events" version="0.4-incubating">
+        <bundle>mvn:org.apache.tamaya.ext/tamaya-events/0.4-incubating/jar</bundle>
+    </features>
+    <features name="org-apache-tamaya-uom" version="0.4-incubating">
+        <bundle>mvn:org.apache.tamaya.ext/tamaya-uom/0.4-incubating/jar</bundle>
+    </features>
+</features>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/a1cd433a/modules/osgi/karaf-shell/bnd.bnd
----------------------------------------------------------------------
diff --git a/modules/osgi/karaf-shell/bnd.bnd b/modules/osgi/karaf-shell/bnd.bnd
new file mode 100644
index 0000000..3bed7ca
--- /dev/null
+++ b/modules/osgi/karaf-shell/bnd.bnd
@@ -0,0 +1,38 @@
+-buildpath: \
+	osgi.annotation; version=6.0.0,\
+	osgi.core; version=6.0,\
+	osgi.cmpn; version=6.0
+
+-testpath: \
+	${junit}
+
+javac.source: 1.8
+javac.target: 1.8
+
+Bundle-Version: ${version}.${tstamp}
+Bundle-Name: Apache Tamaya - Karaf Shell Commands
+Bundle-SymbolicName: org.apache.tamaya.osgi.karaf.shell
+Bundle-Description: Apacha Tamaya Configuration - Karaf Shell Extensions
+Bundle-Category: Implementation
+Bundle-Copyright: (C) Apache Foundation
+Bundle-License: Apache Licence version 2
+Bundle-Vendor: Apache Software Foundation
+Bundle-ContactAddress: dev-tamaya@incubator.apache.org
+Bundle-DocURL: http://tamaya.apache.org
+Export-Package: \
+	org.apache.tamaya.karaf.shell
+Import-Package: \
+    org.osgi.service.cm,\
+    org.osgi.framework,\
+    org.apache.tamaya,\
+    org.apache.tamaya.spi,\
+    org.apache.tamaya.functions,\
+    org.apache.tamaya.spisupport,\
+    org.apache.tamaya.osgi,\
+    org.apache.tamaya.osgi.commands,\
+    org.apache.felix.service.command,\
+    org.apache.karaf.shell.api.console,\
+    org.apache.karaf.shell.api.action,\
+    org.apache.karaf.shell.api.action.lifecycle,\
+    org.apache.karaf.shell.support.completers
+Karaf-Commands: org.apache.tamaya.karaf.shell
\ No newline at end of file



Mime
View raw message