Skip to content

Commit

Permalink
[#1802] Switch pax-web-itest-osgi from javax to jakarta
Browse files Browse the repository at this point in the history
  • Loading branch information
grgrzybek committed Jun 21, 2023
1 parent 918c2fb commit fda9cd0
Show file tree
Hide file tree
Showing 18 changed files with 141 additions and 139 deletions.
19 changes: 11 additions & 8 deletions pax-web-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,6 @@
org.osgi.framework;version="[1.10,2)",
org.osgi.framework.wiring;version="[1.2,2)",

<!-- OSGi CMPN R8.1 140 Whiteboard Specification for Jakarta™ Servlet -->
org.osgi.service.servlet.context;version="2.0.0",
org.osgi.service.servlet.runtime;version="2.0.0",
org.osgi.service.servlet.runtime.dto;version="2.0.0",
org.osgi.service.servlet.whiteboard;version="2.0.0",
org.osgi.service.servlet.whiteboard.annotations;version="2.0.0",
org.osgi.service.servlet.whiteboard.propertytypes;version="2.0.0",

<!-- from pax-logging-api -->
org.slf4j;version="[2,3)"
</Import-Package>
Expand All @@ -155,6 +147,17 @@
org.ops4j.pax.web.utils;version="${pax-web.osgi.version}",
<!-- Special export for org.keycloak:keycloak-osgi-adapter:18.0.x -->
<!-- org.ops4j.pax.web.service;version="7.4",-->

<!-- re-export OSGi CMPN R7 102 HTTP Service packages, but moved to Pax Web -->
org.ops4j.pax.web.service.http;version="${pax-web.osgi.version}",

<!-- OSGi CMPN R8.1 140 Whiteboard Specification for Jakarta™ Servlet -->
org.osgi.service.servlet.context;version="2.0.0",
org.osgi.service.servlet.runtime;version="2.0.0",
org.osgi.service.servlet.runtime.dto;version="2.0.0",
org.osgi.service.servlet.whiteboard;version="2.0.0",
org.osgi.service.servlet.whiteboard.annotations;version="2.0.0",
org.osgi.service.servlet.whiteboard.propertytypes;version="2.0.0",
</Export-Package>
<Include-Resource>
{maven-resources},
Expand Down
36 changes: 22 additions & 14 deletions pax-web-itest/pax-web-itest-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,27 +54,28 @@
<configuration>
<instructions>
<Import-Package>
<!-- ranges indicate Servlet API 3.1+ (JavaEE 7+) -->
javax.servlet;version="[3.1,5)",
javax.servlet.annotation;version="[3.1,5)",
javax.servlet.http;version="[3.1,5)",
javax.websocket;resolution:=optional,
javax.websocket.server;resolution:=optional,

<!-- ranges indicate we can work with OSGi Core R6+ -->
org.osgi.framework;version="[1.8,2)",
<!-- ranges indicate Servlet API 6.0+ (JakartaEE 10+) -->
jakarta.servlet;version="[6,7)",
jakarta.servlet.annotation;version="[6,7)",
jakarta.servlet.http;version="[6,7)",

jakarta.websocket;version="[2.1,3)",
jakarta.websocket.server;version="[2.1,3)",

<!-- OSGi Core R8+ -->
org.osgi.framework;version="[1.10,2)",
org.osgi.framework.wiring;version="[1.2,2)",
org.osgi.util.tracker;version="[1.5,2)",

<!-- OSGi cmpn -->
org.osgi.service.cm;resolution:=optional,
org.osgi.service.http;version="[1.2,2)",
org.osgi.service.http.context;version="[1.1,2)",
org.osgi.service.http.runtime.dto;version="[1.1,2)",
org.osgi.service.http.runtime;version="[1.1,2)",
org.osgi.service.servlet.context;version="[2,3)",
org.osgi.service.servlet.runtime.dto;version="[2,3)",
org.osgi.service.servlet.runtime;version="[2,3)",

<!-- from pax-web-api -->
org.ops4j.pax.web.service;version="${pax-web.osgi.version}",
org.ops4j.pax.web.service.http;version="${pax-web.osgi.version}",

<!-- from pax-web-spi -->
org.ops4j.pax.web.service.spi.model.events;version="${pax-web.osgi.version}",
Expand All @@ -87,7 +88,7 @@
org.ops4j.pax.web.itest.utils.web,

<!-- from pax-logging-api -->
org.slf4j;version="[1.7,2)",
org.slf4j;version="[2,3)",
org.ops4j.pax.logging;version="[2.0,3)",

<!-- test dependencies -->
Expand Down Expand Up @@ -147,6 +148,13 @@
<artifactId>jakarta.servlet-api</artifactId>
</dependency>

<!-- OSGi -->

<dependency>
<groupId>org.osgi</groupId>
<artifactId>osgi.core</artifactId>
</dependency>

<!-- ServiceMIX -->

<dependency>
Expand Down

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions pax-web-itest/pax-web-itest-osgi/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>osgi.cmpn</artifactId>
<artifactId>org.osgi.service.servlet</artifactId>
</dependency>

<dependency>
Expand All @@ -303,7 +303,7 @@
<scope>test</scope>
</dependency>

<!-- JavaEE -->
<!-- JakartaEE -->

<dependency>
<groupId>jakarta.annotation</groupId>
Expand All @@ -313,7 +313,7 @@
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<!-- it has to be "test" - Pax Exam needs javax.servlet classes when loading @Test classes -->
<!-- it has to be "test" - Pax Exam needs jakarta.servlet classes when loading @Test classes -->
<scope>test</scope>
</dependency>

Expand All @@ -334,7 +334,7 @@
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<artifactId>log4j-slf4j2-impl</artifactId>
<scope>test</scope>
</dependency>

Expand Down
2 changes: 1 addition & 1 deletion pax-web-itest/pax-web-itest-osgi/readme.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ When using PaxExam native conainer (not Karaf container), we have two JVM instan
PaxExam itself (before even starting any implementation of `org.ops4j.pax.exam.TestContainer`) uses Slf4J API, so we definitiely want two Maven dependencies in `test` scope:

* org.slf4j:slf4j-api
* org.apache.logging.log4j:log4j-slf4j-impl
* org.apache.logging.log4j:log4j-slf4j2-impl

And configuration file like `src/test/resources/log4j2-test.properties`.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public Option[] configure() {
// to do it's job (like scanning for resources)
mavenBundle("org.ops4j.pax.web.samples", "pax-web-spi-fragment").versionAsInProject().noStart(),

// bundle and two fragments to perform searching of /META-INF/services/javax.servlet.ServletContainerInitializer
// bundle and two fragments to perform searching of /META-INF/services/jakarta.servlet.ServletContainerInitializer
mavenBundle("org.ops4j.pax.web.samples", "initializers").versionAsInProject(),
mavenBundle("org.ops4j.pax.web.samples", "initializers-fragment1").versionAsInProject().noStart(),
mavenBundle("org.ops4j.pax.web.samples", "initializers-fragment2").versionAsInProject().noStart(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import javax.inject.Inject;
import javax.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServlet;

import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
Expand All @@ -37,6 +37,7 @@
import org.ops4j.pax.web.itest.osgi.support.MockServerController;
import org.ops4j.pax.web.service.PaxWebConfig;
import org.ops4j.pax.web.service.PaxWebConstants;
import org.ops4j.pax.web.service.http.HttpService;
import org.ops4j.pax.web.service.spi.ServerController;
import org.ops4j.pax.web.service.spi.ServerControllerFactory;
import org.ops4j.pax.web.service.spi.task.Batch;
Expand All @@ -46,7 +47,6 @@
import org.osgi.framework.ServiceListener;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.ServiceRegistration;
import org.osgi.service.http.HttpService;
import org.osgi.service.metatype.AttributeDefinition;
import org.osgi.service.metatype.MetaTypeInformation;
import org.osgi.service.metatype.MetaTypeService;
Expand Down Expand Up @@ -124,7 +124,7 @@ public void registerFakeServerControllerFactory() throws Exception {
ServiceListener sl1 = (event) -> {
if (event.getType() == ServiceEvent.REGISTERED) {
String[] classes = (String[]) event.getServiceReference().getProperty(Constants.OBJECTCLASS);
if (Arrays.asList(classes).contains("org.osgi.service.http.HttpService")) {
if (Arrays.asList(classes).contains("org.ops4j.pax.web.service.http.HttpService")) {
latch1.countDown();
}
}
Expand Down Expand Up @@ -157,7 +157,7 @@ public void sendBatch(Batch batch) {
ServiceListener sl2 = (event) -> {
if (event.getType() == ServiceEvent.UNREGISTERING) {
String[] classes = (String[]) event.getServiceReference().getProperty(Constants.OBJECTCLASS);
if (Arrays.asList(classes).contains("org.osgi.service.http.HttpService")) {
if (Arrays.asList(classes).contains("org.ops4j.pax.web.service.http.HttpService")) {
latch3.countDown();
}
}
Expand Down Expand Up @@ -186,7 +186,7 @@ public void checkTrackersForHttpServiceFactory() throws Exception {
ServiceListener sl1 = (event) -> {
if (event.getType() == ServiceEvent.REGISTERED) {
String[] classes = (String[]) event.getServiceReference().getProperty(Constants.OBJECTCLASS);
if (Arrays.asList(classes).contains("org.osgi.service.http.HttpService")) {
if (Arrays.asList(classes).contains("org.ops4j.pax.web.service.http.HttpService")) {
latch1.countDown();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import java.util.List;
import java.util.Optional;
import java.util.jar.Manifest;
import javax.servlet.ServletContainerInitializer;
import jakarta.servlet.ServletContainerInitializer;

import org.apache.commons.io.IOUtils;
import org.junit.Test;
Expand Down Expand Up @@ -76,7 +76,7 @@ public Option[] configure() {
mavenBundle("org.ow2.asm", "asm-commons").version(System.getProperty("version.asm")).startLevel(START_LEVEL_TEST_BUNDLE - 1),
mavenBundle("org.ow2.asm", "asm-tree").version(System.getProperty("version.asm")).startLevel(START_LEVEL_TEST_BUNDLE - 1),

// bundle and two fragments to perform searching of /META-INF/services/javax.servlet.ServletContainerInitializer
// bundle and two fragments to perform searching of /META-INF/services/jakarta.servlet.ServletContainerInitializer
mavenBundle("org.ops4j.pax.web.samples", "initializers").versionAsInProject(),
mavenBundle("org.ops4j.pax.web.samples", "initializers-fragment1").versionAsInProject().noStart(),
mavenBundle("org.ops4j.pax.web.samples", "initializers-fragment2").versionAsInProject().noStart(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
package org.ops4j.pax.web.itest.osgi.support;

import java.net.URL;
import javax.servlet.Servlet;
import jakarta.servlet.Servlet;

import org.ops4j.pax.web.service.spi.ServerController;
import org.ops4j.pax.web.service.spi.ServerState;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@

import org.ops4j.pax.web.service.PaxWebConstants;
import org.ops4j.pax.web.service.WebContainer;
import org.ops4j.pax.web.service.http.HttpContext;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import org.osgi.service.http.HttpContext;

public class Bundle2Activator implements BundleActivator {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
import org.osgi.service.http.whiteboard.HttpWhiteboardConstants;
import org.osgi.service.servlet.whiteboard.HttpWhiteboardConstants;

public class FilterBundleActivator implements BundleActivator {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@

import org.ops4j.pax.web.service.PaxWebConstants;
import org.ops4j.pax.web.service.WebContainer;
import org.ops4j.pax.web.service.http.HttpContext;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.ServiceRegistration;
import org.osgi.service.http.HttpContext;

public class ServletBundleActivator implements BundleActivator {

Expand Down
8 changes: 4 additions & 4 deletions pax-web-spi/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,10 @@
org.osgi.util.tracker;version="[1.5,2)",

<!-- OSGi cmpn -->
org.osgi.service.servlet.context;version="[1.1,2)",
org.osgi.service.servlet.whiteboard;version="[1.1,2)",
org.osgi.service.servlet.runtime;version="[1.1,2)",
org.osgi.service.servlet.runtime.dto;version="[1.1,2)",
org.osgi.service.servlet.context;version="[2,3)",
org.osgi.service.servlet.whiteboard;version="[2,3)",
org.osgi.service.servlet.runtime;version="[2,3)",
org.osgi.service.servlet.runtime.dto;version="[2,3)",

<!-- from pax-web-api -->
org.ops4j.pax.web.service;version="${pax-web.osgi.version}",
Expand Down
2 changes: 1 addition & 1 deletion pax-web-tomcat-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
org.ops4j.pax.web.service;version="${pax-web.osgi.version}",

<!-- from pax-logging-api -->
org.apache.juli.logging,
org.apache.juli.logging;version="[9.0,11.0)",

<!-- JavaSE -->
javax.management,
Expand Down
4 changes: 2 additions & 2 deletions samples/samples-jsf/jsf-primefaces-embedded-fragment/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
-->
<Require-Bundle>org.ops4j.pax.web.samples.jsf-primefaces-commons2</Require-Bundle>
<Import-Package>
org.osgi.framework;version="[1.8,2)",
org.osgi.framework;version="[1.10,2)",
*
</Import-Package>
<Private-Package />
Expand Down Expand Up @@ -84,7 +84,7 @@
<artifactId>osgi.core</artifactId>
</dependency>

<!-- JavaEE -->
<!-- JakartaEE -->

<dependency>
<groupId>jakarta.servlet</groupId>
Expand Down
28 changes: 4 additions & 24 deletions samples/samples-jsf/jsf-primefaces-embedded/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,32 +70,12 @@
-->
<Require-Bundle>org.ops4j.pax.web.samples.jsf-primefaces-commons1</Require-Bundle>
<Import-Package>
org.osgi.framework;version="[1.8,2)",
javax.servlet;version="[3.1,5)"
javax.servlet.http;version="[3.1,5)",
org.osgi.framework;version="[1.10,2)",
jakarta.servlet;version="[6,7)"
jakarta.servlet.http;version="[6,7)",
org.ops4j.pax.web.samples.jsf3
</Import-Package>
<DynamicImport-Package>*</DynamicImport-Package>
<!-- <Import-Package>-->
<!-- javax.el,-->
<!-- javax.faces.webapp,-->
<!-- javax.servlet.jsp;version="[2.2,3.0)",-->
<!-- javax.servlet.jsp.jstl.core;version="1.2",-->
<!-- javax.servlet.jsp.jstl.fmt;version="1.2",-->
<!-- javax.servlet.jsp.jstl.tlv;version="1.2",-->
<!-- org.apache.taglibs.standard.resources;version="1.1.2",-->
<!-- org.apache.taglibs.standard.tag.common.core;version="1.1.2",-->
<!-- org.apache.taglibs.standard.tag.rt.core;version="1.1.2",-->
<!-- org.apache.taglibs.standard.tei;version="1.1.2",-->
<!-- org.apache.taglibs.standard.tlv;version="1.1.2",-->
<!-- javax.faces.*,-->
<!-- org.apache.myfaces.webapp,-->
<!-- org.apache.myfaces.config,-->
<!-- org.apache.myfaces.config.impl,-->
<!-- org.apache.myfaces.config.impl.digester,-->
<!-- org.apache.myfaces.config.impl.digester.elements,-->
<!-- *-->
<!-- </Import-Package>-->
<Private-Package />
<Export-Package>!*</Export-Package>
<!--
Expand Down Expand Up @@ -188,7 +168,7 @@
<scope>provided</scope>
</dependency>

<!-- JavaEE -->
<!-- JakartaEE -->

<dependency>
<groupId>jakarta.servlet</groupId>
Expand Down
6 changes: 3 additions & 3 deletions samples/samples-war/war-simplest-osgi/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@
</supportedProjectTypes>
<instructions>
<Import-Package>
org.osgi.framework;version="[1.8,2)",
javax.servlet.*;version="[3.1,5)",
org.osgi.framework;version="[1.10,2)",
jakarta.servlet.*;version="[6,7)",
sun.nio.ch;resolution:=optional,
*
</Import-Package>
Expand Down Expand Up @@ -113,7 +113,7 @@
are packaged in WAR
-->

<!-- JavaEE -->
<!-- JakartaEE -->

<dependency>
<groupId>jakarta.servlet</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@

import java.io.IOException;
import java.nio.charset.StandardCharsets;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

public class SimplestServlet extends HttpServlet {

Expand Down

0 comments on commit fda9cd0

Please sign in to comment.