You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tamaya.apache.org by an...@apache.org on 2017/09/28 20:12:58 UTC
[44/45] incubator-tamaya-sandbox git commit: TAMAYA-297: Added tests
using mocks instead of PAX.
TAMAYA-297: Added tests using mocks instead of PAX.
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/d0e9a65f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/tree/d0e9a65f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/diff/d0e9a65f
Branch: refs/heads/master
Commit: d0e9a65ff9c6eabf9d5106ad75498a6e596e932d
Parents: a8029f4
Author: anatole <an...@apache.org>
Authored: Thu Sep 28 11:21:47 2017 +0200
Committer: anatole <an...@apache.org>
Committed: Thu Sep 28 11:21:47 2017 +0200
----------------------------------------------------------------------
osgi/common/bnd.bnd | 3 +-
osgi/common/pom.xml | 65 ++++++----
.../apache/tamaya/osgi/commands/StringUtil.java | 2 +-
.../apache/tamaya/osgi/AbstractOSGITest.java | 89 +++++++++++++
.../org/apache/tamaya/osgi/OSGIBasicTests.java | 84 ++++++++++++
.../java/org/apache/tamaya/osgi/OSGITest.java | 127 -------------------
.../tamaya/osgi/TamayaConfigPluginTest.java | 116 +++++++++++------
osgi/common/src/test/resources/arquillian.xml | 27 ----
osgi/common/src/test/resources/felix.properties | 23 ----
osgi/pom.xml | 53 +-------
10 files changed, 297 insertions(+), 292 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/d0e9a65f/osgi/common/bnd.bnd
----------------------------------------------------------------------
diff --git a/osgi/common/bnd.bnd b/osgi/common/bnd.bnd
index af8e245..4731c08 100644
--- a/osgi/common/bnd.bnd
+++ b/osgi/common/bnd.bnd
@@ -30,5 +30,4 @@ Import-Package: \
org.apache.tamaya.spi,\
org.apache.tamaya.functions,\
org.apache.tamaya.spisupport
-Export-Service: org.osgi.service.cm.ConfigurationPlugin,\
- org.apache.tamaya.osgi.TamayaConfigPlugin
+Export-Service: org.apache.tamaya.osgi.TamayaConfigPlugin
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/d0e9a65f/osgi/common/pom.xml
----------------------------------------------------------------------
diff --git a/osgi/common/pom.xml b/osgi/common/pom.xml
index fdcb7f3..fd4d8db 100644
--- a/osgi/common/pom.xml
+++ b/osgi/common/pom.xml
@@ -32,21 +32,29 @@
<name>Apache Tamaya :: OSGi :: ConfigurationPlugin</name>
<description>Tamaya Based OSGI ConfigurationPlugin Implementation</description>
+ <properties>
+ <osgi.config.version>1.5.0</osgi.config.version>
+ <osgi.tracker.version>1.5.1</osgi.tracker.version>
+
+ <pax.exam.version>4.9.2</pax.exam.version>
+ <pax.url.version>2.5.2</pax.url.version>
+ <slf4j.version>1.6.6</slf4j.version>
+ <mockito.version>1.9.5</mockito.version>
+ <atinject.version>1.0</atinject.version>
+ </properties>
+
<dependencies>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
- <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.compendium</artifactId>
- <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.util.tracker</artifactId>
- <scope>provided</scope>
</dependency>
<dependency>
@@ -83,53 +91,66 @@
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ </dependency>
- <!-- OSGI Testbed -->
+ <!-- OSGI Testing -->
<dependency>
<groupId>org.ops4j.pax.exam</groupId>
- <artifactId>pax-exam-container-forked</artifactId>
+ <artifactId>pax-exam-container-karaf</artifactId>
+ <version>${pax.exam.version}</version>
+ <scope>test</scope>
</dependency>
<dependency>
<groupId>org.ops4j.pax.exam</groupId>
<artifactId>pax-exam-junit4</artifactId>
+ <version>${pax.exam.version}</version>
+ <scope>test</scope>
</dependency>
<dependency>
<groupId>org.ops4j.pax.exam</groupId>
<artifactId>pax-exam-link-mvn</artifactId>
+ <version>${pax.exam.version}</version>
+ <scope>test</scope>
</dependency>
<dependency>
<groupId>org.ops4j.pax.url</groupId>
<artifactId>pax-url-aether</artifactId>
+ <version>${pax.url.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.tinybundles</groupId>
+ <artifactId>tinybundles</artifactId>
+ <version>2.1.1</version>
+ <scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.framework</artifactId>
+ <version>5.6.8</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.configadmin</artifactId>
+ <version>1.8.16</version>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
+ <version>1.2.3</version>
+ <scope>test</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
+ <version>1.2.3</version>
+ <scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.ops4j.pax.exam</groupId>
- <artifactId>pax-exam</artifactId>
- </dependency>
- <dependency>
- <groupId>org.ops4j.pax.exam</groupId>
- <artifactId>pax-exam-junit4</artifactId>
- </dependency>
- <dependency>
- <groupId>org.ops4j.pax.url</groupId>
- <artifactId>pax-url-wrap</artifactId>
- </dependency>
- <dependency>
- <groupId>org.ops4j.pax.url</groupId>
- <artifactId>pax-url-reference</artifactId>
- </dependency>
-
</dependencies>
</project>
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/d0e9a65f/osgi/common/src/main/java/org/apache/tamaya/osgi/commands/StringUtil.java
----------------------------------------------------------------------
diff --git a/osgi/common/src/main/java/org/apache/tamaya/osgi/commands/StringUtil.java b/osgi/common/src/main/java/org/apache/tamaya/osgi/commands/StringUtil.java
index b6819e8..f7b29ac 100644
--- a/osgi/common/src/main/java/org/apache/tamaya/osgi/commands/StringUtil.java
+++ b/osgi/common/src/main/java/org/apache/tamaya/osgi/commands/StringUtil.java
@@ -21,7 +21,7 @@ package org.apache.tamaya.osgi.commands;
/**
* Some String related helper methods.
*/
-final class StringUtil {
+public final class StringUtil {
private StringUtil(){}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/d0e9a65f/osgi/common/src/test/java/org/apache/tamaya/osgi/AbstractOSGITest.java
----------------------------------------------------------------------
diff --git a/osgi/common/src/test/java/org/apache/tamaya/osgi/AbstractOSGITest.java b/osgi/common/src/test/java/org/apache/tamaya/osgi/AbstractOSGITest.java
new file mode 100644
index 0000000..ac3de0e
--- /dev/null
+++ b/osgi/common/src/test/java/org/apache/tamaya/osgi/AbstractOSGITest.java
@@ -0,0 +1,89 @@
+/*
+ * 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.junit.Before;
+import org.mockito.Mock;
+import org.mockito.stubbing.Answer;
+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;
+
+ @Before
+ public void setup()throws Exception{
+ when(cm.getConfiguration(any())).then(invocation -> {
+ return initConfigurationMock((String)invocation.getArguments()[0]);
+ });
+ 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);
+ }
+ return new Hashtable<>(props);
+ }).when(config).getProperties();
+ return config;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/d0e9a65f/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
new file mode 100644
index 0000000..e175535
--- /dev/null
+++ b/osgi/common/src/test/java/org/apache/tamaya/osgi/OSGIBasicTests.java
@@ -0,0 +1,84 @@
+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/d0e9a65f/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 b65c4d4..0000000
--- a/osgi/common/src/test/java/org/apache/tamaya/osgi/OSGITest.java
+++ /dev/null
@@ -1,127 +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.*;
-
-@RunWith(PaxExam.class)
-@ExamReactorStrategy(PerMethod.class)
-@Ignore
-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 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/d0e9a65f/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 61d76a2..accc0f0 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
@@ -18,60 +18,92 @@
*/
package org.apache.tamaya.osgi;
+import javafx.beans.binding.Bindings;
+import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.runners.MockitoJUnitRunner;
+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 javax.inject.Inject;
+
+import java.util.Collections;
+import java.util.Dictionary;
+import java.util.Hashtable;
import static org.junit.Assert.*;
+import static org.mockito.Mockito.doReturn;
/**
* Created by atsticks on 10.12.16.
*/
-@Ignore
-public class TamayaConfigPluginTest {
+@RunWith(MockitoJUnitRunner.class)
+public class TamayaConfigPluginTest extends AbstractOSGITest{
- private TamayaConfigPlugin configAdmin = new TamayaConfigPlugin(null);
+ @Test
+ public void pluginLoaded() throws Exception {
+ assertNotNull(bundleContext.getService(bundleContext.getServiceReference(TamayaConfigPlugin.class)));
+ }
@Test
- public void createConfigurationOverride() throws Exception {
-// Configuration getConfig = configAdmin.createFactoryConfiguration("tamaya");
-// assertNotNull(getConfig);
-// assertFalse(getConfig.getProperties().isEmpty());
-// assertEquals(getConfig.getProperties().size(), 4);
-// assertEquals(getConfig.getProperties().get("my.testProperty1"), "success1");
+ public void testOperationMode() throws Exception {
+ OperationMode om = tamayaConfigPlugin.getDefaultOperationMode();
+ tamayaConfigPlugin.setDefaultOperationMode(OperationMode.EXTEND);
+ assertEquals(OperationMode.EXTEND, tamayaConfigPlugin.getDefaultOperationMode());
+ tamayaConfigPlugin.setDefaultOperationMode(OperationMode.OVERRIDE);
+ }
+
+ @Test
+ public void testAutoUpdate() throws Exception {
+ boolean autoUpdate = tamayaConfigPlugin.isAutoUpdateEnabled();
+ tamayaConfigPlugin.setAutoUpdateEnabled(!autoUpdate);
+ assertEquals(tamayaConfigPlugin.isAutoUpdateEnabled(),!autoUpdate);
+ tamayaConfigPlugin.setAutoUpdateEnabled(autoUpdate);
+ assertEquals(tamayaConfigPlugin.isAutoUpdateEnabled(),autoUpdate);
+ }
+
+ @Test
+ public void testDefaulEnabled() throws Exception {
+ boolean enabled = tamayaConfigPlugin.isTamayaEnabledByDefault();
+ tamayaConfigPlugin.setTamayaEnabledByDefault(!enabled);
+ assertEquals(tamayaConfigPlugin.isTamayaEnabledByDefault(),!enabled);
+ tamayaConfigPlugin.setTamayaEnabledByDefault(enabled);
+ assertEquals(tamayaConfigPlugin.isTamayaEnabledByDefault(),enabled);
+ }
+
+ @Test
+ public void testSetPluginConfig() throws Exception {
+ Dictionary<String,Object> config = new Hashtable<>();
+ tamayaConfigPlugin.setPluginConfig(config);
+ assertEquals(tamayaConfigPlugin.getPluginConfig(), config);
+ }
+
+ @Test
+ public void testSetGetConfigValue() throws Exception {
+ Dictionary<String,Object> config = new Hashtable<>();
+ String val = (String)tamayaConfigPlugin.getConfigValue("foo");
+ tamayaConfigPlugin.setConfigValue("bar", "foo");
+ assertEquals(tamayaConfigPlugin.getConfigValue("bar"), "foo");
+ }
+
+ @Test
+ public void getTMUpdateConfig() throws Exception {
+ org.apache.tamaya.Configuration config = tamayaConfigPlugin.getTamayaConfiguration("java.");
+ assertNotNull(config);
+ assertNull(config.get("jlkjllj"));
+ assertEquals(config.get("home"),System.getProperty("java.home"));
+ }
+
+ public void getUpdateConfig() throws Exception {
+ Dictionary<String, Object> config = tamayaConfigPlugin.updateConfig("getUpdateConfig");
+ assertNotNull(config);
+ assertEquals(config.get("java.home"), System.getProperty("java.home"));
}
-//
-// @Test
-// public void createFactoryConfigurationWithLocation() throws Exception {
-// Configuration getConfig = configAdmin.createFactoryConfiguration("tamaya", "location");
-// assertNotNull(getConfig);
-// assertFalse(getConfig.getProperties().isEmpty());
-// assertEquals(getConfig.getProperties().size(), 4);
-// assertEquals(getConfig.getProperties().get("my.testProperty2"), "success2");
-// }
-//
-// @Test
-// public void getTamayaConfiguration() throws Exception {
-// Configuration getConfig = configAdmin.getTamayaConfiguration("tamaya");
-// assertNotNull(getConfig);
-// assertFalse(getConfig.getProperties().isEmpty());
-// assertEquals(getConfig.getProperties().size(), 4);
-// assertEquals(getConfig.getProperties().get("my.testProperty3"), "success3");
-// }
-//
-// @Test
-// public void getConfigurationWithLocation() throws Exception {
-// Configuration getConfig = configAdmin.getTamayaConfiguration("tamaya", "location");
-// assertNotNull(getConfig);
-// assertFalse(getConfig.getProperties().isEmpty());
-// assertEquals(getConfig.getProperties().size(), 4);
-// assertEquals(getConfig.getProperties().get("my.testProperty4"), "success4");
-// }
-//
-// @Test
-// public void listConfigurations() throws Exception {
-// Configuration[] configs = configAdmin.listConfigurations(".*");
-// assertNotNull(configs);
-// }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/d0e9a65f/osgi/common/src/test/resources/arquillian.xml
----------------------------------------------------------------------
diff --git a/osgi/common/src/test/resources/arquillian.xml b/osgi/common/src/test/resources/arquillian.xml
deleted file mode 100644
index a4c885a..0000000
--- a/osgi/common/src/test/resources/arquillian.xml
+++ /dev/null
@@ -1,27 +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 current 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.
--->
-<arquillian xmlns="http://jboss.org/schema/arquillian" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
-
- <container qualifier="osgi" default="true">
- <configuration>
- <property name="frameworkProperties">src/test/resources/felix.properties</property>
- </configuration>
- </container>
-</arquillian>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/d0e9a65f/osgi/common/src/test/resources/felix.properties
----------------------------------------------------------------------
diff --git a/osgi/common/src/test/resources/felix.properties b/osgi/common/src/test/resources/felix.properties
deleted file mode 100644
index 4630fa2..0000000
--- a/osgi/common/src/test/resources/felix.properties
+++ /dev/null
@@ -1,23 +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.
-#
-# org.osgi.service.cm;org.apache.felix.cm;org.apache.tamaya;org.apache.tamaya.spi;
-org.osgi.framework.bootdelegation=org.apache.tamaya,org.apache.tamaya.osgi,org.apache.tamaya.osgi.test
-felix.log.level=4 #debug logging
-# felix.auto.deploy.dir=../test-bundles
-org.osgi.framework.storage=target/felix-cache
-felix.fileinstall.dir=./test-bundles
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/d0e9a65f/osgi/pom.xml
----------------------------------------------------------------------
diff --git a/osgi/pom.xml b/osgi/pom.xml
index ab3bf61..9f0edf9 100644
--- a/osgi/pom.xml
+++ b/osgi/pom.xml
@@ -79,24 +79,25 @@
<groupId>org.osgi</groupId>
<artifactId>org.osgi.service.cm</artifactId>
<version>${osgi.config.version}</version>
- <!--<scope>provided</scope>-->
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
<version>${osgi.version}</version>
- <!--<scope>provided</scope>-->
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.compendium</artifactId>
<version>${osgi.compendium.version}</version>
- <!--<scope>provided</scope>-->
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.util.tracker</artifactId>
<version>${osgi.tracker.version}</version>
+ <scope>provided</scope>
</dependency>
<dependency>
@@ -185,51 +186,7 @@
<version>4.9.2</version>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.ops4j.pax.logging</groupId>
- <artifactId>pax-logging-api</artifactId>
- <version>${dependency.pax.logging.version}</version>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- <version>${dependency.slf4j.version}</version>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-ext</artifactId>
- <version>${dependency.slf4j.version}</version>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-simple</artifactId>
- <version>${dependency.slf4j.version}</version>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- <version>${dependency.slf4j.version}</version>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>jul-to-slf4j</artifactId>
- <version>${dependency.slf4j.version}</version>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>jcl-over-slf4j</artifactId>
- <version>${dependency.slf4j.version}</version>
- </dependency>
- <dependency>
- <groupId>ch.qos.logback</groupId>
- <artifactId>logback-core</artifactId>
- <version>${dependency.logback.version}</version>
- </dependency>
- <dependency>
- <groupId>ch.qos.logback</groupId>
- <artifactId>logback-classic</artifactId>
- <version>${dependency.logback.version}</version>
- </dependency>
+
<dependency>
<groupId>org.kohsuke.metainf-services</groupId>