JavaDiagnosticCodec extends DiagnosticCodecSkeleton<byte[]> { @Override public byte[] serialize(Object o) throws DiagnosticCodecException { requireNonNull(o); try (ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos)) { oos.writeObject(o); oos.flush(); return baos.toByteArray(); } catch (Exception e) { throw new DiagnosticCodecException(e); } } JavaDiagnosticCodec(); @Override byte[] serialize(Object o); @Override T deserialize(byte[] encoded, Class<T> target); @Override String toString();  }
@Test public void test_serialize_failure() { exception.expect(DiagnosticCodecException.class); codec.serialize(this); }