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 2016/12/22 21:19:33 UTC

[3/4] incubator-tamaya-sandbox git commit: TAMAYA-145: Fixed tests for basic OSGI support of the core functionality.

TAMAYA-145: Fixed tests for basic OSGI support of the core functionality.


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/a144252f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/tree/a144252f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/diff/a144252f

Branch: refs/heads/master
Commit: a144252f06417ce34e31f90f799d7b86e3e01a99
Parents: 20c558d
Author: anatole <an...@apache.org>
Authored: Thu Dec 22 22:02:46 2016 +0100
Committer: anatole <an...@apache.org>
Committed: Thu Dec 22 22:02:46 2016 +0100

----------------------------------------------------------------------
 .../org/apache/tamaya/osgi/OSGIKarafTest.java   | 23 +++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/a144252f/osgi/features/src/test/java/org/apache/tamaya/osgi/OSGIKarafTest.java
----------------------------------------------------------------------
diff --git a/osgi/features/src/test/java/org/apache/tamaya/osgi/OSGIKarafTest.java b/osgi/features/src/test/java/org/apache/tamaya/osgi/OSGIKarafTest.java
index c0c3880..236913c 100644
--- a/osgi/features/src/test/java/org/apache/tamaya/osgi/OSGIKarafTest.java
+++ b/osgi/features/src/test/java/org/apache/tamaya/osgi/OSGIKarafTest.java
@@ -20,6 +20,7 @@ package org.apache.tamaya.osgi;
 
 import org.apache.karaf.features.Feature;
 import org.apache.karaf.features.FeaturesService;
+import org.apache.tamaya.spi.ServiceContextManager;
 import org.junit.Before;
 import org.junit.Ignore;
 import org.junit.Test;
@@ -33,6 +34,7 @@ import org.ops4j.pax.exam.karaf.options.KarafDistributionOption;
 import org.ops4j.pax.exam.options.BootClasspathLibraryOption;
 import org.ops4j.pax.exam.options.MavenUrlReference;
 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.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceReference;
@@ -43,6 +45,9 @@ import javax.inject.Inject;
 import javax.swing.*;
 import java.awt.*;
 import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.util.Enumeration;
 
 import static org.junit.Assert.*;
 import static org.junit.Assert.assertEquals;
@@ -152,7 +157,7 @@ public class OSGIKarafTest {
         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("*");
+        org.osgi.service.cm.Configuration[] configs = configAdmin.listConfigurations(null);
         for (org.osgi.service.cm.Configuration cfg : configs) {
             b.append("\nConfiguration found in Karaf OSGI Container: " + cfg);
             b.append("\n-------------------------------------------------");
@@ -160,6 +165,22 @@ public class OSGIKarafTest {
         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);
+    }
+
     public ConfigurationAdmin getConfigAdmin() {
         return bundleContext.getService(bundleContext.getServiceReference(ConfigurationAdmin.class));
     }