use tomcat here

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1547292 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2013-12-03 05:46:50 +00:00
parent e61ed9f123
commit 38ac0b9c6a
1 changed files with 37 additions and 0 deletions

View File

@ -27,6 +27,10 @@ import org.apache.archiva.rest.api.services.RepositoriesService;
import org.apache.archiva.rest.api.services.RepositoryGroupService;
import org.apache.archiva.rest.api.services.SearchService;
import org.apache.archiva.webdav.RepositoryServlet;
import org.apache.catalina.Context;
import org.apache.catalina.deploy.ApplicationListener;
import org.apache.catalina.deploy.ApplicationParameter;
import org.apache.catalina.startup.Tomcat;
import org.apache.commons.lang.StringUtils;
import org.apache.cxf.common.util.Base64Utility;
import org.apache.cxf.jaxrs.client.JAXRSClientFactory;
@ -68,6 +72,8 @@ public abstract class AbstractDownloadTest
public Server server = null;
public Tomcat tomcat;
public int port;
public static String encode( String uid, String password )
@ -101,6 +107,8 @@ public abstract class AbstractDownloadTest
{
System.setProperty( "redback.admin.creation.file", "target/auto-admin-creation.properties" );
/*
this.server = new Server( 0 );
ServletContextHandler context = new ServletContextHandler();
@ -128,6 +136,31 @@ public abstract class AbstractDownloadTest
this.server.start();
Connector connector = this.server.getConnectors()[0];
this.port = connector.getLocalPort();
*/
tomcat = new Tomcat();
tomcat.setBaseDir( System.getProperty( "java.io.tmpdir" ) );
tomcat.setPort( 0 );
Context context = tomcat.addContext( "", System.getProperty( "java.io.tmpdir" ) );
ApplicationParameter applicationParameter = new ApplicationParameter();
applicationParameter.setName( "contextConfigLocation" );
applicationParameter.setValue( getSpringConfigLocation() );
context.addApplicationParameter( applicationParameter );
context.addApplicationListener( new ApplicationListener( ContextLoaderListener.class.getName(), false ) );
tomcat.addServlet( context, "cxf", new CXFServlet() );
context.addServletMapping( "/" + getRestServicesPath() + "/*" , "cxf" );
tomcat.addServlet( context, "archivarepo", new RepositoryServlet() );
context.addServletMapping( "/repository/*" , "archivarepo" );
tomcat.start();
port = tomcat.getConnector().getLocalPort();
log.info( "start server on port {}", this.port );
User user = new User();
@ -152,6 +185,10 @@ public abstract class AbstractDownloadTest
{
this.server.stop();
}
if (this.tomcat != null)
{
this.tomcat.stop();
}
}