OAuthResponse implements Parcelable { @Override public void writeToParcel(Parcel out, int flags) { out.writeParcelable(this.authToken, flags); out.writeString(this.userName); out.writeLong(this.userId); } OAuthResponse(TwitterAuthToken authToken, String userName, long userId); private  OAuthResponse(Parcel in); @Override String toString(); @Override int describeContents(); @Override void writeToParcel(Parcel out, int flags); static final Parcelable.Creator<OAuthResponse> CREATOR; final TwitterAuthToken authToken; final String userName; final long userId; }
@Test public void testParcelable() { final TwitterAuthToken authToken = new TwitterAuthToken(TestFixtures.TOKEN, TestFixtures.SECRET); final OAuthResponse authResponse = new OAuthResponse(authToken, TestFixtures.SCREEN_NAME, TestFixtures.USER_ID); final Parcel parcel = Parcel.obtain(); authResponse.writeToParcel(parcel, 0); parcel.setDataPosition(0); final OAuthResponse parceledAuthResponse = OAuthResponse.CREATOR.createFromParcel(parcel); assertEquals(authResponse.authToken, parceledAuthResponse.authToken); assertEquals(TestFixtures.SCREEN_NAME, parceledAuthResponse.userName); assertEquals(TestFixtures.USER_ID, parceledAuthResponse.userId); }