aboutsummaryrefslogtreecommitdiff
path: root/java/src/test/java/com/google/protobuf/RopeByteStringTest.java
diff options
context:
space:
mode:
authorDaniel Martin <fizbin@gmail.com>2014-11-27 07:10:02 -0500
committerDaniel Martin <daniel.martin@crowdstrike.com>2014-11-27 07:11:03 -0500
commita32a1a761bd921ab3f2bfd990052ffb6bb106171 (patch)
tree0ea399e66f490e364b35c90c11bcf60c9a4aaa40 /java/src/test/java/com/google/protobuf/RopeByteStringTest.java
parent5ff8dc8e005f5312af98655786c1c8438a617efb (diff)
downloadprotobuf-a32a1a761bd921ab3f2bfd990052ffb6bb106171.tar.gz
protobuf-a32a1a761bd921ab3f2bfd990052ffb6bb106171.tar.bz2
protobuf-a32a1a761bd921ab3f2bfd990052ffb6bb106171.zip
Add tests for other ByteString subclasses
Diffstat (limited to 'java/src/test/java/com/google/protobuf/RopeByteStringTest.java')
-rw-r--r--java/src/test/java/com/google/protobuf/RopeByteStringTest.java18
1 files changed, 18 insertions, 0 deletions
diff --git a/java/src/test/java/com/google/protobuf/RopeByteStringTest.java b/java/src/test/java/com/google/protobuf/RopeByteStringTest.java
index 9676f527..b3970196 100644
--- a/java/src/test/java/com/google/protobuf/RopeByteStringTest.java
+++ b/java/src/test/java/com/google/protobuf/RopeByteStringTest.java
@@ -30,6 +30,11 @@
package com.google.protobuf;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
import java.io.UnsupportedEncodingException;
import java.util.Arrays;
import java.util.Iterator;
@@ -112,4 +117,17 @@ public class RopeByteStringTest extends LiteralByteStringTest {
assertEquals(classUnderTest + " string must must have same hashCode as the flat string",
flatString.hashCode(), unicode.hashCode());
}
+
+ public void testJavaSerialization() throws Exception {
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ ObjectOutputStream oos = new ObjectOutputStream(out);
+ oos.writeObject(stringUnderTest);
+ oos.close();
+ byte[] pickled = out.toByteArray();
+ InputStream in = new ByteArrayInputStream(pickled);
+ ObjectInputStream ois = new ObjectInputStream(in);
+ Object o = ois.readObject();
+ assertTrue("Didn't get a ByteString back", o instanceof ByteString);
+ assertEquals("Should get an equal ByteString back", stringUnderTest, o);
+ }
}