Repository: cxf Updated Branches: refs/heads/3.0.x-fixes 798dece96 -> 37051f5b7
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/37051f5b Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/37051f5b Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/37051f5b Branch: refs/heads/3.0.x-fixes Commit: 37051f5b761d3247c5b3643ef3ac17f83312ac06 Parents: 798dece Author: Sergey Beryozkin <[email protected]> Authored: Sun Oct 18 15:04:54 2015 +0100 Committer: Sergey Beryozkin <[email protected]> Committed: Sun Oct 18 15:06:42 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/37051f5b/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 757afad..7621ab3 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/37051f5b/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 83ead13..9ac9fb5 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 {
