@Test public void testRandomContents() throws Exception { ByteArrayOutputStream baos = new ByteArrayOutputStream(); DataOutputStream daos = new DataOutputStream(baos); daos.writeChars("Random test string that doesn't make any sense"); DataInputStream dis = new DataInputStream(new ByteArrayInputStream(baos.toByteArray())); T output = createInstance(); assertThat(getSerializer().deserialize(output, dis)).isFalse(); }
public final boolean deserialize(T metrics, DataInput input) throws IOException { if (input.readShort() != MAGIC || input.readShort() != VERSION || input.readLong() != getTag()) { return false; } return deserializeContents(metrics, input); }
SystemMetricsSerializer { public final boolean deserialize(T metrics, DataInput input) throws IOException { if (input.readShort() != MAGIC || input.readShort() != VERSION || input.readLong() != getTag()) { return false; } return deserializeContents(metrics, input); } }
SystemMetricsSerializer { public final boolean deserialize(T metrics, DataInput input) throws IOException { if (input.readShort() != MAGIC || input.readShort() != VERSION || input.readLong() != getTag()) { return false; } return deserializeContents(metrics, input); }  }
SystemMetricsSerializer { public final boolean deserialize(T metrics, DataInput input) throws IOException { if (input.readShort() != MAGIC || input.readShort() != VERSION || input.readLong() != getTag()) { return false; } return deserializeContents(metrics, input); }  final void serialize(T metrics, DataOutput output); final boolean deserialize(T metrics, DataInput input); abstract long getTag(); abstract void serializeContents(T metrics, DataOutput output); abstract boolean deserializeContents(T metrics, DataInput input); }
SystemMetricsSerializer { public final boolean deserialize(T metrics, DataInput input) throws IOException { if (input.readShort() != MAGIC || input.readShort() != VERSION || input.readLong() != getTag()) { return false; } return deserializeContents(metrics, input); }  final void serialize(T metrics, DataOutput output); final boolean deserialize(T metrics, DataInput input); abstract long getTag(); abstract void serializeContents(T metrics, DataOutput output); abstract boolean deserializeContents(T metrics, DataInput input);  }