wink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b...@apache.org
Subject svn commit: r813122 - in /incubator/wink/trunk/wink-itests/wink-itest: wink-itest-providers/src/main/java/org/apache/wink/itest/exceptionmappers/mapped/ wink-itest-providers/src/main/java/org/apache/wink/itest/exceptionmappers/nomapper/ wink-itest-prov...
Date Wed, 09 Sep 2009 21:15:41 GMT
Author: bluk
Date: Wed Sep  9 21:15:40 2009
New Revision: 813122

URL: http://svn.apache.org/viewvc?rev=813122&view=rev
Log:
Update tests to compare without formatting diffs

Modified:
    incubator/wink/trunk/wink-itests/wink-itest/wink-itest-providers/src/main/java/org/apache/wink/itest/exceptionmappers/mapped/Guestbook.java
    incubator/wink/trunk/wink-itests/wink-itest/wink-itest-providers/src/main/java/org/apache/wink/itest/exceptionmappers/mapped/GuestbookDatabase.java
    incubator/wink/trunk/wink-itests/wink-itest/wink-itest-providers/src/main/java/org/apache/wink/itest/exceptionmappers/nomapper/Guestbook.java
    incubator/wink/trunk/wink-itests/wink-itest/wink-itest-providers/src/main/java/org/apache/wink/itest/exceptionmappers/nomapper/GuestbookDatabase.java
    incubator/wink/trunk/wink-itests/wink-itest/wink-itest-providers/src/test/java/org/apache/wink/itest/exceptionmappers/JAXRSExceptionsMappedProvidersTest.java
    incubator/wink/trunk/wink-itests/wink-itest/wink-itest-providers/src/test/java/org/apache/wink/itest/exceptionmappers/JAXRSExceptionsNoMapperTest.java
    incubator/wink/trunk/wink-itests/wink-itest/wink-itest-providers/src/test/java/org/apache/wink/itest/subresources/JAXRSExceptionsSubresourcesTest.java
    incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/contentnegotiation/ContentNegotiationClientTest.java

Modified: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-providers/src/main/java/org/apache/wink/itest/exceptionmappers/mapped/Guestbook.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-providers/src/main/java/org/apache/wink/itest/exceptionmappers/mapped/Guestbook.java?rev=813122&r1=813121&r2=813122&view=diff
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-providers/src/main/java/org/apache/wink/itest/exceptionmappers/mapped/Guestbook.java
(original)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-providers/src/main/java/org/apache/wink/itest/exceptionmappers/mapped/Guestbook.java
Wed Sep  9 21:15:40 2009
@@ -173,5 +173,6 @@
         for (Integer k : keys) {
             GuestbookDatabase.getGuestbook().deleteComment(k);
         }
+        GuestbookDatabase.getGuestbook().resetCounter();
     }
 }

Modified: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-providers/src/main/java/org/apache/wink/itest/exceptionmappers/mapped/GuestbookDatabase.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-providers/src/main/java/org/apache/wink/itest/exceptionmappers/mapped/GuestbookDatabase.java?rev=813122&r1=813121&r2=813122&view=diff
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-providers/src/main/java/org/apache/wink/itest/exceptionmappers/mapped/GuestbookDatabase.java
(original)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-providers/src/main/java/org/apache/wink/itest/exceptionmappers/mapped/GuestbookDatabase.java
Wed Sep  9 21:15:40 2009
@@ -71,4 +71,9 @@
         ++counter;
         return counter;
     }
+
+    public synchronized int resetCounter() {
+        counter = 0;
+        return counter;
+    }
 }

Modified: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-providers/src/main/java/org/apache/wink/itest/exceptionmappers/nomapper/Guestbook.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-providers/src/main/java/org/apache/wink/itest/exceptionmappers/nomapper/Guestbook.java?rev=813122&r1=813121&r2=813122&view=diff
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-providers/src/main/java/org/apache/wink/itest/exceptionmappers/nomapper/Guestbook.java
(original)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-providers/src/main/java/org/apache/wink/itest/exceptionmappers/nomapper/Guestbook.java
Wed Sep  9 21:15:40 2009
@@ -169,5 +169,6 @@
         for (Integer k : keys) {
             GuestbookDatabase.getGuestbook().deleteComment(k);
         }
+        GuestbookDatabase.getGuestbook().resetCounter();
     }
 }

Modified: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-providers/src/main/java/org/apache/wink/itest/exceptionmappers/nomapper/GuestbookDatabase.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-providers/src/main/java/org/apache/wink/itest/exceptionmappers/nomapper/GuestbookDatabase.java?rev=813122&r1=813121&r2=813122&view=diff
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-providers/src/main/java/org/apache/wink/itest/exceptionmappers/nomapper/GuestbookDatabase.java
(original)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-providers/src/main/java/org/apache/wink/itest/exceptionmappers/nomapper/GuestbookDatabase.java
Wed Sep  9 21:15:40 2009
@@ -71,4 +71,9 @@
         ++counter;
         return counter;
     }
+
+    public synchronized int resetCounter() {
+        counter = 0;
+        return counter;
+    }
 }

Modified: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-providers/src/test/java/org/apache/wink/itest/exceptionmappers/JAXRSExceptionsMappedProvidersTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-providers/src/test/java/org/apache/wink/itest/exceptionmappers/JAXRSExceptionsMappedProvidersTest.java?rev=813122&r1=813121&r2=813122&view=diff
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-providers/src/test/java/org/apache/wink/itest/exceptionmappers/JAXRSExceptionsMappedProvidersTest.java
(original)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-providers/src/test/java/org/apache/wink/itest/exceptionmappers/JAXRSExceptionsMappedProvidersTest.java
Wed Sep  9 21:15:40 2009
@@ -19,6 +19,7 @@
 package org.apache.wink.itest.exceptionmappers;
 
 import javax.ws.rs.core.Response.Status;
+import javax.xml.bind.JAXBContext;
 
 import junit.framework.TestCase;
 
@@ -28,6 +29,8 @@
 import org.apache.commons.httpclient.methods.PostMethod;
 import org.apache.commons.httpclient.methods.PutMethod;
 import org.apache.commons.httpclient.methods.StringRequestEntity;
+import org.apache.wink.itest.exceptionmappers.mapped.Comment;
+import org.apache.wink.itest.exceptionmappers.mapped.CommentError;
 import org.apache.wink.test.integration.ServerContainerAssertions;
 import org.apache.wink.test.integration.ServerEnvironmentInfo;
 
@@ -65,8 +68,13 @@
         GetMethod getMethod = new GetMethod(newPostURILocation);
         client.executeMethod(getMethod);
         assertEquals(200, getMethod.getStatusCode());
-        assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><comment><author>Anonymous</author><id>1</id><message>Hello
World!</message></comment>",
-                     getMethod.getResponseBodyAsString());
+
+        Comment c =
+            (Comment)JAXBContext.newInstance(Comment.class.getPackage().getName())
+                .createUnmarshaller().unmarshal(getMethod.getResponseBodyAsStream());
+        assertEquals("Anonymous", c.getAuthor());
+        assertEquals(1, c.getId().intValue());
+        assertEquals("Hello World!", c.getMessage());
     }
 
     /**
@@ -143,8 +151,11 @@
                                                       "text/xml", null));
         client.executeMethod(postMethod);
         assertEquals(400, postMethod.getStatusCode());
-        assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><commenterror><message>Missing
the message in the comment.</message></commenterror>",
-                     postMethod.getResponseBodyAsString());
+
+        CommentError c =
+            (CommentError)JAXBContext.newInstance(CommentError.class.getPackage().getName())
+                .createUnmarshaller().unmarshal(postMethod.getResponseBodyAsStream());
+        assertEquals("Missing the message in the comment.", c.getErrorMessage());
     }
 
     /**
@@ -167,8 +178,11 @@
         assertEquals("Some message", postMethod
             .getResponseHeader("throwemptyentitywebappexception").getValue());
         assertEquals(getBaseURI(), postMethod.getResponseHeader("ExceptionPage").getValue());
-        assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><commenterror><message>WebApplicationExceptionMapProvider
set message</message></commenterror>",
-                     postMethod.getResponseBodyAsString());
+
+        CommentError c =
+            (CommentError)JAXBContext.newInstance(CommentError.class.getPackage().getName())
+                .createUnmarshaller().unmarshal(postMethod.getResponseBodyAsStream());
+        assertEquals("WebApplicationExceptionMapProvider set message", c.getErrorMessage());
     }
 
     /**
@@ -187,8 +201,11 @@
                                                       "text/xml", null));
         client.executeMethod(postMethod);
         assertEquals(498, postMethod.getStatusCode());
-        assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><commenterror><message>Cannot
post an invalid message.</message></commenterror>",
-                     postMethod.getResponseBodyAsString());
+
+        CommentError c =
+            (CommentError)JAXBContext.newInstance(CommentError.class.getPackage().getName())
+                .createUnmarshaller().unmarshal(postMethod.getResponseBodyAsStream());
+        assertEquals("Cannot post an invalid message.", c.getErrorMessage());
     }
 
     /**
@@ -206,11 +223,11 @@
         DeleteMethod postMethod = new DeleteMethod(getBaseURI() + "/abcd");
         client.executeMethod(postMethod);
         assertEquals(450, postMethod.getStatusCode());
-        String responseBody = postMethod.getResponseBodyAsString();
-        assertTrue(responseBody,
-                   "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><commenterror><message>For
input string: \"abcd\"</message></commenterror>"
-                       .equals(responseBody) || "<?xml version=\"1.0\" encoding=\"UTF-8\"
standalone=\"yes\"?><commenterror><message>For input string: &quot;abcd&quot;</message></commenterror>"
-                       .equals(responseBody));
+
+        CommentError c =
+            (CommentError)JAXBContext.newInstance(CommentError.class.getPackage().getName())
+                .createUnmarshaller().unmarshal(postMethod.getResponseBodyAsStream());
+        assertEquals("For input string: \"abcd\"", c.getErrorMessage());
     }
 
     /**
@@ -224,8 +241,11 @@
         DeleteMethod postMethod = new DeleteMethod(getBaseURI() + "/10000");
         client.executeMethod(postMethod);
         assertEquals(451, postMethod.getStatusCode());
-        assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><commenterror><message>The
comment did not previously exist.</message></commenterror>",
-                     postMethod.getResponseBodyAsString());
+
+        CommentError c =
+            (CommentError)JAXBContext.newInstance(CommentError.class.getPackage().getName())
+                .createUnmarshaller().unmarshal(postMethod.getResponseBodyAsStream());
+        assertEquals("The comment did not previously exist.", c.getErrorMessage());
     }
 
     /**
@@ -239,8 +259,11 @@
         DeleteMethod postMethod = new DeleteMethod(getBaseURI() + "/-99999");
         client.executeMethod(postMethod);
         assertEquals(453, postMethod.getStatusCode());
-        assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><commenterror><message>Simulated
error</message></commenterror>",
-                     postMethod.getResponseBodyAsString());
+
+        CommentError c =
+            (CommentError)JAXBContext.newInstance(CommentError.class.getPackage().getName())
+                .createUnmarshaller().unmarshal(postMethod.getResponseBodyAsStream());
+        assertEquals("Simulated error", c.getErrorMessage());
     }
 
     /**
@@ -258,7 +281,10 @@
                                                       "text/xml", null));
         client.executeMethod(putMethod);
         assertEquals(454, putMethod.getStatusCode());
-        assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><commenterror><message>Unexpected
ID.</message></commenterror>",
-                     putMethod.getResponseBodyAsString());
+
+        CommentError c =
+            (CommentError)JAXBContext.newInstance(CommentError.class.getPackage().getName())
+                .createUnmarshaller().unmarshal(putMethod.getResponseBodyAsStream());
+        assertEquals("Unexpected ID.", c.getErrorMessage());
     }
 }

Modified: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-providers/src/test/java/org/apache/wink/itest/exceptionmappers/JAXRSExceptionsNoMapperTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-providers/src/test/java/org/apache/wink/itest/exceptionmappers/JAXRSExceptionsNoMapperTest.java?rev=813122&r1=813121&r2=813122&view=diff
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-providers/src/test/java/org/apache/wink/itest/exceptionmappers/JAXRSExceptionsNoMapperTest.java
(original)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-providers/src/test/java/org/apache/wink/itest/exceptionmappers/JAXRSExceptionsNoMapperTest.java
Wed Sep  9 21:15:40 2009
@@ -20,6 +20,7 @@
 package org.apache.wink.itest.exceptionmappers;
 
 import javax.ws.rs.core.Response.Status;
+import javax.xml.bind.JAXBContext;
 
 import junit.framework.TestCase;
 
@@ -29,6 +30,8 @@
 import org.apache.commons.httpclient.methods.PostMethod;
 import org.apache.commons.httpclient.methods.PutMethod;
 import org.apache.commons.httpclient.methods.StringRequestEntity;
+import org.apache.wink.itest.exceptionmappers.nomapper.Comment;
+import org.apache.wink.itest.exceptionmappers.nomapper.CommentError;
 import org.apache.wink.test.integration.ServerContainerAssertions;
 import org.apache.wink.test.integration.ServerEnvironmentInfo;
 
@@ -70,8 +73,13 @@
         GetMethod getMethod = new GetMethod(newPostURILocation);
         client.executeMethod(getMethod);
         assertEquals(200, getMethod.getStatusCode());
-        assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><comment><author>Anonymous</author><id>1</id><message>Hello
World!</message></comment>",
-                     getMethod.getResponseBodyAsString());
+
+        Comment c =
+            (Comment)JAXBContext.newInstance(Comment.class.getPackage().getName())
+                .createUnmarshaller().unmarshal(getMethod.getResponseBodyAsStream());
+        assertEquals("Anonymous", c.getAuthor());
+        assertEquals(1, c.getId().intValue());
+        assertEquals("Hello World!", c.getMessage());
     }
 
     /**
@@ -145,8 +153,11 @@
                                                       "text/xml", null));
         client.executeMethod(postMethod);
         assertEquals(Status.BAD_REQUEST.getStatusCode(), postMethod.getStatusCode());
-        assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><commenterror><message>Missing
the message in the comment.</message></commenterror>",
-                     postMethod.getResponseBodyAsString());
+
+        CommentError c =
+            (CommentError)JAXBContext.newInstance(CommentError.class.getPackage().getName())
+                .createUnmarshaller().unmarshal(postMethod.getResponseBodyAsStream());
+        assertEquals("Missing the message in the comment.", c.getErrorMessage());
     }
 
     /**
@@ -165,8 +176,11 @@
                                                       "text/xml", null));
         client.executeMethod(postMethod);
         assertEquals(498, postMethod.getStatusCode());
-        assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><commenterror><message>Cannot
post an invalid message.</message></commenterror>",
-                     postMethod.getResponseBodyAsString());
+
+        CommentError c =
+            (CommentError)JAXBContext.newInstance(CommentError.class.getPackage().getName())
+                .createUnmarshaller().unmarshal(postMethod.getResponseBodyAsStream());
+        assertEquals("Cannot post an invalid message.", c.getErrorMessage());
     }
 
     /**

Modified: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-providers/src/test/java/org/apache/wink/itest/subresources/JAXRSExceptionsSubresourcesTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-providers/src/test/java/org/apache/wink/itest/subresources/JAXRSExceptionsSubresourcesTest.java?rev=813122&r1=813121&r2=813122&view=diff
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-providers/src/test/java/org/apache/wink/itest/subresources/JAXRSExceptionsSubresourcesTest.java
(original)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-providers/src/test/java/org/apache/wink/itest/subresources/JAXRSExceptionsSubresourcesTest.java
Wed Sep  9 21:15:40 2009
@@ -20,6 +20,7 @@
 package org.apache.wink.itest.subresources;
 
 import javax.ws.rs.core.Response.Status;
+import javax.xml.bind.JAXBContext;
 
 import junit.framework.TestCase;
 
@@ -29,6 +30,8 @@
 import org.apache.commons.httpclient.methods.PostMethod;
 import org.apache.commons.httpclient.methods.PutMethod;
 import org.apache.commons.httpclient.methods.StringRequestEntity;
+import org.apache.wink.itest.exceptionmappers.nomapper.CommentError;
+import org.apache.wink.itest.subresource.Comment;
 import org.apache.wink.test.integration.ServerEnvironmentInfo;
 
 public class JAXRSExceptionsSubresourcesTest extends TestCase {
@@ -65,8 +68,13 @@
         try {
             client.executeMethod(getMethod);
             assertEquals(200, getMethod.getStatusCode());
-            assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><comment><author>Anonymous</author><id>10000</id><message>Hi
there</message></comment>",
-                         getMethod.getResponseBodyAsString());
+
+            Comment c =
+                (Comment)JAXBContext.newInstance(Comment.class.getPackage().getName())
+                    .createUnmarshaller().unmarshal(getMethod.getResponseBodyAsStream());
+            assertEquals("Anonymous", c.getAuthor());
+            assertEquals(10000, c.getId().intValue());
+            assertEquals("Hi there", c.getMessage());
         } finally {
             getMethod.releaseConnection();
         }
@@ -88,8 +96,12 @@
             // postMethod.addRequestHeader("Accept", "text/xml");
             client.executeMethod(postMethod);
             assertEquals(Status.BAD_REQUEST.getStatusCode(), postMethod.getStatusCode());
-            assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><commenterror><message>Please
include a comment ID, a message, and your name.</message></commenterror>",
-                         postMethod.getResponseBodyAsString());
+
+            CommentError c =
+                (CommentError)JAXBContext.newInstance(CommentError.class.getPackage().getName())
+                    .createUnmarshaller().unmarshal(postMethod.getResponseBodyAsStream());
+            assertEquals("Please include a comment ID, a message, and your name.", c
+                .getErrorMessage());
         } finally {
             postMethod.releaseConnection();
         }

Modified: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/contentnegotiation/ContentNegotiationClientTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/contentnegotiation/ContentNegotiationClientTest.java?rev=813122&r1=813121&r2=813122&view=diff
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/contentnegotiation/ContentNegotiationClientTest.java
(original)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/contentnegotiation/ContentNegotiationClientTest.java
Wed Sep  9 21:15:40 2009
@@ -21,6 +21,10 @@
 
 import java.io.IOException;
 
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Unmarshaller;
+
 import junit.framework.TestCase;
 
 import org.apache.commons.httpclient.HttpClient;
@@ -45,7 +49,7 @@
                                                    : "/contentNegotiation")
                                                    + "/customerservice";
 
-    public void testGetReturningXML() {
+    public void testGetReturningXML() throws JAXBException {
         // Sent HTTP GET request to query customer info, expect XML
         System.out.println("Sent HTTP GET request to query customer info, expect XML");
         GetMethod get = new GetMethod(BASE_URI + "/customers/123");
@@ -58,7 +62,12 @@
             String responseBody = get.getResponseBodyAsString();
             System.out.println(responseBody);
             assertTrue(result == 200);
-            assertTrue(responseBody.contains("<Customer><id>123</id><name>John</name></Customer>"));
+            Unmarshaller unmarshaller =
+                JAXBContext.newInstance(ObjectFactory.class.getPackage().getName())
+                    .createUnmarshaller();
+            Customer c = (Customer)unmarshaller.unmarshal(get.getResponseBodyAsStream());
+            assertEquals(123, c.getId());
+            assertEquals("John", c.getName());
         } catch (IOException ioe) {
             ioe.printStackTrace();
             fail(ioe.getMessage());



Mime
View raw message