migrate all tests to jetty 9.4

Signed-off-by: olivier lamy <olamy@apache.org>
This commit is contained in:
olivier lamy 2017-05-12 16:19:41 +10:00
parent 3c036f325b
commit e9376eeb6d
15 changed files with 143 additions and 63 deletions

View File

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!--
~ 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.
-->
<configuration>
<appenders>
<Console name="console" target="SYSTEM_OUT">
<PatternLayout pattern="%d [%t] %-5p %c %x - %m%n"/>
</Console>
</appenders>
<loggers>
<logger name="org.springframework" level="error"/>
<!--
<logger name="org.apache.http" level="debug"/>
-->
<root level="info">
<appender-ref ref="console"/>
</root>
</loggers>
</configuration>

View File

@ -38,8 +38,10 @@ import org.apache.archiva.policies.SnapshotsPolicy;
import org.apache.archiva.repository.ManagedRepositoryContent;
import org.assertj.core.api.Assertions;
import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.HttpConnectionFactory;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.server.handler.AbstractHandler;
import org.junit.After;
import org.junit.Before;
@ -164,11 +166,13 @@ public class HttpProxyTransferTest
}
};
server = new Server( 0 );
server = new Server( );
ServerConnector serverConnector = new ServerConnector( server, new HttpConnectionFactory());
server.addConnector( serverConnector );
server.setHandler( handler );
server.start();
int port = server.getConnectors()[0].getLocalPort();
int port = serverConnector.getLocalPort();
NetworkProxyConfiguration proxyConfig = new NetworkProxyConfiguration();
proxyConfig.setHost( "localhost" );

View File

@ -31,7 +31,9 @@ import org.apache.maven.index.MAVEN;
import org.apache.maven.index.NexusIndexer;
import org.apache.maven.index.expr.StringSearchExpression;
import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.server.HttpConnectionFactory;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.servlet.DefaultServlet;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;
@ -61,6 +63,7 @@ public class DownloadRemoteIndexTaskTest
{
private Server server;
private ServerConnector serverConnector;
private int port;
@ -81,12 +84,12 @@ public class DownloadRemoteIndexTaskTest
public void initialize()
throws Exception
{
server = new Server( 0 );
server = new Server( );
serverConnector = new ServerConnector( server, new HttpConnectionFactory());
server.addConnector( serverConnector );
createContext( server, new File( "src/test/" ) );
this.server.start();
Connector connector = this.server.getConnectors()[0];
this.port = connector.getLocalPort();
this.port = serverConnector.getLocalPort();
log.info( "start server on port {}", this.port );
nexusIndexer = plexusSisuBridge.lookup( NexusIndexer.class );
}

View File

@ -19,7 +19,7 @@
-->
<configuration status="debug">
<configuration>
<appenders>
<Console name="console" target="SYSTEM_OUT">
<PatternLayout pattern="%d [%t] %-5p %c %x - %m%n"/>
@ -29,7 +29,7 @@
<logger name="org.springframework" level="error"/>
<logger name="org.apache.archiva.scheduler.indexing" level="debug"/>
<logger name="org.apache.archiva.scheduler.indexing" level="info"/>
<!--
<logger name="org.apache.http" level="debug"/>
-->

View File

@ -37,7 +37,6 @@
-->
<redbackTestJdbcUrl>jdbc:hsqldb:mem:redback-test</redbackTestJdbcUrl>
<redbackTestJdbcDriver>org.hsqldb.jdbcDriver</redbackTestJdbcDriver>
<jetty.version>9.4.5.v20170502</jetty.version>
</properties>
<dependencies>
@ -387,12 +386,12 @@
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>${jetty.version}</version>
<version>${jettyVersion}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
<version>${jetty.version}</version>
<version>${jettyVersion}</version>
</dependency>
<dependency>
<groupId>xerces</groupId>

View File

@ -30,7 +30,7 @@
<logger name="org.apache.archiva.redback.rest.services" level="error"/>
<logger name="JPOX" level="error"/>
<logger name="org.apache.archiva.rest.services" level="info"/>
<logger name="org.springframework" level="info"/>
<logger name="org.springframework" level="error"/>
<logger name="org.apache.commons.configuration" level="error"/>
<root level="info">

View File

@ -235,6 +235,11 @@
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>

View File

@ -25,7 +25,9 @@ import org.apache.archiva.test.utils.ArchivaBlockJUnit4ClassRunner;
import org.apache.commons.io.FileUtils;
import org.apache.maven.wagon.providers.http.HttpWagon;
import org.apache.maven.wagon.repository.Repository;
import org.eclipse.jetty.server.HttpConnectionFactory;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;
import org.junit.After;
@ -96,7 +98,9 @@ public class DownloadArtifactsTest
// repo handler
this.repoServer = new Server( 0 );
this.repoServer = new Server( );
ServerConnector repoServerConnector = new ServerConnector( this.repoServer, new HttpConnectionFactory());
this.repoServer.addConnector( repoServerConnector );
ServletHolder shRepo = new ServletHolder( RepoServlet.class );
ServletContextHandler contextRepo = new ServletContextHandler();
@ -105,12 +109,16 @@ public class DownloadArtifactsTest
contextRepo.addServlet( shRepo, "/*" );
repoServer.setHandler( contextRepo );
repoServer.start();
this.repoServerPort = repoServer.getConnectors()[0].getLocalPort();
this.repoServerPort = repoServerConnector.getLocalPort();
//redirect handler
this.redirectServer = new Server( 0 );
this.redirectServer = new Server( );
ServerConnector redirectServerConnector = new ServerConnector( this.redirectServer, new HttpConnectionFactory());
this.redirectServer.addConnector( redirectServerConnector );
ServletHolder shRedirect = new ServletHolder( RedirectServlet.class );
ServletContextHandler contextRedirect = new ServletContextHandler();
contextRedirect.setAttribute( "redirectToPort", Integer.toString( this.repoServerPort ) );
@ -120,7 +128,7 @@ public class DownloadArtifactsTest
redirectServer.setHandler( contextRedirect );
redirectServer.start();
this.redirectPort = redirectServer.getConnectors()[0].getLocalPort();
this.redirectPort = redirectServerConnector.getLocalPort();
log.info( "redirect server port {}", redirectPort );
}

View File

@ -24,7 +24,9 @@ import org.apache.archiva.rest.api.services.RemoteRepositoriesService;
import org.apache.commons.io.FileUtils;
import org.apache.cxf.jaxrs.client.WebClient;
import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.HttpConnectionFactory;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.server.handler.DefaultHandler;
import org.eclipse.jetty.server.handler.HandlerList;
import org.eclipse.jetty.server.handler.ResourceHandler;
@ -71,6 +73,9 @@ public class RemoteRepositoryConnectivityCheckTest
Server repoServer =
buildStaticServer( new File( System.getProperty( "basedir" ) + "/src/test/repositories/test-repo" ) );
ServerConnector serverConnector = new ServerConnector( repoServer, new HttpConnectionFactory());
repoServer.addConnector( serverConnector );
repoServer.start();
RemoteRepositoriesService service = getRemoteRepositoriesService();
@ -80,7 +85,7 @@ public class RemoteRepositoryConnectivityCheckTest
try
{
int repoServerPort = repoServer.getConnectors()[0].getLocalPort();
int repoServerPort = serverConnector.getLocalPort();
RemoteRepository repo = getRemoteRepository();
@ -104,6 +109,8 @@ public class RemoteRepositoryConnectivityCheckTest
File tmpDir = Files.createTempDirectory( "test" ).toFile();
Server repoServer = buildStaticServer( tmpDir );
ServerConnector serverConnector = new ServerConnector( repoServer, new HttpConnectionFactory());
repoServer.addConnector( serverConnector );
repoServer.start();
RemoteRepositoriesService service = getRemoteRepositoriesService();
@ -113,7 +120,7 @@ public class RemoteRepositoryConnectivityCheckTest
try
{
int repoServerPort = repoServer.getConnectors()[0].getLocalPort();
int repoServerPort = serverConnector.getLocalPort();
RemoteRepository repo = getRemoteRepository();
@ -160,7 +167,7 @@ public class RemoteRepositoryConnectivityCheckTest
protected Server buildStaticServer( File path )
{
Server repoServer = new Server( 0 );
Server repoServer = new Server( );
ResourceHandler resourceHandler = new ResourceHandler();
resourceHandler.setDirectoriesListed( true );

View File

@ -28,15 +28,15 @@
<loggers>
<logger name="org.springframework" level="error"/>
<logger name="org.apache.archiva" level="error"/>
<logger name="org.apache.archiva.web" level="info"/>
<logger name="org.apache.commons.configuration" level="error"/>
<logger name="org.apache.archiva.scheduler.indexing" level="debug"/>
<logger name="org.apache.archiva.remotedownload" level="debug"/>
<logger name="org.apache.archiva.scheduler.indexing" level="info"/>
<logger name="org.apache.archiva.remotedownload" level="info"/>
<logger name="org.apache.jackrabbit" level="error"/>
<logger name="org.quartz" level="error"/>
<logger name="JPOX.RDBMS" level="error"/>
<logger name="JPOX" level="error"/>
<root level="info">
<appender-ref ref="console"/>
</root>

View File

@ -159,6 +159,11 @@
<artifactId>xmlunit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>

View File

@ -28,7 +28,9 @@ import org.apache.archiva.policies.ChecksumPolicy;
import org.apache.archiva.policies.ReleasesPolicy;
import org.apache.archiva.policies.SnapshotsPolicy;
import org.apache.commons.io.FileUtils;
import org.eclipse.jetty.server.HttpConnectionFactory;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
import org.eclipse.jetty.servlet.DefaultServlet;
import org.eclipse.jetty.servlet.ServletContextHandler;
@ -137,7 +139,9 @@ public abstract class AbstractRepositoryServletProxiedTestCase
repo.root.mkdirs();
}
repo.server = new Server( 0 );
repo.server = new Server( );
ServerConnector serverConnector = new ServerConnector( repo.server, new HttpConnectionFactory());
repo.server.addConnector( serverConnector );
ContextHandlerCollection contexts = new ContextHandlerCollection();
repo.server.setHandler( contexts );
@ -154,7 +158,7 @@ public abstract class AbstractRepositoryServletProxiedTestCase
repo.server.start();
int port = repo.server.getConnectors()[0].getLocalPort();
int port = serverConnector.getLocalPort();
repo.url = "http://localhost:" + port + repo.context;
log.info( "Remote HTTP Server started on {}", repo.url );

View File

@ -20,46 +20,30 @@ package org.apache.archiva.webdav;
*/
import junit.framework.TestCase;
import org.apache.archiva.redback.authentication.AuthenticationException;
import org.apache.archiva.redback.policy.AccountLockedException;
import org.apache.archiva.redback.policy.MustChangePasswordException;
import org.apache.archiva.redback.users.User;
import org.apache.jackrabbit.webdav.DavSessionProvider;
import org.apache.jackrabbit.webdav.WebdavRequest;
import org.apache.jackrabbit.webdav.WebdavRequestImpl;
import org.apache.archiva.security.ServletAuthenticator;
import org.apache.archiva.redback.authentication.AuthenticationDataSource;
import org.apache.archiva.redback.authentication.AuthenticationException;
import org.apache.archiva.redback.authentication.AuthenticationResult;
import org.apache.archiva.redback.authorization.AuthorizationException;
import org.apache.archiva.redback.authorization.UnauthorizedException;
import org.apache.archiva.redback.system.SecuritySession;
import org.apache.archiva.redback.integration.filter.authentication.HttpAuthenticator;
import javax.servlet.AsyncContext;
import javax.servlet.DispatcherType;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletInputStream;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import javax.servlet.http.Part;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.security.Principal;
import java.util.Collection;
import java.util.Enumeration;
import java.util.Locale;
import java.util.Map;
import org.apache.archiva.redback.policy.AccountLockedException;
import org.apache.archiva.redback.policy.MustChangePasswordException;
import org.apache.archiva.redback.system.SecuritySession;
import org.apache.archiva.redback.users.User;
import org.apache.archiva.security.ServletAuthenticator;
import org.apache.archiva.test.utils.ArchivaBlockJUnit4ClassRunner;
import org.apache.jackrabbit.webdav.DavSessionProvider;
import org.apache.jackrabbit.webdav.WebdavRequest;
import org.apache.jackrabbit.webdav.WebdavRequestImpl;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.mock.web.MockHttpServletRequest;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
@RunWith( ArchivaBlockJUnit4ClassRunner.class )
public class ArchivaDavSessionProviderTest
@ -76,7 +60,7 @@ public class ArchivaDavSessionProviderTest
{
super.setUp();
sessionProvider = new ArchivaDavSessionProvider( new ServletAuthenticatorMock(), new HttpAuthenticatorMock() );
request = new WebdavRequestImpl( new HttpServletRequestMock(), null );
request = new WebdavRequestImpl( new MockHttpServletRequest(), null );
}
@Test
@ -101,10 +85,30 @@ public class ArchivaDavSessionProviderTest
}
@SuppressWarnings( "unchecked" )
/*
private class HttpServletRequestMock
implements HttpServletRequest
{
@Override
public long getContentLengthLong()
{
throw new UnsupportedOperationException( "Not supported yet." );
}
@Override
public String changeSessionId()
{
throw new UnsupportedOperationException( "Not supported yet." );
}
@Override
public <T extends HttpUpgradeHandler> T upgrade( Class<T> handlerClass )
throws IOException, ServletException
{
throw new UnsupportedOperationException( "Not supported yet." );
}
@Override
public boolean authenticate( HttpServletResponse httpServletResponse )
throws IOException, ServletException
@ -513,6 +517,7 @@ public class ArchivaDavSessionProviderTest
}
}
*/
private class ServletAuthenticatorMock
implements ServletAuthenticator
{

View File

@ -19,7 +19,7 @@
-->
<configuration status="debug">
<configuration>
<appenders>
<Console name="console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
@ -31,7 +31,6 @@
<logger name="org.springframework" level="error"/>
<root level="info">
<appender-ref ref="console"/>
</root>

View File

@ -86,7 +86,7 @@
<httpclient.version>4.5.2</httpclient.version>
<httpclient.core.version>4.4.4</httpclient.core.version>
<javaxMailVersion>1.4</javaxMailVersion>
<jettyVersion>8.1.14.v20131031</jettyVersion>
<jettyVersion>9.4.5.v20170502</jettyVersion>
<guava.version>16.0.1</guava.version>
<!-- restore when we will be able to use a derby in memory database -->