[jackson-jaxrs-providers] 36/162: ...
Timo Aaltonen
tjaalton at moszumanska.debian.org
Mon Sep 8 22:16:25 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 0053e4cc8b8e3dfb19e25eb815bcc21a416e5ee2
Author: Tatu Saloranta <tsaloranta at gmail.com>
Date: Thu Apr 11 22:52:13 2013 -0700
...
---
.../jackson/jaxrs/json/JaxrsTestBase.java | 2 +-
.../jackson/jaxrs/json/dw/TestSimpleEndpoint.java | 30 +++++++++++++++++++---
2 files changed, 27 insertions(+), 5 deletions(-)
diff --git a/json/src/test/java/com/fasterxml/jackson/jaxrs/json/JaxrsTestBase.java b/json/src/test/java/com/fasterxml/jackson/jaxrs/json/JaxrsTestBase.java
index b55c2c9..1e9eb92 100644
--- a/json/src/test/java/com/fasterxml/jackson/jaxrs/json/JaxrsTestBase.java
+++ b/json/src/test/java/com/fasterxml/jackson/jaxrs/json/JaxrsTestBase.java
@@ -24,7 +24,7 @@ public abstract class JaxrsTestBase
/**********************************************************
*/
- protected Server startServer(int port, Class<?> appClass)
+ protected Server startServer(int port, Class<? extends Application> appClass)
{
Server server = new Server(port);
final ContextHandlerCollection contexts = new ContextHandlerCollection();
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 ad2a86d..bf7e4c2 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
@@ -1,5 +1,7 @@
package com.fasterxml.jackson.jaxrs.json.dw;
+import java.io.*;
+import java.net.URL;
import java.util.*;
import javax.ws.rs.GET;
@@ -10,6 +12,7 @@ import javax.ws.rs.core.MediaType;
import org.eclipse.jetty.server.Server;
+import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
import com.fasterxml.jackson.jaxrs.json.JaxrsTestBase;
public class TestSimpleEndpoint extends JaxrsTestBase
@@ -18,8 +21,8 @@ public class TestSimpleEndpoint extends JaxrsTestBase
public int x, y;
}
- static class SimpleResource {
- @Path("/point")
+ @Path("/point")
+ public static class SimpleResource {
@GET
@Produces(MediaType.APPLICATION_JSON)
public Point getPoint() {
@@ -27,11 +30,22 @@ public class TestSimpleEndpoint extends JaxrsTestBase
}
}
- static class SimpleResourceApp extends Application
+ public static class SimpleResourceApp extends JsonApplication {
+ public SimpleResourceApp() { super(new SimpleResource()); }
+ }
+
+ static abstract class JsonApplication extends Application
{
+ protected final Object _resource;
+
+ protected JsonApplication(Object r) { _resource = r; }
+
@Override
public Set<Object> getSingletons() {
- return new HashSet<Object>(Arrays.<Object>asList(SimpleResource.class));
+ HashSet<Object> singletons = new HashSet<Object>();
+ singletons.add(new JacksonJsonProvider());
+ singletons.add(_resource);
+ return singletons;
}
}
@@ -44,6 +58,14 @@ public class TestSimpleEndpoint extends JaxrsTestBase
public void testStandardJson() throws Exception
{
Server server = startServer(6061, SimpleResourceApp.class);
+ InputStream in = new URL("http://localhost:6061/point").openStream();
+ ByteArrayOutputStream bytes = new ByteArrayOutputStream();
+ int i;
+
+ while ((i = in.read()) >= 0) {
+ bytes.write((byte) i);
+ }
+ System.out.println("Bytes: "+bytes.size()+" -> "+bytes.toString("UTF-8"));
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