Return-Path: X-Original-To: apmail-cxf-commits-archive@www.apache.org Delivered-To: apmail-cxf-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 29B2010811 for ; Wed, 11 Feb 2015 10:30:00 +0000 (UTC) Received: (qmail 10553 invoked by uid 500); 11 Feb 2015 10:29:56 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 10502 invoked by uid 500); 11 Feb 2015 10:29:56 -0000 Mailing-List: contact commits-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list commits@cxf.apache.org Received: (qmail 10484 invoked by uid 99); 11 Feb 2015 10:29:56 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 11 Feb 2015 10:29:56 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 5BF81E01CB; Wed, 11 Feb 2015 10:29:56 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: sergeyb@apache.org To: commits@cxf.apache.org Message-Id: <29598ff30d434b80807eb87771e6f3b5@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: cxf git commit: CXF-6132: Provide JAX-RS ServletContextInitializer. Adding more test cases. Date: Wed, 11 Feb 2015 10:29:56 +0000 (UTC) Repository: cxf Updated Branches: refs/heads/3.0.x-fixes bb7d0d8ce -> 8e5bae551 CXF-6132: Provide JAX-RS ServletContextInitializer. Adding more test cases. Project: http://git-wip-us.apache.org/repos/asf/cxf/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/8e5bae55 Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/8e5bae55 Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/8e5bae55 Branch: refs/heads/3.0.x-fixes Commit: 8e5bae551334d9af2d28f11b336b24ceea6b5fe5 Parents: bb7d0d8 Author: reta Authored: Wed Feb 4 22:04:12 2015 -0500 Committer: Sergey Beryozkin Committed: Wed Feb 11 10:29:03 2015 +0000 ---------------------------------------------------------------------- .../JaxrsServletContainerInitializer.java | 5 +- .../jetty/JettyEmptyApplicationTest.java | 64 ++++++++++++++++++ .../jetty/JettyEmptyPathApplicationTest.java | 71 ++++++++++++++++++++ .../applications/empty/BookApplication.java | 26 +++++++ .../applications/emptypath/BookApplication.java | 24 +++++++ .../src/test/resources/WEB-INF/web-subclass.xml | 10 +++ 6 files changed, 198 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf/blob/8e5bae55/rt/rs/http-sci/src/main/java/org/apache/cxf/jaxrs/servlet/JaxrsServletContainerInitializer.java ---------------------------------------------------------------------- diff --git a/rt/rs/http-sci/src/main/java/org/apache/cxf/jaxrs/servlet/JaxrsServletContainerInitializer.java b/rt/rs/http-sci/src/main/java/org/apache/cxf/jaxrs/servlet/JaxrsServletContainerInitializer.java index 89c6b39..c872926 100644 --- a/rt/rs/http-sci/src/main/java/org/apache/cxf/jaxrs/servlet/JaxrsServletContainerInitializer.java +++ b/rt/rs/http-sci/src/main/java/org/apache/cxf/jaxrs/servlet/JaxrsServletContainerInitializer.java @@ -82,7 +82,7 @@ public class JaxrsServletContainerInitializer implements ServletContainerInitial // If application is null or empty then try to create a new application from available // resource and provider classes if (app == null - || app.getClasses().isEmpty() && app.getSingletons().isEmpty()) { + || (app.getClasses().isEmpty() && app.getSingletons().isEmpty())) { // The best effort at detecting a CXFNonSpringJaxrsServlet // Custom servlets using non-standard mechanisms to create Application will not be detected if (isCxfServletAvailable(ctx)) { @@ -98,7 +98,8 @@ public class JaxrsServletContainerInitializer implements ServletContainerInitial // Servlet mapping is obtained from a servlet registration // with a JAX-RS Application class name servletMapping = getServletMapping(ctx, servletName); - } + } + app = new Application() { @Override public Set> getClasses() { http://git-wip-us.apache.org/repos/asf/cxf/blob/8e5bae55/systests/rs-http-sci/src/test/java/org/apache/cxf/jaxrs/servlet/jetty/JettyEmptyApplicationTest.java ---------------------------------------------------------------------- diff --git a/systests/rs-http-sci/src/test/java/org/apache/cxf/jaxrs/servlet/jetty/JettyEmptyApplicationTest.java b/systests/rs-http-sci/src/test/java/org/apache/cxf/jaxrs/servlet/jetty/JettyEmptyApplicationTest.java new file mode 100644 index 0000000..af8a5be --- /dev/null +++ b/systests/rs-http-sci/src/test/java/org/apache/cxf/jaxrs/servlet/jetty/JettyEmptyApplicationTest.java @@ -0,0 +1,64 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.cxf.jaxrs.servlet.jetty; + +import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider; + +import org.apache.cxf.jaxrs.model.AbstractResourceInfo; +import org.apache.cxf.jaxrs.servlet.AbstractSciTest; +import org.eclipse.jetty.util.resource.Resource; +import org.junit.BeforeClass; +import org.junit.Ignore; + +public class JettyEmptyApplicationTest extends AbstractSciTest { + @Ignore + public static class EmbeddedJettyServer extends AbstractJettyServer { + public static final int PORT = allocatePortAsInt(EmbeddedJettyServer.class); + + public EmbeddedJettyServer() { + super("/", + new Resource[] { + // Limit the classpath scanning to org.apache.demo.resources package + Resource.newClassPathResource("/org/apache/demo/resources"), + // Include JAX-RS application from org.apache.applications.empty package + Resource.newClassPathResource("/org/apache/demo/applications/empty"), + // Include Jackson @Providers into classpath scanning + Resource.newResource(JacksonJsonProvider.class.getProtectionDomain().getCodeSource().getLocation()) + }, PORT); + } + } + + @BeforeClass + public static void startServers() throws Exception { + AbstractResourceInfo.clearAllMaps(); + assertTrue("server did not launch correctly", launchServer(EmbeddedJettyServer.class, true)); + createStaticBus(); + } + + @Override + protected int getPort() { + return EmbeddedJettyServer.PORT; + } + + @Override + protected String getContextPath() { + return "/api"; + } +} http://git-wip-us.apache.org/repos/asf/cxf/blob/8e5bae55/systests/rs-http-sci/src/test/java/org/apache/cxf/jaxrs/servlet/jetty/JettyEmptyPathApplicationTest.java ---------------------------------------------------------------------- diff --git a/systests/rs-http-sci/src/test/java/org/apache/cxf/jaxrs/servlet/jetty/JettyEmptyPathApplicationTest.java b/systests/rs-http-sci/src/test/java/org/apache/cxf/jaxrs/servlet/jetty/JettyEmptyPathApplicationTest.java new file mode 100644 index 0000000..0318bd8 --- /dev/null +++ b/systests/rs-http-sci/src/test/java/org/apache/cxf/jaxrs/servlet/jetty/JettyEmptyPathApplicationTest.java @@ -0,0 +1,71 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.cxf.jaxrs.servlet.jetty; + +import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider; + +import org.apache.cxf.jaxrs.model.AbstractResourceInfo; +import org.apache.cxf.jaxrs.servlet.AbstractSciTest; +import org.eclipse.jetty.util.resource.Resource; +import org.eclipse.jetty.webapp.WebAppContext; +import org.junit.BeforeClass; +import org.junit.Ignore; + +public class JettyEmptyPathApplicationTest extends AbstractSciTest { + @Ignore + public static class EmbeddedJettyServer extends AbstractJettyServer { + public static final int PORT = allocatePortAsInt(EmbeddedJettyServer.class); + + public EmbeddedJettyServer() { + super("/", + new Resource[] { + // Limit the classpath scanning to org.apache.demo.resources package + Resource.newClassPathResource("/org/apache/demo/resources"), + // Include JAX-RS application from org.apache.applications.empty package + Resource.newClassPathResource("/org/apache/demo/applications/emptypath"), + // Include Jackson @Providers into classpath scanning + Resource.newResource(JacksonJsonProvider.class.getProtectionDomain().getCodeSource().getLocation()) + }, PORT); + } + + @Override + protected void configureContext(final WebAppContext context) throws Exception { + context.setDescriptor(Resource + .newClassPathResource("/WEB-INF/web-subclass.xml").getFile().toURI().getPath()); + } + } + + @BeforeClass + public static void startServers() throws Exception { + AbstractResourceInfo.clearAllMaps(); + assertTrue("server did not launch correctly", launchServer(EmbeddedJettyServer.class, true)); + createStaticBus(); + } + + @Override + protected int getPort() { + return EmbeddedJettyServer.PORT; + } + + @Override + protected String getContextPath() { + return "/subapi"; + } +} http://git-wip-us.apache.org/repos/asf/cxf/blob/8e5bae55/systests/rs-http-sci/src/test/java/org/apache/demo/applications/empty/BookApplication.java ---------------------------------------------------------------------- diff --git a/systests/rs-http-sci/src/test/java/org/apache/demo/applications/empty/BookApplication.java b/systests/rs-http-sci/src/test/java/org/apache/demo/applications/empty/BookApplication.java new file mode 100644 index 0000000..a90f529 --- /dev/null +++ b/systests/rs-http-sci/src/test/java/org/apache/demo/applications/empty/BookApplication.java @@ -0,0 +1,26 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.demo.applications.empty; + +import javax.ws.rs.ApplicationPath; +import javax.ws.rs.core.Application; + +@ApplicationPath("/api") +public class BookApplication extends Application { +} http://git-wip-us.apache.org/repos/asf/cxf/blob/8e5bae55/systests/rs-http-sci/src/test/java/org/apache/demo/applications/emptypath/BookApplication.java ---------------------------------------------------------------------- diff --git a/systests/rs-http-sci/src/test/java/org/apache/demo/applications/emptypath/BookApplication.java b/systests/rs-http-sci/src/test/java/org/apache/demo/applications/emptypath/BookApplication.java new file mode 100644 index 0000000..cb91d5f --- /dev/null +++ b/systests/rs-http-sci/src/test/java/org/apache/demo/applications/emptypath/BookApplication.java @@ -0,0 +1,24 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.demo.applications.emptypath; + +import javax.ws.rs.core.Application; + +public class BookApplication extends Application { +} http://git-wip-us.apache.org/repos/asf/cxf/blob/8e5bae55/systests/rs-http-sci/src/test/resources/WEB-INF/web-subclass.xml ---------------------------------------------------------------------- diff --git a/systests/rs-http-sci/src/test/resources/WEB-INF/web-subclass.xml b/systests/rs-http-sci/src/test/resources/WEB-INF/web-subclass.xml new file mode 100644 index 0000000..fb8984a --- /dev/null +++ b/systests/rs-http-sci/src/test/resources/WEB-INF/web-subclass.xml @@ -0,0 +1,10 @@ + + + org.apache.demo.applications.emptypath.BookApplication + + + org.apache.demo.applications.emptypath.BookApplication + /subapi/* + + \ No newline at end of file