Skip to content

Commit

Permalink
[#1802] Switch pax-web-itest-server from javax to jakarta (only 2 jet…
Browse files Browse the repository at this point in the history
…ty/websocket tests fail!)
  • Loading branch information
grgrzybek committed Jun 19, 2023
1 parent 29f2c1f commit 95d42dc
Show file tree
Hide file tree
Showing 83 changed files with 659 additions and 459 deletions.
29 changes: 19 additions & 10 deletions pax-web-itest/pax-web-itest-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,11 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.ops4j.pax.web.samples</groupId>
<artifactId>the-wab-jar</artifactId>
<scope>test</scope>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.ops4j.pax.web.samples</groupId>-->
<!-- <artifactId>the-wab-jar</artifactId>-->
<!-- <scope>test</scope>-->
<!-- </dependency>-->

<!-- OPS4J dependencies -->

Expand All @@ -151,11 +151,11 @@
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>osgi.cmpn</artifactId>
<artifactId>org.osgi.service.servlet</artifactId>
<scope>test</scope>
</dependency>

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

<dependency>
<groupId>jakarta.el</groupId>
Expand All @@ -172,14 +172,19 @@
<artifactId>jakarta.websocket-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>jakarta.websocket</groupId>
<artifactId>jakarta.websocket-client-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-jsp-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.taglibs</groupId>
<artifactId>taglibs-standard-impl</artifactId>
<groupId>org.glassfish.web</groupId>
<artifactId>jakarta.servlet.jsp.jstl</artifactId>
<scope>test</scope>
</dependency>

Expand Down Expand Up @@ -273,7 +278,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 Expand Up @@ -310,6 +315,10 @@

<!-- Testing -->

<!--
Stay at JUnit 4 with much better @Parameterized support
https://github.com/junit-team/junit5/issues/878
-->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
package org.ops4j.pax.web.test.tags;

import java.io.IOException;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;
import jakarta.servlet.jsp.JspException;
import jakarta.servlet.jsp.tagext.TagSupport;

public class TestTag extends TagSupport {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ org.apache.el.ExpressionFactoryImpl

# The service-impl-first in this file is because it's required by jakarta.el:jakarta.el-api:3.0.3 and we treat
# it as _canonical_ EL API Jar
# Its javax.el.FactoryFinder class reads only the first line of this file...
# Its jakarta.el.FactoryFinder class reads only the first line of this file...
# org.apache.tomcat:tomcat-el skips the comments correctly because it's using generic java.util.ServiceLoader API
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,18 @@
import java.util.concurrent.Executors;
import java.util.function.Consumer;
import java.util.function.Supplier;
import javax.servlet.Filter;
import javax.servlet.Servlet;
import javax.servlet.ServletContainerInitializer;
import javax.servlet.ServletContext;
import jakarta.servlet.Filter;
import jakarta.servlet.Servlet;
import jakarta.servlet.ServletContainerInitializer;
import jakarta.servlet.ServletContext;

import org.apache.commons.compress.archivers.ArchiveEntry;
import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream;
import org.apache.commons.io.IOUtils;
import org.apache.felix.utils.extender.Extension;
import org.apache.jasper.servlet.JspServlet;
import org.apache.tomcat.websocket.server.WsSci;
import org.eclipse.jetty.websocket.javax.server.config.JavaxWebSocketServletContainerInitializer;
import org.eclipse.jetty.ee10.websocket.jakarta.server.config.JakartaWebSocketServletContainerInitializer;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
Expand Down Expand Up @@ -133,10 +133,10 @@
import org.osgi.framework.wiring.BundleRevision;
import org.osgi.framework.wiring.BundleWire;
import org.osgi.framework.wiring.BundleWiring;
import org.osgi.service.http.HttpContext;
import org.osgi.service.http.context.ServletContextHelper;
import org.osgi.service.http.whiteboard.HttpWhiteboardConstants;
import org.osgi.service.http.whiteboard.Preprocessor;
import org.ops4j.pax.web.service.http.HttpContext;
import org.osgi.service.servlet.context.ServletContextHelper;
import org.osgi.service.servlet.whiteboard.HttpWhiteboardConstants;
import org.osgi.service.servlet.whiteboard.Preprocessor;
import org.osgi.util.tracker.ServiceTracker;
import org.osgi.util.tracker.ServiceTrackerCustomizer;
import org.slf4j.Logger;
Expand Down Expand Up @@ -257,13 +257,13 @@ public void initAll() throws Exception {
when(jspBundle.getBundleId()).thenReturn(101L);
when(jspBundle.getState()).thenReturn(Bundle.ACTIVE);
when(jspBundle.getEntry("/")).thenReturn(new URL("bundle://101.0:0/"));
when(jspBundle.getResources("META-INF/services/javax.el.ExpressionFactory"))
when(jspBundle.getResources("META-INF/services/jakarta.el.ExpressionFactory"))
.thenReturn(Collections.enumeration(Collections.singletonList(
org.ops4j.pax.web.jsp.JspServlet.class.getResource("/META-INF/services/javax.el.ExpressionFactory")))
org.ops4j.pax.web.jsp.JspServlet.class.getResource("/META-INF/services/jakarta.el.ExpressionFactory")))
);
when(jspBundle.getResources("META-INF/services/javax.servlet.ServletContainerInitializer"))
when(jspBundle.getResources("META-INF/services/jakarta.servlet.ServletContainerInitializer"))
.thenReturn(Collections.enumeration(Collections.singletonList(
org.ops4j.pax.web.jsp.JspServlet.class.getResource("/META-INF/services/javax.servlet.ServletContainerInitializer")))
org.ops4j.pax.web.jsp.JspServlet.class.getResource("/META-INF/services/jakarta.servlet.ServletContainerInitializer")))
);
when(jspBundle.loadClass(anyString()))
.thenAnswer(i -> JspServlet.class.getClassLoader().loadClass(i.getArgument(0, String.class)));
Expand Down Expand Up @@ -337,7 +337,7 @@ public void initAll() throws Exception {

if (enableWebSockets()) {
wsGenericBundle = mockBundle("org.ops4j.pax.web.pax-web-websocket", null, false);
wsJettyBundle = mockBundle("org.eclipse.jetty.websocket.javax.server", null, false);
wsJettyBundle = mockBundle("org.eclipse.jetty.ee10.websocket.jakarta.server", null, false);
wsTomcatBundle = mockBundle("org.ops4j.pax.web.pax-web-tomcat-websocket", null, false);
wsUndertowBundle = mockBundle("org.ops4j.pax.web.pax-web-undertow-websocket", null, false);

Expand All @@ -353,7 +353,7 @@ public void initAll() throws Exception {
when(wsGenericBundle.loadClass(anyString()))
.thenAnswer(i -> PaxWebWebSocketsServletContainerInitializer.class.getClassLoader().loadClass(i.getArgument(0, String.class)));
when(wsJettyBundle.loadClass(anyString()))
.thenAnswer(i -> JavaxWebSocketServletContainerInitializer.class.getClassLoader().loadClass(i.getArgument(0, String.class)));
.thenAnswer(i -> JakartaWebSocketServletContainerInitializer.class.getClassLoader().loadClass(i.getArgument(0, String.class)));
when(wsTomcatBundle.loadClass(anyString()))
.thenAnswer(i -> WsSci.class.getClassLoader().loadClass(i.getArgument(0, String.class)));
when(wsUndertowBundle.loadClass(anyString()))
Expand Down Expand Up @@ -482,7 +482,7 @@ protected Bundle mockBundle(String symbolicName, String contextPath, boolean obt
}

try {
when(bundle.getResources("META-INF/services/javax.servlet.ServletContainerInitializer"))
when(bundle.getResources("META-INF/services/jakarta.servlet.ServletContainerInitializer"))
.thenReturn(Collections.emptyEnumeration());
} catch (IOException ignored) {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,18 @@
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.Servlet;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletRequestAttributeEvent;
import javax.servlet.ServletRequestAttributeListener;
import javax.servlet.http.HttpFilter;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.Filter;
import jakarta.servlet.FilterChain;
import jakarta.servlet.Servlet;
import jakarta.servlet.ServletConfig;
import jakarta.servlet.ServletContext;
import jakarta.servlet.ServletException;
import jakarta.servlet.ServletRequestAttributeEvent;
import jakarta.servlet.ServletRequestAttributeListener;
import jakarta.servlet.http.HttpFilter;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import org.junit.Test;
import org.junit.runner.RunWith;
Expand Down Expand Up @@ -70,7 +70,7 @@
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import org.osgi.service.http.HttpContext;
import org.ops4j.pax.web.service.http.HttpContext;

import static org.hamcrest.CoreMatchers.endsWith;
import static org.hamcrest.CoreMatchers.equalTo;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
package org.ops4j.pax.web.itest.server.controller;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.ServletRegistration;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.ServletException;
import jakarta.servlet.ServletRegistration;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import org.junit.Test;
import org.junit.runner.RunWith;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import java.io.FileNotFoundException;
import java.util.Arrays;
import java.util.Collections;
import javax.servlet.Servlet;
import jakarta.servlet.Servlet;

import org.junit.Test;
import org.junit.runner.RunWith;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
Expand All @@ -37,7 +37,7 @@
import org.ops4j.pax.web.service.spi.ServerController;
import org.ops4j.pax.web.service.spi.model.ServerModel;
import org.osgi.framework.Bundle;
import org.osgi.service.http.HttpContext;
import org.ops4j.pax.web.service.http.HttpContext;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@

import java.util.Arrays;
import java.util.Collections;
import javax.servlet.Filter;
import javax.servlet.Servlet;
import javax.servlet.ServletContext;
import jakarta.servlet.Filter;
import jakarta.servlet.Servlet;
import jakarta.servlet.ServletContext;

import org.junit.Test;
import org.junit.runner.RunWith;
Expand Down Expand Up @@ -65,7 +65,7 @@ public void initAll() throws Exception {
}

/**
* {@link Servlet}, {@link Filter} and {@link org.osgi.service.http.context.ServletContextHelper}
* {@link Servlet}, {@link Filter} and {@link org.osgi.service.servlet.context.ServletContextHelper}
* are registered from single {@link Bundle} and associated with each other.
* @throws Exception
*/
Expand Down Expand Up @@ -162,7 +162,7 @@ public void singleServletContext() throws Exception {
}

/**
* {@link Servlet}, {@link Filter} and {@link org.osgi.service.http.context.ServletContextHelper}
* {@link Servlet}, {@link Filter} and {@link org.osgi.service.servlet.context.ServletContextHelper}
* are registered through different bundle-scoped instances of {@link WebContainerContext}.
* @throws Exception
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
import java.io.IOException;
import java.util.Dictionary;
import java.util.Hashtable;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import org.junit.Test;
import org.junit.runner.RunWith;
Expand All @@ -34,7 +34,7 @@
import org.ops4j.pax.web.service.spi.model.OsgiContextModel;
import org.osgi.framework.Bundle;
import org.osgi.framework.ServiceReference;
import org.osgi.service.http.HttpContext;
import org.ops4j.pax.web.service.http.HttpContext;

import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.startsWith;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import org.ops4j.pax.web.service.spi.model.OsgiContextModel;
import org.osgi.framework.Bundle;
import org.osgi.framework.ServiceReference;
import org.osgi.service.http.HttpContext;
import org.ops4j.pax.web.service.http.HttpContext;

import static org.hamcrest.CoreMatchers.endsWith;
import static org.hamcrest.CoreMatchers.startsWith;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
package org.ops4j.pax.web.itest.server.httpservice;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.descriptor.JspConfigDescriptor;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.ServletException;
import jakarta.servlet.descriptor.JspConfigDescriptor;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import org.junit.Test;
import org.junit.runner.RunWith;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import org.ops4j.pax.web.service.spi.model.OsgiContextModel;
import org.osgi.framework.Bundle;
import org.osgi.framework.ServiceReference;
import org.osgi.service.http.HttpContext;
import org.ops4j.pax.web.service.http.HttpContext;

import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.startsWith;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
import org.ops4j.pax.web.service.internal.StoppableHttpService;
import org.osgi.framework.Bundle;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.security.Principal;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
package org.ops4j.pax.web.itest.server.httpservice;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import org.apache.hc.client5.http.classic.methods.HttpGet;
import org.apache.hc.client5.http.cookie.BasicCookieStore;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
import java.io.ObjectInputStream;
import java.util.LinkedHashMap;
import java.util.Map;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import org.apache.commons.io.FileUtils;
import org.apache.hc.client5.http.classic.methods.HttpGet;
Expand Down
Loading

0 comments on commit 95d42dc

Please sign in to comment.