cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject [07/16] git commit: Few more fixes to JAXRS tests to get them running with Moxy
Date Fri, 04 Apr 2014 15:01:43 GMT
Few more fixes to JAXRS tests to get them running with Moxy


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

Branch: refs/heads/2.7.x-fixes
Commit: 8f82a3e23cc6374c8c0f0b9f14f7f92c0ae4d92c
Parents: b8eb4c0
Author: Sergey Beryozkin <sberyozkin@talend.com>
Authored: Fri Mar 28 21:51:27 2014 +0000
Committer: Daniel Kulp <dkulp@apache.org>
Committed: Fri Apr 4 09:57:57 2014 -0400

----------------------------------------------------------------------
 .../jaxrs/JAXRSClientServerNonSpringBookTest.java  |  9 ++++++++-
 .../JAXRSClientServerProxySpringBookTest.java      | 15 +++++++++++----
 ...ClientServerResourceCreatedOutsideBookTest.java | 16 ++++++++++++----
 ...SClientServerResourceCreatedSpringBookTest.java | 10 +++++++++-
 ...entServerResourceCreatedSpringProviderTest.java | 15 +++++++++++----
 .../cxf/systest/jaxrs/JAXRSMultipartTest.java      | 13 +++++++++++--
 .../cxf/systest/jaxrs/JAXRSSoapBookTest.java       | 17 +++++++++++++----
 .../jaxrs/security/AbstractSpringSecurityTest.java | 11 +++++++++--
 8 files changed, 84 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/8f82a3e2/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerNonSpringBookTest.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerNonSpringBookTest.java
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerNonSpringBookTest.java
index bfb82c3..8241d7b 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerNonSpringBookTest.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerNonSpringBookTest.java
@@ -219,7 +219,7 @@ public class JAXRSClientServerNonSpringBookTest extends AbstractBusClientServerT
             assertEquals(expectedStatus, result);
             String content = getStringFromInputStream(get.getResponseBodyAsStream());
             assertEquals("Expected value is wrong", 
-                         expectedValue, content);
+                         stripXmlInstructionIfNeeded(expectedValue), stripXmlInstructionIfNeeded(content));
             if (expectedContentType != null) {
                 Header ct = get.getResponseHeader("Content-Type");
                 assertEquals("Wrong type of response", expectedContentType, ct.getValue());
@@ -229,6 +229,13 @@ public class JAXRSClientServerNonSpringBookTest extends AbstractBusClientServerT
         }
     }
     
+    private String stripXmlInstructionIfNeeded(String str) {
+        if (str != null && str.startsWith("<?xml")) {
+            int index = str.indexOf("?>");
+            str = str.substring(index + 2);
+        }
+        return str;
+    }
     
     private String getStringFromInputStream(InputStream in) throws Exception {        
         CachedOutputStream bos = new CachedOutputStream();

http://git-wip-us.apache.org/repos/asf/cxf/blob/8f82a3e2/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerProxySpringBookTest.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerProxySpringBookTest.java
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerProxySpringBookTest.java
index e5f2e5d..f933e6a 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerProxySpringBookTest.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerProxySpringBookTest.java
@@ -60,8 +60,8 @@ public class JAXRSClientServerProxySpringBookTest extends AbstractBusClientServe
             .getResourceAsStream("resources/expected_get_book_notfound_mapped.txt");
 
         assertEquals("Exception is not mapped correctly", 
-                     getStringFromInputStream(expected).trim(),
-                     getStringFromInputStream(in).trim());
+                     stripXmlInstructionIfNeeded(getStringFromInputStream(expected).trim()),
+                     stripXmlInstructionIfNeeded(getStringFromInputStream(in).trim()));
     }
     
     @Test
@@ -115,7 +115,8 @@ public class JAXRSClientServerProxySpringBookTest extends AbstractBusClientServe
 
         InputStream expected = getClass()
             .getResourceAsStream("resources/expected_get_book123.txt");
-        assertEquals(getStringFromInputStream(expected), getStringFromInputStream(in));
+        assertEquals(stripXmlInstructionIfNeeded(getStringFromInputStream(expected)), 
+                     stripXmlInstructionIfNeeded(getStringFromInputStream(in)));
     }
     
     @Test
@@ -140,7 +141,6 @@ public class JAXRSClientServerProxySpringBookTest extends AbstractBusClientServe
         InputStream expected = getClass()
             .getResourceAsStream("resources/expected_get_book123json.txt");
 
-        //System.out.println("---" + getStringFromInputStream(in));
         assertEquals(getStringFromInputStream(expected), getStringFromInputStream(in)); 
     }
 
@@ -164,4 +164,11 @@ public class JAXRSClientServerProxySpringBookTest extends AbstractBusClientServe
         return str;
     }
 
+    private String stripXmlInstructionIfNeeded(String str) {
+        if (str != null && str.startsWith("<?xml")) {
+            int index = str.indexOf("?>");
+            str = str.substring(index + 2);
+        }
+        return str;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/8f82a3e2/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedOutsideBookTest.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedOutsideBookTest.java
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedOutsideBookTest.java
index f3eb029..e79e88c 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedOutsideBookTest.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedOutsideBookTest.java
@@ -59,7 +59,8 @@ public class JAXRSClientServerResourceCreatedOutsideBookTest extends AbstractBus
         InputStream expected = getClass()
             .getResourceAsStream("resources/expected_get_book123.txt");
 
-        assertEquals(getStringFromInputStream(expected), getStringFromInputStream(in)); 
+        assertEquals(stripXmlInstructionIfNeeded(getStringFromInputStream(expected)), 
+                     stripXmlInstructionIfNeeded(getStringFromInputStream(in))); 
     }
     
     @Test
@@ -100,11 +101,18 @@ public class JAXRSClientServerResourceCreatedOutsideBookTest extends
AbstractBus
         assertEquals(200, responseCode);
         
         InputStream expected = getClass().getResourceAsStream("resources/expected_add_book.txt");

-        assertEquals(getStringFromInputStream(expected), getStringFromInputStream(httpUrlConnection
-            .getInputStream()));  
+        assertEquals(stripXmlInstructionIfNeeded(getStringFromInputStream(expected)), 
+                     stripXmlInstructionIfNeeded(getStringFromInputStream(httpUrlConnection
+            .getInputStream())));  
         httpUrlConnection.disconnect();        
     } 
-    
+    private String stripXmlInstructionIfNeeded(String str) {
+        if (str != null && str.startsWith("<?xml")) {
+            int index = str.indexOf("?>");
+            str = str.substring(index + 2);
+        }
+        return str;
+    }
     private String getStringFromInputStream(InputStream in) throws Exception {        
         CachedOutputStream bos = new CachedOutputStream();
         IOUtils.copy(in, bos);

http://git-wip-us.apache.org/repos/asf/cxf/blob/8f82a3e2/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedSpringBookTest.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedSpringBookTest.java
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedSpringBookTest.java
index 48d78ab..58736ef 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedSpringBookTest.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedSpringBookTest.java
@@ -80,7 +80,15 @@ public class JAXRSClientServerResourceCreatedSpringBookTest extends AbstractBusC
         InputStream expected = getClass()
             .getResourceAsStream("resources/expected_get_book123.txt");
 
-        assertEquals(getStringFromInputStream(expected), getStringFromInputStream(in)); 
+        assertEquals(stripXmlInstructionIfNeeded(getStringFromInputStream(expected)), 
+                     stripXmlInstructionIfNeeded(getStringFromInputStream(in))); 
+    }
+    private String stripXmlInstructionIfNeeded(String str) {
+        if (str != null && str.startsWith("<?xml")) {
+            int index = str.indexOf("?>");
+            str = str.substring(index + 2);
+        }
+        return str;
     }
     
     @Test

http://git-wip-us.apache.org/repos/asf/cxf/blob/8f82a3e2/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedSpringProviderTest.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedSpringProviderTest.java
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedSpringProviderTest.java
index 2ed0c94..dc39ed6 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedSpringProviderTest.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedSpringProviderTest.java
@@ -204,10 +204,17 @@ public class JAXRSClientServerResourceCreatedSpringProviderTest extends
Abstract
             .getResourceAsStream("resources/expected_get_book123badgerfish.txt");
 
         assertEquals("BadgerFish output not correct", 
-                     getStringFromInputStream(expected).trim(),
-                     getStringFromInputStream(in).trim());
+                     stripXmlInstructionIfNeeded(getStringFromInputStream(expected).trim()),
+                     stripXmlInstructionIfNeeded(getStringFromInputStream(in).trim()));
     }
     
+    private String stripXmlInstructionIfNeeded(String str) {
+        if (str != null && str.startsWith("<?xml")) {
+            int index = str.indexOf("?>");
+            str = str.substring(index + 2);
+        }
+        return str;
+    }
     @Test
     public void testGetBookNotFound() throws Exception {
         
@@ -224,8 +231,8 @@ public class JAXRSClientServerResourceCreatedSpringProviderTest extends
Abstract
             .getResourceAsStream("resources/expected_get_book_notfound_mapped.txt");
 
         assertEquals("Exception is not mapped correctly", 
-                     getStringFromInputStream(expected).trim(),
-                     getStringFromInputStream(in).trim());
+                     stripXmlInstructionIfNeeded(getStringFromInputStream(expected).trim()),
+                     stripXmlInstructionIfNeeded(getStringFromInputStream(in).trim()));
     }
     
     @Test

http://git-wip-us.apache.org/repos/asf/cxf/blob/8f82a3e2/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartTest.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartTest.java
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartTest.java
index 152396e..b01a9c7 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartTest.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartTest.java
@@ -855,7 +855,8 @@ public class JAXRSMultipartTest extends AbstractBusClientServerTestBase
{
             assertEquals(status, result);
             if (status == 200) {
                 InputStream expected = getClass().getResourceAsStream("resources/expected_add_book.txt");
-                assertEquals(getStringFromInputStream(expected), post.getResponseBodyAsString());
+                assertEquals(stripXmlInstructionIfNeeded(getStringFromInputStream(expected)),

+                             stripXmlInstructionIfNeeded(post.getResponseBodyAsString()));
             }
         } finally {
             // Release current connection to the connection pool once you are done
@@ -879,7 +880,8 @@ public class JAXRSMultipartTest extends AbstractBusClientServerTestBase
{
             assertEquals(status, result);
             if (status == 200) {
                 InputStream expected = getClass().getResourceAsStream("resources/expected_add_book.txt");
-                assertEquals(getStringFromInputStream(expected), post.getResponseBodyAsString());
+                assertEquals(stripXmlInstructionIfNeeded(getStringFromInputStream(expected)),

+                             stripXmlInstructionIfNeeded(post.getResponseBodyAsString()));
             }
         } finally {
             // Release current connection to the connection pool once you are done
@@ -908,4 +910,11 @@ public class JAXRSMultipartTest extends AbstractBusClientServerTestBase
{
                                  MediaType.APPLICATION_JSON_TYPE, null, is);
         
     }
+    private String stripXmlInstructionIfNeeded(String str) {
+        if (str != null && str.startsWith("<?xml")) {
+            int index = str.indexOf("?>");
+            str = str.substring(index + 2);
+        }
+        return str;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/8f82a3e2/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java
index 295687c..c9a9309 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java
@@ -343,7 +343,8 @@ public class JAXRSSoapBookTest extends AbstractBusClientServerTestBase
{
         
         InputStream in = getHttpInputStream("http://localhost:" + PORT + "/test/services/rest/bookstore/0");
         InputStream expected = getClass().getResourceAsStream("resources/expected_get_book123.txt");
-        assertEquals(getStringFromInputStream(expected), getStringFromInputStream(in));
+        assertEquals(stripXmlInstructionIfNeeded(getStringFromInputStream(expected)), 
+                     stripXmlInstructionIfNeeded(getStringFromInputStream(in)));
                 
     }
     
@@ -353,7 +354,8 @@ public class JAXRSSoapBookTest extends AbstractBusClientServerTestBase
{
         InputStream in = getHttpInputStream("http://localhost:" + PORT + "/test/services/rest/bookstore/123");
         
         InputStream expected = getClass().getResourceAsStream("resources/expected_get_book123.txt");
-        assertEquals(getStringFromInputStream(expected), getStringFromInputStream(in));
+        assertEquals(stripXmlInstructionIfNeeded(getStringFromInputStream(expected)), 
+                     stripXmlInstructionIfNeeded(getStringFromInputStream(in)));
                 
     }
     
@@ -757,7 +759,8 @@ public class JAXRSSoapBookTest extends AbstractBusClientServerTestBase
{
             
             InputStream expected = getClass().getResourceAsStream("resources/expected_add_book.txt");
             
-            assertEquals(getStringFromInputStream(expected), post.getResponseBodyAsString());
+            assertEquals(stripXmlInstructionIfNeeded(getStringFromInputStream(expected)),
+                         stripXmlInstructionIfNeeded(post.getResponseBodyAsString()));
         } finally {
             // Release current connection to the connection pool once you are done
             post.releaseConnection();
@@ -1126,5 +1129,11 @@ public class JAXRSSoapBookTest extends AbstractBusClientServerTestBase
{
         }
 
     }
-    
+    private String stripXmlInstructionIfNeeded(String str) {
+        if (str != null && str.startsWith("<?xml")) {
+            int index = str.indexOf("?>");
+            str = str.substring(index + 2);
+        }
+        return str;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/8f82a3e2/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/AbstractSpringSecurityTest.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/AbstractSpringSecurityTest.java
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/AbstractSpringSecurityTest.java
index 00abc4d..af74fca 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/AbstractSpringSecurityTest.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/AbstractSpringSecurityTest.java
@@ -60,12 +60,19 @@ public abstract class AbstractSpringSecurityTest extends AbstractBusClientServer
                 String resource = "/org/apache/cxf/systest/jaxrs/resources/expected_get_book123.txt";
                 InputStream expected = getClass().getResourceAsStream(resource);
                 assertEquals("Expected value is wrong", 
-                             getStringFromInputStream(expected), content);
+                             stripXmlInstructionIfNeeded(getStringFromInputStream(expected)),

+                             stripXmlInstructionIfNeeded(content));
             }
         } finally {
             get.releaseConnection();
         }
         
     }
-   
+    private String stripXmlInstructionIfNeeded(String str) {
+        if (str != null && str.startsWith("<?xml")) {
+            int index = str.indexOf("?>");
+            str = str.substring(index + 2);
+        }
+        return str;
+    }   
 }


Mime
View raw message