cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject [1/2] git commit: CXF-5576: Initital support for CDI integration. Added Jetty-based test cases for programmatic and WAR-based deployments
Date Sun, 09 Mar 2014 20:36:07 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 566ac6d95 -> 777887681


CXF-5576: Initital support for CDI integration. Added Jetty-based test cases for programmatic
and WAR-based deployments


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/d711d752
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/d711d752
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/d711d752

Branch: refs/heads/master
Commit: d711d7523901b5b14f4af265710a1c997708a808
Parents: 566ac6d
Author: reta <drreta@gmail.com>
Authored: Sun Mar 9 16:34:42 2014 -0400
Committer: reta <drreta@gmail.com>
Committed: Sun Mar 9 16:34:42 2014 -0400

----------------------------------------------------------------------
 .../cdi/src/main/resources/META-INF/beans.xml   |   3 +-
 parent/pom.xml                                  |   1 +
 systests/cdi/pom.xml                            | 180 +++++++++++++++++++
 .../java/org/apache/cxf/systest/jaxrs/Book.java |  54 ++++++
 .../org/apache/cxf/systest/jaxrs/BookStore.java |  61 +++++++
 .../cxf/systest/jaxrs/BookStoreApplication.java |  26 +++
 .../cxf/systest/jaxrs/BookStoreService.java     |  44 +++++
 .../cxf/systest/jaxrs/cdi/AbstractCDITest.java  |  83 +++++++++
 .../systest/jaxrs/cdi/AbstractJettyServer.java  |  99 ++++++++++
 .../systest/jaxrs/cdi/JettyEmbeddedTest.java    |  48 +++++
 .../cxf/systest/jaxrs/cdi/JettyWarTest.java     |  48 +++++
 .../cdi/src/test/resources/META-INF/beans.xml   |   6 +
 .../test/resources/jaxrs_cdi/WEB-INF/web.xml    |  25 +++
 systests/pom.xml                                |   1 +
 14 files changed, 677 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/d711d752/integration/cdi/src/main/resources/META-INF/beans.xml
----------------------------------------------------------------------
diff --git a/integration/cdi/src/main/resources/META-INF/beans.xml b/integration/cdi/src/main/resources/META-INF/beans.xml
index 3306820..aff28d9 100644
--- a/integration/cdi/src/main/resources/META-INF/beans.xml
+++ b/integration/cdi/src/main/resources/META-INF/beans.xml
@@ -1,6 +1,5 @@
 <?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"
-	version="1.1">
+	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/d711d752/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index 015413b..b250214 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -157,6 +157,7 @@
         <cxf.xpp3.bundle.version>1.1.4c_6</cxf.xpp3.bundle.version>
         <cxf.validation.api.version>1.1.0.Final</cxf.validation.api.version>
         <cxf.cdi.api.version>1.1</cxf.cdi.api.version>
+        <cxf.jboss.weld.version>2.1.2.Final</cxf.jboss.weld.version>
         <cxf.osgi.validation.api.version>1.1.0</cxf.osgi.validation.api.version>
         <cxf.hibernate.validator.version>5.0.2.Final</cxf.hibernate.validator.version>
         <cxf.javax.el.version>3.0.0</cxf.javax.el.version>

http://git-wip-us.apache.org/repos/asf/cxf/blob/d711d752/systests/cdi/pom.xml
----------------------------------------------------------------------
diff --git a/systests/cdi/pom.xml b/systests/cdi/pom.xml
new file mode 100644
index 0000000..f9a69ff
--- /dev/null
+++ b/systests/cdi/pom.xml
@@ -0,0 +1,180 @@
+<?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>
+        <artifactId>cxf-parent</artifactId>
+        <groupId>org.apache.cxf</groupId>
+        <version>3.0.0-SNAPSHOT</version>
+        <relativePath>../../parent/pom.xml</relativePath>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.apache.cxf.systests</groupId>
+    <artifactId>cxf-systests-cdi</artifactId>
+    <name>Apache CXF CDI Integration System Tests</name>
+    <description>Apache CXF CDI Integration System Tests</description>
+    <url>http://cxf.apache.org</url>
+    <properties>
+        <cxf.el.api.version>3.0-b02</cxf.el.api.version>
+        <cxf.glassfish.el.version>3.0-b01</cxf.glassfish.el.version>
+        <cxf.surefire.fork.vmargs>-XX:MaxPermSize=192m</cxf.surefire.fork.vmargs>
+        <cxf.server.launcher.vmargs>-XX:MaxPermSize=192m</cxf.server.launcher.vmargs>
+        
+    </properties>
+    <dependencies>
+        <dependency>
+            <groupId>javax.validation</groupId>
+            <artifactId>validation-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.hibernate</groupId>
+            <artifactId>hibernate-validator</artifactId>
+            <version>${cxf.hibernate.validator.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.jboss.weld.servlet</groupId>
+            <artifactId>weld-servlet</artifactId>
+            <version>${cxf.jboss.weld.version}</version>
+        </dependency>        
+        <dependency>
+            <groupId>org.jboss.weld</groupId>
+            <artifactId>weld-core</artifactId>
+            <version>${cxf.jboss.weld.version}</version>
+        </dependency>                
+        <!--
+          <dependency>
+            <groupId>org.apache.bval</groupId>
+            <artifactId>bval-jsr</artifactId>
+            <version>1.1.0-alpha-SNAPSHOT</version>
+          </dependency>
+        -->
+        <dependency>
+            <groupId>javax.el</groupId>
+            <artifactId>javax.el-api</artifactId>
+            <version>${cxf.el.api.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.glassfish</groupId>
+            <artifactId>javax.el</artifactId>
+            <version>${cxf.glassfish.el.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.eclipse.jetty</groupId>
+            <artifactId>jetty-server</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.eclipse.jetty</groupId>
+            <artifactId>jetty-plus</artifactId>
+            <version>${cxf.jetty.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.eclipse.jetty</groupId>
+            <artifactId>jetty-webapp</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.eclipse.jetty</groupId>
+            <artifactId>jetty-jsp</artifactId>
+            <version>${cxf.jetty.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-jdk14</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-core</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-rt-transports-http-jetty</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-rt-frontend-jaxrs</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-rt-rs-client</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-integration-cdi</artifactId>
+            <version>${project.version}</version>
+        </dependency>                
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-testutils</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>javax.annotation</groupId>
+            <artifactId>jsr250-api</artifactId>
+            <version>1.0</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>com.fasterxml.jackson.jaxrs</groupId>
+            <artifactId>jackson-jaxrs-json-provider</artifactId>
+            <version>2.2.1</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.httpcomponents</groupId>
+            <artifactId>httpclient</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>com.ning</groupId>
+            <artifactId>async-http-client</artifactId>
+            <version>${cxf.ahc.version}</version>
+            <scope>test</scope>
+            <exclusions>
+                <exclusion>
+                    <groupId>io.netty</groupId>
+                    <artifactId>netty</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+    </dependencies>
+    <build>
+        <plugins>
+            <plugin>
+                <artifactId>maven-jar-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>attach-sources</id>
+                        <goals>
+                            <goal>test-jar</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+</project>

http://git-wip-us.apache.org/repos/asf/cxf/blob/d711d752/systests/cdi/src/test/java/org/apache/cxf/systest/jaxrs/Book.java
----------------------------------------------------------------------
diff --git a/systests/cdi/src/test/java/org/apache/cxf/systest/jaxrs/Book.java b/systests/cdi/src/test/java/org/apache/cxf/systest/jaxrs/Book.java
new file mode 100644
index 0000000..8e6c189
--- /dev/null
+++ b/systests/cdi/src/test/java/org/apache/cxf/systest/jaxrs/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.systest.jaxrs;
+
+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/d711d752/systests/cdi/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
----------------------------------------------------------------------
diff --git a/systests/cdi/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java b/systests/cdi/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
new file mode 100644
index 0000000..c6182f1
--- /dev/null
+++ b/systests/cdi/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
@@ -0,0 +1,61 @@
+/**
+ * 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.Collection;
+
+import javax.inject.Inject;
+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.core.Context;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
+
+@Path("/bookstore/")
+public class BookStore {
+    @Inject private BookStoreService service;
+
+    @GET
+    @Path("/books/{bookId}")
+    @NotNull
+    public Book getBook(@PathParam("bookId") String id) {
+        return service.get(id);
+    }
+    
+    @GET
+    @Path("/books")
+    @NotNull
+    public Collection< Book > getBooks() {
+        return service.all();
+    }
+    
+    @POST
+    @Path("/books")
+    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/d711d752/systests/cdi/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreApplication.java
----------------------------------------------------------------------
diff --git a/systests/cdi/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreApplication.java
b/systests/cdi/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreApplication.java
new file mode 100644
index 0000000..bf3fdcc
--- /dev/null
+++ b/systests/cdi/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("/api")
+public class BookStoreApplication extends Application {
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/d711d752/systests/cdi/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreService.java
----------------------------------------------------------------------
diff --git a/systests/cdi/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreService.java
b/systests/cdi/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreService.java
new file mode 100644
index 0000000..f451dd8
--- /dev/null
+++ b/systests/cdi/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreService.java
@@ -0,0 +1,44 @@
+/**
+ * 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.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.inject.Named;
+
+@Named
+public class BookStoreService {
+    private Map< String, Book > books = new HashMap< String, Book >();
+
+    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;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/d711d752/systests/cdi/src/test/java/org/apache/cxf/systest/jaxrs/cdi/AbstractCDITest.java
----------------------------------------------------------------------
diff --git a/systests/cdi/src/test/java/org/apache/cxf/systest/jaxrs/cdi/AbstractCDITest.java
b/systests/cdi/src/test/java/org/apache/cxf/systest/jaxrs/cdi/AbstractCDITest.java
new file mode 100644
index 0000000..f2b49a1
--- /dev/null
+++ b/systests/cdi/src/test/java/org/apache/cxf/systest/jaxrs/cdi/AbstractCDITest.java
@@ -0,0 +1,83 @@
+/**
+ * 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 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 javax.ws.rs.core.Response.Status;
+
+import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
+
+import org.apache.cxf.jaxrs.client.WebClient;
+import org.apache.cxf.systest.jaxrs.Book;
+import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
+import org.junit.Test;
+
+
+public abstract class AbstractCDITest extends AbstractBusClientServerTestBase {
+    @Test
+    public void testResponseHasBeenReceivedWhenAddingNewBook() {
+        Response r = createWebClient("/rest/api/bookstore/books").post(
+            new Form()
+                .param("id", "1234")
+                .param("name", "Book 1234"));
+        assertEquals(Status.CREATED.getStatusCode(), r.getStatus());
+    }
+    
+    @Test
+    public void testResponseHasBeenReceivedWhenQueringAllBooks() {
+        Response r = createWebClient("/rest/api/bookstore/books").get();
+        assertEquals(Status.OK.getStatusCode(), r.getStatus());
+    }
+    
+    @Test
+    public void testAddAndQueryOneBook() {
+        final String id = UUID.randomUUID().toString();
+        
+        Response r = createWebClient("/rest/api/bookstore/books").post(
+            new Form()
+                .param("id", id)
+                .param("name", "Book 1234"));
+        assertEquals(Status.CREATED.getStatusCode(), r.getStatus());
+        
+        r = createWebClient("/rest/api/bookstore/books").path(id).get();
+        assertEquals(Status.OK.getStatusCode(), r.getStatus());
+        
+        Book book = r.readEntity(Book.class);
+        assertEquals(id, book.getId());
+    }
+    
+    protected WebClient createWebClient(final String url) {
+        final List< ? > providers = Arrays.asList(new JacksonJsonProvider());
+        
+        final WebClient wc = WebClient
+            .create("http://localhost:" + getPort() + url, providers)
+            .accept(MediaType.APPLICATION_JSON);
+        
+        WebClient.getConfig(wc).getHttpConduit().getClient().setReceiveTimeout(10000000L);
+        return wc;
+    }
+    
+    abstract protected int getPort();
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/d711d752/systests/cdi/src/test/java/org/apache/cxf/systest/jaxrs/cdi/AbstractJettyServer.java
----------------------------------------------------------------------
diff --git a/systests/cdi/src/test/java/org/apache/cxf/systest/jaxrs/cdi/AbstractJettyServer.java
b/systests/cdi/src/test/java/org/apache/cxf/systest/jaxrs/cdi/AbstractJettyServer.java
new file mode 100644
index 0000000..1f1bf70
--- /dev/null
+++ b/systests/cdi/src/test/java/org/apache/cxf/systest/jaxrs/cdi/AbstractJettyServer.java
@@ -0,0 +1,99 @@
+/**
+ * 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.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;
+import org.jboss.weld.environment.servlet.BeanManagerResourceBindingListener;
+import org.jboss.weld.environment.servlet.Listener;
+
+public abstract class AbstractJettyServer extends AbstractBusTestServerBase {
+
+    private org.eclipse.jetty.server.Server server;
+    private final String resourcePath;
+    private final String contextPath;
+    private final int port;
+    
+    protected AbstractJettyServer(final String contextPath, int portNumber) {
+        this(null, contextPath, portNumber);
+    }
+    
+    protected AbstractJettyServer(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 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(new Listener());         
+                context.addEventListener(new BeanManagerResourceBindingListener());
+                context.addServlet(servletHolder, "/rest/*");
+                server.setHandler(context);
+            } else {        
+                final WebAppContext context = new WebAppContext();
+                context.setContextPath(contextPath);
+                context.setWar(getClass().getResource(resourcePath).toURI().getPath());
+        
+                HandlerCollection handlers = new HandlerCollection();
+                handlers.setHandlers(new Handler[] {context, new DefaultHandler()});
+                server.setHandler(handlers);
+            }           
+        
+            configureServer(server);
+            server.start();        
+        } catch (final Exception ex) {
+            ex.printStackTrace();
+            fail(ex.getMessage());
+        }
+    }
+    
+    protected void configureServer(org.eclipse.jetty.server.Server theserver) throws Exception
{
+        
+    }
+        
+    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/d711d752/systests/cdi/src/test/java/org/apache/cxf/systest/jaxrs/cdi/JettyEmbeddedTest.java
----------------------------------------------------------------------
diff --git a/systests/cdi/src/test/java/org/apache/cxf/systest/jaxrs/cdi/JettyEmbeddedTest.java
b/systests/cdi/src/test/java/org/apache/cxf/systest/jaxrs/cdi/JettyEmbeddedTest.java
new file mode 100644
index 0000000..03efeb9
--- /dev/null
+++ b/systests/cdi/src/test/java/org/apache/cxf/systest/jaxrs/cdi/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;
+
+import org.apache.cxf.jaxrs.model.AbstractResourceInfo;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+
+public class JettyEmbeddedTest extends AbstractCDITest {  
+    @Ignore
+    public static class EmbeddedJettyServer extends AbstractJettyServer {
+        public static final int PORT = allocatePortAsInt(EmbeddedJettyServer.class);
+
+        public EmbeddedJettyServer() {
+            super("/", PORT);
+        }
+    }
+    
+    @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/d711d752/systests/cdi/src/test/java/org/apache/cxf/systest/jaxrs/cdi/JettyWarTest.java
----------------------------------------------------------------------
diff --git a/systests/cdi/src/test/java/org/apache/cxf/systest/jaxrs/cdi/JettyWarTest.java
b/systests/cdi/src/test/java/org/apache/cxf/systest/jaxrs/cdi/JettyWarTest.java
new file mode 100644
index 0000000..100cbb1
--- /dev/null
+++ b/systests/cdi/src/test/java/org/apache/cxf/systest/jaxrs/cdi/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;
+
+import org.apache.cxf.jaxrs.model.AbstractResourceInfo;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+
+public class JettyWarTest extends AbstractCDITest {  
+    @Ignore
+    public static class EmbeddedJettyServer extends AbstractJettyServer {
+        public static final int PORT = allocatePortAsInt(EmbeddedJettyServer.class);
+
+        public EmbeddedJettyServer() {
+            super("/jaxrs_cdi", "/", PORT);
+        }
+    }
+    
+    @BeforeClass
+    public static void startServers() throws Exception {
+        AbstractResourceInfo.clearAllMaps();
+        assertTrue("server did not launch correctly", launchServer(EmbeddedJettyServer.class,
true));
+        createStaticBus();
+    }
+    
+    @Override
+    protected int getPort() {
+        return EmbeddedJettyServer.PORT;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/d711d752/systests/cdi/src/test/resources/META-INF/beans.xml
----------------------------------------------------------------------
diff --git a/systests/cdi/src/test/resources/META-INF/beans.xml b/systests/cdi/src/test/resources/META-INF/beans.xml
new file mode 100644
index 0000000..2f48c57
--- /dev/null
+++ b/systests/cdi/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/d711d752/systests/cdi/src/test/resources/jaxrs_cdi/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/systests/cdi/src/test/resources/jaxrs_cdi/WEB-INF/web.xml b/systests/cdi/src/test/resources/jaxrs_cdi/WEB-INF/web.xml
new file mode 100644
index 0000000..66cc81a
--- /dev/null
+++ b/systests/cdi/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/d711d752/systests/pom.xml
----------------------------------------------------------------------
diff --git a/systests/pom.xml b/systests/pom.xml
index 45ddb9a..69e7e93 100644
--- a/systests/pom.xml
+++ b/systests/pom.xml
@@ -44,5 +44,6 @@
         <module>ws-security-examples</module>
         <module>rs-security</module>
         <module>wsdl_maven</module>
+        <module>cdi</module>
     </modules>
 </project>


Mime
View raw message