You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by "Artur W." <a_...@gazeta.pl> on 2008/11/01 13:52:33 UTC

WicketTester.assertErrorMessages - encoding problem

Hi!

My test failed becouse Wicket returns FeedbackMessages in different encoding
(?) than the expected messages.

Example:

tester.assertErrorMessages(new String[] { "Pole 'domena' musi zawierać od 3
do 32 znaków." };

gives:
junit.framework.AssertionFailedError:
expect (1):
   Pole 'domena' musi zawierać od 3 do 32 znaków.
but was (1):
   Pole 'domena' musi zawierać od 3 do 32 znaków.

I compile my tests with javac with encoding set to UTF-8. I don't know how
are feedback messages encoded or if it is some other problem when comparing
error msgs in the test.


Thanks in advance,
Artur


-- 
View this message in context: http://www.nabble.com/WicketTester.assertErrorMessages---encoding-problem-tp20280074p20280074.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: WicketTester.assertErrorMessages - encoding problem

Posted by "Artur W." <a_...@gazeta.pl>.
Hi Martin!

Martin Makundi wrote:
> 
> Have you tried in your WicketApplication.init to set encoding:
> 
>    
> getMarkupSettings().setDefaultMarkupEncoding(WebPageConstants.ISO_8859_1);
> 

I tried both of this:

tester.getApplication().getMarkupSettings().setDefaultMarkupEncoding("ISO-8859-1");
tester.getApplication().getMarkupSettings().setDefaultMarkupEncoding("UTF-8");

but it didn't help.

Best regards,
Artur


-- 
View this message in context: http://www.nabble.com/WicketTester.assertErrorMessages---encoding-problem-tp20280074p20280503.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: WicketTester.assertErrorMessages - encoding problem

Posted by Martin Makundi <ma...@koodaripalvelut.com>.
Hi!

Have you tried in your WicketApplication.init to set encoding:

    getMarkupSettings().setDefaultMarkupEncoding(WebPageConstants.ISO_8859_1);

**
Martin

2008/11/1 Artur W. <a_...@gazeta.pl>:
>
> Hi!
>
> My test failed becouse Wicket returns FeedbackMessages in different encoding
> (?) than the expected messages.
>
> Example:
>
> tester.assertErrorMessages(new String[] { "Pole 'domena' musi zawierać od 3
> do 32 znaków." };
>
> gives:
> junit.framework.AssertionFailedError:
> expect (1):
>   Pole 'domena' musi zawierać od 3 do 32 znaków.
> but was (1):
>   Pole 'domena' musi zawierać od 3 do 32 znaków.
>
> I compile my tests with javac with encoding set to UTF-8. I don't know how
> are feedback messages encoded or if it is some other problem when comparing
> error msgs in the test.
>
>
> Thanks in advance,
> Artur
>
>
> --
> View this message in context: http://www.nabble.com/WicketTester.assertErrorMessages---encoding-problem-tp20280074p20280074.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: WicketTester.assertErrorMessages - encoding problem

Posted by Marat Radchenko <sl...@gmail.com>.
Cbuttic bug in locale-specifics handling. I think it is a candidate for a
bugreport.

2008/11/1 Artur W. <a_...@gazeta.pl>

>
> The problem is in tester.assertErrorMessages at:
> msgs.add(iterator.next().toString());
>
> The .toString() returns string with iso-8859-1 encoding.
>
>
> The workaround is to create your own assertErrorMessages like this:
>
>                List<Serializable> actualMessages =
> tester.getMessages(FeedbackMessage.ERROR);
>                List<Serializable> msgs = new ArrayList<Serializable>();
>                for (Iterator<Serializable> iterator =
> actualMessages.iterator();
> iterator.hasNext();) {
>                        msgs.add( new
> String(iterator.next().toString().getBytes("ISO-8859-1"),
> "UTF-8") );
>                }
>
>  WicketTesterHelper.assertEquals(Arrays.asList(expectedErrorMessages),
> msgs);
>
> What do you think about fixing the tester code as above? Maybe this is a
> good idea because AFAIK Wicket works in UTF-8 but default.
>
> Thanks,
> Artur
>
>
> --
> View this message in context:
> http://www.nabble.com/WicketTester.assertErrorMessages---encoding-problem-tp20280074p20280466.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: WicketTester.assertErrorMessages - encoding problem

Posted by "Artur W." <a_...@gazeta.pl>.
The problem is in tester.assertErrorMessages at:
msgs.add(iterator.next().toString());

The .toString() returns string with iso-8859-1 encoding.


The workaround is to create your own assertErrorMessages like this:

		List<Serializable> actualMessages =
tester.getMessages(FeedbackMessage.ERROR);
		List<Serializable> msgs = new ArrayList<Serializable>();
		for (Iterator<Serializable> iterator = actualMessages.iterator();
iterator.hasNext();) {
			msgs.add( new String(iterator.next().toString().getBytes("ISO-8859-1"),
"UTF-8") );
		}
		WicketTesterHelper.assertEquals(Arrays.asList(expectedErrorMessages),
msgs);

What do you think about fixing the tester code as above? Maybe this is a
good idea because AFAIK Wicket works in UTF-8 but default.

Thanks,
Artur


-- 
View this message in context: http://www.nabble.com/WicketTester.assertErrorMessages---encoding-problem-tp20280074p20280466.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org