PageState in unit testing
Emmanuel Gaillot <[email protected]>
| Newsgroups | gmane.linux.redhat.ccm.general |
|---|---|
| Organization | Open Wide / Paris |
| Message-ID | <1080567170.16787.29.camel@devpt04> |
Greetings,
I am trying to unit test a Bebop header that I develop. This header
extends SimpleContainer, and overrides the generateXML method. I want
one of the tests to check the returned value of this overridden method,
but generateXML needs a PageState as a parameter, and I have no idea how
to instanciate (or mock) a PageState.
If I attempt the following instanciation (with mocked HTTP context):
---------------
public void testHeaderXMLGeneration() {
// Some code
PageState myNewPageState = new PageState(
new Page(),
new MockHttpRequest(),
new MockHttpResponse()
);
// Some more code
}
---------------
I get the following error stack trace :
java.lang.ExceptionInInitializerError: java.lang.IllegalStateException:
SessionManager has not been initialized:
url is null
username is null
password is null
at
com.arsdigita.persistence.SessionManager$1.initialValue(SessionManager.java:159)
at java.lang.ThreadLocal.get(ThreadLocal.java:98)
at
com.arsdigita.persistence.SessionManager.getSession(SessionManager.java:74)
at
com.arsdigita.globalization.Globalization.loadLocaleToCharsetMap(Globalization.java:80)
at
com.arsdigita.globalization.Globalization.<clinit>(Globalization.java:72)
at
com.arsdigita.bebop.parameters.ParameterModel.transformSingleValue(ParameterModel.java:267)
at
com.arsdigita.bebop.parameters.StringParameter.transformValue(StringParameter.java:54)
at
com.arsdigita.bebop.parameters.ParameterModel.createParameterData(ParameterModel.java:346)
at com.arsdigita.bebop.FormData.createParameterData(FormData.java:591)
at com.arsdigita.bebop.FormData.<init>(FormData.java:268)
at com.arsdigita.bebop.FormData.<init>(FormData.java:161)
at com.arsdigita.bebop.PageState.<init>(PageState.java:309)
at
com.thales.portalprototype.ui.HeaderTest.testHeaderXMLGeneration(HeaderTest.java:35)
(... And some more.)
Any suggestion would be much appreciated...
-- Emmanuel.
--
Redhat-ccm-list mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/redhat-ccm-list
Archives: https://www.redhat.com/pipermail/redhat-ccm-list/