<properties>
<jettyVersion>7.5.3.v20111011</jettyVersion>
- <tomcatVersion>7.0.21</tomcatVersion>
+ <tomcatVersion>7.0.27</tomcatVersion>
<test.useTomcat>false</test.useTomcat>
</properties>
<artifactId>commons-io</artifactId>
</dependency>
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- <scope>provided</scope>
- </dependency>
-
<dependency>
<groupId>org.apache.archiva.redback</groupId>
<artifactId>redback-users-api</artifactId>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
</exclusion>
+ <exclusion>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-servlet_2.5_spec</artifactId>
+ </exclusion>
<exclusion>
<groupId>org.codehaus.jettison</groupId>
<artifactId>jettison</artifactId>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.eclipse.jetty</groupId>
- <artifactId>jetty-server</artifactId>
- <version>${jettyVersion}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.eclipse.jetty</groupId>
- <artifactId>jetty-plus</artifactId>
- <version>${jettyVersion}</version>
- <scope>test</scope>
- </dependency>
-
- <!--
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-core</artifactId>
<version>${tomcatVersion}</version>
<scope>test</scope>
</dependency>
- -->
+ <dependency>
+ <groupId>org.apache.tomcat</groupId>
+ <artifactId>tomcat-servlet-api</artifactId>
+ <version>${tomcatVersion}</version>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>org.slf4j</groupId>
*/
import junit.framework.TestCase;
+import org.apache.archiva.redback.integration.security.role.RedbackRoleConstants;
+import org.apache.archiva.redback.rest.api.model.User;
+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.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.codehaus.jackson.jaxrs.JacksonJaxbJsonProvider;
-import org.apache.archiva.redback.integration.security.role.RedbackRoleConstants;
-import org.apache.archiva.redback.rest.api.model.User;
-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.eclipse.jetty.server.Connector;
-import org.eclipse.jetty.server.Server;
-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;
{
protected Logger log = LoggerFactory.getLogger( getClass() );
- public Server server = null;
-
- //private Tomcat tomcat;
+ private Tomcat tomcat;
public int port;
return "restServices";
}
- static boolean useTomcat = Boolean.getBoolean( "test.useTomcat" );
-
@Before
public void startServer()
throws Exception
{
- this.server = new Server( 0 );
-
- ServletContextHandler context = new ServletContextHandler();
-
- context.setContextPath( "/" );
-
- context.setInitParameter( "contextConfigLocation", getSpringConfigLocation() );
+ tomcat = new Tomcat();
+ tomcat.setBaseDir( System.getProperty( "java.io.tmpdir" ) );
+ tomcat.setPort( 0 );
- ContextLoaderListener contextLoaderListener = new ContextLoaderListener();
+ Context context = tomcat.addContext( "", System.getProperty( "java.io.tmpdir" ) );
- context.addEventListener( contextLoaderListener );
+ ApplicationParameter applicationParameter = new ApplicationParameter();
+ applicationParameter.setName( "contextConfigLocation" );
+ applicationParameter.setValue( getSpringConfigLocation() );
+ context.addApplicationParameter( applicationParameter );
- ServletHolder sh = new ServletHolder( CXFServlet.class );
+ context.addApplicationListener( ContextLoaderListener.class.getName() );
- SessionHandler sessionHandler = new SessionHandler();
+ Tomcat.addServlet( context, "cxf", new CXFServlet() );
+ context.addServletMapping( "/" + getRestServicesPath() + "/*", "cxf" );
- context.setSessionHandler( sessionHandler );
+ tomcat.start();
- context.addServlet( sh, "/" + getRestServicesPath() + "/*" );
- server.setHandler( context );
- this.server.start();
- Connector connector = this.server.getConnectors()[0];
- this.port = connector.getLocalPort();
+ this.port = tomcat.getConnector().getLocalPort();
log.info( "start server on port " + this.port );
public void stopServer()
throws Exception
{
- if ( this.server != null && this.server.isRunning() )
+ if ( this.tomcat != null )
{
- this.server.stop();
+ this.tomcat.stop();
}
}