From: Olivier Lamy Date: Tue, 3 Dec 2013 05:46:50 +0000 (+0000) Subject: use tomcat here X-Git-Tag: archiva-2.0.0-RC1~169 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=38ac0b9c6abdaf4cf411eacebabccc4a73970a8d;p=archiva.git use tomcat here git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1547292 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/remotedownload/AbstractDownloadTest.java b/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/remotedownload/AbstractDownloadTest.java index 881377931..bd0e48a46 100644 --- a/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/remotedownload/AbstractDownloadTest.java +++ b/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/remotedownload/AbstractDownloadTest.java @@ -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(); + } }