Updates to get some of the tests passed with the Moxy profile

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

Branch: refs/heads/2.7.x-fixes
Commit: b8eb4c0667056920e700d90c421beb0d0fdde6e3
Parents: 0940d45
Author: Sergey Beryozkin <[email protected]>
Authored: Fri Mar 28 17:46:11 2014 +0000
Committer: Daniel Kulp <[email protected]>
Committed: Fri Apr 4 09:57:40 2014 -0400

----------------------------------------------------------------------
 .../jaxrs/JAXRSClientServerBookTest.java        | 21 ++++++++++++++------
 .../jaxrs/JAXRSClientServerSpringBookTest.java  | 14 +++++++++++--
 2 files changed, 27 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/b8eb4c06/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 8990b06..b0575bf 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
@@ -2053,7 +2053,8 @@ public class JAXRSClientServerBookTest 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();
@@ -2087,8 +2088,8 @@ public class JAXRSClientServerBookTest extends 
AbstractBusClientServerTestBase {
             int result = httpclient.executeMethod(put);
             assertEquals(200, result);
             InputStream expected = 
getClass().getResourceAsStream("resources/expected_update_book.txt");
-            assertEquals(getStringFromInputStream(expected), 
-                         
getStringFromInputStream(put.getResponseBodyAsStream()));
+            
assertEquals(stripXmlInstructionIfNeeded(getStringFromInputStream(expected)), 
+                         
stripXmlInstructionIfNeeded(getStringFromInputStream(put.getResponseBodyAsStream())));
         } finally {
             // Release current connection to the connection pool once you are
             // done
@@ -2135,8 +2136,8 @@ public class JAXRSClientServerBookTest extends 
AbstractBusClientServerTestBase {
             int result = httpclient.executeMethod(put);
             assertEquals(200, result);
             InputStream expected = 
getClass().getResourceAsStream("resources/expected_update_book.txt");
-            assertEquals(getStringFromInputStream(expected), 
-                         
getStringFromInputStream(put.getResponseBodyAsStream()));
+            
assertEquals(stripXmlInstructionIfNeeded(getStringFromInputStream(expected)), 
+                         
stripXmlInstructionIfNeeded(getStringFromInputStream(put.getResponseBodyAsStream())));
         } finally {
             // Release current connection to the connection pool once you are
             // done
@@ -2463,7 +2464,7 @@ public class JAXRSClientServerBookTest extends 
AbstractBusClientServerTestBase {
             assertEquals(expectedStatus, result);
             String content = 
getStringFromInputStream(get.getResponseBodyAsStream());
             assertEquals("Expected value is wrong", 
-                         expectedValue, content);
+                         stripXmlInstructionIfNeeded(expectedValue), 
stripXmlInstructionIfNeeded(content));
             if (expectedStatus == 200) {
                 assertEquals("123", 
get.getResponseHeader("BookId").getValue());
                 assertNotNull(get.getResponseHeader("Date"));
@@ -2480,6 +2481,14 @@ public class JAXRSClientServerBookTest extends 
AbstractBusClientServerTestBase {
         }
     }
     
+    private String stripXmlInstructionIfNeeded(String str) {
+        if (str != null && str.startsWith("<?xml")) {
+            int index = str.indexOf("?>");
+            str = str.substring(index + 2);
+        }
+        return str;
+    }
+    
     private void getAndCompareStrings(String address, 
                                String[] expectedValue,
                                String acceptType,

http://git-wip-us.apache.org/repos/asf/cxf/blob/b8eb4c06/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java
----------------------------------------------------------------------
diff --git 
a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java
 
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java
index 5d54975..90e5d2d 100644
--- 
a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java
+++ 
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java
@@ -576,7 +576,8 @@ public class JAXRSClientServerSpringBookTest extends 
AbstractBusClientServerTest
         InputStream in = connect.getInputStream();           
 
         InputStream expected = getClass().getResourceAsStream(resource);
-        assertEquals(getStringFromInputStream(expected), 
getStringFromInputStream(in));
+        
assertEquals(stripXmlInstructionIfNeeded(getStringFromInputStream(expected)), 
+                     
stripXmlInstructionIfNeeded(getStringFromInputStream(in)));
     }
     
     private void getBookAegis(String endpointAddress, String type) throws 
Exception {
@@ -829,7 +830,8 @@ public class JAXRSClientServerSpringBookTest extends 
AbstractBusClientServerTest
             
             if (expectedStatus != 400) {
                 InputStream expected = 
getClass().getResourceAsStream(expectedResource);
-                assertEquals(getStringFromInputStream(expected), 
post.getResponseBodyAsString());
+                
assertEquals(stripXmlInstructionIfNeeded(getStringFromInputStream(expected)), 
+                             
stripXmlInstructionIfNeeded(post.getResponseBodyAsString()));
             } else {
                 assertTrue(post.getResponseBodyAsString()
                                .contains("Cannot find the declaration of 
element"));
@@ -840,6 +842,14 @@ public class JAXRSClientServerSpringBookTest extends 
AbstractBusClientServerTest
         }
     }
     
+    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);

Reply via email to