Serialization { public static <T> T deserialize(Path filePath) throws SerializationException { try { return deserialize(Files.newInputStream(filePath)); } catch (IOException e) { throw new SerializationException("Deserialization failed", e); } } private  Serialization(); static void serialize(Object object, Path file); static void serialize(Object object, OutputStream outputStream); static byte[] serialize(Object object); static T deserialize(Path filePath); @SuppressWarnings("unchecked") static T deserialize(InputStream inputStream); @SuppressWarnings("unchecked") static T deserialize(byte[] bytes); static T requireSerializable(T o, String name);  }
@Test public void deserializeShouldPropagateSerializationExceptions() throws SerializationException { exception.expect(SerializationException.class); Serialization.deserialize(new ByteArrayInputStream("foobar".getBytes())); }