[jackson-dataformat-smile] 08/31: merge unit test update from svn
Hilko Bengen
bengen at alioth.debian.org
Mon Sep 2 17:37:21 UTC 2013
This is an automated email from the git hooks/post-receive script.
bengen pushed a commit to annotated tag jackson-dataformat-smile-2.0.0
in repository jackson-dataformat-smile.
commit b10e48d22846c218cfacde33e22a479d265c250f
Author: Tatu <tatu at ning.com>
Date: Tue Dec 13 07:44:45 2011 -0800
merge unit test update from svn
---
.../jackson/dataformat/smile/SmileTestBase.java | 16 ++++++++++-
.../jackson/dataformat/smile/TestMapper.java | 28 ++++++++++++++++++++
2 files changed, 43 insertions(+), 1 deletion(-)
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/smile/SmileTestBase.java b/src/test/java/com/fasterxml/jackson/dataformat/smile/SmileTestBase.java
index ed39a0d..2457f8d 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/smile/SmileTestBase.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/smile/SmileTestBase.java
@@ -7,6 +7,7 @@ import java.util.Arrays;
import org.junit.Assert;
import org.codehaus.jackson.*;
+import org.codehaus.jackson.map.ObjectMapper;
import com.fasterxml.jackson.dataformat.smile.SmileFactory;
import com.fasterxml.jackson.dataformat.smile.SmileGenerator;
@@ -64,10 +65,23 @@ abstract class SmileTestBase
{
return f.createJsonParser(input);
}
+
+ protected ObjectMapper smileMapper() {
+ return smileMapper(false);
+ }
+
+ protected ObjectMapper smileMapper(boolean requireHeader) {
+ return smileMapper(requireHeader, false, false);
+ }
+
+ protected ObjectMapper smileMapper(boolean requireHeader,
+ boolean writeHeader, boolean writeEndMarker)
+ {
+ return new ObjectMapper(smileFactory(requireHeader, writeHeader, writeEndMarker));
+ }
protected SmileFactory smileFactory(boolean requireHeader,
boolean writeHeader, boolean writeEndMarker)
- throws IOException
{
SmileFactory f = new SmileFactory();
f.configure(SmileParser.Feature.REQUIRE_HEADER, requireHeader);
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/smile/TestMapper.java b/src/test/java/com/fasterxml/jackson/dataformat/smile/TestMapper.java
new file mode 100644
index 0000000..64ead5f
--- /dev/null
+++ b/src/test/java/com/fasterxml/jackson/dataformat/smile/TestMapper.java
@@ -0,0 +1,28 @@
+package com.fasterxml.jackson.dataformat.smile;
+
+import java.io.IOException;
+
+import org.codehaus.jackson.map.ObjectMapper;
+import org.junit.Assert;
+
+public class TestMapper extends SmileTestBase
+{
+ static class BytesBean {
+ public byte[] bytes;
+
+ public BytesBean() { }
+ public BytesBean(byte[] b) { bytes = b; }
+ }
+
+ // [JACKSON-733]
+ public void testBinary() throws IOException
+ {
+ byte[] input = new byte[] { 1, 2, 3, -1, 8, 0, 42 };
+ ObjectMapper mapper = smileMapper();
+ byte[] smile = mapper.writeValueAsBytes(new BytesBean(input));
+ BytesBean result = mapper.readValue(smile, BytesBean.class);
+
+ assertNotNull(result.bytes);
+ Assert.assertArrayEquals(input, result.bytes);
+ }
+}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/jackson-dataformat-smile.git
More information about the pkg-java-commits
mailing list