Hi all,
First time I've used Gmock and it has really helped me a lot! So much
better than using other mocking frameworks in the past. I'm using it
to test Struts action, with Struts 2.
I've come across the necessity to do some partial mocking of a method
that comes from the struts ActionSupport class which resolves messages
in message bundles. Normally at runtime the "TextProvider" is set up
which would provide the message when asked using the method
getText("message.key") but I just get null pointer exceptions.
I've tried all the following but I still get the NPE and the test
crashes out:
def controller = new CompleteRegistrationAction()
def mockLTU = mock(LocalizedTextUtil)
def mockTPS = mock(TextProviderSupport)
mock(ActionSupport).addActionError("errorString")
mock(ActionSupport).getText("registration.error.password.mismatch").returns
"errorString"
mock(controller).addActionError("errorString")
mock(controller).addActionError("errorString")
mockTPS.getText("registration.error.password.mismatch").returns
"errorString"
mockLTU.findText("registration.error.password.mismatch").returns
"errorString"
13:48:17,657 DEBUG [ActionSupport] Action context not initialized
java.lang.NullPointerException
at
com.opensymphony.xwork2.util.LocalizedTextUtil.findText(LocalizedTextUtil.java:
362)
at
com.opensymphony.xwork2.TextProviderSupport.getText(TextProviderSupport.java:
191)
at
com.opensymphony.xwork2.TextProviderSupport.getText(TextProviderSupport.java:
106)
at com.opensymphony.xwork2.ActionSupport.getText(ActionSupport.java:
80)
at
com.web.action.registration.CompleteRegistrationAction.doExecute(CompleteRegistrationAction.java:
91)
Any ideas?
Thanks in advance.
--
You received this message because you are subscribed to the Google Groups "gmock-user" group.
To post to this group, send email to
gmock...@googlegroups.com.
To unsubscribe from this group, send email to
gmock-user+...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/gmock-user?hl=en.