use of net.morimekta.test.providence.testing.ExceptionFields in project providence by morimekta.
the class ProvidenceTest method testSerializable.
@Test
public void testSerializable() throws IOException, ClassNotFoundException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
PApplicationException originalCause = new PApplicationException("test", PApplicationExceptionType.BAD_SEQUENCE_ID);
ExceptionFields original = generator.generate(ExceptionFields.kDescriptor);
original.initCause(originalCause);
oos.writeObject(original);
oos.close();
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
ObjectInputStream in = new ObjectInputStream(bais);
ExceptionFields actual = (ExceptionFields) in.readObject();
assertThat(actual, is(equalToMessage(original)));
assertThat(actual.getCause(), is(originalCause));
assertThat(actual.getStackTrace(), is(original.getStackTrace()));
}
Aggregations