Details
-
Type:
Bug
-
Status:
Open
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: 2.5.1
-
Fix Version/s: None
-
Component/s: JMock 2.x.x Library
-
Labels:None
Description
In the following test ExpectationError cannot be Serialized as it has a number of non-transient fields whichc annot be serialized.
private static final Mockery MOCKERY = new Mockery(); public static void test_expectationErrorSerialization() throws IOException { try { final List list = MOCKERY.mock(List.class); MOCKERY.checking(new Expectations() {{ oneOf(list).add(1); }}); list.add(2); MOCKERY.assertIsSatisfied(); } catch (Throwable e) { assertTrue(e instanceof Serializable); ObjectOutputStream oos = new ObjectOutputStream(new ByteArrayOutputStream()); oos.writeObject(e); } }
Why do you care? What exactly are you trying to achieve?
The Throwable base class implements Serializable, so we can't make an ExpectationError non-serializable. However, it makes no sense to serialize an ExpectationError because it refers to the Mockery and other information that is used to diagnose test failures.