From 0b9f6c8d45a5426dac29ff9c832b057b8e0e7ea3 Mon Sep 17 00:00:00 2001 From: olivier lamy Date: Thu, 11 May 2017 16:13:39 +1000 Subject: [PATCH 1/6] use jetty 9.3.19 for testing -> really faster to start Signed-off-by: olivier lamy --- pom.xml | 2 +- .../redback-rest-services/pom.xml | 33 +++--------- .../services/AbstractRestServicesTest.java | 54 +++++++++++-------- 3 files changed, 41 insertions(+), 48 deletions(-) diff --git a/pom.xml b/pom.xml index b3948655..de751eb7 100644 --- a/pom.xml +++ b/pom.xml @@ -73,7 +73,7 @@ 4.2.1.RELEASE 1.7.12 - 2.3 + 2.8.2 UTF-8 true diff --git a/redback-integrations/redback-rest/redback-rest-services/pom.xml b/redback-integrations/redback-rest/redback-rest-services/pom.xml index 2de4c002..bfd1770c 100644 --- a/redback-integrations/redback-rest/redback-rest-services/pom.xml +++ b/redback-integrations/redback-rest/redback-rest-services/pom.xml @@ -33,6 +33,7 @@ 7.0.57 + 9.3.19.v20170502 1000000 @@ -138,34 +139,14 @@ - org.apache.tomcat.embed - tomcat-embed-core - ${tomcatVersion} - test + org.eclipse.jetty + jetty-server + ${jetty.version} - org.apache.tomcat - tomcat-juli - ${tomcatVersion} - test - - - org.apache.tomcat.embed - tomcat-embed-logging-juli - ${tomcatVersion} - test - - - org.apache.tomcat - tomcat-servlet-api - ${tomcatVersion} - provided - - - org.apache.tomcat - tomcat-jsp-api - ${tomcatVersion} - provided + org.eclipse.jetty + jetty-servlet + ${jetty.version} diff --git a/redback-integrations/redback-rest/redback-rest-services/src/test/java/org/apache/archiva/redback/rest/services/AbstractRestServicesTest.java b/redback-integrations/redback-rest/redback-rest-services/src/test/java/org/apache/archiva/redback/rest/services/AbstractRestServicesTest.java index 4b565a2c..a6c34ef5 100644 --- a/redback-integrations/redback-rest/redback-rest-services/src/test/java/org/apache/archiva/redback/rest/services/AbstractRestServicesTest.java +++ b/redback-integrations/redback-rest/redback-rest-services/src/test/java/org/apache/archiva/redback/rest/services/AbstractRestServicesTest.java @@ -27,14 +27,18 @@ import org.apache.archiva.redback.rest.api.services.LdapGroupMappingService; 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.eclipse.jetty.server.HttpConnectionFactory; +import org.eclipse.jetty.server.Server; +import org.eclipse.jetty.server.ServerConnector; +import org.eclipse.jetty.server.session.SessionHandler; +import org.eclipse.jetty.servlet.ServletContextHandler; +import org.eclipse.jetty.servlet.ServletHandler; +import org.eclipse.jetty.servlet.ServletHolder; import org.junit.After; import org.junit.Before; import org.junit.runner.RunWith; @@ -56,8 +60,8 @@ public abstract class AbstractRestServicesTest { protected Logger log = LoggerFactory.getLogger( getClass() ); - private Tomcat tomcat; - + Server server; + ServerConnector serverConnector; public int port; public String authorizationHeader = getAdminAuthzHeader(); @@ -98,17 +102,10 @@ public abstract class AbstractRestServicesTest public void startServer() throws Exception { - - SLF4JBridgeHandler.removeHandlersForRootLogger(); - - SLF4JBridgeHandler.install(); - - tomcat = new Tomcat(); - tomcat.setBaseDir( System.getProperty( "java.io.tmpdir" ) ); - tomcat.setPort( 0 ); - - Context context = tomcat.addContext( "", System.getProperty( "java.io.tmpdir" ) ); - + server = new Server(); + serverConnector = new ServerConnector( server, new HttpConnectionFactory()); + server.addConnector(serverConnector); + /* ApplicationParameter applicationParameter = new ApplicationParameter(); applicationParameter.setName( "contextConfigLocation" ); applicationParameter.setValue( getSpringConfigLocation() ); @@ -118,10 +115,25 @@ public abstract class AbstractRestServicesTest Tomcat.addServlet( context, "cxf", new CXFServlet() ); context.addServletMapping( "/" + getRestServicesPath() + "/*", "cxf" ); + */ + ServletHolder servletHolder = new ServletHolder( new CXFServlet() ); - tomcat.start(); + ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS); + context.setSessionHandler( new SessionHandler( ) ); + context.setContextPath( "/" ); + context.addServlet( servletHolder, "/" + getRestServicesPath() + "/*" ); + context.setInitParameter( "contextConfigLocation", getSpringConfigLocation() ); + context.addEventListener(new ContextLoaderListener()); - this.port = tomcat.getConnector().getLocalPort(); + server.setHandler( context ); + server.start(); + + if (log.isDebugEnabled()) + { + log.debug( "jetty dump: {}", server.dump() ); + } + + this.port = serverConnector.getLocalPort(); log.info( "start server on port {}", this.port ); @@ -143,16 +155,16 @@ public abstract class AbstractRestServicesTest { return JAXRSClientFactory.create( "http://localhost:" + port + "/" + getRestServicesPath() + "/fakeCreateAdminService/", - FakeCreateAdminService.class, Collections.singletonList( new com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider() ) ); + FakeCreateAdminService.class, Collections.singletonList( new JacksonJaxbJsonProvider() ) ); } @After public void stopServer() throws Exception { - if ( this.tomcat != null ) + if ( this.server != null ) { - this.tomcat.stop(); + this.server.stop(); } } From a54f10dd22b35540a213fbf66e54295a5b822199 Mon Sep 17 00:00:00 2001 From: olivier lamy Date: Thu, 11 May 2017 16:16:43 +1000 Subject: [PATCH 2/6] unused import Signed-off-by: olivier lamy --- .../redback/rest/services/AbstractRestServicesTest.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/redback-integrations/redback-rest/redback-rest-services/src/test/java/org/apache/archiva/redback/rest/services/AbstractRestServicesTest.java b/redback-integrations/redback-rest/redback-rest-services/src/test/java/org/apache/archiva/redback/rest/services/AbstractRestServicesTest.java index a6c34ef5..451f99fc 100644 --- a/redback-integrations/redback-rest/redback-rest-services/src/test/java/org/apache/archiva/redback/rest/services/AbstractRestServicesTest.java +++ b/redback-integrations/redback-rest/redback-rest-services/src/test/java/org/apache/archiva/redback/rest/services/AbstractRestServicesTest.java @@ -37,7 +37,6 @@ import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.ServerConnector; import org.eclipse.jetty.server.session.SessionHandler; import org.eclipse.jetty.servlet.ServletContextHandler; -import org.eclipse.jetty.servlet.ServletHandler; import org.eclipse.jetty.servlet.ServletHolder; import org.junit.After; import org.junit.Before; @@ -45,7 +44,6 @@ import org.junit.runner.RunWith; import org.junit.runners.JUnit4; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.slf4j.bridge.SLF4JBridgeHandler; import org.springframework.web.context.ContextLoaderListener; import javax.ws.rs.core.MediaType; @@ -132,7 +130,7 @@ public abstract class AbstractRestServicesTest { log.debug( "jetty dump: {}", server.dump() ); } - + this.port = serverConnector.getLocalPort(); log.info( "start server on port {}", this.port ); From 2a027a21546d0049b72db9c41f5cb56f4b1566ea Mon Sep 17 00:00:00 2001 From: olivier lamy Date: Thu, 11 May 2017 17:17:56 +1000 Subject: [PATCH 3/6] remove non used code Signed-off-by: olivier lamy --- .../rest/services/AbstractRestServicesTest.java | 11 ----------- .../src/test/resources/log4j2-test.xml | 2 +- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/redback-integrations/redback-rest/redback-rest-services/src/test/java/org/apache/archiva/redback/rest/services/AbstractRestServicesTest.java b/redback-integrations/redback-rest/redback-rest-services/src/test/java/org/apache/archiva/redback/rest/services/AbstractRestServicesTest.java index 451f99fc..ac4c8020 100644 --- a/redback-integrations/redback-rest/redback-rest-services/src/test/java/org/apache/archiva/redback/rest/services/AbstractRestServicesTest.java +++ b/redback-integrations/redback-rest/redback-rest-services/src/test/java/org/apache/archiva/redback/rest/services/AbstractRestServicesTest.java @@ -103,22 +103,11 @@ public abstract class AbstractRestServicesTest server = new Server(); serverConnector = new ServerConnector( server, new HttpConnectionFactory()); server.addConnector(serverConnector); - /* - ApplicationParameter applicationParameter = new ApplicationParameter(); - applicationParameter.setName( "contextConfigLocation" ); - applicationParameter.setValue( getSpringConfigLocation() ); - context.addApplicationParameter( applicationParameter ); - context.addApplicationListener( ContextLoaderListener.class.getName() ); - - Tomcat.addServlet( context, "cxf", new CXFServlet() ); - context.addServletMapping( "/" + getRestServicesPath() + "/*", "cxf" ); - */ ServletHolder servletHolder = new ServletHolder( new CXFServlet() ); ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS); context.setSessionHandler( new SessionHandler( ) ); - context.setContextPath( "/" ); context.addServlet( servletHolder, "/" + getRestServicesPath() + "/*" ); context.setInitParameter( "contextConfigLocation", getSpringConfigLocation() ); context.addEventListener(new ContextLoaderListener()); diff --git a/redback-integrations/redback-rest/redback-rest-services/src/test/resources/log4j2-test.xml b/redback-integrations/redback-rest/redback-rest-services/src/test/resources/log4j2-test.xml index e058bdb7..5f8bb09f 100644 --- a/redback-integrations/redback-rest/redback-rest-services/src/test/resources/log4j2-test.xml +++ b/redback-integrations/redback-rest/redback-rest-services/src/test/resources/log4j2-test.xml @@ -31,7 +31,7 @@ - + From 900e010b927fa7d2ea3ba04c41be0bfad34426eb Mon Sep 17 00:00:00 2001 From: olivier lamy Date: Thu, 11 May 2017 21:14:53 +1000 Subject: [PATCH 4/6] jetty version 9.4.5.v20170502 Signed-off-by: olivier lamy --- redback-integrations/redback-rest/redback-rest-services/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/redback-integrations/redback-rest/redback-rest-services/pom.xml b/redback-integrations/redback-rest/redback-rest-services/pom.xml index bfd1770c..cec68486 100644 --- a/redback-integrations/redback-rest/redback-rest-services/pom.xml +++ b/redback-integrations/redback-rest/redback-rest-services/pom.xml @@ -33,7 +33,7 @@ 7.0.57 - 9.3.19.v20170502 + 9.4.5.v20170502 1000000 From bc3018edbe00a0c3a0fc8068e86484226e5d7c48 Mon Sep 17 00:00:00 2001 From: olivier lamy Date: Thu, 11 May 2017 21:31:00 +1000 Subject: [PATCH 5/6] configure a resource base Signed-off-by: olivier lamy --- .travis.yml | 4 ++-- .../redback/rest/services/AbstractRestServicesTest.java | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index ea38ef36..5e9c272e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: java jdk: - - openjdk7 - - oraclejdk7 + - openjdk8 + - oraclejdk8 script: "mvn clean install" diff --git a/redback-integrations/redback-rest/redback-rest-services/src/test/java/org/apache/archiva/redback/rest/services/AbstractRestServicesTest.java b/redback-integrations/redback-rest/redback-rest-services/src/test/java/org/apache/archiva/redback/rest/services/AbstractRestServicesTest.java index ac4c8020..4421abec 100644 --- a/redback-integrations/redback-rest/redback-rest-services/src/test/java/org/apache/archiva/redback/rest/services/AbstractRestServicesTest.java +++ b/redback-integrations/redback-rest/redback-rest-services/src/test/java/org/apache/archiva/redback/rest/services/AbstractRestServicesTest.java @@ -28,6 +28,7 @@ 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.commons.lang.StringUtils; +import org.apache.commons.lang.SystemUtils; import org.apache.cxf.common.util.Base64Utility; import org.apache.cxf.jaxrs.client.JAXRSClientFactory; import org.apache.cxf.jaxrs.client.WebClient; @@ -105,8 +106,8 @@ public abstract class AbstractRestServicesTest server.addConnector(serverConnector); ServletHolder servletHolder = new ServletHolder( new CXFServlet() ); - ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS); + context.setResourceBase( SystemUtils.JAVA_IO_TMPDIR ); context.setSessionHandler( new SessionHandler( ) ); context.addServlet( servletHolder, "/" + getRestServicesPath() + "/*" ); context.setInitParameter( "contextConfigLocation", getSpringConfigLocation() ); From ddf79072433edc909c8f5a27c5fb45f7b18ee5e4 Mon Sep 17 00:00:00 2001 From: olivier lamy Date: Thu, 11 May 2017 21:41:00 +1000 Subject: [PATCH 6/6] no openjdk8 Signed-off-by: olivier lamy --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 5e9c272e..488d5807 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,5 @@ language: java jdk: - - openjdk8 - oraclejdk8 script: "mvn clean install"