Details
-
Improvement
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
1.3.0-beta2
-
None
-
linux 2.6 jdk6
Description
When turn on logger level to info, testing with wicketTester see lots of SerializableChecker$WicketNotSerializableException stacktrace:
ERROR - Objects - Error serializing object class org.apache.wicket.util.tester.DummyHomePage [object=[Page class = org.apache.wicket.util.tester.DummyHomePage, id = 0, version = 0]]
org.apache.wicket.util.io.SerializableChecker$WicketNotSerializableException: Unable to serialize class: org.apache.wicket.util.tester.WicketTesterTest
Field hierarchy is:
0 [class=org.apache.wicket.util.tester.DummyHomePage, path=0]
private org.apache.wicket.util.tester.ITestPageSource org.apache.wicket.util.tester.DummyHomePage.testPageSource [class=org.apache.wicket.util.tester.WicketTesterTest$1]
final org.apache.wicket.util.tester.WicketTesterTest org.apache.wicket.util.tester.WicketTesterTest$1.this$0 [class=org.apache.wicket.util.tester.WicketTesterTest] <----- field that is not serializable
at org.apache.wicket.util.io.SerializableChecker.check(SerializableChecker.java:347)
at org.apache.wicket.util.io.SerializableChecker.checkFields(SerializableChecker.java:615)
The cause of error is annoymous inner class ITestPageSource:
tester.startPage(new ITestPageSource()
{
private static final long serialVersionUID = 1L;
public Page getTestPage()
{ Book mockBook = new Book("xxId", "xxName"); return new ViewBook(mockBook); }});
annonymous ITestPageSource instance reference to TestCase and TestCase is not serializable.
To avoid serialize TestCase, we can make ITestPageSource field of DummyHomePage transient:
public class DummyHomePage extends WebPage
{
private transient ITestPageSource testPageSource;
....
}