Repository: cxf
Updated Branches:
  refs/heads/master 92f88c0e6 -> 58af366de


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/32facce6
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/32facce6
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/32facce6

Branch: refs/heads/master
Commit: 32facce6b46d44a9a1536e3ba70cf5d1e171739f
Parents: 974526c
Author: Sergey Beryozkin <[email protected]>
Authored: Fri Mar 28 17:46:11 2014 +0000
Committer: Sergey Beryozkin <[email protected]>
Committed: Fri Mar 28 17:46:11 2014 +0000

----------------------------------------------------------------------
 .../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/32facce6/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 664e98f..34aad22 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
@@ -2075,7 +2075,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();
@@ -2109,8 +2110,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
@@ -2157,8 +2158,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
@@ -2487,7 +2488,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"));
@@ -2504,6 +2505,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/32facce6/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 1bcafff..bea04ca 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
@@ -578,7 +578,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 {
@@ -831,7 +832,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"));
@@ -842,6 +844,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