]> source.dussan.org Git - archiva.git/commitdiff
use tomcat here
authorOlivier Lamy <olamy@apache.org>
Tue, 3 Dec 2013 05:46:50 +0000 (05:46 +0000)
committerOlivier Lamy <olamy@apache.org>
Tue, 3 Dec 2013 05:46:50 +0000 (05:46 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1547292 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/remotedownload/AbstractDownloadTest.java

index 88137793174dc98d57a2a5f8e961e18c5cc2b501..bd0e48a469b040146dea765ab8c7e5a14893bfc7 100644 (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();
+        }
     }