[jackson-jaxrs-providers] 123/162: further test stuff
Timo Aaltonen
tjaalton at moszumanska.debian.org
Mon Sep 8 22:16:35 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 a831c2ced1712f2887c6bb0843c10e51db4f17c6
Author: Tatu Saloranta <tatu.saloranta at iki.fi>
Date: Fri Feb 7 21:36:53 2014 -0800
further test stuff
---
.../jackson/jaxrs/cbor/dw/ResourceTestBase.java | 1 -
.../jackson/jaxrs/cbor/dw/SimpleEndpointTestBase.java | 1 -
.../fasterxml/jackson/jaxrs/smile/JaxrsTestBase.java | 5 ++---
.../com/fasterxml/jackson/jaxrs/xml/JaxrsTestBase.java | 15 +++++++++++++++
.../jackson/jaxrs/xml}/dw/ResourceTestBase.java | 17 ++++++++---------
.../jackson/jaxrs/xml}/dw/SimpleEndpointTestBase.java | 16 ++++++++--------
.../jackson/jaxrs/xml/jersey/SimpleEndpointTest.java | 11 +++++++++++
7 files changed, 44 insertions(+), 22 deletions(-)
diff --git a/cbor/src/test/java/com/fasterxml/jackson/jaxrs/cbor/dw/ResourceTestBase.java b/cbor/src/test/java/com/fasterxml/jackson/jaxrs/cbor/dw/ResourceTestBase.java
index 13bded1..b5080c8 100644
--- a/cbor/src/test/java/com/fasterxml/jackson/jaxrs/cbor/dw/ResourceTestBase.java
+++ b/cbor/src/test/java/com/fasterxml/jackson/jaxrs/cbor/dw/ResourceTestBase.java
@@ -1,6 +1,5 @@
package com.fasterxml.jackson.jaxrs.cbor.dw;
-import java.io.*;
import java.util.HashSet;
import java.util.Set;
diff --git a/cbor/src/test/java/com/fasterxml/jackson/jaxrs/cbor/dw/SimpleEndpointTestBase.java b/cbor/src/test/java/com/fasterxml/jackson/jaxrs/cbor/dw/SimpleEndpointTestBase.java
index 87881d4..83f80b0 100644
--- a/cbor/src/test/java/com/fasterxml/jackson/jaxrs/cbor/dw/SimpleEndpointTestBase.java
+++ b/cbor/src/test/java/com/fasterxml/jackson/jaxrs/cbor/dw/SimpleEndpointTestBase.java
@@ -6,7 +6,6 @@ import java.net.*;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
import org.eclipse.jetty.server.Server;
import org.junit.Assert;
diff --git a/smile/src/test/java/com/fasterxml/jackson/jaxrs/smile/JaxrsTestBase.java b/smile/src/test/java/com/fasterxml/jackson/jaxrs/smile/JaxrsTestBase.java
index b340976..8762b68 100644
--- a/smile/src/test/java/com/fasterxml/jackson/jaxrs/smile/JaxrsTestBase.java
+++ b/smile/src/test/java/com/fasterxml/jackson/jaxrs/smile/JaxrsTestBase.java
@@ -95,11 +95,10 @@ public abstract class JaxrsTestBase
return json.replace("'", "\"");
}
- protected String readUTF8(InputStream in) throws IOException
- {
+ protected String readUTF8(InputStream in) throws IOException {
return new String(readAll(in), "UTF-8");
}
-
+
protected byte[] readAll(InputStream in) throws IOException
{
ByteArrayOutputStream bytes = new ByteArrayOutputStream(100);
diff --git a/xml/src/test/java/com/fasterxml/jackson/jaxrs/xml/JaxrsTestBase.java b/xml/src/test/java/com/fasterxml/jackson/jaxrs/xml/JaxrsTestBase.java
index 99dfc44..7d00d7f 100644
--- a/xml/src/test/java/com/fasterxml/jackson/jaxrs/xml/JaxrsTestBase.java
+++ b/xml/src/test/java/com/fasterxml/jackson/jaxrs/xml/JaxrsTestBase.java
@@ -1,6 +1,8 @@
package com.fasterxml.jackson.jaxrs.xml;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.util.Arrays;
import org.junit.Assert;
@@ -88,4 +90,17 @@ public abstract class JaxrsTestBase
public String quote(String str) {
return '"'+str+'"';
}
+
+ protected byte[] readAll(InputStream in) throws IOException
+ {
+ ByteArrayOutputStream bytes = new ByteArrayOutputStream(100);
+ byte[] buffer = new byte[500];
+ int count;
+
+ while ((count = in.read(buffer)) > 0) {
+ bytes.write(buffer, 0, count);
+ }
+ in.close();
+ return bytes.toByteArray();
+ }
}
diff --git a/cbor/src/test/java/com/fasterxml/jackson/jaxrs/cbor/dw/ResourceTestBase.java b/xml/src/test/java/com/fasterxml/jackson/jaxrs/xml/dw/ResourceTestBase.java
similarity index 83%
copy from cbor/src/test/java/com/fasterxml/jackson/jaxrs/cbor/dw/ResourceTestBase.java
copy to xml/src/test/java/com/fasterxml/jackson/jaxrs/xml/dw/ResourceTestBase.java
index 13bded1..7d1c27a 100644
--- a/cbor/src/test/java/com/fasterxml/jackson/jaxrs/cbor/dw/ResourceTestBase.java
+++ b/xml/src/test/java/com/fasterxml/jackson/jaxrs/xml/dw/ResourceTestBase.java
@@ -1,6 +1,5 @@
-package com.fasterxml.jackson.jaxrs.cbor.dw;
+package com.fasterxml.jackson.jaxrs.xml.dw;
-import java.io.*;
import java.util.HashSet;
import java.util.Set;
@@ -14,20 +13,20 @@ import org.eclipse.jetty.server.handler.ContextHandlerCollection;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;
-import com.fasterxml.jackson.jaxrs.cbor.JacksonCBORProvider;
-import com.fasterxml.jackson.jaxrs.cbor.JaxrsTestBase;
+import com.fasterxml.jackson.jaxrs.xml.JacksonXMLProvider;
+import com.fasterxml.jackson.jaxrs.xml.JaxrsTestBase;
/**
* Intermediate base for tests that run actual full JAX-RS resource.
*/
public abstract class ResourceTestBase extends JaxrsTestBase
{
- protected static abstract class CBORApplication extends Application
+ protected static abstract class XMLApplication extends Application
{
protected final Object _provider;
protected final Object _resource;
- protected CBORApplication(Object provider, Object resource) {
+ protected XMLApplication(Object provider, Object resource) {
_provider = provider;
_resource = resource;
}
@@ -41,10 +40,10 @@ public abstract class ResourceTestBase extends JaxrsTestBase
}
}
- protected static abstract class CBORApplicationWithJackson extends CBORApplication
+ protected static abstract class XMLApplicationWithJackson extends XMLApplication
{
- public CBORApplicationWithJackson(Object resource) {
- super(new JacksonCBORProvider(), resource);
+ public XMLApplicationWithJackson(Object resource) {
+ super(new JacksonXMLProvider(), resource);
}
}
diff --git a/cbor/src/test/java/com/fasterxml/jackson/jaxrs/cbor/dw/SimpleEndpointTestBase.java b/xml/src/test/java/com/fasterxml/jackson/jaxrs/xml/dw/SimpleEndpointTestBase.java
similarity index 82%
copy from cbor/src/test/java/com/fasterxml/jackson/jaxrs/cbor/dw/SimpleEndpointTestBase.java
copy to xml/src/test/java/com/fasterxml/jackson/jaxrs/xml/dw/SimpleEndpointTestBase.java
index 87881d4..d5d7027 100644
--- a/cbor/src/test/java/com/fasterxml/jackson/jaxrs/cbor/dw/SimpleEndpointTestBase.java
+++ b/xml/src/test/java/com/fasterxml/jackson/jaxrs/xml/dw/SimpleEndpointTestBase.java
@@ -1,4 +1,4 @@
-package com.fasterxml.jackson.jaxrs.cbor.dw;
+package com.fasterxml.jackson.jaxrs.xml.dw;
import java.io.*;
import java.net.*;
@@ -12,8 +12,8 @@ import org.eclipse.jetty.server.Server;
import org.junit.Assert;
import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.dataformat.cbor.CBORFactory;
-import com.fasterxml.jackson.jaxrs.cbor.CBORMediaTypes;
+import com.fasterxml.jackson.dataformat.xml.XmlMapper;
+import com.sun.jersey.core.header.MediaTypes;
public abstract class SimpleEndpointTestBase extends ResourceTestBase
{
@@ -33,13 +33,13 @@ public abstract class SimpleEndpointTestBase extends ResourceTestBase
public static class SimpleResource
{
@GET
- @Produces({ CBORMediaTypes.APPLICATION_JACKSON_CBOR })
+ @Produces({ MediaType.APPLICATION_XML })
public Point getPoint() {
return new Point(1, 2);
}
}
- public static class SimpleResourceApp extends CBORApplicationWithJackson {
+ public static class SimpleResourceApp extends XMLApplicationWithJackson {
public SimpleResourceApp() { super(new SimpleResource()); }
}
@@ -50,13 +50,13 @@ public abstract class SimpleEndpointTestBase extends ResourceTestBase
{
@GET
@Path("bytes")
- @Produces({ CBORMediaTypes.APPLICATION_JACKSON_CBOR })
+ @Produces({ MediaType.APPLICATION_XML })
public byte[] getBytes() throws IOException {
return UNTOUCHABLE_RESPONSE;
}
}
- public static class SimpleRawApp extends CBORApplicationWithJackson {
+ public static class SimpleRawApp extends XMLApplicationWithJackson {
public SimpleRawApp() { super(new RawResource()); }
}
@@ -68,7 +68,7 @@ public abstract class SimpleEndpointTestBase extends ResourceTestBase
public void testStandardSmile() throws Exception
{
- final ObjectMapper mapper = new ObjectMapper(new CBORFactory());
+ final ObjectMapper mapper = new XmlMapper();
Server server = startServer(TEST_PORT, SimpleResourceApp.class);
Point p;
diff --git a/xml/src/test/java/com/fasterxml/jackson/jaxrs/xml/jersey/SimpleEndpointTest.java b/xml/src/test/java/com/fasterxml/jackson/jaxrs/xml/jersey/SimpleEndpointTest.java
new file mode 100644
index 0000000..a9c81f5
--- /dev/null
+++ b/xml/src/test/java/com/fasterxml/jackson/jaxrs/xml/jersey/SimpleEndpointTest.java
@@ -0,0 +1,11 @@
+package com.fasterxml.jackson.jaxrs.xml.jersey;
+
+import javax.servlet.Servlet;
+
+import com.fasterxml.jackson.jaxrs.xml.dw.SimpleEndpointTestBase;
+import com.sun.jersey.spi.container.servlet.ServletContainer;
+
+public class SimpleEndpointTest extends SimpleEndpointTestBase {
+ @Override
+ protected Class<? extends Servlet> servletContainerClass() { return ServletContainer.class; }
+}
--
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