[CXF-6988] Add more systests for CDI, including OpenWebBeans. This closes #184.
Project: http://git-wip-us.apache.org/repos/asf/cxf/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/faf46115 Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/faf46115 Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/faf46115 Branch: refs/heads/master Commit: faf461150f178f7f7ae89a3b7c345671e53b8b04 Parents: 8c49fe5 Author: John D. Ament <[email protected]> Authored: Sat Oct 22 21:08:16 2016 -0400 Committer: reta <[email protected]> Committed: Thu Oct 27 21:09:59 2016 -0400 ---------------------------------------------------------------------- systests/cdi/base/pom.xml | 89 ++++++ .../cdi/base/AbstractCdiMultiAppTest.java | 66 +++++ .../cdi/base/AbstractCdiSingleAppTest.java | 96 +++++++ .../org/apache/cxf/systests/cdi/base/Book.java | 54 ++++ .../apache/cxf/systests/cdi/base/BookStore.java | 75 +++++ .../cxf/systests/cdi/base/BookStoreService.java | 53 ++++ .../cdi/base/jetty/AbstractJettyServer.java | 97 +++++++ .../cdi/base/tomcat/AbstractTomcatServer.java | 88 ++++++ .../base/src/main/resources/META-INF/beans.xml | 6 + .../cdi/cdi-owb/cdi-multiple-apps-owb/pom.xml | 32 +++ .../cxf/systest/jaxrs/BookStoreApplication.java | 26 ++ .../jaxrs/BookStoreCustomApplication.java | 49 ++++ .../jaxrs/cdi/jetty/JettyEmbeddedTest.java | 49 ++++ .../systest/jaxrs/cdi/jetty/JettyWarTest.java | 49 ++++ .../systest/jaxrs/cdi/tomcat/TomcatWarTest.java | 48 ++++ .../src/test/resources/META-INF/beans.xml | 6 + .../test/resources/jaxrs_cdi/WEB-INF/web.xml | 24 ++ systests/cdi/cdi-owb/cdi-no-apps-owb/pom.xml | 35 +++ .../jaxrs/cdi/jetty/JettyEmbeddedTest.java | 48 ++++ .../systest/jaxrs/cdi/jetty/JettyWarTest.java | 48 ++++ .../systest/jaxrs/cdi/tomcat/TomcatWarTest.java | 47 ++++ .../src/test/resources/META-INF/beans.xml | 6 + .../test/resources/jaxrs_cdi/WEB-INF/web.xml | 24 ++ systests/cdi/cdi-owb/pom.xml | 121 ++++++++ .../cdi/cdi-weld/cdi-multiple-apps-weld/pom.xml | 32 +++ .../cxf/systest/jaxrs/BookStoreApplication.java | 26 ++ .../jaxrs/BookStoreCustomApplication.java | 49 ++++ .../jaxrs/cdi/WeldDiscoverableContainer.java | 56 ++++ .../jaxrs/cdi/jetty/JettyEmbeddedTest.java | 51 ++++ .../systest/jaxrs/cdi/jetty/JettyWarTest.java | 54 ++++ .../systest/jaxrs/cdi/tomcat/TomcatWarTest.java | 51 ++++ .../src/test/resources/META-INF/beans.xml | 6 + .../org.jboss.weld.environment.Container | 1 + .../test/resources/jaxrs_cdi/WEB-INF/web.xml | 25 ++ systests/cdi/cdi-weld/cdi-no-apps-weld/pom.xml | 35 +++ .../jaxrs/cdi/WeldDiscoverableContainer.java | 56 ++++ .../jaxrs/cdi/jetty/JettyEmbeddedTest.java | 50 ++++ .../systest/jaxrs/cdi/jetty/JettyWarTest.java | 53 ++++ .../systest/jaxrs/cdi/tomcat/TomcatWarTest.java | 50 ++++ .../src/test/resources/META-INF/beans.xml | 6 + .../org.jboss.weld.environment.Container | 1 + .../test/resources/jaxrs_cdi/WEB-INF/web.xml | 25 ++ systests/cdi/cdi-weld/pom.xml | 116 ++++++++ systests/cdi/pom.xml | 278 ++++++++----------- .../cxf/systest/jaxrs/BookStoreApplication.java | 30 -- .../jaxrs/BookStoreCustomApplication.java | 49 ---- .../cxf/systest/jaxrs/BookStoreService.java | 46 --- .../cxf/systest/jaxrs/cdi/AbstractCDITest.java | 104 ------- .../org/apache/cxf/systest/jaxrs/cdi/Book.java | 54 ---- .../apache/cxf/systest/jaxrs/cdi/BookStore.java | 77 ----- .../jaxrs/cdi/WeldDiscoverableContainer.java | 56 ---- .../jaxrs/cdi/jetty/AbstractJettyServer.java | 105 ------- .../jaxrs/cdi/jetty/JettyEmbeddedTest.java | 49 ---- .../systest/jaxrs/cdi/jetty/JettyWarTest.java | 49 ---- .../jaxrs/cdi/tomcat/AbstractTomcatServer.java | 96 ------- .../systest/jaxrs/cdi/tomcat/TomcatWarTest.java | 49 ---- .../cdi/src/test/resources/META-INF/beans.xml | 6 - .../org.jboss.weld.environment.Container | 1 - .../test/resources/jaxrs_cdi/WEB-INF/web.xml | 25 -- 59 files changed, 2102 insertions(+), 951 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf/blob/faf46115/systests/cdi/base/pom.xml ---------------------------------------------------------------------- diff --git a/systests/cdi/base/pom.xml b/systests/cdi/base/pom.xml new file mode 100644 index 0000000..6bdc414 --- /dev/null +++ b/systests/cdi/base/pom.xml @@ -0,0 +1,89 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ~ 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. + --> + +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <parent> + <artifactId>cxf-systests-cdi</artifactId> + <groupId>org.apache.cxf.systests</groupId> + <version>3.2.0-SNAPSHOT</version> + </parent> + <modelVersion>4.0.0</modelVersion> + + <artifactId>cxf-systests-cdi-base</artifactId> + <name>Apache CXF CDI Integration System Tests - Base</name> + <dependencies> + <dependency> + <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-server</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-plus</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-webapp</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.jetty</groupId> + <artifactId>apache-jsp</artifactId> + </dependency> + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-testutils</artifactId> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-integration-cdi</artifactId> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>org.apache.tomcat.embed</groupId> + <artifactId>tomcat-embed-core</artifactId> + </dependency> + <dependency> + <groupId>org.apache.tomcat.embed</groupId> + <artifactId>tomcat-embed-logging-juli</artifactId> + </dependency> + <dependency> + <groupId>org.apache.tomcat</groupId> + <artifactId>tomcat-jasper</artifactId> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.jaxrs</groupId> + <artifactId>jackson-jaxrs-json-provider</artifactId> + </dependency> + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-rs-client</artifactId> + </dependency> + <dependency> + <groupId>javax.validation</groupId> + <artifactId>validation-api</artifactId> + </dependency> + </dependencies> +</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cxf/blob/faf46115/systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/AbstractCdiMultiAppTest.java ---------------------------------------------------------------------- diff --git a/systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/AbstractCdiMultiAppTest.java b/systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/AbstractCdiMultiAppTest.java new file mode 100644 index 0000000..68815d8 --- /dev/null +++ b/systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/AbstractCdiMultiAppTest.java @@ -0,0 +1,66 @@ +/** + * 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.systests.cdi.base; + +import java.util.Arrays; +import java.util.List; +import java.util.UUID; + +import javax.ws.rs.core.Form; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider; + +import org.apache.cxf.jaxrs.client.WebClient; +import org.junit.Test; + +public abstract class AbstractCdiMultiAppTest extends AbstractCdiSingleAppTest { + @Test + public void testAddOneBookWithValidation() { + final String id = UUID.randomUUID().toString(); + + Response r = createWebClient("/rest/v2/bookstore/books").post( + new Form() + .param("id", id)); + assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), r.getStatus()); + } + + + protected WebClient createWebClient(final String url) { + return createWebClient(url, MediaType.APPLICATION_JSON); + } + + protected WebClient createWebClient(final String url, final String mediaType) { + final List< ? > providers = Arrays.asList(new JacksonJsonProvider()); + + final WebClient wc = WebClient + .create("http://localhost:" + getPort() + url, providers) + .accept(mediaType); + + WebClient.getConfig(wc).getHttpConduit().getClient().setReceiveTimeout(10000000L); + return wc; + } + + protected String getBasePath() { + return "/rest/v1/bookstore"; + } + + protected abstract int getPort(); +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cxf/blob/faf46115/systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/AbstractCdiSingleAppTest.java ---------------------------------------------------------------------- diff --git a/systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/AbstractCdiSingleAppTest.java b/systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/AbstractCdiSingleAppTest.java new file mode 100644 index 0000000..f690d06 --- /dev/null +++ b/systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/AbstractCdiSingleAppTest.java @@ -0,0 +1,96 @@ +/** + * 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.systests.cdi.base; + +import java.util.Arrays; +import java.util.List; +import java.util.UUID; + +import javax.ws.rs.core.Form; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider; + +import org.apache.cxf.jaxrs.client.WebClient; +import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase; +import org.junit.Test; + +public abstract class AbstractCdiSingleAppTest extends AbstractBusClientServerTestBase { + @Test + public void testInjectedVersionIsProperlyReturned() { + Response r = createWebClient("/rest/bookstore/version", MediaType.TEXT_PLAIN).get(); + assertEquals(Response.Status.OK.getStatusCode(), r.getStatus()); + assertEquals("1.0", r.readEntity(String.class)); + } + + @Test + public void testResponseHasBeenReceivedWhenAddingNewBook() { + Response r = createWebClient(getBasePath() + "/books").post( + new Form() + .param("id", "1234") + .param("name", "Book 1234")); + assertEquals(Response.Status.CREATED.getStatusCode(), r.getStatus()); + } + + @Test + public void testResponseHasBeenReceivedWhenQueringAllBooks() { + Response r = createWebClient(getBasePath() + "/books").get(); + assertEquals(Response.Status.OK.getStatusCode(), r.getStatus()); + } + + @Test + public void testAddAndQueryOneBook() { + final String id = UUID.randomUUID().toString(); + + Response r = createWebClient(getBasePath() + "/books").post( + new Form() + .param("id", id) + .param("name", "Book 1234")); + assertEquals(Response.Status.CREATED.getStatusCode(), r.getStatus()); + + r = createWebClient(getBasePath() + "/books").path(id).get(); + assertEquals(Response.Status.OK.getStatusCode(), r.getStatus()); + + Book book = r.readEntity(Book.class); + assertEquals(id, book.getId()); + } + + + protected WebClient createWebClient(final String url) { + return createWebClient(url, MediaType.APPLICATION_JSON); + } + + protected WebClient createWebClient(final String url, final String mediaType) { + final List< ? > providers = Arrays.asList(new JacksonJsonProvider()); + + final WebClient wc = WebClient + .create("http://localhost:" + getPort() + url, providers) + .accept(mediaType); + + WebClient.getConfig(wc).getHttpConduit().getClient().setReceiveTimeout(10000000L); + return wc; + } + + protected String getBasePath() { + return "/rest/bookstore"; + } + + protected abstract int getPort(); +} http://git-wip-us.apache.org/repos/asf/cxf/blob/faf46115/systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/Book.java ---------------------------------------------------------------------- diff --git a/systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/Book.java b/systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/Book.java new file mode 100644 index 0000000..08f454b --- /dev/null +++ b/systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/Book.java @@ -0,0 +1,54 @@ +/** + * 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.systests.cdi.base; + +import javax.validation.constraints.NotNull; + +public class Book { + @NotNull private String name; + private String id; + + public Book() { + } + + public Book(String id) { + this.id = id; + } + + public Book(String name, String id) { + this.name = name; + this.id = id; + } + + public void setName(String n) { + name = n; + } + + public String getName() { + return name; + } + + public void setId(String i) { + id = i; + } + + public String getId() { + return id; + } +} http://git-wip-us.apache.org/repos/asf/cxf/blob/faf46115/systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/BookStore.java ---------------------------------------------------------------------- diff --git a/systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/BookStore.java b/systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/BookStore.java new file mode 100644 index 0000000..81b113a --- /dev/null +++ b/systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/BookStore.java @@ -0,0 +1,75 @@ +/** + * 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.systests.cdi.base; + +import java.util.Collection; + +import javax.inject.Inject; +import javax.validation.Valid; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; +import javax.ws.rs.FormParam; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.UriInfo; + +@Path("/bookstore/") +public class BookStore { + @Inject private BookStoreService service; + @Inject private String version; + + @GET + @Path("/version") + @Produces(MediaType.TEXT_PLAIN) + public String getVersion() { + return version; + } + + @GET + @Path("/books/{bookId}") + @NotNull + @Produces(MediaType.APPLICATION_JSON) + public Book getBook(@PathParam("bookId") String id) { + return service.get(id); + } + + @GET + @Path("/books") + @NotNull @Valid + @Produces(MediaType.APPLICATION_JSON) + public Collection< Book > getBooks() { + return service.all(); + } + + @POST + @Path("/books") + @Produces(MediaType.APPLICATION_JSON) + public Response addBook(@Context final UriInfo uriInfo, + @NotNull @Size(min = 1, max = 50) @FormParam("id") String id, + @NotNull @FormParam("name") String name) { + final Book book = service.store(id, name); + return Response.created(uriInfo.getRequestUriBuilder().path(id).build()).entity(book).build(); + } +} http://git-wip-us.apache.org/repos/asf/cxf/blob/faf46115/systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/BookStoreService.java ---------------------------------------------------------------------- diff --git a/systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/BookStoreService.java b/systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/BookStoreService.java new file mode 100644 index 0000000..7809498 --- /dev/null +++ b/systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/BookStoreService.java @@ -0,0 +1,53 @@ +/** + * 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.systests.cdi.base; + + +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; + +import javax.enterprise.context.Dependent; +import javax.enterprise.inject.Produces; +import javax.inject.Named; + +@Named +public class BookStoreService { + private Map< String, Book> books = new HashMap<>(); + + public Book get(final String id) { + return books.get(id); + } + + public Collection< Book > all() { + return books.values(); + } + + public Book store(final String id, final String name) { + final Book book = new Book(name, id); + books.put(id, book); + return book; + } + + @Produces + @Dependent + public String version() { + return "1.0"; + } +} http://git-wip-us.apache.org/repos/asf/cxf/blob/faf46115/systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/jetty/AbstractJettyServer.java ---------------------------------------------------------------------- diff --git a/systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/jetty/AbstractJettyServer.java b/systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/jetty/AbstractJettyServer.java new file mode 100644 index 0000000..6cc5e2e --- /dev/null +++ b/systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/jetty/AbstractJettyServer.java @@ -0,0 +1,97 @@ +/** + * 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.systests.cdi.base.jetty; + +import java.util.EventListener; + +import org.apache.cxf.cdi.CXFCdiServlet; +import org.apache.cxf.testutil.common.AbstractBusTestServerBase; +import org.eclipse.jetty.server.Handler; +import org.eclipse.jetty.server.Server; +import org.eclipse.jetty.server.handler.DefaultHandler; +import org.eclipse.jetty.server.handler.HandlerCollection; +import org.eclipse.jetty.servlet.ServletContextHandler; +import org.eclipse.jetty.servlet.ServletHolder; +import org.eclipse.jetty.webapp.WebAppContext; + +public abstract class AbstractJettyServer extends AbstractBusTestServerBase { + + private Server server; + private final String resourcePath; + private final String contextPath; + private final int port; + private final EventListener listener; + + protected AbstractJettyServer(final String contextPath, int portNumber, EventListener listener) { + this(null, contextPath, portNumber, listener); + } + + protected AbstractJettyServer(final String resourcePath, final String contextPath, int portNumber, + EventListener listener) { + this.resourcePath = resourcePath; + this.contextPath = contextPath; + this.port = portNumber; + this.listener = listener; + } + + protected void run() { + System.setProperty("java.naming.factory.url", "org.eclipse.jetty.jndi"); + System.setProperty("java.naming.factory.initial", "org.eclipse.jetty.jndi.InitialContextFactory"); + + server = new Server(port); + + try { + if (resourcePath == null) { + // Register and map the dispatcher servlet + final ServletHolder servletHolder = new ServletHolder(new CXFCdiServlet()); + final ServletContextHandler context = new ServletContextHandler(); + context.setContextPath(contextPath); + context.addEventListener(listener); + context.addServlet(servletHolder, "/rest/*"); + server.setHandler(context); + } else { + final WebAppContext context = new WebAppContext(); + context.setContextPath(contextPath); + context.setWar(getClass().getResource(resourcePath).toURI().getPath()); + context.setServerClasses(new String[] { + "org.eclipse.jetty.servlet.ServletContextHandler.Decorator" + }); + + HandlerCollection handlers = new HandlerCollection(); + handlers.setHandlers(new Handler[] {context, new DefaultHandler()}); + server.setHandler(handlers); + } + + server.start(); + } catch (final Exception ex) { + ex.printStackTrace(); + fail(ex.getMessage()); + } + } + + public void tearDown() throws Exception { + super.tearDown(); + + if (server != null) { + server.stop(); + server.destroy(); + server = null; + } + } +} http://git-wip-us.apache.org/repos/asf/cxf/blob/faf46115/systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/tomcat/AbstractTomcatServer.java ---------------------------------------------------------------------- diff --git a/systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/tomcat/AbstractTomcatServer.java b/systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/tomcat/AbstractTomcatServer.java new file mode 100644 index 0000000..a70e3d4 --- /dev/null +++ b/systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/tomcat/AbstractTomcatServer.java @@ -0,0 +1,88 @@ +/** + * 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.systests.cdi.base.tomcat; + +import java.io.File; +import java.io.IOException; + +import org.apache.catalina.startup.Tomcat; +import org.apache.cxf.testutil.common.AbstractBusTestServerBase; + +public abstract class AbstractTomcatServer extends AbstractBusTestServerBase { + + private Tomcat server; + private final String resourcePath; + private final String contextPath; + private final int port; + + protected AbstractTomcatServer(final String resourcePath, final String contextPath, int portNumber) { + this.resourcePath = resourcePath; + this.contextPath = contextPath; + this.port = portNumber; + } + + protected void run() { + System.setProperty("java.naming.factory.url", "org.eclipse.jetty.jndi"); + System.setProperty("java.naming.factory.initial", "org.eclipse.jetty.jndi.InitialContextFactory"); + + server = new Tomcat(); + server.setPort(port); + + try { + final File base = createTemporaryDirectory(); + server.setBaseDir(base.getAbsolutePath()); + + server.getHost().setAppBase(base.getAbsolutePath()); + server.getHost().setAutoDeploy(true); + server.getHost().setDeployOnStartup(true); + + server.addWebapp(contextPath, getClass().getResource(resourcePath).toURI().getPath().toString()); + server.start(); + } catch (final Exception ex) { + ex.printStackTrace(); + fail(ex.getMessage()); + } + } + + private static File createTemporaryDirectory() throws IOException { + final File base = File.createTempFile("tmp-", ""); + + if (!base.delete()) { + throw new IOException("Cannot (re)create base folder: " + base.getAbsolutePath()); + } + + if (!base.mkdir()) { + throw new IOException("Cannot create base folder: " + base.getAbsolutePath()); + } + + base.deleteOnExit(); + return base; + } + + public void tearDown() throws Exception { + super.tearDown(); + + if (server != null) { + server.stop(); + server.destroy(); + server = null; + } + } +} http://git-wip-us.apache.org/repos/asf/cxf/blob/faf46115/systests/cdi/base/src/main/resources/META-INF/beans.xml ---------------------------------------------------------------------- diff --git a/systests/cdi/base/src/main/resources/META-INF/beans.xml b/systests/cdi/base/src/main/resources/META-INF/beans.xml new file mode 100644 index 0000000..2f48c57 --- /dev/null +++ b/systests/cdi/base/src/main/resources/META-INF/beans.xml @@ -0,0 +1,6 @@ +<?xml version="1.0"?> +<beans xmlns="http://java.sun.com/xml/ns/javaee" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://jboss.org/schema/cdi/beans_1_1.xsd"> + +</beans> http://git-wip-us.apache.org/repos/asf/cxf/blob/faf46115/systests/cdi/cdi-owb/cdi-multiple-apps-owb/pom.xml ---------------------------------------------------------------------- diff --git a/systests/cdi/cdi-owb/cdi-multiple-apps-owb/pom.xml b/systests/cdi/cdi-owb/cdi-multiple-apps-owb/pom.xml new file mode 100644 index 0000000..e1e07ac --- /dev/null +++ b/systests/cdi/cdi-owb/cdi-multiple-apps-owb/pom.xml @@ -0,0 +1,32 @@ +<?xml version="1.0"?> +<!-- + 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. +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <parent> + <groupId>org.apache.cxf.systests</groupId> + <artifactId>cxf-systests-cdi-owb</artifactId> + <version>3.2.0-SNAPSHOT</version> + <relativePath>../</relativePath> + </parent> + <modelVersion>4.0.0</modelVersion> + <artifactId>cxf-systests-cdi-owb-multiple-apps</artifactId> + <name>Apache CXF CDI Integration System Tests - OWB with multiple apps</name> + <description>Apache CXF CDI Integration System Tests - OpenWebBeans with multiple apps</description> + <url>http://cxf.apache.org</url> +</project> http://git-wip-us.apache.org/repos/asf/cxf/blob/faf46115/systests/cdi/cdi-owb/cdi-multiple-apps-owb/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreApplication.java ---------------------------------------------------------------------- diff --git a/systests/cdi/cdi-owb/cdi-multiple-apps-owb/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreApplication.java b/systests/cdi/cdi-owb/cdi-multiple-apps-owb/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreApplication.java new file mode 100644 index 0000000..268b402 --- /dev/null +++ b/systests/cdi/cdi-owb/cdi-multiple-apps-owb/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreApplication.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.cxf.systest.jaxrs; + +import javax.ws.rs.ApplicationPath; +import javax.ws.rs.core.Application; + +@ApplicationPath("/v1") +public class BookStoreApplication extends Application { +} http://git-wip-us.apache.org/repos/asf/cxf/blob/faf46115/systests/cdi/cdi-owb/cdi-multiple-apps-owb/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreCustomApplication.java ---------------------------------------------------------------------- diff --git a/systests/cdi/cdi-owb/cdi-multiple-apps-owb/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreCustomApplication.java b/systests/cdi/cdi-owb/cdi-multiple-apps-owb/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreCustomApplication.java new file mode 100644 index 0000000..4438aaf --- /dev/null +++ b/systests/cdi/cdi-owb/cdi-multiple-apps-owb/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreCustomApplication.java @@ -0,0 +1,49 @@ +/** + * 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.systest.jaxrs; + +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; + +import javax.ws.rs.ApplicationPath; +import javax.ws.rs.core.Application; + +import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider; + +import org.apache.cxf.jaxrs.validation.JAXRSBeanValidationFeature; +import org.apache.cxf.jaxrs.validation.ValidationExceptionMapper; +import org.apache.cxf.systests.cdi.base.BookStore; + +@ApplicationPath("/v2") +public class BookStoreCustomApplication extends Application { + @Override + public Set< Object > getSingletons() { + Set<Object> singletons = new HashSet<>(); + singletons.add(new JacksonJsonProvider()); + singletons.add(new ValidationExceptionMapper()); + singletons.add(new JAXRSBeanValidationFeature()); + return singletons; + } + + @Override + public Set<Class<?>> getClasses() { + return Collections.<Class<?>>singleton(BookStore.class); + } +} http://git-wip-us.apache.org/repos/asf/cxf/blob/faf46115/systests/cdi/cdi-owb/cdi-multiple-apps-owb/src/test/java/org/apache/cxf/systest/jaxrs/cdi/jetty/JettyEmbeddedTest.java ---------------------------------------------------------------------- diff --git a/systests/cdi/cdi-owb/cdi-multiple-apps-owb/src/test/java/org/apache/cxf/systest/jaxrs/cdi/jetty/JettyEmbeddedTest.java b/systests/cdi/cdi-owb/cdi-multiple-apps-owb/src/test/java/org/apache/cxf/systest/jaxrs/cdi/jetty/JettyEmbeddedTest.java new file mode 100644 index 0000000..b5d54e9 --- /dev/null +++ b/systests/cdi/cdi-owb/cdi-multiple-apps-owb/src/test/java/org/apache/cxf/systest/jaxrs/cdi/jetty/JettyEmbeddedTest.java @@ -0,0 +1,49 @@ +/** + * 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.systest.jaxrs.cdi.jetty; + +import org.apache.cxf.jaxrs.model.AbstractResourceInfo; +import org.apache.cxf.systests.cdi.base.AbstractCdiMultiAppTest; +import org.apache.cxf.systests.cdi.base.jetty.AbstractJettyServer; +import org.apache.webbeans.servlet.WebBeansConfigurationListener; +import org.junit.BeforeClass; + +public class JettyEmbeddedTest extends AbstractCdiMultiAppTest { + public static class EmbeddedJettyServer extends AbstractJettyServer { + public static final int PORT = allocatePortAsInt(EmbeddedJettyServer.class); + + public EmbeddedJettyServer() { + super("/", PORT, new WebBeansConfigurationListener()); + } + } + + @BeforeClass + public static void startServers() throws Exception { + AbstractResourceInfo.clearAllMaps(); + //keep out of process due to stack traces testing failures + assertTrue("server did not launch correctly", launchServer(EmbeddedJettyServer.class, true)); + createStaticBus(); + } + + @Override + protected int getPort() { + return EmbeddedJettyServer.PORT; + } +} http://git-wip-us.apache.org/repos/asf/cxf/blob/faf46115/systests/cdi/cdi-owb/cdi-multiple-apps-owb/src/test/java/org/apache/cxf/systest/jaxrs/cdi/jetty/JettyWarTest.java ---------------------------------------------------------------------- diff --git a/systests/cdi/cdi-owb/cdi-multiple-apps-owb/src/test/java/org/apache/cxf/systest/jaxrs/cdi/jetty/JettyWarTest.java b/systests/cdi/cdi-owb/cdi-multiple-apps-owb/src/test/java/org/apache/cxf/systest/jaxrs/cdi/jetty/JettyWarTest.java new file mode 100644 index 0000000..fb21c5c --- /dev/null +++ b/systests/cdi/cdi-owb/cdi-multiple-apps-owb/src/test/java/org/apache/cxf/systest/jaxrs/cdi/jetty/JettyWarTest.java @@ -0,0 +1,49 @@ +/** + * 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.systest.jaxrs.cdi.jetty; + +import org.apache.cxf.jaxrs.model.AbstractResourceInfo; +import org.apache.cxf.systests.cdi.base.AbstractCdiMultiAppTest; +import org.apache.cxf.systests.cdi.base.jetty.AbstractJettyServer; +import org.apache.webbeans.servlet.WebBeansConfigurationListener; +import org.junit.BeforeClass; + +public class JettyWarTest extends AbstractCdiMultiAppTest { + public static class EmbeddedJettyServer extends AbstractJettyServer { + public static final int PORT = allocatePortAsInt(EmbeddedJettyServer.class); + + public EmbeddedJettyServer() { + super("/jaxrs_cdi", "/", PORT, new WebBeansConfigurationListener()); + } + } + + @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; + } + +} http://git-wip-us.apache.org/repos/asf/cxf/blob/faf46115/systests/cdi/cdi-owb/cdi-multiple-apps-owb/src/test/java/org/apache/cxf/systest/jaxrs/cdi/tomcat/TomcatWarTest.java ---------------------------------------------------------------------- diff --git a/systests/cdi/cdi-owb/cdi-multiple-apps-owb/src/test/java/org/apache/cxf/systest/jaxrs/cdi/tomcat/TomcatWarTest.java b/systests/cdi/cdi-owb/cdi-multiple-apps-owb/src/test/java/org/apache/cxf/systest/jaxrs/cdi/tomcat/TomcatWarTest.java new file mode 100644 index 0000000..b364817 --- /dev/null +++ b/systests/cdi/cdi-owb/cdi-multiple-apps-owb/src/test/java/org/apache/cxf/systest/jaxrs/cdi/tomcat/TomcatWarTest.java @@ -0,0 +1,48 @@ +/** + * 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.systest.jaxrs.cdi.tomcat; + +import org.apache.cxf.jaxrs.model.AbstractResourceInfo; +import org.apache.cxf.systests.cdi.base.AbstractCdiMultiAppTest; +import org.apache.cxf.systests.cdi.base.tomcat.AbstractTomcatServer; +import org.junit.BeforeClass; + +public class TomcatWarTest extends AbstractCdiMultiAppTest { + public static class EmbeddedTomcatServer extends AbstractTomcatServer { + public static final int PORT = allocatePortAsInt(EmbeddedTomcatServer.class); + + public EmbeddedTomcatServer() { + super("/jaxrs_cdi", "/", PORT); + } + } + + @BeforeClass + public static void startServers() throws Exception { + AbstractResourceInfo.clearAllMaps(); + assertTrue("server did not launch correctly", launchServer(EmbeddedTomcatServer.class, true)); + createStaticBus(); + } + + @Override + protected int getPort() { + return EmbeddedTomcatServer.PORT; + } + +} http://git-wip-us.apache.org/repos/asf/cxf/blob/faf46115/systests/cdi/cdi-owb/cdi-multiple-apps-owb/src/test/resources/META-INF/beans.xml ---------------------------------------------------------------------- diff --git a/systests/cdi/cdi-owb/cdi-multiple-apps-owb/src/test/resources/META-INF/beans.xml b/systests/cdi/cdi-owb/cdi-multiple-apps-owb/src/test/resources/META-INF/beans.xml new file mode 100644 index 0000000..2f48c57 --- /dev/null +++ b/systests/cdi/cdi-owb/cdi-multiple-apps-owb/src/test/resources/META-INF/beans.xml @@ -0,0 +1,6 @@ +<?xml version="1.0"?> +<beans xmlns="http://java.sun.com/xml/ns/javaee" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://jboss.org/schema/cdi/beans_1_1.xsd"> + +</beans> http://git-wip-us.apache.org/repos/asf/cxf/blob/faf46115/systests/cdi/cdi-owb/cdi-multiple-apps-owb/src/test/resources/jaxrs_cdi/WEB-INF/web.xml ---------------------------------------------------------------------- diff --git a/systests/cdi/cdi-owb/cdi-multiple-apps-owb/src/test/resources/jaxrs_cdi/WEB-INF/web.xml b/systests/cdi/cdi-owb/cdi-multiple-apps-owb/src/test/resources/jaxrs_cdi/WEB-INF/web.xml new file mode 100644 index 0000000..5087b97 --- /dev/null +++ b/systests/cdi/cdi-owb/cdi-multiple-apps-owb/src/test/resources/jaxrs_cdi/WEB-INF/web.xml @@ -0,0 +1,24 @@ +<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + + <listener> + <listener-class>org.apache.webbeans.servlet.WebBeansConfigurationListener</listener-class> + </listener> + + <servlet> + <servlet-name>CXFServlet</servlet-name> + <display-name>CXF Servlet</display-name> + <servlet-class>org.apache.cxf.cdi.CXFCdiServlet</servlet-class> + <load-on-startup>1</load-on-startup> + </servlet> + + <servlet-mapping> + <servlet-name>CXFServlet</servlet-name> + <url-pattern>/rest/*</url-pattern> + </servlet-mapping> + + <resource-env-ref> + <resource-env-ref-name>BeanManager</resource-env-ref-name> + <resource-env-ref-type>javax.enterprise.inject.spi.BeanManager</resource-env-ref-type> + </resource-env-ref> +</web-app> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cxf/blob/faf46115/systests/cdi/cdi-owb/cdi-no-apps-owb/pom.xml ---------------------------------------------------------------------- diff --git a/systests/cdi/cdi-owb/cdi-no-apps-owb/pom.xml b/systests/cdi/cdi-owb/cdi-no-apps-owb/pom.xml new file mode 100644 index 0000000..cd7fd56 --- /dev/null +++ b/systests/cdi/cdi-owb/cdi-no-apps-owb/pom.xml @@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ~ 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. + --> + +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <parent> + <groupId>org.apache.cxf.systests</groupId> + <artifactId>cxf-systests-cdi-owb</artifactId> + <version>3.2.0-SNAPSHOT</version> + <relativePath>../</relativePath> + </parent> + <modelVersion>4.0.0</modelVersion> + <artifactId>cxf-systests-cdi-owb-no-apps</artifactId> + <name>Apache CXF CDI Integration System Tests - OWB with no apps</name> + <description>Apache CXF CDI Integration System Tests - OpenWebBeans with no apps</description> + <url>http://cxf.apache.org</url> +</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cxf/blob/faf46115/systests/cdi/cdi-owb/cdi-no-apps-owb/src/test/java/org/apache/cxf/systest/jaxrs/cdi/jetty/JettyEmbeddedTest.java ---------------------------------------------------------------------- diff --git a/systests/cdi/cdi-owb/cdi-no-apps-owb/src/test/java/org/apache/cxf/systest/jaxrs/cdi/jetty/JettyEmbeddedTest.java b/systests/cdi/cdi-owb/cdi-no-apps-owb/src/test/java/org/apache/cxf/systest/jaxrs/cdi/jetty/JettyEmbeddedTest.java new file mode 100644 index 0000000..f1281c4 --- /dev/null +++ b/systests/cdi/cdi-owb/cdi-no-apps-owb/src/test/java/org/apache/cxf/systest/jaxrs/cdi/jetty/JettyEmbeddedTest.java @@ -0,0 +1,48 @@ +/** + * 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.systest.jaxrs.cdi.jetty; + +import org.apache.cxf.jaxrs.model.AbstractResourceInfo; +import org.apache.cxf.systests.cdi.base.AbstractCdiSingleAppTest; +import org.apache.cxf.systests.cdi.base.jetty.AbstractJettyServer; +import org.apache.webbeans.servlet.WebBeansConfigurationListener; +import org.junit.BeforeClass; + +public class JettyEmbeddedTest extends AbstractCdiSingleAppTest { + public static class EmbeddedJettyServer extends AbstractJettyServer { + public static final int PORT = allocatePortAsInt(EmbeddedJettyServer.class); + + public EmbeddedJettyServer() { + super("/", PORT, new WebBeansConfigurationListener()); + } + } + + @BeforeClass + public static void startServers() throws Exception { + AbstractResourceInfo.clearAllMaps(); + //keep out of process due to stack traces testing failures + assertTrue("server did not launch correctly", launchServer(EmbeddedJettyServer.class, true)); + createStaticBus(); + } + + @Override + protected int getPort() { + return EmbeddedJettyServer.PORT; + } +} http://git-wip-us.apache.org/repos/asf/cxf/blob/faf46115/systests/cdi/cdi-owb/cdi-no-apps-owb/src/test/java/org/apache/cxf/systest/jaxrs/cdi/jetty/JettyWarTest.java ---------------------------------------------------------------------- diff --git a/systests/cdi/cdi-owb/cdi-no-apps-owb/src/test/java/org/apache/cxf/systest/jaxrs/cdi/jetty/JettyWarTest.java b/systests/cdi/cdi-owb/cdi-no-apps-owb/src/test/java/org/apache/cxf/systest/jaxrs/cdi/jetty/JettyWarTest.java new file mode 100644 index 0000000..6fb06db --- /dev/null +++ b/systests/cdi/cdi-owb/cdi-no-apps-owb/src/test/java/org/apache/cxf/systest/jaxrs/cdi/jetty/JettyWarTest.java @@ -0,0 +1,48 @@ +/** + * 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.systest.jaxrs.cdi.jetty; + +import org.apache.cxf.jaxrs.model.AbstractResourceInfo; +import org.apache.cxf.systests.cdi.base.AbstractCdiSingleAppTest; +import org.apache.cxf.systests.cdi.base.jetty.AbstractJettyServer; +import org.apache.webbeans.servlet.WebBeansConfigurationListener; +import org.junit.BeforeClass; + +public class JettyWarTest extends AbstractCdiSingleAppTest { + public static class EmbeddedJettyServer extends AbstractJettyServer { + public static final int PORT = allocatePortAsInt(EmbeddedJettyServer.class); + + public EmbeddedJettyServer() { + super("/jaxrs_cdi", "/", PORT, new WebBeansConfigurationListener()); + } + } + + @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; + } + +} http://git-wip-us.apache.org/repos/asf/cxf/blob/faf46115/systests/cdi/cdi-owb/cdi-no-apps-owb/src/test/java/org/apache/cxf/systest/jaxrs/cdi/tomcat/TomcatWarTest.java ---------------------------------------------------------------------- diff --git a/systests/cdi/cdi-owb/cdi-no-apps-owb/src/test/java/org/apache/cxf/systest/jaxrs/cdi/tomcat/TomcatWarTest.java b/systests/cdi/cdi-owb/cdi-no-apps-owb/src/test/java/org/apache/cxf/systest/jaxrs/cdi/tomcat/TomcatWarTest.java new file mode 100644 index 0000000..3c0ef7e --- /dev/null +++ b/systests/cdi/cdi-owb/cdi-no-apps-owb/src/test/java/org/apache/cxf/systest/jaxrs/cdi/tomcat/TomcatWarTest.java @@ -0,0 +1,47 @@ +/** + * 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.systest.jaxrs.cdi.tomcat; + +import org.apache.cxf.jaxrs.model.AbstractResourceInfo; +import org.apache.cxf.systests.cdi.base.AbstractCdiSingleAppTest; +import org.apache.cxf.systests.cdi.base.tomcat.AbstractTomcatServer; +import org.junit.BeforeClass; + +public class TomcatWarTest extends AbstractCdiSingleAppTest { + public static class EmbeddedTomcatServer extends AbstractTomcatServer { + public static final int PORT = allocatePortAsInt(EmbeddedTomcatServer.class); + + public EmbeddedTomcatServer() { + super("/jaxrs_cdi", "/", PORT); + } + } + + @BeforeClass + public static void startServers() throws Exception { + AbstractResourceInfo.clearAllMaps(); + assertTrue("server did not launch correctly", launchServer(EmbeddedTomcatServer.class, true)); + createStaticBus(); + } + + @Override + protected int getPort() { + return EmbeddedTomcatServer.PORT; + } + +} http://git-wip-us.apache.org/repos/asf/cxf/blob/faf46115/systests/cdi/cdi-owb/cdi-no-apps-owb/src/test/resources/META-INF/beans.xml ---------------------------------------------------------------------- diff --git a/systests/cdi/cdi-owb/cdi-no-apps-owb/src/test/resources/META-INF/beans.xml b/systests/cdi/cdi-owb/cdi-no-apps-owb/src/test/resources/META-INF/beans.xml new file mode 100644 index 0000000..2f48c57 --- /dev/null +++ b/systests/cdi/cdi-owb/cdi-no-apps-owb/src/test/resources/META-INF/beans.xml @@ -0,0 +1,6 @@ +<?xml version="1.0"?> +<beans xmlns="http://java.sun.com/xml/ns/javaee" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://jboss.org/schema/cdi/beans_1_1.xsd"> + +</beans> http://git-wip-us.apache.org/repos/asf/cxf/blob/faf46115/systests/cdi/cdi-owb/cdi-no-apps-owb/src/test/resources/jaxrs_cdi/WEB-INF/web.xml ---------------------------------------------------------------------- diff --git a/systests/cdi/cdi-owb/cdi-no-apps-owb/src/test/resources/jaxrs_cdi/WEB-INF/web.xml b/systests/cdi/cdi-owb/cdi-no-apps-owb/src/test/resources/jaxrs_cdi/WEB-INF/web.xml new file mode 100644 index 0000000..5087b97 --- /dev/null +++ b/systests/cdi/cdi-owb/cdi-no-apps-owb/src/test/resources/jaxrs_cdi/WEB-INF/web.xml @@ -0,0 +1,24 @@ +<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + + <listener> + <listener-class>org.apache.webbeans.servlet.WebBeansConfigurationListener</listener-class> + </listener> + + <servlet> + <servlet-name>CXFServlet</servlet-name> + <display-name>CXF Servlet</display-name> + <servlet-class>org.apache.cxf.cdi.CXFCdiServlet</servlet-class> + <load-on-startup>1</load-on-startup> + </servlet> + + <servlet-mapping> + <servlet-name>CXFServlet</servlet-name> + <url-pattern>/rest/*</url-pattern> + </servlet-mapping> + + <resource-env-ref> + <resource-env-ref-name>BeanManager</resource-env-ref-name> + <resource-env-ref-type>javax.enterprise.inject.spi.BeanManager</resource-env-ref-type> + </resource-env-ref> +</web-app> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cxf/blob/faf46115/systests/cdi/cdi-owb/pom.xml ---------------------------------------------------------------------- diff --git a/systests/cdi/cdi-owb/pom.xml b/systests/cdi/cdi-owb/pom.xml new file mode 100644 index 0000000..355583d --- /dev/null +++ b/systests/cdi/cdi-owb/pom.xml @@ -0,0 +1,121 @@ +<?xml version="1.0"?> +<!-- + 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. +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <parent> + <groupId>org.apache.cxf.systests</groupId> + <artifactId>cxf-systests-cdi</artifactId> + <version>3.2.0-SNAPSHOT</version> + <relativePath>../</relativePath> + </parent> + <modelVersion>4.0.0</modelVersion> + <artifactId>cxf-systests-cdi-owb</artifactId> + <packaging>pom</packaging> + <name>Apache CXF CDI Integration System Tests - OWB</name> + <description>Apache CXF CDI Integration System Tests - OpenWebBeans</description> + <url>http://cxf.apache.org</url> + + <modules> + <module>cdi-multiple-apps-owb</module> + <module>cdi-no-apps-owb</module> + </modules> + + <dependencies> + <dependency> + <groupId>javax.validation</groupId> + <artifactId>validation-api</artifactId> + </dependency> + <dependency> + <groupId>org.hibernate</groupId> + <artifactId>hibernate-validator</artifactId> + </dependency> + <dependency> + <groupId>org.apache.openwebbeans</groupId> + <artifactId>openwebbeans-impl</artifactId> + <version>${cxf.openwebbeans.version}</version> + </dependency> + <dependency> + <groupId>org.apache.openwebbeans</groupId> + <artifactId>openwebbeans-web</artifactId> + <version>${cxf.openwebbeans.version}</version> + </dependency> + <dependency> + <groupId>org.apache.geronimo.specs</groupId> + <artifactId>geronimo-interceptor_1.2_spec</artifactId> + <version>1.0</version> + </dependency> + <dependency> + <groupId>javax.el</groupId> + <artifactId>javax.el-api</artifactId> + </dependency> + <dependency> + <groupId>org.glassfish</groupId> + <artifactId>javax.el</artifactId> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-jdk14</artifactId> + </dependency> + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-core</artifactId> + </dependency> + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-transports-http-jetty</artifactId> + </dependency> + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-frontend-jaxrs</artifactId> + </dependency> + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-rs-client</artifactId> + </dependency> + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-testutils</artifactId> + </dependency> + <dependency> + <groupId>org.apache.cxf.systests</groupId> + <artifactId>cxf-systests-cdi-base</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>javax.annotation</groupId> + <artifactId>jsr250-api</artifactId> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.jaxrs</groupId> + <artifactId>jackson-jaxrs-json-provider</artifactId> + </dependency> + <dependency> + <groupId>org.apache.httpcomponents</groupId> + <artifactId>httpclient</artifactId> + </dependency> + <dependency> + <groupId>com.ning</groupId> + <artifactId>async-http-client</artifactId> + </dependency> + </dependencies> +</project> http://git-wip-us.apache.org/repos/asf/cxf/blob/faf46115/systests/cdi/cdi-weld/cdi-multiple-apps-weld/pom.xml ---------------------------------------------------------------------- diff --git a/systests/cdi/cdi-weld/cdi-multiple-apps-weld/pom.xml b/systests/cdi/cdi-weld/cdi-multiple-apps-weld/pom.xml new file mode 100644 index 0000000..0099c4b --- /dev/null +++ b/systests/cdi/cdi-weld/cdi-multiple-apps-weld/pom.xml @@ -0,0 +1,32 @@ +<?xml version="1.0"?> +<!-- + 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. +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <parent> + <groupId>org.apache.cxf.systests</groupId> + <artifactId>cxf-systests-cdi-weld</artifactId> + <version>3.2.0-SNAPSHOT</version> + <relativePath>../</relativePath> + </parent> + <modelVersion>4.0.0</modelVersion> + <artifactId>cxf-systests-cdi-weld-multiple-apps</artifactId> + <name>Apache CXF CDI Integration System Tests - Weld with multiple apps</name> + <description>Apache CXF CDI Integration System Tests - Weld with multiple apps</description> + <url>http://cxf.apache.org</url> +</project> http://git-wip-us.apache.org/repos/asf/cxf/blob/faf46115/systests/cdi/cdi-weld/cdi-multiple-apps-weld/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreApplication.java ---------------------------------------------------------------------- diff --git a/systests/cdi/cdi-weld/cdi-multiple-apps-weld/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreApplication.java b/systests/cdi/cdi-weld/cdi-multiple-apps-weld/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreApplication.java new file mode 100644 index 0000000..268b402 --- /dev/null +++ b/systests/cdi/cdi-weld/cdi-multiple-apps-weld/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreApplication.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.cxf.systest.jaxrs; + +import javax.ws.rs.ApplicationPath; +import javax.ws.rs.core.Application; + +@ApplicationPath("/v1") +public class BookStoreApplication extends Application { +} http://git-wip-us.apache.org/repos/asf/cxf/blob/faf46115/systests/cdi/cdi-weld/cdi-multiple-apps-weld/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreCustomApplication.java ---------------------------------------------------------------------- diff --git a/systests/cdi/cdi-weld/cdi-multiple-apps-weld/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreCustomApplication.java b/systests/cdi/cdi-weld/cdi-multiple-apps-weld/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreCustomApplication.java new file mode 100644 index 0000000..4438aaf --- /dev/null +++ b/systests/cdi/cdi-weld/cdi-multiple-apps-weld/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreCustomApplication.java @@ -0,0 +1,49 @@ +/** + * 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.systest.jaxrs; + +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; + +import javax.ws.rs.ApplicationPath; +import javax.ws.rs.core.Application; + +import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider; + +import org.apache.cxf.jaxrs.validation.JAXRSBeanValidationFeature; +import org.apache.cxf.jaxrs.validation.ValidationExceptionMapper; +import org.apache.cxf.systests.cdi.base.BookStore; + +@ApplicationPath("/v2") +public class BookStoreCustomApplication extends Application { + @Override + public Set< Object > getSingletons() { + Set<Object> singletons = new HashSet<>(); + singletons.add(new JacksonJsonProvider()); + singletons.add(new ValidationExceptionMapper()); + singletons.add(new JAXRSBeanValidationFeature()); + return singletons; + } + + @Override + public Set<Class<?>> getClasses() { + return Collections.<Class<?>>singleton(BookStore.class); + } +} http://git-wip-us.apache.org/repos/asf/cxf/blob/faf46115/systests/cdi/cdi-weld/cdi-multiple-apps-weld/src/test/java/org/apache/cxf/systest/jaxrs/cdi/WeldDiscoverableContainer.java ---------------------------------------------------------------------- diff --git a/systests/cdi/cdi-weld/cdi-multiple-apps-weld/src/test/java/org/apache/cxf/systest/jaxrs/cdi/WeldDiscoverableContainer.java b/systests/cdi/cdi-weld/cdi-multiple-apps-weld/src/test/java/org/apache/cxf/systest/jaxrs/cdi/WeldDiscoverableContainer.java new file mode 100644 index 0000000..2fabdd1 --- /dev/null +++ b/systests/cdi/cdi-weld/cdi-multiple-apps-weld/src/test/java/org/apache/cxf/systest/jaxrs/cdi/WeldDiscoverableContainer.java @@ -0,0 +1,56 @@ +/** + * 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.systest.jaxrs.cdi; + +import org.jboss.weld.environment.Container; +import org.jboss.weld.environment.ContainerContext; +import org.jboss.weld.environment.jetty.JettyContainer; +import org.jboss.weld.environment.tomcat.TomcatContainer; +import org.jboss.weld.resources.spi.ResourceLoader; + +/** + * Because we are mixing several Servlet Containers in the same project, JBoss Weld + * needs some help to figure out the correct one we are running right now. + */ +public class WeldDiscoverableContainer implements Container { + private final Container delegate; + + public WeldDiscoverableContainer() { + if (JettyContainer.class.getName().equals(System.getProperty(Container.class.getName()))) { + delegate = JettyContainer.INSTANCE; + } else { + delegate = TomcatContainer.INSTANCE; + } + } + + @Override + public boolean touch(ResourceLoader loader, ContainerContext context) throws Exception { + return delegate.touch(loader, context); + } + + @Override + public void initialize(ContainerContext context) { + delegate.initialize(context); + } + + @Override + public void destroy(ContainerContext context) { + delegate.destroy(context); + } +} http://git-wip-us.apache.org/repos/asf/cxf/blob/faf46115/systests/cdi/cdi-weld/cdi-multiple-apps-weld/src/test/java/org/apache/cxf/systest/jaxrs/cdi/jetty/JettyEmbeddedTest.java ---------------------------------------------------------------------- diff --git a/systests/cdi/cdi-weld/cdi-multiple-apps-weld/src/test/java/org/apache/cxf/systest/jaxrs/cdi/jetty/JettyEmbeddedTest.java b/systests/cdi/cdi-weld/cdi-multiple-apps-weld/src/test/java/org/apache/cxf/systest/jaxrs/cdi/jetty/JettyEmbeddedTest.java new file mode 100644 index 0000000..a802093 --- /dev/null +++ b/systests/cdi/cdi-weld/cdi-multiple-apps-weld/src/test/java/org/apache/cxf/systest/jaxrs/cdi/jetty/JettyEmbeddedTest.java @@ -0,0 +1,51 @@ +/** + * 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.systest.jaxrs.cdi.jetty; + +import org.apache.cxf.jaxrs.model.AbstractResourceInfo; +import org.apache.cxf.systests.cdi.base.AbstractCdiMultiAppTest; +import org.apache.cxf.systests.cdi.base.jetty.AbstractJettyServer; +import org.jboss.weld.environment.Container; +import org.jboss.weld.environment.jetty.JettyContainer; +import org.jboss.weld.environment.servlet.Listener; +import org.junit.BeforeClass; + +public class JettyEmbeddedTest extends AbstractCdiMultiAppTest { + public static class EmbeddedJettyServer extends AbstractJettyServer { + public static final int PORT = allocatePortAsInt(EmbeddedJettyServer.class); + + public EmbeddedJettyServer() { + super("/", PORT, new Listener()); + } + } + + @BeforeClass + public static void startServers() throws Exception { + AbstractResourceInfo.clearAllMaps(); + System.setProperty(Container.class.getName(), JettyContainer.class.getName()); + assertTrue("server did not launch correctly", launchServer(EmbeddedJettyServer.class, true)); + createStaticBus(); + } + + @Override + protected int getPort() { + return EmbeddedJettyServer.PORT; + } +} http://git-wip-us.apache.org/repos/asf/cxf/blob/faf46115/systests/cdi/cdi-weld/cdi-multiple-apps-weld/src/test/java/org/apache/cxf/systest/jaxrs/cdi/jetty/JettyWarTest.java ---------------------------------------------------------------------- diff --git a/systests/cdi/cdi-weld/cdi-multiple-apps-weld/src/test/java/org/apache/cxf/systest/jaxrs/cdi/jetty/JettyWarTest.java b/systests/cdi/cdi-weld/cdi-multiple-apps-weld/src/test/java/org/apache/cxf/systest/jaxrs/cdi/jetty/JettyWarTest.java new file mode 100644 index 0000000..dfc4dc7 --- /dev/null +++ b/systests/cdi/cdi-weld/cdi-multiple-apps-weld/src/test/java/org/apache/cxf/systest/jaxrs/cdi/jetty/JettyWarTest.java @@ -0,0 +1,54 @@ +/** + * 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.systest.jaxrs.cdi.jetty; + +import org.apache.cxf.jaxrs.model.AbstractResourceInfo; +import org.apache.cxf.systests.cdi.base.AbstractCdiMultiAppTest; +import org.apache.cxf.systests.cdi.base.jetty.AbstractJettyServer; +import org.jboss.weld.environment.Container; +import org.jboss.weld.environment.jetty.JettyContainer; +import org.jboss.weld.environment.servlet.Listener; +import org.junit.BeforeClass; +import org.junit.Ignore; + +public class JettyWarTest extends AbstractCdiMultiAppTest { + @Ignore + public static class EmbeddedJettyServer extends AbstractJettyServer { + public static final int PORT = allocatePortAsInt(EmbeddedJettyServer.class); + + public EmbeddedJettyServer() { + super("/jaxrs_cdi", "/", PORT, new Listener()); + } + } + + @BeforeClass + public static void startServers() throws Exception { + AbstractResourceInfo.clearAllMaps(); + System.setProperty(Container.class.getName(), JettyContainer.class.getName()); + assertTrue("server did not launch correctly", launchServer(EmbeddedJettyServer.class, true)); + createStaticBus(); + } + + @Override + protected int getPort() { + return EmbeddedJettyServer.PORT; + } + +} http://git-wip-us.apache.org/repos/asf/cxf/blob/faf46115/systests/cdi/cdi-weld/cdi-multiple-apps-weld/src/test/java/org/apache/cxf/systest/jaxrs/cdi/tomcat/TomcatWarTest.java ---------------------------------------------------------------------- diff --git a/systests/cdi/cdi-weld/cdi-multiple-apps-weld/src/test/java/org/apache/cxf/systest/jaxrs/cdi/tomcat/TomcatWarTest.java b/systests/cdi/cdi-weld/cdi-multiple-apps-weld/src/test/java/org/apache/cxf/systest/jaxrs/cdi/tomcat/TomcatWarTest.java new file mode 100644 index 0000000..7f7a079 --- /dev/null +++ b/systests/cdi/cdi-weld/cdi-multiple-apps-weld/src/test/java/org/apache/cxf/systest/jaxrs/cdi/tomcat/TomcatWarTest.java @@ -0,0 +1,51 @@ +/** + * 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.systest.jaxrs.cdi.tomcat; + +import org.apache.cxf.jaxrs.model.AbstractResourceInfo; +import org.apache.cxf.systests.cdi.base.AbstractCdiMultiAppTest; +import org.apache.cxf.systests.cdi.base.tomcat.AbstractTomcatServer; +import org.jboss.weld.environment.Container; +import org.jboss.weld.environment.tomcat.TomcatContainer; +import org.junit.BeforeClass; + +public class TomcatWarTest extends AbstractCdiMultiAppTest { + public static class EmbeddedTomcatServer extends AbstractTomcatServer { + public static final int PORT = allocatePortAsInt(EmbeddedTomcatServer.class); + + public EmbeddedTomcatServer() { + super("/jaxrs_cdi", "/", PORT); + } + } + + @BeforeClass + public static void startServers() throws Exception { + AbstractResourceInfo.clearAllMaps(); + System.setProperty(Container.class.getName(), TomcatContainer.class.getName()); + assertTrue("server did not launch correctly", launchServer(EmbeddedTomcatServer.class, true)); + createStaticBus(); + } + + @Override + protected int getPort() { + return EmbeddedTomcatServer.PORT; + } + +} http://git-wip-us.apache.org/repos/asf/cxf/blob/faf46115/systests/cdi/cdi-weld/cdi-multiple-apps-weld/src/test/resources/META-INF/beans.xml ---------------------------------------------------------------------- diff --git a/systests/cdi/cdi-weld/cdi-multiple-apps-weld/src/test/resources/META-INF/beans.xml b/systests/cdi/cdi-weld/cdi-multiple-apps-weld/src/test/resources/META-INF/beans.xml new file mode 100644 index 0000000..2f48c57 --- /dev/null +++ b/systests/cdi/cdi-weld/cdi-multiple-apps-weld/src/test/resources/META-INF/beans.xml @@ -0,0 +1,6 @@ +<?xml version="1.0"?> +<beans xmlns="http://java.sun.com/xml/ns/javaee" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://jboss.org/schema/cdi/beans_1_1.xsd"> + +</beans> http://git-wip-us.apache.org/repos/asf/cxf/blob/faf46115/systests/cdi/cdi-weld/cdi-multiple-apps-weld/src/test/resources/META-INF/services/org.jboss.weld.environment.Container ---------------------------------------------------------------------- diff --git a/systests/cdi/cdi-weld/cdi-multiple-apps-weld/src/test/resources/META-INF/services/org.jboss.weld.environment.Container b/systests/cdi/cdi-weld/cdi-multiple-apps-weld/src/test/resources/META-INF/services/org.jboss.weld.environment.Container new file mode 100644 index 0000000..df31f74 --- /dev/null +++ b/systests/cdi/cdi-weld/cdi-multiple-apps-weld/src/test/resources/META-INF/services/org.jboss.weld.environment.Container @@ -0,0 +1 @@ +org.apache.cxf.systest.jaxrs.cdi.WeldDiscoverableContainer \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cxf/blob/faf46115/systests/cdi/cdi-weld/cdi-multiple-apps-weld/src/test/resources/jaxrs_cdi/WEB-INF/web.xml ---------------------------------------------------------------------- diff --git a/systests/cdi/cdi-weld/cdi-multiple-apps-weld/src/test/resources/jaxrs_cdi/WEB-INF/web.xml b/systests/cdi/cdi-weld/cdi-multiple-apps-weld/src/test/resources/jaxrs_cdi/WEB-INF/web.xml new file mode 100644 index 0000000..66cc81a --- /dev/null +++ b/systests/cdi/cdi-weld/cdi-multiple-apps-weld/src/test/resources/jaxrs_cdi/WEB-INF/web.xml @@ -0,0 +1,25 @@ +<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + + <listener> + <listener-class>org.jboss.weld.environment.servlet.Listener</listener-class> + </listener> + + <servlet> + <servlet-name>CXFServlet</servlet-name> + <display-name>CXF Servlet</display-name> + <servlet-class>org.apache.cxf.cdi.CXFCdiServlet</servlet-class> + <load-on-startup>1</load-on-startup> + </servlet> + + <servlet-mapping> + <servlet-name>CXFServlet</servlet-name> + <url-pattern>/rest/*</url-pattern> + </servlet-mapping> + + <resource-env-ref> + <resource-env-ref-name>BeanManager</resource-env-ref-name> + <resource-env-ref-type>javax.enterprise.inject.spi.BeanManager + </resource-env-ref-type> + </resource-env-ref> +</web-app> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cxf/blob/faf46115/systests/cdi/cdi-weld/cdi-no-apps-weld/pom.xml ---------------------------------------------------------------------- diff --git a/systests/cdi/cdi-weld/cdi-no-apps-weld/pom.xml b/systests/cdi/cdi-weld/cdi-no-apps-weld/pom.xml new file mode 100644 index 0000000..2799a9f --- /dev/null +++ b/systests/cdi/cdi-weld/cdi-no-apps-weld/pom.xml @@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ~ 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. + --> + +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <parent> + <groupId>org.apache.cxf.systests</groupId> + <artifactId>cxf-systests-cdi-weld</artifactId> + <version>3.2.0-SNAPSHOT</version> + <relativePath>../</relativePath> + </parent> + <modelVersion>4.0.0</modelVersion> + <artifactId>cxf-systests-cdi-weld-no-apps</artifactId> + <name>Apache CXF CDI Integration System Tests - Weld with no apps</name> + <description>Apache CXF CDI Integration System Tests - Weld with no apps</description> + <url>http://cxf.apache.org</url> +</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cxf/blob/faf46115/systests/cdi/cdi-weld/cdi-no-apps-weld/src/test/java/org/apache/cxf/systest/jaxrs/cdi/WeldDiscoverableContainer.java ---------------------------------------------------------------------- diff --git a/systests/cdi/cdi-weld/cdi-no-apps-weld/src/test/java/org/apache/cxf/systest/jaxrs/cdi/WeldDiscoverableContainer.java b/systests/cdi/cdi-weld/cdi-no-apps-weld/src/test/java/org/apache/cxf/systest/jaxrs/cdi/WeldDiscoverableContainer.java new file mode 100644 index 0000000..2fabdd1 --- /dev/null +++ b/systests/cdi/cdi-weld/cdi-no-apps-weld/src/test/java/org/apache/cxf/systest/jaxrs/cdi/WeldDiscoverableContainer.java @@ -0,0 +1,56 @@ +/** + * 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.systest.jaxrs.cdi; + +import org.jboss.weld.environment.Container; +import org.jboss.weld.environment.ContainerContext; +import org.jboss.weld.environment.jetty.JettyContainer; +import org.jboss.weld.environment.tomcat.TomcatContainer; +import org.jboss.weld.resources.spi.ResourceLoader; + +/** + * Because we are mixing several Servlet Containers in the same project, JBoss Weld + * needs some help to figure out the correct one we are running right now. + */ +public class WeldDiscoverableContainer implements Container { + private final Container delegate; + + public WeldDiscoverableContainer() { + if (JettyContainer.class.getName().equals(System.getProperty(Container.class.getName()))) { + delegate = JettyContainer.INSTANCE; + } else { + delegate = TomcatContainer.INSTANCE; + } + } + + @Override + public boolean touch(ResourceLoader loader, ContainerContext context) throws Exception { + return delegate.touch(loader, context); + } + + @Override + public void initialize(ContainerContext context) { + delegate.initialize(context); + } + + @Override + public void destroy(ContainerContext context) { + delegate.destroy(context); + } +}
