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 test with two BeanParams in the same method signature
Date Sun, 18 Oct 2015 14:05:13 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 2fc83b76e -> 1f7439c1a


Adding a test with two BeanParams in the same method signature


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

Branch: refs/heads/master
Commit: 1f7439c1a1e4dfd868c7c4d761352e653ffe6423
Parents: 2fc83b7
Author: Sergey Beryozkin <sberyozkin@gmail.com>
Authored: Sun Oct 18 15:04:54 2015 +0100
Committer: Sergey Beryozkin <sberyozkin@gmail.com>
Committed: Sun Oct 18 15:04:54 2015 +0100

----------------------------------------------------------------------
 .../org/apache/cxf/systest/jaxrs/BookStore.java | 48 +++++++++++++++++++-
 .../jaxrs/JAXRSClientServerBookTest.java        | 14 +++++-
 2 files changed, 60 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/1f7439c1/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 311faa5..25c4053 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
@@ -338,8 +338,19 @@ public class BookStore {
         if (bean.getNested().getId4() != id) {
             throw new RuntimeException();
         }
+        return books.get(id);
+    }
+    
+    @GET
+    @Path("/beanparam2/{id}")
+    @Produces("application/xml")
+    public Book getBeanParamBook2(@BeanParam BookBean2 bean1, 
+                                  @BeanParam BookBeanNested bean2) {
         
-        
+        long id = bean1.getId() + bean1.getId2() + bean1.getId3(); 
+        if (bean2.getId4() != id) {
+            throw new RuntimeException();
+        }
         return books.get(id);
     }
     
@@ -1811,6 +1822,41 @@ public class BookStore {
         
     }
     
+    public static class BookBean2 {
+        private long id;
+        @QueryParam("id_2")
+        private long id2;
+        private long id3;
+        public long getId() {
+            return id;
+        }
+
+        @PathParam("id")
+        public void setId(long id) {
+            this.id = id;
+        }
+        
+        public long getId2() {
+            return id2;
+        }
+
+        public void setId2(long id2) {
+            this.id2 = id2;
+        }
+        
+        @Context
+        public void setUriInfo(UriInfo ui) {
+            String id3Value = ui.getQueryParameters().getFirst("id3");
+            if (id3Value != null) {
+                this.id3 = Long.valueOf(id3Value);
+            }
+        }
+
+        public long getId3() {
+            return id3;
+        }
+    }
+    
     public static class BookNotReturnedException extends RuntimeException {
 
         private static final long serialVersionUID = 4935423670510083220L;

http://git-wip-us.apache.org/repos/asf/cxf/blob/1f7439c1/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
index 26e277f..d1b5f81 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
@@ -453,7 +453,6 @@ public class JAXRSClientServerBookTest extends AbstractBusClientServerTestBase
{
     @Test
     public void testProxyBeanParam() throws Exception {
         BookStore store = JAXRSClientFactory.create("http://localhost:" + PORT, BookStore.class);
-        WebClient.getConfig(store).getHttpConduit().getClient().setReceiveTimeout(10000000L);
         BookStore.BookBean bean = new BookStore.BookBean();
         bean.setId(100L);
         bean.setId2(23L);
@@ -465,6 +464,19 @@ public class JAXRSClientServerBookTest extends AbstractBusClientServerTestBase
{
         assertEquals(123L, book.getId());
         
     }
+    @Test
+    public void testProxyBeanParam2() throws Exception {
+        BookStore store = JAXRSClientFactory.create("http://localhost:" + PORT, BookStore.class);
+        WebClient.getConfig(store).getHttpConduit().getClient().setReceiveTimeout(10000000L);
+        BookStore.BookBean2 bean = new BookStore.BookBean2();
+        bean.setId(100L);
+        bean.setId2(23L);
+        BookStore.BookBeanNested nested = new BookStore.BookBeanNested();
+        nested.setId4(123);
+        Book book = store.getBeanParamBook2(bean, nested);
+        assertEquals(123L, book.getId());
+        
+    }
     
     @Test
     public void testGetBookWithCustomHeader() throws Exception {


Mime
View raw message