Permalink
Browse files

Added toString() for ResponseMessage.

Change-Id: Ie627cd14631a01a0258d67337251c552e90aa3bc
Reviewed-on: http://review.couchbase.org/13361
Reviewed-by: Matt Ingenthron <matt@couchbase.com>
Tested-by: Matt Ingenthron <matt@couchbase.com>
  • Loading branch information...
1 parent 0c5bacd commit abcb8b32d7559ffdefa097ac0e53a4f429a10fdd @ingenthr ingenthr committed with ingenthr Feb 19, 2012
@@ -25,6 +25,8 @@
import java.nio.ByteBuffer;
import java.util.LinkedList;
import java.util.List;
+import net.spy.memcached.CachedData;
+import net.spy.memcached.transcoders.SerializingTranscoder;
/**
* A representation of a tap stream message sent from a tap stream server.
@@ -283,4 +285,23 @@ public ByteBuffer getBytes() {
}
return bb;
}
+
+ @Override
+ public String toString() {
+ return String.format("Key: %s, Flags: %d, TTL: %d, Size: %d\nValue: %s",
+ getKey(), getItemFlags(), getTTL(), getValue().length, deserialize());
+ }
+
+ /**
+ * Attempt to get the object represented by the given serialized bytes.
+ */
+ private Object deserialize() {
+ SerializingTranscoder tc = new SerializingTranscoder();
+ CachedData d = new CachedData(this.getItemFlags(), this.getValue(),
+ CachedData.MAX_SIZE);
+ Object rv = null;
+ rv = tc.decode(d);
+ return rv;
+ }
+
}
@@ -193,4 +193,12 @@ public void testGetBytes() {
assertEquals((byte)42, result[result.length-1]);
}
+ /**
+ * Test of toString method, of class ResponseMessage.
+ */
+ @Test
+ public void testToString() {
+ assertNotNull(instance.toString());
+ }
+
}

0 comments on commit abcb8b3

Please sign in to comment.