MyParcelable implements Parcelable { @Override public void writeToParcel(Parcel dest, int flags) { Postman.writeToParcel(this, dest); } MyParcelable();  MyParcelable(String myString); @Override int describeContents(); @Override void writeToParcel(Parcel dest, int flags); static final Creator<MyParcelable> CREATOR; }
@Test public void testNonParceledClassThrowsPostmanException() { Object o = new Object(); boolean exceptionCaught = false; try { Postman.writeToParcel(o, Parcel.obtain()); } catch (PostmanException e) { exceptionCaught = true; assertTrue("expected cause to be of type ClassNotFoundException but found " + e.getCause().getClass().getCanonicalName(), e.getCause() instanceof ClassNotFoundException); } assertTrue(exceptionCaught); }