You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by jb...@apache.org on 2019/05/12 04:39:43 UTC

[karaf] branch master updated: [KARAF-6277] Upgrade to Felix HTTP 4.0.8 and add new itests (#835)

This is an automated email from the ASF dual-hosted git repository.

jbonofre pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/karaf.git


The following commit(s) were added to refs/heads/master by this push:
     new 612dc4a  [KARAF-6277] Upgrade to Felix HTTP 4.0.8 and add new itests (#835)
612dc4a is described below

commit 612dc4a14e9ff29b40486d5808bb83eb3486060e
Author: Jean-Baptiste Onofré <jb...@apache.org>
AuthorDate: Sun May 12 06:39:37 2019 +0200

    [KARAF-6277] Upgrade to Felix HTTP 4.0.8 and add new itests (#835)
    
    [KARAF-6277] Upgrade to Felix HTTP 4.0.8 and add new itests
---
 .../features/standard/src/main/feature/feature.xml | 14 +++--
 .../org/apache/karaf/itests/FelixHttpTest.java     | 63 ++++++++++++++++++++++
 .../itests/features/StandardFeaturesTest.java      | 10 ++++
 pom.xml                                            |  6 +++
 4 files changed, 88 insertions(+), 5 deletions(-)

diff --git a/assemblies/features/standard/src/main/feature/feature.xml b/assemblies/features/standard/src/main/feature/feature.xml
index 09a2d14..1b5ab7f 100644
--- a/assemblies/features/standard/src/main/feature/feature.xml
+++ b/assemblies/features/standard/src/main/feature/feature.xml
@@ -829,12 +829,12 @@ start-level = admin                           # admin can set any start level, i
         <requirement>http-service</requirement>
     </feature>
 
-    <feature name="httplite" version="${project.version}" description="Felix Httplite OSGi HTTP Service">
+    <feature name="felix-httplite" version="${felix.httplite.version}" description="Felix Httplite HTTP Service">
         <bundle start-level="30">mvn:org.apache.felix/org.apache.felix.httplite.complete/${felix.httplite.version}</bundle>
         <capability>http-service;provider:=felix-httplite</capability>
     </feature>
 
-    <feature name="felix-http" version="4.0.6" description="Felix HTTP Jetty Service">
+    <feature name="felix-http" version="${felix.http.version}" description="Felix HTTP Service">
         <config name="org.apache.felix.http">
 ################################################################################
 #
@@ -855,12 +855,16 @@ start-level = admin                           # admin can set any start level, i
 #
 ################################################################################
 
-org.apache.felix.http.port=8181
+org.osgi.service.http.port=8181
         </config>
         <bundle start-level="30" dependency="true">mvn:org.apache.felix/org.apache.felix.http.servlet-api/1.1.2</bundle>
-        <bundle start-level="30">mvn:org.apache.felix/org.apache.felix.http.jetty/4.0.6</bundle>
+        <bundle start-level="30">mvn:org.apache.felix/org.apache.felix.http.jetty/${felix.http.version}</bundle>
         <bundle start-level="30">mvn:org.apache.felix/org.apache.felix.http.whiteboard/4.0.0</bundle>
-        <capability>http-service;provider:=felix</capability>
+        <capability>http-service;provider:=felix-http</capability>
+        <conditional>
+            <condition>webconsole</condition>
+            <bundle start-level="30">mvn:org.apache.karaf.webconsole/org.apache.karaf.webconsole.http/${project.version}</bundle>
+        </conditional>
     </feature>
 
     <feature name="pax-http-service" description="Pax-Web OSGi HTTP Service" version="${pax.web.version}">
diff --git a/itests/test/src/test/java/org/apache/karaf/itests/FelixHttpTest.java b/itests/test/src/test/java/org/apache/karaf/itests/FelixHttpTest.java
new file mode 100644
index 0000000..64c013c
--- /dev/null
+++ b/itests/test/src/test/java/org/apache/karaf/itests/FelixHttpTest.java
@@ -0,0 +1,63 @@
+/*
+ *  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.karaf.itests;
+
+import org.junit.Before;
+import org.junit.Test;
+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.PerClass;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.net.URL;
+
+@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerClass.class)
+public class FelixHttpTest extends KarafTestSupport {
+
+    @Before
+    public void setup() throws Exception {
+        installAndAssertFeature("felix-http");
+    }
+
+    @Test
+    public void testHttpService() throws Exception {
+        waitForService("(objectClass=org.osgi.service.http.HttpService)", 5000);
+
+        installBundle("mvn:org.apache.karaf.examples/karaf-servlet-example-registration/" + System.getProperty("karaf.version"), true);
+
+        URL url = new URL("http://localhost:8181/servlet-example");
+        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
+        connection.setRequestMethod("GET");
+        connection.setDoInput(true);
+
+        BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
+        String line;
+        StringBuffer buffer = new StringBuffer();
+        while ((line = reader.readLine()) != null) {
+            buffer.append(line);
+        }
+
+        String output = buffer.toString();
+        System.out.println(output);
+        assertContains("<h1>Example Servlet</h1>", output);
+    }
+
+}
diff --git a/itests/test/src/test/java/org/apache/karaf/itests/features/StandardFeaturesTest.java b/itests/test/src/test/java/org/apache/karaf/itests/features/StandardFeaturesTest.java
index ae6fc1d..7d1ff56 100644
--- a/itests/test/src/test/java/org/apache/karaf/itests/features/StandardFeaturesTest.java
+++ b/itests/test/src/test/java/org/apache/karaf/itests/features/StandardFeaturesTest.java
@@ -95,6 +95,16 @@ public class StandardFeaturesTest extends KarafTestSupport {
     public void installWebConsoleFeature() throws Exception {
         installAssertAndUninstallFeatures("webconsole");
     }
+
+    @Test
+    public void installFelixHttplisteFeature() throws Exception {
+        installAssertAndUninstallFeatures("felix-httplite");
+    }
+
+    @Test
+    public void installFelixHttpFeature() throws Exception {
+        installAssertAndUninstallFeatures("felix-http");
+    }
     
     @Test
     public void installSchedulerFeature() throws Exception {
diff --git a/pom.xml b/pom.xml
index 83429ff..b7be17a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -203,6 +203,7 @@
         <felix.gogo.runtime.version>1.1.2</felix.gogo.runtime.version>
         <felix.gogo.jline.version>1.1.4</felix.gogo.jline.version>
         <felix.httplite.version>0.1.6</felix.httplite.version>
+        <felix.http.version>4.0.8</felix.http.version>
         <felix.inventory.version>1.0.4</felix.inventory.version>
         <felix.plugin.version>4.1.0</felix.plugin.version>
         <felix.utils.version>1.11.2</felix.utils.version>
@@ -966,6 +967,11 @@
             </dependency>
             <dependency>
                 <groupId>org.apache.felix</groupId>
+                <artifactId>org.apache.felix.http.jetty</artifactId>
+                <version>${felix.http.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>org.apache.felix</groupId>
                 <artifactId>org.apache.felix.eventadmin</artifactId>
                 <version>${felix.eventadmin.version}</version>
                 <exclusions>