Issue
I want to test if my Class write the right data in the Parcel, so i wrote following test.:
@Test
public void parcelOutAndIn() {
Trip trip = new Trip("id123", new Date());
Parcel parcel = Parcel.obtain();
trip.writeToParcel(parcel, 0);
Trip tripResult = new Trip(parcel);
Assert.assertThat(tripResult.getId(), equalTo(trip.getId()));
Assert.assertThat(tripResult.getStartTime(), equalTo(trip.getStartTime()));
}
my writeToParcel looks like this:
@Override
public void writeToParcel(Parcel parcel, int i) {
parcel.writeString(id);
parcel.writeSerializable(startTime);
}
I've got following Error:
java.lang.NoSuchMethodError: java.util.Arrays.checkOffsetAndCount
What can i do? Is it a Bug in Robolectric? I use Robolectric 2.1.1.
The Stacktrace:
java.lang.NoSuchMethodError: java.util.Arrays.checkOffsetAndCount(III)V
at android.os.Parcel.writeByteArray(Parcel.java:472)
at android.os.Parcel.writeByteArray(Parcel.java:457)
at android.os.Parcel.writeSerializable(Parcel.java:1277)
at de.telekom.connectedcar.shuttle.driver.model.Trip.writeToParcel(Trip.java:92)
at de.telekom.connectedcar.shuttle.driver.model.TripTest.parcelOutAndInUsingCreator(TripTest.java:48)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:241)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.robolectric.RobolectricTestRunner$1.evaluate(RobolectricTestRunner.java:177)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Solution
Unfortunately, Roboelectric's ShadowParcel doesn't include implementation for the writeByteArray() method.
There is an active pull request here: https://github.com/robolectric/robolectric/pull/474
Answered By - simp
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.