You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by re...@apache.org on 2017/05/08 21:53:47 UTC
cxf git commit: CXF-7346: CDI Extension ignores producer methods and
fields
Repository: cxf
Updated Branches:
refs/heads/master c2e63fa2a -> 4b96a222a
CXF-7346: CDI Extension ignores producer methods and fields
Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/4b96a222
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/4b96a222
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/4b96a222
Branch: refs/heads/master
Commit: 4b96a222aea61f9fe80083c4c4bb1519955890ab
Parents: c2e63fa
Author: reta <dr...@gmail.com>
Authored: Mon May 8 17:53:34 2017 -0400
Committer: reta <dr...@gmail.com>
Committed: Mon May 8 17:53:34 2017 -0400
----------------------------------------------------------------------
.../cxf/cdi/JAXRSCdiResourceExtension.java | 36 +++++++-
.../org/apache/cxf/systests/cdi/base/Book.java | 2 +
systests/cdi/cdi-owb/cdi-producers-owb/pom.xml | 51 +++++++++++
.../cxf/systest/jaxrs/cdi/BookStoreFeed.java | 56 ++++++++++++
.../jaxrs/cdi/BookStoreProducerApplication.java | 55 ++++++++++++
.../jaxrs/cdi/BookStoreValidatingFeed.java | 41 +++++++++
.../cxf/systest/jaxrs/cdi/SampleFeature.java | 33 +++++++
.../jaxrs/cdi/jetty/JettyEmbeddedTest.java | 89 ++++++++++++++++++
.../systest/jaxrs/cdi/jetty/JettyWarTest.java | 91 +++++++++++++++++++
.../systest/jaxrs/cdi/tomcat/TomcatWarTest.java | 89 ++++++++++++++++++
.../src/test/resources/META-INF/beans.xml | 14 +++
.../org.jboss.weld.environment.Container | 1 +
.../test/resources/jaxrs_cdi/WEB-INF/web.xml | 24 +++++
systests/cdi/cdi-owb/pom.xml | 3 +-
.../cdi/cdi-weld/cdi-producers-weld/pom.xml | 51 +++++++++++
.../cxf/systest/jaxrs/cdi/BookStoreFeed.java | 56 ++++++++++++
.../jaxrs/cdi/BookStoreProducerApplication.java | 55 ++++++++++++
.../jaxrs/cdi/BookStoreValidatingFeed.java | 41 +++++++++
.../cxf/systest/jaxrs/cdi/SampleFeature.java | 33 +++++++
.../jaxrs/cdi/WeldDiscoverableContainer.java | 56 ++++++++++++
.../jaxrs/cdi/jetty/JettyEmbeddedTest.java | 92 +++++++++++++++++++
.../systest/jaxrs/cdi/jetty/JettyWarTest.java | 94 ++++++++++++++++++++
.../systest/jaxrs/cdi/tomcat/TomcatWarTest.java | 92 +++++++++++++++++++
.../src/test/resources/META-INF/beans.xml | 14 +++
.../org.jboss.weld.environment.Container | 1 +
.../test/resources/jaxrs_cdi/WEB-INF/web.xml | 25 ++++++
systests/cdi/cdi-weld/pom.xml | 1 +
27 files changed, 1193 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cxf/blob/4b96a222/integration/cdi/src/main/java/org/apache/cxf/cdi/JAXRSCdiResourceExtension.java
----------------------------------------------------------------------
diff --git a/integration/cdi/src/main/java/org/apache/cxf/cdi/JAXRSCdiResourceExtension.java b/integration/cdi/src/main/java/org/apache/cxf/cdi/JAXRSCdiResourceExtension.java
index 8ec1781..5ce8807 100644
--- a/integration/cdi/src/main/java/org/apache/cxf/cdi/JAXRSCdiResourceExtension.java
+++ b/integration/cdi/src/main/java/org/apache/cxf/cdi/JAXRSCdiResourceExtension.java
@@ -18,6 +18,7 @@
*/
package org.apache.cxf.cdi;
+import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -37,6 +38,8 @@ import javax.enterprise.inject.spi.BeforeShutdown;
import javax.enterprise.inject.spi.Extension;
import javax.enterprise.inject.spi.InjectionTarget;
import javax.enterprise.inject.spi.ProcessBean;
+import javax.enterprise.inject.spi.ProcessProducerField;
+import javax.enterprise.inject.spi.ProcessProducerMethod;
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.Path;
import javax.ws.rs.core.Application;
@@ -116,6 +119,16 @@ public class JAXRSCdiResourceExtension implements Extension {
hasBus = true;
}
}
+
+ public <T, X> void collect(@Observes final ProcessProducerField< T, X > event) {
+ final Type baseType = event.getAnnotatedProducerField().getBaseType();
+ processProducer(event, baseType);
+ }
+
+ public <T, X> void collect(@Observes final ProcessProducerMethod< T, X > event) {
+ final Type baseType = event.getAnnotatedProducerMethod().getBaseType();
+ processProducer(event, baseType);
+ }
public void load(@Observes final AfterDeploymentValidation event, final BeanManager beanManager) {
// no need of creational context, it only works for app scoped instances anyway
@@ -301,7 +314,7 @@ public class JAXRSCdiResourceExtension implements Extension {
instances.add(
beanManager.getReference(
bean,
- bean.getBeanClass(),
+ Object.class,
createCreationalContext(beanManager, bean)
)
);
@@ -324,7 +337,7 @@ public class JAXRSCdiResourceExtension implements Extension {
features.add(
(Feature) beanManager.getReference(
bean,
- bean.getBeanClass(),
+ Feature.class,
createCreationalContext(beanManager, bean)
)
);
@@ -367,4 +380,23 @@ public class JAXRSCdiResourceExtension implements Extension {
}
return creationalContext;
}
+
+ /**
+ * Extracts relevant beans from producers.
+ * @param event process bean event
+ * @param baseType base type of the producer
+ */
+ private <T> void processProducer(final ProcessBean<T> event, final Type baseType) {
+ if (baseType instanceof Class<?>) {
+ final Class<?> clazz = (Class<?>)baseType;
+ if (clazz.isAnnotationPresent(Path.class)) {
+ serviceBeans.add(event.getBean());
+ } else if (clazz.isAnnotationPresent(Provider.class)) {
+ providerBeans.add(event.getBean());
+ } else if (clazz.isAnnotationPresent(ApplicationPath.class)) {
+ applicationBeans.add(event.getBean());
+ }
+ }
+ }
+
}
http://git-wip-us.apache.org/repos/asf/cxf/blob/4b96a222/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
index 08f454b..1bf6b15 100644
--- 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
@@ -19,7 +19,9 @@
package org.apache.cxf.systests.cdi.base;
import javax.validation.constraints.NotNull;
+import javax.xml.bind.annotation.XmlRootElement;
+@XmlRootElement
public class Book {
@NotNull private String name;
private String id;
http://git-wip-us.apache.org/repos/asf/cxf/blob/4b96a222/systests/cdi/cdi-owb/cdi-producers-owb/pom.xml
----------------------------------------------------------------------
diff --git a/systests/cdi/cdi-owb/cdi-producers-owb/pom.xml b/systests/cdi/cdi-owb/cdi-producers-owb/pom.xml
new file mode 100644
index 0000000..e27fe6a
--- /dev/null
+++ b/systests/cdi/cdi-owb/cdi-producers-owb/pom.xml
@@ -0,0 +1,51 @@
+<?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-producers</artifactId>
+ <name>Apache CXF CDI Integration System Tests - OWB with producers</name>
+ <description>Apache CXF CDI Integration System Tests - OpenWebBeans with producers</description>
+ <url>http://cxf.apache.org</url>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-rs-extension-providers</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.abdera</groupId>
+ <artifactId>abdera-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.abdera</groupId>
+ <artifactId>abdera-parser</artifactId>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cxf/blob/4b96a222/systests/cdi/cdi-owb/cdi-producers-owb/src/test/java/org/apache/cxf/systest/jaxrs/cdi/BookStoreFeed.java
----------------------------------------------------------------------
diff --git a/systests/cdi/cdi-owb/cdi-producers-owb/src/test/java/org/apache/cxf/systest/jaxrs/cdi/BookStoreFeed.java b/systests/cdi/cdi-owb/cdi-producers-owb/src/test/java/org/apache/cxf/systest/jaxrs/cdi/BookStoreFeed.java
new file mode 100644
index 0000000..89f0d52
--- /dev/null
+++ b/systests/cdi/cdi-owb/cdi-producers-owb/src/test/java/org/apache/cxf/systest/jaxrs/cdi/BookStoreFeed.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 javax.validation.Valid;
+import javax.validation.constraints.NotNull;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+
+import org.apache.abdera.model.Feed;
+import org.apache.abdera.parser.stax.FOMEntry;
+import org.apache.abdera.parser.stax.FOMFeed;
+import org.apache.cxf.systests.cdi.base.Book;
+import org.apache.cxf.systests.cdi.base.BookStoreService;
+
+@Path("/bookstore/")
+public class BookStoreFeed {
+ private final BookStoreService service;
+
+ public BookStoreFeed(BookStoreService service) {
+ this.service = service;
+ }
+
+ @GET
+ @Path("/books/feed")
+ @NotNull @Valid
+ @Produces("application/atom+xml")
+ public Feed getBooks() {
+ final FOMFeed feed = new FOMFeed();
+
+ for (final Book book: service.all()) {
+ final FOMEntry entry = new FOMEntry();
+ entry.addLink("/bookstore/books/" + book.getId());
+ feed.addEntry(entry);
+ }
+
+ return feed;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cxf/blob/4b96a222/systests/cdi/cdi-owb/cdi-producers-owb/src/test/java/org/apache/cxf/systest/jaxrs/cdi/BookStoreProducerApplication.java
----------------------------------------------------------------------
diff --git a/systests/cdi/cdi-owb/cdi-producers-owb/src/test/java/org/apache/cxf/systest/jaxrs/cdi/BookStoreProducerApplication.java b/systests/cdi/cdi-owb/cdi-producers-owb/src/test/java/org/apache/cxf/systest/jaxrs/cdi/BookStoreProducerApplication.java
new file mode 100644
index 0000000..5d2217a
--- /dev/null
+++ b/systests/cdi/cdi-owb/cdi-producers-owb/src/test/java/org/apache/cxf/systest/jaxrs/cdi/BookStoreProducerApplication.java
@@ -0,0 +1,55 @@
+/**
+ * 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 javax.enterprise.inject.Produces;
+import javax.inject.Inject;
+import javax.ws.rs.ApplicationPath;
+import javax.ws.rs.core.Application;
+import javax.ws.rs.core.Feature;
+
+import org.apache.cxf.jaxrs.validation.JAXRSBeanValidationFeature;
+import org.apache.cxf.jaxrs.validation.ValidationExceptionMapper;
+import org.apache.cxf.systests.cdi.base.BookStoreService;
+
+@ApplicationPath("/")
+public class BookStoreProducerApplication extends Application {
+ @Produces protected BookStoreValidatingFeed bookStoreValidatingFeed = new BookStoreValidatingFeed();
+ @Inject private BookStoreService service;
+
+ @Produces
+ public ValidationExceptionMapper validationExceptionMapper() {
+ return new ValidationExceptionMapper();
+ }
+
+ @Produces
+ public Feature sampleFeature() {
+ return new SampleFeature();
+ }
+
+ @Produces
+ public BookStoreFeed bookStoreFeed() {
+ return new BookStoreFeed(service);
+ }
+
+ @Produces
+ public org.apache.cxf.feature.Feature validationFeature() {
+ return new JAXRSBeanValidationFeature();
+ }
+}
http://git-wip-us.apache.org/repos/asf/cxf/blob/4b96a222/systests/cdi/cdi-owb/cdi-producers-owb/src/test/java/org/apache/cxf/systest/jaxrs/cdi/BookStoreValidatingFeed.java
----------------------------------------------------------------------
diff --git a/systests/cdi/cdi-owb/cdi-producers-owb/src/test/java/org/apache/cxf/systest/jaxrs/cdi/BookStoreValidatingFeed.java b/systests/cdi/cdi-owb/cdi-producers-owb/src/test/java/org/apache/cxf/systest/jaxrs/cdi/BookStoreValidatingFeed.java
new file mode 100644
index 0000000..acf2fb6
--- /dev/null
+++ b/systests/cdi/cdi-owb/cdi-producers-owb/src/test/java/org/apache/cxf/systest/jaxrs/cdi/BookStoreValidatingFeed.java
@@ -0,0 +1,41 @@
+/**
+ * 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 javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+import javax.ws.rs.FormParam;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
+
+@Path("/bookstore/")
+public class BookStoreValidatingFeed {
+ @POST
+ @Path("/books/feed")
+ @Produces("application/atom+xml")
+ public Response addBook(@Context final UriInfo uriInfo,
+ @NotNull @Size(min = 1, max = 50) @FormParam("id") String id,
+ @NotNull @FormParam("name") String name) {
+ return Response.created(uriInfo.getRequestUriBuilder().path(id).build()).build();
+ }
+}
http://git-wip-us.apache.org/repos/asf/cxf/blob/4b96a222/systests/cdi/cdi-owb/cdi-producers-owb/src/test/java/org/apache/cxf/systest/jaxrs/cdi/SampleFeature.java
----------------------------------------------------------------------
diff --git a/systests/cdi/cdi-owb/cdi-producers-owb/src/test/java/org/apache/cxf/systest/jaxrs/cdi/SampleFeature.java b/systests/cdi/cdi-owb/cdi-producers-owb/src/test/java/org/apache/cxf/systest/jaxrs/cdi/SampleFeature.java
new file mode 100644
index 0000000..6a108dc
--- /dev/null
+++ b/systests/cdi/cdi-owb/cdi-producers-owb/src/test/java/org/apache/cxf/systest/jaxrs/cdi/SampleFeature.java
@@ -0,0 +1,33 @@
+/**
+ * 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 javax.ws.rs.core.Feature;
+import javax.ws.rs.core.FeatureContext;
+
+import org.apache.cxf.jaxrs.provider.atom.AtomFeedProvider;
+
+public class SampleFeature implements Feature {
+ @Override
+ public boolean configure(FeatureContext context) {
+ context.register(AtomFeedProvider.class);
+ return false;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cxf/blob/4b96a222/systests/cdi/cdi-owb/cdi-producers-owb/src/test/java/org/apache/cxf/systest/jaxrs/cdi/jetty/JettyEmbeddedTest.java
----------------------------------------------------------------------
diff --git a/systests/cdi/cdi-owb/cdi-producers-owb/src/test/java/org/apache/cxf/systest/jaxrs/cdi/jetty/JettyEmbeddedTest.java b/systests/cdi/cdi-owb/cdi-producers-owb/src/test/java/org/apache/cxf/systest/jaxrs/cdi/jetty/JettyEmbeddedTest.java
new file mode 100644
index 0000000..911fc0d
--- /dev/null
+++ b/systests/cdi/cdi-owb/cdi-producers-owb/src/test/java/org/apache/cxf/systest/jaxrs/cdi/jetty/JettyEmbeddedTest.java
@@ -0,0 +1,89 @@
+/**
+ * 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 java.util.UUID;
+
+import javax.ws.rs.core.Form;
+import javax.ws.rs.core.Response;
+
+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;
+import org.junit.Test;
+
+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();
+ assertTrue("server did not launch correctly", launchServer(EmbeddedJettyServer.class, true));
+ createStaticBus();
+ }
+
+ @Test
+ public void testAddOneBookWithValidation() {
+ final String id = UUID.randomUUID().toString();
+
+ Response r = createWebClient(getBasePath() + "/books").post(
+ new Form()
+ .param("id", id));
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), r.getStatus());
+ }
+
+ @Test
+ public void testResponseHasBeenReceivedWhenQueringAllBookAsAtomFeed() {
+ Response r = createWebClient(getBasePath() + "/books/feed", "application/atom+xml").get();
+ assertEquals(Response.Status.OK.getStatusCode(), r.getStatus());
+ assertEquals("application/atom+xml", r.getMediaType().toString());
+ }
+
+ @Test
+ public void testBookHasBeenValidatedWhenPostedAsAtomFeed() {
+ Response r = createWebClient(getBasePath() + "/books/feed", "application/atom+xml").post(
+ new Form()
+ .param("name", "Book 1234"));
+
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), r.getStatus());
+ }
+
+ @Test
+ public void testBookHasBeenCreatedWhenPostedAsAtomFeed() {
+ Response r = createWebClient(getBasePath() + "/books/feed", "application/atom+xml").post(
+ new Form()
+ .param("id", "1234")
+ .param("name", "Book 1234"));
+
+ assertEquals(Response.Status.CREATED.getStatusCode(), r.getStatus());
+ }
+
+ @Override
+ protected int getPort() {
+ return EmbeddedJettyServer.PORT;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cxf/blob/4b96a222/systests/cdi/cdi-owb/cdi-producers-owb/src/test/java/org/apache/cxf/systest/jaxrs/cdi/jetty/JettyWarTest.java
----------------------------------------------------------------------
diff --git a/systests/cdi/cdi-owb/cdi-producers-owb/src/test/java/org/apache/cxf/systest/jaxrs/cdi/jetty/JettyWarTest.java b/systests/cdi/cdi-owb/cdi-producers-owb/src/test/java/org/apache/cxf/systest/jaxrs/cdi/jetty/JettyWarTest.java
new file mode 100644
index 0000000..ba5dc11
--- /dev/null
+++ b/systests/cdi/cdi-owb/cdi-producers-owb/src/test/java/org/apache/cxf/systest/jaxrs/cdi/jetty/JettyWarTest.java
@@ -0,0 +1,91 @@
+/**
+ * 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 java.util.UUID;
+
+import javax.ws.rs.core.Form;
+import javax.ws.rs.core.Response;
+
+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;
+import org.junit.Ignore;
+import org.junit.Test;
+
+public class JettyWarTest extends AbstractCdiSingleAppTest {
+ @Ignore
+ 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();
+ }
+
+ @Test
+ public void testAddOneBookWithValidation() {
+ final String id = UUID.randomUUID().toString();
+
+ Response r = createWebClient(getBasePath() + "/books").post(
+ new Form()
+ .param("id", id));
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), r.getStatus());
+ }
+
+ @Test
+ public void testResponseHasBeenReceivedWhenQueringAllBookAsAtomFeed() {
+ Response r = createWebClient(getBasePath() + "/books/feed", "application/atom+xml").get();
+ assertEquals(Response.Status.OK.getStatusCode(), r.getStatus());
+ assertEquals("application/atom+xml", r.getMediaType().toString());
+ }
+
+ @Test
+ public void testBookHasBeenValidatedWhenPostedAsAtomFeed() {
+ Response r = createWebClient(getBasePath() + "/books/feed", "application/atom+xml").post(
+ new Form()
+ .param("name", "Book 1234"));
+
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), r.getStatus());
+ }
+
+ @Test
+ public void testBookHasBeenCreatedWhenPostedAsAtomFeed() {
+ Response r = createWebClient(getBasePath() + "/books/feed", "application/atom+xml").post(
+ new Form()
+ .param("id", "1234")
+ .param("name", "Book 1234"));
+
+ assertEquals(Response.Status.CREATED.getStatusCode(), r.getStatus());
+ }
+
+ @Override
+ protected int getPort() {
+ return EmbeddedJettyServer.PORT;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cxf/blob/4b96a222/systests/cdi/cdi-owb/cdi-producers-owb/src/test/java/org/apache/cxf/systest/jaxrs/cdi/tomcat/TomcatWarTest.java
----------------------------------------------------------------------
diff --git a/systests/cdi/cdi-owb/cdi-producers-owb/src/test/java/org/apache/cxf/systest/jaxrs/cdi/tomcat/TomcatWarTest.java b/systests/cdi/cdi-owb/cdi-producers-owb/src/test/java/org/apache/cxf/systest/jaxrs/cdi/tomcat/TomcatWarTest.java
new file mode 100644
index 0000000..f7b15a3
--- /dev/null
+++ b/systests/cdi/cdi-owb/cdi-producers-owb/src/test/java/org/apache/cxf/systest/jaxrs/cdi/tomcat/TomcatWarTest.java
@@ -0,0 +1,89 @@
+/**
+ * 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 java.util.UUID;
+
+import javax.ws.rs.core.Form;
+import javax.ws.rs.core.Response;
+
+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;
+import org.junit.Test;
+
+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();
+ }
+
+ @Test
+ public void testAddOneBookWithValidation() {
+ final String id = UUID.randomUUID().toString();
+
+ Response r = createWebClient(getBasePath() + "/books").post(
+ new Form()
+ .param("id", id));
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), r.getStatus());
+ }
+
+ @Test
+ public void testResponseHasBeenReceivedWhenQueringAllBookAsAtomFeed() {
+ Response r = createWebClient(getBasePath() + "/books/feed", "application/atom+xml").get();
+ assertEquals(Response.Status.OK.getStatusCode(), r.getStatus());
+ assertEquals("application/atom+xml", r.getMediaType().toString());
+ }
+
+ @Test
+ public void testBookHasBeenValidatedWhenPostedAsAtomFeed() {
+ Response r = createWebClient(getBasePath() + "/books/feed", "application/atom+xml").post(
+ new Form()
+ .param("name", "Book 1234"));
+
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), r.getStatus());
+ }
+
+ @Test
+ public void testBookHasBeenCreatedWhenPostedAsAtomFeed() {
+ Response r = createWebClient(getBasePath() + "/books/feed", "application/atom+xml").post(
+ new Form()
+ .param("id", "1234")
+ .param("name", "Book 1234"));
+
+ assertEquals(Response.Status.CREATED.getStatusCode(), r.getStatus());
+ }
+
+ @Override
+ protected int getPort() {
+ return EmbeddedTomcatServer.PORT;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/cxf/blob/4b96a222/systests/cdi/cdi-owb/cdi-producers-owb/src/test/resources/META-INF/beans.xml
----------------------------------------------------------------------
diff --git a/systests/cdi/cdi-owb/cdi-producers-owb/src/test/resources/META-INF/beans.xml b/systests/cdi/cdi-owb/cdi-producers-owb/src/test/resources/META-INF/beans.xml
new file mode 100644
index 0000000..b03debc
--- /dev/null
+++ b/systests/cdi/cdi-owb/cdi-producers-owb/src/test/resources/META-INF/beans.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0"?>
+<beans xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:weld="http://jboss.org/schema/weld/beans"
+ xsi:schemaLocation="
+ http://java.sun.com/xml/ns/javaee http://docs.jboss.org/cdi/beans_1_0.xsd
+ http://java.sun.com/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd">
+
+ <scan>
+ <exclude name="org.apache.cxf.systest.jaxrs.cdi.SampleFeature" />
+ <exclude name="org.apache.cxf.systest.jaxrs.cdi.BookStoreFeed" />
+ <exclude name="org.apache.cxf.systest.jaxrs.cdi.BookStoreValidatingFeed" />
+ </scan>
+</beans>
http://git-wip-us.apache.org/repos/asf/cxf/blob/4b96a222/systests/cdi/cdi-owb/cdi-producers-owb/src/test/resources/META-INF/services/org.jboss.weld.environment.Container
----------------------------------------------------------------------
diff --git a/systests/cdi/cdi-owb/cdi-producers-owb/src/test/resources/META-INF/services/org.jboss.weld.environment.Container b/systests/cdi/cdi-owb/cdi-producers-owb/src/test/resources/META-INF/services/org.jboss.weld.environment.Container
new file mode 100644
index 0000000..df31f74
--- /dev/null
+++ b/systests/cdi/cdi-owb/cdi-producers-owb/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/4b96a222/systests/cdi/cdi-owb/cdi-producers-owb/src/test/resources/jaxrs_cdi/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/systests/cdi/cdi-owb/cdi-producers-owb/src/test/resources/jaxrs_cdi/WEB-INF/web.xml b/systests/cdi/cdi-owb/cdi-producers-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-producers-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/4b96a222/systests/cdi/cdi-owb/pom.xml
----------------------------------------------------------------------
diff --git a/systests/cdi/cdi-owb/pom.xml b/systests/cdi/cdi-owb/pom.xml
index e8ebc93..8a779aa 100644
--- a/systests/cdi/cdi-owb/pom.xml
+++ b/systests/cdi/cdi-owb/pom.xml
@@ -31,9 +31,10 @@
<description>Apache CXF CDI Integration System Tests - OpenWebBeans</description>
<url>http://cxf.apache.org</url>
- <modules>
+ <modules>
<module>cdi-multiple-apps-owb</module>
<module>cdi-no-apps-owb</module>
+ <module>cdi-producers-owb</module>
</modules>
<dependencies>
http://git-wip-us.apache.org/repos/asf/cxf/blob/4b96a222/systests/cdi/cdi-weld/cdi-producers-weld/pom.xml
----------------------------------------------------------------------
diff --git a/systests/cdi/cdi-weld/cdi-producers-weld/pom.xml b/systests/cdi/cdi-weld/cdi-producers-weld/pom.xml
new file mode 100644
index 0000000..a626bba
--- /dev/null
+++ b/systests/cdi/cdi-weld/cdi-producers-weld/pom.xml
@@ -0,0 +1,51 @@
+<?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-producers</artifactId>
+ <name>Apache CXF CDI Integration System Tests - Weld with producers</name>
+ <description>Apache CXF CDI Integration System Tests - Weld with producers</description>
+ <url>http://cxf.apache.org</url>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-rs-extension-providers</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.abdera</groupId>
+ <artifactId>abdera-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.abdera</groupId>
+ <artifactId>abdera-parser</artifactId>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cxf/blob/4b96a222/systests/cdi/cdi-weld/cdi-producers-weld/src/test/java/org/apache/cxf/systest/jaxrs/cdi/BookStoreFeed.java
----------------------------------------------------------------------
diff --git a/systests/cdi/cdi-weld/cdi-producers-weld/src/test/java/org/apache/cxf/systest/jaxrs/cdi/BookStoreFeed.java b/systests/cdi/cdi-weld/cdi-producers-weld/src/test/java/org/apache/cxf/systest/jaxrs/cdi/BookStoreFeed.java
new file mode 100644
index 0000000..89f0d52
--- /dev/null
+++ b/systests/cdi/cdi-weld/cdi-producers-weld/src/test/java/org/apache/cxf/systest/jaxrs/cdi/BookStoreFeed.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 javax.validation.Valid;
+import javax.validation.constraints.NotNull;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+
+import org.apache.abdera.model.Feed;
+import org.apache.abdera.parser.stax.FOMEntry;
+import org.apache.abdera.parser.stax.FOMFeed;
+import org.apache.cxf.systests.cdi.base.Book;
+import org.apache.cxf.systests.cdi.base.BookStoreService;
+
+@Path("/bookstore/")
+public class BookStoreFeed {
+ private final BookStoreService service;
+
+ public BookStoreFeed(BookStoreService service) {
+ this.service = service;
+ }
+
+ @GET
+ @Path("/books/feed")
+ @NotNull @Valid
+ @Produces("application/atom+xml")
+ public Feed getBooks() {
+ final FOMFeed feed = new FOMFeed();
+
+ for (final Book book: service.all()) {
+ final FOMEntry entry = new FOMEntry();
+ entry.addLink("/bookstore/books/" + book.getId());
+ feed.addEntry(entry);
+ }
+
+ return feed;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cxf/blob/4b96a222/systests/cdi/cdi-weld/cdi-producers-weld/src/test/java/org/apache/cxf/systest/jaxrs/cdi/BookStoreProducerApplication.java
----------------------------------------------------------------------
diff --git a/systests/cdi/cdi-weld/cdi-producers-weld/src/test/java/org/apache/cxf/systest/jaxrs/cdi/BookStoreProducerApplication.java b/systests/cdi/cdi-weld/cdi-producers-weld/src/test/java/org/apache/cxf/systest/jaxrs/cdi/BookStoreProducerApplication.java
new file mode 100644
index 0000000..5d2217a
--- /dev/null
+++ b/systests/cdi/cdi-weld/cdi-producers-weld/src/test/java/org/apache/cxf/systest/jaxrs/cdi/BookStoreProducerApplication.java
@@ -0,0 +1,55 @@
+/**
+ * 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 javax.enterprise.inject.Produces;
+import javax.inject.Inject;
+import javax.ws.rs.ApplicationPath;
+import javax.ws.rs.core.Application;
+import javax.ws.rs.core.Feature;
+
+import org.apache.cxf.jaxrs.validation.JAXRSBeanValidationFeature;
+import org.apache.cxf.jaxrs.validation.ValidationExceptionMapper;
+import org.apache.cxf.systests.cdi.base.BookStoreService;
+
+@ApplicationPath("/")
+public class BookStoreProducerApplication extends Application {
+ @Produces protected BookStoreValidatingFeed bookStoreValidatingFeed = new BookStoreValidatingFeed();
+ @Inject private BookStoreService service;
+
+ @Produces
+ public ValidationExceptionMapper validationExceptionMapper() {
+ return new ValidationExceptionMapper();
+ }
+
+ @Produces
+ public Feature sampleFeature() {
+ return new SampleFeature();
+ }
+
+ @Produces
+ public BookStoreFeed bookStoreFeed() {
+ return new BookStoreFeed(service);
+ }
+
+ @Produces
+ public org.apache.cxf.feature.Feature validationFeature() {
+ return new JAXRSBeanValidationFeature();
+ }
+}
http://git-wip-us.apache.org/repos/asf/cxf/blob/4b96a222/systests/cdi/cdi-weld/cdi-producers-weld/src/test/java/org/apache/cxf/systest/jaxrs/cdi/BookStoreValidatingFeed.java
----------------------------------------------------------------------
diff --git a/systests/cdi/cdi-weld/cdi-producers-weld/src/test/java/org/apache/cxf/systest/jaxrs/cdi/BookStoreValidatingFeed.java b/systests/cdi/cdi-weld/cdi-producers-weld/src/test/java/org/apache/cxf/systest/jaxrs/cdi/BookStoreValidatingFeed.java
new file mode 100644
index 0000000..acf2fb6
--- /dev/null
+++ b/systests/cdi/cdi-weld/cdi-producers-weld/src/test/java/org/apache/cxf/systest/jaxrs/cdi/BookStoreValidatingFeed.java
@@ -0,0 +1,41 @@
+/**
+ * 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 javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+import javax.ws.rs.FormParam;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
+
+@Path("/bookstore/")
+public class BookStoreValidatingFeed {
+ @POST
+ @Path("/books/feed")
+ @Produces("application/atom+xml")
+ public Response addBook(@Context final UriInfo uriInfo,
+ @NotNull @Size(min = 1, max = 50) @FormParam("id") String id,
+ @NotNull @FormParam("name") String name) {
+ return Response.created(uriInfo.getRequestUriBuilder().path(id).build()).build();
+ }
+}
http://git-wip-us.apache.org/repos/asf/cxf/blob/4b96a222/systests/cdi/cdi-weld/cdi-producers-weld/src/test/java/org/apache/cxf/systest/jaxrs/cdi/SampleFeature.java
----------------------------------------------------------------------
diff --git a/systests/cdi/cdi-weld/cdi-producers-weld/src/test/java/org/apache/cxf/systest/jaxrs/cdi/SampleFeature.java b/systests/cdi/cdi-weld/cdi-producers-weld/src/test/java/org/apache/cxf/systest/jaxrs/cdi/SampleFeature.java
new file mode 100644
index 0000000..6a108dc
--- /dev/null
+++ b/systests/cdi/cdi-weld/cdi-producers-weld/src/test/java/org/apache/cxf/systest/jaxrs/cdi/SampleFeature.java
@@ -0,0 +1,33 @@
+/**
+ * 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 javax.ws.rs.core.Feature;
+import javax.ws.rs.core.FeatureContext;
+
+import org.apache.cxf.jaxrs.provider.atom.AtomFeedProvider;
+
+public class SampleFeature implements Feature {
+ @Override
+ public boolean configure(FeatureContext context) {
+ context.register(AtomFeedProvider.class);
+ return false;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cxf/blob/4b96a222/systests/cdi/cdi-weld/cdi-producers-weld/src/test/java/org/apache/cxf/systest/jaxrs/cdi/WeldDiscoverableContainer.java
----------------------------------------------------------------------
diff --git a/systests/cdi/cdi-weld/cdi-producers-weld/src/test/java/org/apache/cxf/systest/jaxrs/cdi/WeldDiscoverableContainer.java b/systests/cdi/cdi-weld/cdi-producers-weld/src/test/java/org/apache/cxf/systest/jaxrs/cdi/WeldDiscoverableContainer.java
new file mode 100644
index 0000000..f3b6dcd
--- /dev/null
+++ b/systests/cdi/cdi-weld/cdi-producers-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/4b96a222/systests/cdi/cdi-weld/cdi-producers-weld/src/test/java/org/apache/cxf/systest/jaxrs/cdi/jetty/JettyEmbeddedTest.java
----------------------------------------------------------------------
diff --git a/systests/cdi/cdi-weld/cdi-producers-weld/src/test/java/org/apache/cxf/systest/jaxrs/cdi/jetty/JettyEmbeddedTest.java b/systests/cdi/cdi-weld/cdi-producers-weld/src/test/java/org/apache/cxf/systest/jaxrs/cdi/jetty/JettyEmbeddedTest.java
new file mode 100644
index 0000000..56694a4
--- /dev/null
+++ b/systests/cdi/cdi-weld/cdi-producers-weld/src/test/java/org/apache/cxf/systest/jaxrs/cdi/jetty/JettyEmbeddedTest.java
@@ -0,0 +1,92 @@
+/**
+ * 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 java.util.UUID;
+
+import javax.ws.rs.core.Form;
+import javax.ws.rs.core.Response;
+
+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.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.Test;
+
+public class JettyEmbeddedTest extends AbstractCdiSingleAppTest {
+ 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();
+ }
+
+ @Test
+ public void testAddOneBookWithValidation() {
+ final String id = UUID.randomUUID().toString();
+
+ Response r = createWebClient(getBasePath() + "/books").post(
+ new Form()
+ .param("id", id));
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), r.getStatus());
+ }
+
+ @Test
+ public void testResponseHasBeenReceivedWhenQueringAllBookAsAtomFeed() {
+ Response r = createWebClient(getBasePath() + "/books/feed", "application/atom+xml").get();
+ assertEquals(Response.Status.OK.getStatusCode(), r.getStatus());
+ assertEquals("application/atom+xml", r.getMediaType().toString());
+ }
+
+ @Test
+ public void testBookHasBeenValidatedWhenPostedAsAtomFeed() {
+ Response r = createWebClient(getBasePath() + "/books/feed", "application/atom+xml").post(
+ new Form()
+ .param("name", "Book 1234"));
+
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), r.getStatus());
+ }
+
+ @Test
+ public void testBookHasBeenCreatedWhenPostedAsAtomFeed() {
+ Response r = createWebClient(getBasePath() + "/books/feed", "application/atom+xml").post(
+ new Form()
+ .param("id", "1234")
+ .param("name", "Book 1234"));
+
+ assertEquals(Response.Status.CREATED.getStatusCode(), r.getStatus());
+ }
+
+ @Override
+ protected int getPort() {
+ return EmbeddedJettyServer.PORT;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cxf/blob/4b96a222/systests/cdi/cdi-weld/cdi-producers-weld/src/test/java/org/apache/cxf/systest/jaxrs/cdi/jetty/JettyWarTest.java
----------------------------------------------------------------------
diff --git a/systests/cdi/cdi-weld/cdi-producers-weld/src/test/java/org/apache/cxf/systest/jaxrs/cdi/jetty/JettyWarTest.java b/systests/cdi/cdi-weld/cdi-producers-weld/src/test/java/org/apache/cxf/systest/jaxrs/cdi/jetty/JettyWarTest.java
new file mode 100644
index 0000000..433cf9e
--- /dev/null
+++ b/systests/cdi/cdi-weld/cdi-producers-weld/src/test/java/org/apache/cxf/systest/jaxrs/cdi/jetty/JettyWarTest.java
@@ -0,0 +1,94 @@
+/**
+ * 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 java.util.UUID;
+
+import javax.ws.rs.core.Form;
+import javax.ws.rs.core.Response;
+
+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.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;
+import org.junit.Test;
+
+public class JettyWarTest extends AbstractCdiSingleAppTest {
+ @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();
+ }
+
+ @Test
+ public void testAddOneBookWithValidation() {
+ final String id = UUID.randomUUID().toString();
+
+ Response r = createWebClient(getBasePath() + "/books").post(
+ new Form()
+ .param("id", id));
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), r.getStatus());
+ }
+
+ @Test
+ public void testResponseHasBeenReceivedWhenQueringAllBookAsAtomFeed() {
+ Response r = createWebClient(getBasePath() + "/books/feed", "application/atom+xml").get();
+ assertEquals(Response.Status.OK.getStatusCode(), r.getStatus());
+ assertEquals("application/atom+xml", r.getMediaType().toString());
+ }
+
+ @Test
+ public void testBookHasBeenValidatedWhenPostedAsAtomFeed() {
+ Response r = createWebClient(getBasePath() + "/books/feed", "application/atom+xml").post(
+ new Form()
+ .param("name", "Book 1234"));
+
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), r.getStatus());
+ }
+
+ @Test
+ public void testBookHasBeenCreatedWhenPostedAsAtomFeed() {
+ Response r = createWebClient(getBasePath() + "/books/feed", "application/atom+xml").post(
+ new Form()
+ .param("id", "1234")
+ .param("name", "Book 1234"));
+
+ assertEquals(Response.Status.CREATED.getStatusCode(), r.getStatus());
+ }
+
+ @Override
+ protected int getPort() {
+ return EmbeddedJettyServer.PORT;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cxf/blob/4b96a222/systests/cdi/cdi-weld/cdi-producers-weld/src/test/java/org/apache/cxf/systest/jaxrs/cdi/tomcat/TomcatWarTest.java
----------------------------------------------------------------------
diff --git a/systests/cdi/cdi-weld/cdi-producers-weld/src/test/java/org/apache/cxf/systest/jaxrs/cdi/tomcat/TomcatWarTest.java b/systests/cdi/cdi-weld/cdi-producers-weld/src/test/java/org/apache/cxf/systest/jaxrs/cdi/tomcat/TomcatWarTest.java
new file mode 100644
index 0000000..cd16f70
--- /dev/null
+++ b/systests/cdi/cdi-weld/cdi-producers-weld/src/test/java/org/apache/cxf/systest/jaxrs/cdi/tomcat/TomcatWarTest.java
@@ -0,0 +1,92 @@
+/**
+ * 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 java.util.UUID;
+
+import javax.ws.rs.core.Form;
+import javax.ws.rs.core.Response;
+
+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.jboss.weld.environment.Container;
+import org.jboss.weld.environment.tomcat.TomcatContainer;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+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();
+ System.setProperty(Container.class.getName(), TomcatContainer.class.getName());
+ assertTrue("server did not launch correctly", launchServer(EmbeddedTomcatServer.class, true));
+ createStaticBus();
+ }
+
+ @Test
+ public void testAddOneBookWithValidation() {
+ final String id = UUID.randomUUID().toString();
+
+ Response r = createWebClient(getBasePath() + "/books").post(
+ new Form()
+ .param("id", id));
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), r.getStatus());
+ }
+
+ @Test
+ public void testResponseHasBeenReceivedWhenQueringAllBookAsAtomFeed() {
+ Response r = createWebClient(getBasePath() + "/books/feed", "application/atom+xml").get();
+ assertEquals(Response.Status.OK.getStatusCode(), r.getStatus());
+ assertEquals("application/atom+xml", r.getMediaType().toString());
+ }
+
+ @Test
+ public void testBookHasBeenValidatedWhenPostedAsAtomFeed() {
+ Response r = createWebClient(getBasePath() + "/books/feed", "application/atom+xml").post(
+ new Form()
+ .param("name", "Book 1234"));
+
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), r.getStatus());
+ }
+
+ @Test
+ public void testBookHasBeenCreatedWhenPostedAsAtomFeed() {
+ Response r = createWebClient(getBasePath() + "/books/feed", "application/atom+xml").post(
+ new Form()
+ .param("id", "1234")
+ .param("name", "Book 1234"));
+
+ assertEquals(Response.Status.CREATED.getStatusCode(), r.getStatus());
+ }
+
+ @Override
+ protected int getPort() {
+ return EmbeddedTomcatServer.PORT;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/cxf/blob/4b96a222/systests/cdi/cdi-weld/cdi-producers-weld/src/test/resources/META-INF/beans.xml
----------------------------------------------------------------------
diff --git a/systests/cdi/cdi-weld/cdi-producers-weld/src/test/resources/META-INF/beans.xml b/systests/cdi/cdi-weld/cdi-producers-weld/src/test/resources/META-INF/beans.xml
new file mode 100644
index 0000000..b03debc
--- /dev/null
+++ b/systests/cdi/cdi-weld/cdi-producers-weld/src/test/resources/META-INF/beans.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0"?>
+<beans xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:weld="http://jboss.org/schema/weld/beans"
+ xsi:schemaLocation="
+ http://java.sun.com/xml/ns/javaee http://docs.jboss.org/cdi/beans_1_0.xsd
+ http://java.sun.com/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd">
+
+ <scan>
+ <exclude name="org.apache.cxf.systest.jaxrs.cdi.SampleFeature" />
+ <exclude name="org.apache.cxf.systest.jaxrs.cdi.BookStoreFeed" />
+ <exclude name="org.apache.cxf.systest.jaxrs.cdi.BookStoreValidatingFeed" />
+ </scan>
+</beans>
http://git-wip-us.apache.org/repos/asf/cxf/blob/4b96a222/systests/cdi/cdi-weld/cdi-producers-weld/src/test/resources/META-INF/services/org.jboss.weld.environment.Container
----------------------------------------------------------------------
diff --git a/systests/cdi/cdi-weld/cdi-producers-weld/src/test/resources/META-INF/services/org.jboss.weld.environment.Container b/systests/cdi/cdi-weld/cdi-producers-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-producers-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/4b96a222/systests/cdi/cdi-weld/cdi-producers-weld/src/test/resources/jaxrs_cdi/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/systests/cdi/cdi-weld/cdi-producers-weld/src/test/resources/jaxrs_cdi/WEB-INF/web.xml b/systests/cdi/cdi-weld/cdi-producers-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-producers-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/4b96a222/systests/cdi/cdi-weld/pom.xml
----------------------------------------------------------------------
diff --git a/systests/cdi/cdi-weld/pom.xml b/systests/cdi/cdi-weld/pom.xml
index 2fd36b5..8fc7389 100644
--- a/systests/cdi/cdi-weld/pom.xml
+++ b/systests/cdi/cdi-weld/pom.xml
@@ -34,6 +34,7 @@
<modules>
<module>cdi-multiple-apps-weld</module>
<module>cdi-no-apps-weld</module>
+ <module>cdi-producers-weld</module>
</modules>
<dependencies>