Author: timothyjward
Date: Wed Jan 30 09:20:04 2019
New Revision: 1852510
URL: http://svn.apache.org/viewvc?rev=1852510&view=rev
Log:
Add a capability advertising that the HttpService is provided by this bundle
Fixes [FELIX-6029]
Modified:
felix/trunk/http/itest/src/test/java/org/apache/felix/http/itest/HttpServiceTest.java
felix/trunk/http/jetty/pom.xml
Modified:
felix/trunk/http/itest/src/test/java/org/apache/felix/http/itest/HttpServiceTest.java
URL:
http://svn.apache.org/viewvc/felix/trunk/http/itest/src/test/java/org/apache/felix/http/itest/HttpServiceTest.java?rev=1852510&r1=1852509&r2=1852510&view=diff
==============================================================================
---
felix/trunk/http/itest/src/test/java/org/apache/felix/http/itest/HttpServiceTest.java
(original)
+++
felix/trunk/http/itest/src/test/java/org/apache/felix/http/itest/HttpServiceTest.java
Wed Jan 30 09:20:04 2019
@@ -19,6 +19,9 @@
package org.apache.felix.http.itest;
+import static javax.servlet.http.HttpServletResponse.SC_NOT_FOUND;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
@@ -29,6 +32,7 @@ import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
+import javax.naming.directory.SearchControls;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
@@ -44,7 +48,11 @@ import org.junit.runner.RunWith;
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.Bundle;
+import org.osgi.framework.Constants;
import org.osgi.framework.ServiceRegistration;
+import org.osgi.framework.wiring.BundleCapability;
+import org.osgi.framework.wiring.BundleWiring;
import org.osgi.service.http.HttpService;
import org.osgi.service.http.runtime.HttpServiceRuntime;
@@ -142,4 +150,43 @@ public class HttpServiceTest extends Bas
}
}
+ /**
+ * Tests the starting of Jetty.
+ */
+ @Test
+ public void testHttpServiceCapabiltiy() throws Exception
+ {
+ setupLatches(0);
+
+ Bundle httpJettyBundle = getHttpJettyBundle();
+
+ BundleWiring wiring = httpJettyBundle.adapt(BundleWiring.class);
+
+ List<BundleCapability> capabilities =
wiring.getCapabilities("osgi.service");
+
+ assertFalse(capabilities.isEmpty());
+
+ boolean found = false;
+
+ for (BundleCapability capability : capabilities) {
+ @SuppressWarnings("unchecked")
+ List<String> objectClass = (List<String>)
capability.getAttributes().get(Constants.OBJECTCLASS);
+
+ assertNotNull(objectClass);
+
+ if(objectClass.contains(HttpService.class.getName())) {
+ String uses =
capability.getDirectives().get("uses");
+
+ assertNotNull(uses);
+
+
assertTrue(uses.contains(HttpService.class.getPackage().getName()));
+
+ found = true;
+ break;
+ }
+ }
+
+ assertTrue("Missing HttpService capability", found);
+ }
+
}
Modified: felix/trunk/http/jetty/pom.xml
URL:
http://svn.apache.org/viewvc/felix/trunk/http/jetty/pom.xml?rev=1852510&r1=1852509&r2=1852510&view=diff
==============================================================================
--- felix/trunk/http/jetty/pom.xml (original)
+++ felix/trunk/http/jetty/pom.xml Wed Jan 30 09:20:04 2019
@@ -109,7 +109,9 @@
osgi.implementation;osgi.implementation="osgi.http";version:Version="1.1";
uses:="javax.servlet,javax.servlet.http,org.osgi.service.http.context,org.osgi.service.http.whiteboard",
osgi.service;objectClass:List<String>="org.osgi.service.http.runtime.HttpServiceRuntime";
-
uses:="org.osgi.service.http.runtime,org.osgi.service.http.runtime.dto"
+
uses:="org.osgi.service.http.runtime,org.osgi.service.http.runtime.dto",
+
osgi.service;objectClass:List<String>="org.osgi.service.http.HttpService";
+ uses:="org.osgi.service.http"
</Provide-Capability>
<Require-Capability>
osgi.contract;filter:="(&(osgi.contract=JavaServlet)(version=3.1))"