cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject [2/2] cxf git commit: [CXF-7119] Adding a test
Date Thu, 24 Nov 2016 11:07:57 GMT
[CXF-7119] Adding a test


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

Branch: refs/heads/3.1.x-fixes
Commit: 96f64799f9acff60e9d393db9dd4a6979626f023
Parents: b943102
Author: Sergey Beryozkin <sberyozkin@gmail.com>
Authored: Thu Nov 24 11:02:43 2016 +0000
Committer: Sergey Beryozkin <sberyozkin@gmail.com>
Committed: Thu Nov 24 11:07:27 2016 +0000

----------------------------------------------------------------------
 .../jaxrs/JAXRSClientServerBookTest.java        | 129 ++++++++-----------
 1 file changed, 57 insertions(+), 72 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/96f64799/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 e7dd9b5..da1f046 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
@@ -407,10 +407,7 @@ public class JAXRSClientServerBookTest extends AbstractBusClientServerTestBase
{
     
     private void doTestUseParamBeanWebClient(String address) {
         WebClient wc = WebClient.create(address);
-        wc.path("100");
-        wc.query("id_2", "20");
-        wc.query("id3", "3");
-        wc.query("id4", "123");
+        wc.path("100").query("id_2", "20").query("id3", "3").query("id4", "123");
         Book book = wc.get(Book.class);
         assertEquals(123L, book.getId());
     }
@@ -426,8 +423,7 @@ public class JAXRSClientServerBookTest extends AbstractBusClientServerTestBase
{
     public void testGetIntroChapterFromSelectedBook2() {
         String address = "http://localhost:" + PORT + "/bookstore/";
         WebClient wc = WebClient.create(address);
-        wc.path("books[id=le=123]");
-        wc.path("chapter");
+        wc.path("books[id=le=123]").path("chapter");
         wc.accept("application/xml");
         Chapter chapter = wc.get(Chapter.class);
         assertEquals("chapter 1", chapter.getTitle());
@@ -488,7 +484,6 @@ public class JAXRSClientServerBookTest extends AbstractBusClientServerTestBase
{
     @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);
@@ -977,21 +972,21 @@ public class JAXRSClientServerBookTest extends AbstractBusClientServerTestBase
{
             + "org.apache.cxf.systest.jaxrs.BookNotFoundFault: Book Exception</ns1:faultstring>"
             + "</ns1:XMLFault>";
         getAndCompare("http://localhost:" + PORT + "/bookstore/propagate-exception2",
-                      data, "application/xml", 500);
+                      data, "application/xml", null, 500);
     }
     
     @Test
     public void testPropogateException3() throws Exception {
         String data = "<nobook/>";
         getAndCompare("http://localhost:" + PORT + "/bookstore/propagate-exception3",
-                      data, "application/xml", 500);
+                      data, "application/xml", null, 500);
     }
     
     @Test
     public void testPropogateException4() throws Exception {
         String data = "<nobook/>";
         getAndCompare("http://localhost:" + PORT + "/bookstore/propogateExceptionVar/1",
-                      data, "application/xml", 500);
+                      data, "application/xml", null, 500);
     }
     
     @Test
@@ -1077,7 +1072,7 @@ public class JAXRSClientServerBookTest extends AbstractBusClientServerTestBase
{
     public void testWebApplicationException() throws Exception {
         getAndCompare("http://localhost:" + PORT + "/bookstore/webappexception",
                       "This is a WebApplicationException",
-                      "application/xml", 500);
+                      "application/xml", null, 500);
     }
     
     @Test 
@@ -1212,7 +1207,7 @@ public class JAXRSClientServerBookTest extends AbstractBusClientServerTestBase
{
         getAndCompareAsStrings("http://localhost:" + PORT 
                                + "/bookstore/bookurl/http%3A%2F%2Ftest.com%2Frss%2F123",
                                "resources/expected_get_book123.txt",
-                               "application/xml", 200);
+                               "application/xml", "application/xml", 200);
     }
     
     @Test
@@ -1429,21 +1424,21 @@ public class JAXRSClientServerBookTest extends AbstractBusClientServerTestBase
{
         getAndCompareAsStrings("http://localhost:" + PORT + "/bookstore/bookquery?"
                                + "urlid=http%3A%2F%2Ftest.com%2Frss%2F123",
                                "resources/expected_get_book123.txt",
-                               "application/xml", 200);
+                               "application/xml", "application/xml", 200);
     }
     
     @Test
     public void testGetGenericBook() throws Exception {
         getAndCompareAsStrings("http://localhost:" + PORT + "/bookstore/genericbooks/123",
                                "resources/expected_get_book123.txt",
-                               "application/xml", 200);
+                               "application/xml", "application/xml", 200);
     }
     
     @Test
     public void testGetGenericResponseBook() throws Exception {
         getAndCompareAsStrings("http://localhost:" + PORT + "/bookstore/genericresponse/123",
                                "resources/expected_get_book123.txt",
-                               "application/xml", 200);
+                               "application/xml", "application/xml", 200);
     }
     
     @Test
@@ -1451,21 +1446,21 @@ public class JAXRSClientServerBookTest extends AbstractBusClientServerTestBase
{
         getAndCompareAsStrings("http://localhost:" + PORT + "/bookstore/bookidarray?"
                                + "id=1&id=2&id=3",
                                "resources/expected_get_book123.txt",
-                               "application/xml", 200);
+                               "application/xml", "application/xml", 200);
     }
         
     @Test
     public void testNoRootResourceException() throws Exception {
         getAndCompare("http://localhost:" + PORT + "/nobookstore/webappexception",
                       "",
-                      "application/xml", 404);
+                      "application/xml", null, 404);
     }
     
     @Test
     public void testNoPathMatch() throws Exception {
         getAndCompare("http://localhost:" + PORT + "/bookstore/bookqueries",
                       "",
-                      "application/xml", 404);
+                      "application/xml", null, 404);
     }
     
     @Test
@@ -1485,13 +1480,13 @@ public class JAXRSClientServerBookTest extends AbstractBusClientServerTestBase
{
     public void testWriteAndFailEarly() throws Exception {
         getAndCompare("http://localhost:" + PORT + "/bookstore/books/fail-early",
                       "This is supposed to go on the wire",
-                      "application/bar, text/plain", 410);
+                      "application/bar, text/plain", null, 410);
     }
     
     @Test
     public void testWriteAndFailLate() throws Exception {
         getAndCompare("http://localhost:" + PORT + "/bookstore/books/fail-late",
-                      "", "application/bar", 410);
+                      "", "application/bar", null, 410);
     }
     
     
@@ -1499,14 +1494,14 @@ public class JAXRSClientServerBookTest extends AbstractBusClientServerTestBase
{
     public void testAcceptTypeMismatch() throws Exception {
         getAndCompare("http://localhost:" + PORT + "/bookstore/booknames/123",
                       "",
-                      "foo/bar", 406);
+                      "foo/bar", null, 406);
     }
             
     @Test
     public void testWrongHttpMethod() throws Exception {
         getAndCompare("http://localhost:" + PORT + "/bookstore/unsupportedcontenttype",
                       "",
-                      "foo/bar", 405);
+                      "foo/bar", null, 405);
     }
     
     @Test
@@ -1514,7 +1509,7 @@ public class JAXRSClientServerBookTest extends AbstractBusClientServerTestBase
{
         getAndCompare("http://localhost:" + PORT + "/bookstore/wrongparametertype?p=1",
                       "Parameter Class java.util.Map has no constructor with single String
"
                       + "parameter, static valueOf(String) or fromString(String) methods",
-                      "*/*", 500);
+                      "*/*", null, 500);
     }
 
     @Test
@@ -1535,14 +1530,14 @@ public class JAXRSClientServerBookTest extends AbstractBusClientServerTestBase
{
     public void testExceptionDuringConstruction() throws Exception {
         getAndCompare("http://localhost:" + PORT + "/bookstore/exceptionconstruction?p=1",
                       "",
-                      "foo/bar", 404);
+                      "foo/bar", null, 404);
     }
     
     @Test
     public void testSubresourceMethodNotFound() throws Exception {
         getAndCompare("http://localhost:" + PORT + "/bookstore/interface/thesubresource",
                       "",
-                      "foo/bar", 404);
+                      "foo/bar", null, 404);
     }
     
     @Test
@@ -1666,7 +1661,7 @@ public class JAXRSClientServerBookTest extends AbstractBusClientServerTestBase
{
     public void testGetBookCustomExpression() throws Exception {
         getAndCompareAsStrings("http://localhost:" + PORT + "/bookstore/books/custom/123",
                                "resources/expected_get_book123.txt",
-                               "application/xml", 200);
+                               "application/xml", "application/xml", 200);
     }
     
     @Test
@@ -1772,7 +1767,7 @@ public class JAXRSClientServerBookTest extends AbstractBusClientServerTestBase
{
         getAndCompareAsStrings("http://localhost:" + PORT + "/bookstore/books/search"
                                + "?_s=name==CXF*;id=ge=123;id=lt=124",
                                "resources/expected_get_book123.txt",
-                               "application/xml", 200);
+                               "application/xml", "application/xml", 200);
     }
     
     @Test
@@ -1801,7 +1796,7 @@ public class JAXRSClientServerBookTest extends AbstractBusClientServerTestBase
{
     public void testGetBook123CGLIB() throws Exception {
         getAndCompareAsStrings("http://localhost:" + PORT + "/bookstore/books/123/cglib",
                                "resources/expected_get_book123.txt",
-                               "application/xml", 200);
+                               "application/xml", "application/xml", 200);
     }
     
     @Test
@@ -1905,19 +1900,19 @@ public class JAXRSClientServerBookTest extends AbstractBusClientServerTestBase
{
     public void testGetBook123() throws Exception {
         getAndCompareAsStrings("http://localhost:" + PORT + "/bookstore/books/123",
                                "resources/expected_get_book123.txt",
-                               "application/xml", 200);
+                               "application/xml", "application/xml", 200);
         
         getAndCompareAsStrings("http://localhost:" + PORT + "/bookstore/books/query?bookId=123",
                                "resources/expected_get_book123.txt",
-                               "application/xml", 200);
+                               "application/xml", "application/xml", 200);
         
         getAndCompareAsStrings("http://localhost:" + PORT + "/bookstore/books/defaultquery",
                                "resources/expected_get_book123.txt",
-                               "application/xml", 200);
+                               "application/xml", "application/xml", 200);
         
         getAndCompareAsStrings("http://localhost:" + PORT + "/bookstore/books/missingquery",
                                "resources/expected_get_book123.txt",
-                               "application/xml", 200);
+                               "application/xml", "application/xml", 200);
         
         getAndCompareAsStrings("http://localhost:" + PORT + "/bookstore/books/123",
                                "resources/expected_get_book123json.txt",
@@ -1943,36 +1938,36 @@ public class JAXRSClientServerBookTest extends AbstractBusClientServerTestBase
{
     public void testGetBookBuffer() throws Exception {
         getAndCompareAsStrings("http://localhost:" + PORT + "/bookstore/books/buffer",
                                "resources/expected_get_book123.txt",
-                               "application/bar", 200);
+                               "application/bar", "application/bar", 200);
     }    
     
     @Test
     public void testGetBookBySegment() throws Exception {
         getAndCompareAsStrings("http://localhost:" + PORT + "/bookstore/segment/matrix2;first=12;second=3",
                                "resources/expected_get_book123.txt",
-                               "application/xml", 200);
+                               "application/xml", "application/xml", 200);
         getAndCompareAsStrings("http://localhost:" + PORT + "/bookstore;bar/segment;foo/"
                                + "matrix2;first=12;second=3;third",
                                "resources/expected_get_book123.txt",
-                               "application/xml", 200);
+                               "application/xml", "application/xml", 200);
     }
     
     @Test
     public void testGetBookByListOfSegments() throws Exception {
         getAndCompareAsStrings("http://localhost:" + PORT + "/bookstore/segment/list/1/2/3",
                                "resources/expected_get_book123.txt",
-                               "application/xml", 200);
+                               "application/xml", "application/xml", 200);
     }
     
     @Test
     public void testGetBookByMatrixParameters() throws Exception {
         getAndCompareAsStrings("http://localhost:" + PORT + "/bookstore/segment/matrix;first=12;second=3",
                                "resources/expected_get_book123.txt",
-                               "application/xml", 200);
+                               "application/xml", "application/xml", 200);
         getAndCompareAsStrings("http://localhost:" + PORT + "/bookstore;bar;first=12/segment;foo;"
                                + "second=3/matrix;third",
                                "resources/expected_get_book123.txt",
-                               "application/xml", 200);
+                               "application/xml", "application/xml", 200);
     }
     
     @Test
@@ -1980,7 +1975,7 @@ public class JAXRSClientServerBookTest extends AbstractBusClientServerTestBase
{
         getAndCompareAsStrings(
             "http://localhost:" + PORT + "/bookstore/segment;first=12;second=3/matrix-middle",
             "resources/expected_get_book123.txt",
-            "application/xml", 200);
+            "application/xml", "application/xml", 200);
     }
     
     @Test
@@ -2051,7 +2046,7 @@ public class JAXRSClientServerBookTest extends AbstractBusClientServerTestBase
{
     public void testGetBookElement() throws Exception {
         getAndCompareAsStrings("http://localhost:" + PORT + "/bookstore/books/element",
                                "resources/expected_get_book123.txt",
-                               "application/xml", 200);
+                               "application/xml", "application/xml", 200);
     }
     
     @Test
@@ -2090,7 +2085,7 @@ public class JAXRSClientServerBookTest extends AbstractBusClientServerTestBase
{
     public void testGetBookAdapter() throws Exception {
         getAndCompareAsStrings("http://localhost:" + PORT + "/bookstore/books/adapter",
                                "resources/expected_get_book123.txt",
-                               "application/xml", 200);
+                               "application/xml", "application/xml", 200);
     }
     
     @Test
@@ -2127,7 +2122,7 @@ public class JAXRSClientServerBookTest extends AbstractBusClientServerTestBase
{
     public void testGetBookAdapterInterface() throws Exception {
         getAndCompareAsStrings("http://localhost:" + PORT + "/bookstore/books/interface/adapter",
                                "resources/expected_get_book123.txt",
-                               "application/xml", 200);
+                               "application/xml", "application/xml", 200);
     }
     
     @Test
@@ -2166,7 +2161,7 @@ public class JAXRSClientServerBookTest extends AbstractBusClientServerTestBase
{
     public void testGetBook123FromSub() throws Exception {
         getAndCompareAsStrings("http://localhost:" + PORT + "/bookstore/interface/subresource",
                                "resources/expected_get_book123.txt",
-                               "application/xml", 200);
+                               "application/xml", "application/xml", 200);
         
         getAndCompareAsStrings("http://localhost:" + PORT + "/bookstore/books/123",
                                "resources/expected_get_book123json.txt",
@@ -2248,7 +2243,7 @@ public class JAXRSClientServerBookTest extends AbstractBusClientServerTestBase
{
         getAndCompareAsStrings("http://localhost:" 
                                + PORT + "/bookstore/booksubresource/123/chapters/sub/1/recurse",
                                "resources/expected_get_chapter1_utf.txt",
-                               "application/xml", 200);
+                               "application/xml", "application/xml", 200);
         getAndCompareAsStrings("http://localhost:"
                                + PORT + "/bookstore/booksubresource/123/chapters/sub/1/recurse2",
                                "resources/expected_get_chapter1.txt",
@@ -2268,7 +2263,7 @@ public class JAXRSClientServerBookTest extends AbstractBusClientServerTestBase
{
     public void testGetBook123ReturnString() throws Exception {
         getAndCompareAsStrings("http://localhost:" + PORT + "/bookstore/booknames/123",
                                "resources/expected_get_book123_returnstring.txt",
-                               "text/plain", 200);
+                               "text/plain", "text/plain", 200);
     }
     
     @Test
@@ -2452,7 +2447,7 @@ public class JAXRSClientServerBookTest extends AbstractBusClientServerTestBase
{
         
         getAndCompareAsStrings("http://localhost:" + PORT + "/bookstore/cd/123",
                                "resources/expected_get_cdjson.txt",
-                               "application/json", 200);
+                               "application/json", "application/json", 200);
         
     }
     
@@ -2544,7 +2539,7 @@ public class JAXRSClientServerBookTest extends AbstractBusClientServerTestBase
{
         
         getAndCompareAsStrings("http://localhost:" + PORT + "/bookstore/cd/123",
                                "resources/expected_get_cd.txt",
-                               "application/xml", 200);
+                               "application/xml", "application/xml", 200);
     }
 
     @Test
@@ -2567,7 +2562,7 @@ public class JAXRSClientServerBookTest extends AbstractBusClientServerTestBase
{
     public void testGetCDWithMultiContentTypesJSON() throws Exception {
         getAndCompareAsStrings("http://localhost:" + PORT + "/bookstore/cdwithmultitypes/123",
                                "resources/expected_get_cdjson.txt",
-                               "application/json", 200);
+                               "application/json", "application/json", 200);
         getAndCompareAsStrings("http://localhost:" + PORT + "/bookstore/cdwithmultitypes/123",
                                "resources/expected_get_cdjson.txt",
                                "*/*,application/xml;q=0.9,application/json", "application/json",
200);
@@ -2647,6 +2642,20 @@ public class JAXRSClientServerBookTest extends AbstractBusClientServerTestBase
{
     }
 
     @Test
+    public void testNonExistentWithGetCustomEx() throws Exception {
+        String address = "http://localhostt/bookstore";
+        BookStore c = JAXRSClientFactory.create(address, BookStore.class);
+        WebClient.getConfig(c).getInFaultInterceptors().add(new CustomFaultInInterceptor());
+        try {
+            c.getBook("123");
+            fail("Exception expected");
+        } catch (ProcessingException ex) {
+            assertEquals("UnknownHostException: Microservice at http://localhostt/bookstore/bookstore/books/123/"
+                          + " is not available", ex.getMessage());
+        }
+    }
+    
+    @Test
     public void testBadlyQuotedHeaders() throws Exception {
 
         String endpointAddress =
@@ -2682,19 +2691,6 @@ public class JAXRSClientServerBookTest extends AbstractBusClientServerTestBase
{
     }
 
 
-    private void getAndCompareAsStrings(String address,
-                                        String resourcePath,
-                                        String acceptType,
-                                        int status) throws Exception {
-        String expected = getStringFromInputStream(
-                              getClass().getResourceAsStream(resourcePath));
-        getAndCompare(address,
-                      expected,
-                      acceptType,
-                      acceptType,
-                      status);
-    }
-    
     private void getAndCompareAsStrings(String address, 
                                         String resourcePath,
                                         String acceptType,
@@ -2712,17 +2708,6 @@ public class JAXRSClientServerBookTest extends AbstractBusClientServerTestBase
{
     private void getAndCompare(String address, 
                                String expectedValue,
                                String acceptType,
-                               int expectedStatus) throws Exception {
-        getAndCompare(address,
-                      expectedValue,
-                      acceptType,
-                      null,
-                      expectedStatus);
-    }
-    
-    private void getAndCompare(String address, 
-                               String expectedValue,
-                               String acceptType,
                                String expectedContentType,
                                int expectedStatus) throws Exception {
         GetMethod get = new GetMethod(address);


Mime
View raw message