You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Miguel Almeida <mi...@almeida.at> on 2011/11/16 12:57:26 UTC

Message lookup (from key) in Test

Dear all,

I am unit-testing an application under the skin using
SpringStrutsTestCase as base (actually, things are a bit more
complicated because I'm doing it from Cucumber, but that's another
story).

How do you get the value of your message from within the test? The
assertion I'm trying is:

assertEquals(expectedMessage,
action.getActionErrors().iterator().next());

But actionErrors() contains the key (error.authorisation) and not the
value ("you cannot do this"). What's the cleanest way to retrieve the
value from the test?


Cheers,

Miguel Almeida

Re: Message lookup (from key) in Test

Posted by Li Ying <li...@gmail.com>.
Hi  Miguel:

How did you generate the error message?

(A)Did you add the message key to the action errors, like:
     this.addActionError("error.authorisation");
(B)or did you retrieve the message text by the key, then add the text
to the action errors, like:
     this.addActionError(this.getText("error.authorisation"));

Method (B) is correct, (A) is not.




2011/11/16 Miguel Almeida <mi...@almeida.at>:
> Dear all,
>
> I am unit-testing an application under the skin using
> SpringStrutsTestCase as base (actually, things are a bit more
> complicated because I'm doing it from Cucumber, but that's another
> story).
>
> How do you get the value of your message from within the test? The
> assertion I'm trying is:
>
> assertEquals(expectedMessage,
> action.getActionErrors().iterator().next());
>
> But actionErrors() contains the key (error.authorisation) and not the
> value ("you cannot do this"). What's the cleanest way to retrieve the
> value from the test?
>
>
> Cheers,
>
> Miguel Almeida
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org