jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • jMock
  • JMOCK-224

ExpectationError is Serializable but cannot be Serialized

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Bug Bug
  • Status: Open Open
  • Priority: Major 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);
    }
}

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
Nat Pryce added a comment - 07/May/09 5:40 AM - edited

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.

Show
Nat Pryce added a comment - 07/May/09 5:40 AM - edited 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.
Hide
Permalink
Nat Pryce added a comment - 07/May/09 5:41 AM

If you want to serialise throwables that report expectation failures, you can plug your own ErrorTranslator into the Mockery that translates ExpectationErrors into an ErrorType that is serializable.

Show
Nat Pryce added a comment - 07/May/09 5:41 AM If you want to serialise throwables that report expectation failures, you can plug your own ErrorTranslator into the Mockery that translates ExpectationErrors into an ErrorType that is serializable.

People

  • Assignee:
    Unassigned
    Reporter:
    Peter Lawrey
Vote (0)
Watch (0)

Dates

  • Created:
    06/May/09 11:47 AM
    Updated:
    11/May/09 4:22 PM
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.