SerializableUtils { public static <T extends Serializable> T ensureSerializable(T value) { return clone(value); }  static byte[] serializeToByteArray(Serializable value); static Object deserializeFromByteArray(byte[] encodedValue, String description); static T ensureSerializableRoundTrip(T value); static T ensureSerializable(T value); static T clone(T value); static Coder<?> ensureSerializable(Coder<?> coder); static T ensureSerializableByCoder(Coder<T> coder, T value, String errorContext);  }
@Test public void testTranscode() { String stringValue = "hi bob"; int intValue = 42; SerializableByJava testObject = new SerializableByJava(stringValue, intValue); SerializableByJava testCopy = SerializableUtils.ensureSerializable(testObject); assertEquals(stringValue, testCopy.stringValue); assertEquals(intValue, testCopy.intValue); }
@Test public void testEnsureSerializableWithUnserializableCoderByJava() { expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage("unable to serialize"); SerializableUtils.ensureSerializable(new UnserializableCoderByJava()); }