[jackson-jaxrs-providers] 104/162: Added unit test to try to reproduce #34

Timo Aaltonen tjaalton at moszumanska.debian.org
Mon Sep 8 22:16:33 UTC 2014


This is an automated email from the git hooks/post-receive script.

tjaalton pushed a commit to branch master
in repository jackson-jaxrs-providers.

commit 4072405b6800b583316dd213d1663a120990443f
Author: Tatu Saloranta <tatu.saloranta at iki.fi>
Date:   Wed Nov 6 22:30:37 2013 -0800

    Added unit test to try to reproduce #34
---
 .../jackson/jaxrs/json/dw/TestSimpleEndpoint.java  | 46 ++++++++++++++++++++--
 1 file changed, 43 insertions(+), 3 deletions(-)

diff --git a/json/src/test/java/com/fasterxml/jackson/jaxrs/json/dw/TestSimpleEndpoint.java b/json/src/test/java/com/fasterxml/jackson/jaxrs/json/dw/TestSimpleEndpoint.java
index d21a99c..83c2c5e 100644
--- a/json/src/test/java/com/fasterxml/jackson/jaxrs/json/dw/TestSimpleEndpoint.java
+++ b/json/src/test/java/com/fasterxml/jackson/jaxrs/json/dw/TestSimpleEndpoint.java
@@ -9,6 +9,7 @@ import javax.ws.rs.Produces;
 import javax.ws.rs.core.MediaType;
 
 import org.eclipse.jetty.server.Server;
+import org.junit.Assert;
 
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.jaxrs.json.ResourceTestBase;
@@ -40,13 +41,37 @@ public class TestSimpleEndpoint extends ResourceTestBase
     public static class SimpleResourceApp extends JsonApplication {
         public SimpleResourceApp() { super(new SimpleResource()); }
     }
-    
+
+    private final static String UNTOUCHABLE_RESPONSE = "[1]";
+
+    @Path("/raw")
+    public static class RawResource
+    {
+        @GET
+        @Produces({ MediaType.APPLICATION_JSON, "application/javascript" })
+        @Path("string")
+        public String getString() {
+            return UNTOUCHABLE_RESPONSE;
+        }
+
+        @GET
+        @Path("bytes")
+        @Produces({ MediaType.APPLICATION_JSON, "application/javascript" })
+        public byte[] getBytes() throws IOException {
+            return UNTOUCHABLE_RESPONSE.getBytes("UTF-8");
+        }
+    }
+
+    public static class SimpleRawApp extends JsonApplication {
+        public SimpleRawApp() { super(new RawResource()); }
+    }
+
     /*
     /**********************************************************
     /* Test methods
     /**********************************************************
      */
-    
+
     public void testStandardJson() throws Exception
     {
         final ObjectMapper mapper = new ObjectMapper();
@@ -65,7 +90,7 @@ public class TestSimpleEndpoint extends ResourceTestBase
         assertEquals(1, p.x);
         assertEquals(2, p.y);
     }
-
+    
     public void testAcceptJavascriptType() throws Exception
     {
         final ObjectMapper mapper = new ObjectMapper();
@@ -102,4 +127,19 @@ public class TestSimpleEndpoint extends ResourceTestBase
         
     }
     
+    // [Issue#34] Verify that Untouchables act the way as they should
+    @SuppressWarnings("resource")
+    public void testUntouchables() throws Exception
+    {
+        Server server = startServer(TEST_PORT, SimpleRawApp.class);
+        try {
+            InputStream in = new URL("http://localhost:"+TEST_PORT+"/raw/string").openStream();
+            assertEquals(UNTOUCHABLE_RESPONSE, readUTF8(in));
+
+            in = new URL("http://localhost:"+TEST_PORT+"/raw/bytes").openStream();
+            Assert.assertArrayEquals(UNTOUCHABLE_RESPONSE.getBytes("UTF-8"), readAll(in));
+        } finally {
+            server.stop();
+        }
+    }
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/jackson-jaxrs-providers.git



More information about the pkg-java-commits mailing list