merge Jetty 9.4 branch

This commit is contained in:
olivier lamy 2017-05-18 13:48:37 +10:00
commit de4bdc329e
5 changed files with 39 additions and 59 deletions

View File

@ -1,7 +1,6 @@
language: java
jdk:
- openjdk7
- oraclejdk7
- oraclejdk8
script: "mvn clean install"

View File

@ -73,7 +73,7 @@
<properties>
<springVersion>4.2.1.RELEASE</springVersion>
<slf4jVersion>1.7.12</slf4jVersion>
<log4j2Version>2.3</log4j2Version>
<log4j2Version>2.8.2</log4j2Version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<gpg.useagent>true</gpg.useagent>

View File

@ -33,6 +33,7 @@
<properties>
<tomcatVersion>7.0.57</tomcatVersion>
<jetty.version>9.4.5.v20170502</jetty.version>
<rest.test.timeout>1000000</rest.test.timeout>
</properties>
@ -138,34 +139,14 @@
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-core</artifactId>
<version>${tomcatVersion}</version>
<scope>test</scope>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>${jetty.version}</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-juli</artifactId>
<version>${tomcatVersion}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-logging-juli</artifactId>
<version>${tomcatVersion}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-servlet-api</artifactId>
<version>${tomcatVersion}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-jsp-api</artifactId>
<version>${tomcatVersion}</version>
<scope>provided</scope>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
<version>${jetty.version}</version>
</dependency>
<dependency>

View File

@ -27,21 +27,24 @@ import org.apache.archiva.redback.rest.api.services.LdapGroupMappingService;
import org.apache.archiva.redback.rest.api.services.LoginService;
import org.apache.archiva.redback.rest.api.services.RoleManagementService;
import org.apache.archiva.redback.rest.api.services.UserService;
import org.apache.catalina.Context;
import org.apache.catalina.deploy.ApplicationParameter;
import org.apache.catalina.startup.Tomcat;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.SystemUtils;
import org.apache.cxf.common.util.Base64Utility;
import org.apache.cxf.jaxrs.client.JAXRSClientFactory;
import org.apache.cxf.jaxrs.client.WebClient;
import org.apache.cxf.transport.servlet.CXFServlet;
import org.eclipse.jetty.server.HttpConnectionFactory;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.server.session.SessionHandler;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;
import org.junit.After;
import org.junit.Before;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.bridge.SLF4JBridgeHandler;
import org.springframework.web.context.ContextLoaderListener;
import javax.ws.rs.core.MediaType;
@ -56,8 +59,8 @@ public abstract class AbstractRestServicesTest
{
protected Logger log = LoggerFactory.getLogger( getClass() );
private Tomcat tomcat;
Server server;
ServerConnector serverConnector;
public int port;
public String authorizationHeader = getAdminAuthzHeader();
@ -98,30 +101,27 @@ public abstract class AbstractRestServicesTest
public void startServer()
throws Exception
{
server = new Server();
serverConnector = new ServerConnector( server, new HttpConnectionFactory());
server.addConnector(serverConnector);
SLF4JBridgeHandler.removeHandlersForRootLogger();
ServletHolder servletHolder = new ServletHolder( new CXFServlet() );
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
context.setResourceBase( SystemUtils.JAVA_IO_TMPDIR );
context.setSessionHandler( new SessionHandler( ) );
context.addServlet( servletHolder, "/" + getRestServicesPath() + "/*" );
context.setInitParameter( "contextConfigLocation", getSpringConfigLocation() );
context.addEventListener(new ContextLoaderListener());
SLF4JBridgeHandler.install();
server.setHandler( context );
server.start();
tomcat = new Tomcat();
tomcat.setBaseDir( System.getProperty( "java.io.tmpdir" ) );
tomcat.setPort( 0 );
if (log.isDebugEnabled())
{
log.debug( "jetty dump: {}", server.dump() );
}
Context context = tomcat.addContext( "", System.getProperty( "java.io.tmpdir" ) );
ApplicationParameter applicationParameter = new ApplicationParameter();
applicationParameter.setName( "contextConfigLocation" );
applicationParameter.setValue( getSpringConfigLocation() );
context.addApplicationParameter( applicationParameter );
context.addApplicationListener( ContextLoaderListener.class.getName() );
Tomcat.addServlet( context, "cxf", new CXFServlet() );
context.addServletMapping( "/" + getRestServicesPath() + "/*", "cxf" );
tomcat.start();
this.port = tomcat.getConnector().getLocalPort();
this.port = serverConnector.getLocalPort();
log.info( "start server on port {}", this.port );
@ -143,16 +143,16 @@ public abstract class AbstractRestServicesTest
{
return JAXRSClientFactory.create(
"http://localhost:" + port + "/" + getRestServicesPath() + "/fakeCreateAdminService/",
FakeCreateAdminService.class, Collections.singletonList( new com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider() ) );
FakeCreateAdminService.class, Collections.singletonList( new JacksonJaxbJsonProvider() ) );
}
@After
public void stopServer()
throws Exception
{
if ( this.tomcat != null )
if ( this.server != null )
{
this.tomcat.stop();
this.server.stop();
}
}

View File

@ -31,7 +31,7 @@
<logger name="org.springframework" level="error"/>
<logger name="org.apache.archiva.redback.components.cache" level="error"/>
<logger name="org.apache.archiva.redback.rest.services.interceptors" level="debug"/>
<logger name="org.apache.archiva.redback.rest.services" level="debug"/>
<logger name="org.apache.archiva.redback.rest.services" level="info"/>
<logger name="org.apache.catalina" level="off" />
<logger name="JPOX" level="ERROR"/>
<root level="info">