cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject cxf git commit: Adding a local transport test with Jackson
Date Wed, 15 Jul 2015 14:34:27 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.0.x-fixes a5f83ebe4 -> 02ec499af


Adding a local transport test with Jackson


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

Branch: refs/heads/3.0.x-fixes
Commit: 02ec499af6967608692f0c534805c3260aa65d01
Parents: a5f83eb
Author: Sergey Beryozkin <sberyozkin@talend.com>
Authored: Wed Jul 15 17:32:41 2015 +0300
Committer: Sergey Beryozkin <sberyozkin@talend.com>
Committed: Wed Jul 15 17:33:53 2015 +0300

----------------------------------------------------------------------
 .../org/apache/cxf/systest/jaxrs/BookStore.java |  7 +++++-
 .../systest/jaxrs/JAXRSLocalTransportTest.java  | 24 ++++++++++++++++++++
 2 files changed, 30 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/02ec499a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
index 01a5c75..2684b98 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
@@ -157,7 +157,12 @@ public class BookStore {
     public void preDestroy() {
         //System.out.println("PreDestroy called");
     }
-
+    @GET
+    @Path("/booktype")
+    @Produces("application/json")
+    public BookType getBookType() {
+        return new BookType("root", 124L);
+    }
     @GET
     @Path("/")
     public Book getBookRoot() {

http://git-wip-us.apache.org/repos/asf/cxf/blob/02ec499a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLocalTransportTest.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLocalTransportTest.java
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLocalTransportTest.java
index 05229fd..0245cb9 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLocalTransportTest.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLocalTransportTest.java
@@ -21,10 +21,13 @@ package org.apache.cxf.systest.jaxrs;
 
 import java.net.URI;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 
 import javax.ws.rs.core.Response;
 
+import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
+
 import org.apache.cxf.endpoint.Server;
 import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.interceptor.Interceptor;
@@ -55,6 +58,7 @@ public class JAXRSLocalTransportTest extends AbstractBusClientServerTestBase
{
                                new SingletonResourceProvider(new BookStore(), true));
         sf.setResourceProvider(BookStoreSpring.class,
                                new SingletonResourceProvider(new BookStoreSpring(), true));
+        sf.setProvider(new JacksonJsonProvider());
         List<Interceptor<? extends Message>> outInts = new ArrayList<Interceptor<?
extends Message>>();
         outInts.add(new CustomOutInterceptor());
         sf.setOutInterceptors(outInts);
@@ -82,6 +86,15 @@ public class JAXRSLocalTransportTest extends AbstractBusClientServerTestBase
{
         Book book = localProxy.getBook("123");
         assertEquals(123L, book.getId());
     }
+    @Test
+    public void testProxyPipedDispatchGetBookType() throws Exception {
+        BookStore localProxy = 
+            JAXRSClientFactory.create("local://books", 
+                                      BookStore.class,
+                                      Collections.singletonList(new JacksonJsonProvider()));
+        BookType book = localProxy.getBookType();
+        assertEquals(124L, book.getId());
+    }
     
     @Test
     public void testProxyServerInFaultMapped() throws Exception {
@@ -191,6 +204,17 @@ public class JAXRSLocalTransportTest extends AbstractBusClientServerTestBase
{
     }
     
     @Test
+    public void testWebClientDirectDispatchBookType() throws Exception {
+        WebClient localClient = WebClient.create("local://books",
+                                                 Collections.singletonList(new JacksonJsonProvider()));
+        
+        WebClient.getConfig(localClient).getRequestContext().put(LocalConduit.DIRECT_DISPATCH,
Boolean.TRUE);
+        localClient.path("bookstore/booktype");
+        BookType book = localClient.get(BookType.class);
+        assertEquals(124L, book.getId());
+    }
+    
+    @Test
     public void testWebClientPipedDispatch() throws Exception {
         WebClient localClient = WebClient.create("local://books");
         localClient.accept("text/xml");


Mime
View raw message