Commit c158cda6 authored by Arent-Jan Banck's avatar Arent-Jan Banck

REPO-2139 Update JaxRS tests to work with Tomcat 9.

parent 17a41213
/*
* Copyright 2015 Hippo B.V. (http://www.onehippo.com)
* Copyright 2015-2018 Hippo B.V. (http://www.onehippo.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -55,6 +55,7 @@ public class EmbeddingTest {
tomcat.setBaseDir(getTmpTomcatFolderName());
int portNumber = PortUtil.getPortNumber(getClass());
tomcat.setPort(portNumber);
tomcat.getConnector(); // Trigger the creation of the default connector
Context context = tomcat.addContext("", getTmpTomcatFolderName());
Tomcat.addServlet(context, "embedTomcat", new HttpServlet() {
......@@ -66,7 +67,7 @@ public class EmbeddingTest {
w.flush();
}
});
context.addServletMapping("/embedTomcat/*", "embedTomcat");
context.addServletMappingDecoded("/embedTomcat/*", "embedTomcat");
tomcat.start();
......@@ -86,6 +87,7 @@ public class EmbeddingTest {
tomcat.setBaseDir(getTmpTomcatFolderName());
int portNumber = PortUtil.getPortNumber(getClass());
tomcat.setPort(portNumber);
tomcat.getConnector(); // Trigger the creation of the default connector
Context context = tomcat.addContext("", getTmpTomcatFolderName());
Wrapper servlet = context.createWrapper();
......@@ -96,7 +98,7 @@ public class EmbeddingTest {
HelloWorldResource.class.getName()
);
context.addChild(servlet);
context.addServletMapping( "/embedCXF/*", "embedCXF" );
context.addServletMappingDecoded( "/embedCXF/*", "embedCXF" );
tomcat.start();
......@@ -116,10 +118,11 @@ public class EmbeddingTest {
tomcat.setBaseDir(getTmpTomcatFolderName());
int portNumber = PortUtil.getPortNumber(getClass());
tomcat.setPort(portNumber);
tomcat.getConnector(); // Trigger the creation of the default connector
Context context = tomcat.addContext("", getTmpTomcatFolderName());
Tomcat.addServlet(context, "embedRepositoryJaxrsServlet", new RepositoryJaxrsServlet());
context.addServletMapping("/embedRepositoryJaxrsServlet/*", "embedRepositoryJaxrsServlet");
context.addServletMappingDecoded("/embedRepositoryJaxrsServlet/*", "embedRepositoryJaxrsServlet");
tomcat.start();
RepositoryJaxrsEndpoint jaxrsEndpoint = new CXFRepositoryJaxrsEndpoint("/")
......
/*
* Copyright 2015 Hippo B.V. (http://www.onehippo.com)
* Copyright 2015-2018 Hippo B.V. (http://www.onehippo.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -81,6 +81,7 @@ public class RepositoryJaxrsServiceTest extends RepositoryTestCase {
tomcat.setBaseDir(getTmpTomcatFolderName());
portNumber = PortUtil.getPortNumber(getClass());
tomcat.setPort(portNumber);
tomcat.getConnector(); // Trigger the creation of the default connector
Context context = tomcat.addContext("/plain", getTmpTomcatFolderName());
Tomcat.addServlet(context, "plain", new HttpServlet() {
protected void service(HttpServletRequest req, HttpServletResponse resp)
......@@ -91,7 +92,7 @@ public class RepositoryJaxrsServiceTest extends RepositoryTestCase {
w.flush();
}
});
context.addServletMapping("/*", "plain");
context.addServletMappingDecoded("/*", "plain");
tomcat.start();
if (HippoServiceRegistry.getService(RepositoryService.class) == null) {
......@@ -195,13 +196,13 @@ public class RepositoryJaxrsServiceTest extends RepositoryTestCase {
HelloWorldResource.class.getName()
);
context.addChild(servlet);
context.addServletMapping( "/*", "embedCXF" );
context.addServletMappingDecoded( "/*", "embedCXF" );
}
private void initializeRepoJaxrsService() {
Context context = tomcat.addContext("/jaxrs", getTmpTomcatFolderName());
Tomcat.addServlet(context, "jaxrs", new RepositoryJaxrsServlet());
context.addServletMapping("/*", "jaxrs");
context.addServletMappingDecoded("/*", "jaxrs");
}
@Test
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment