Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse: infinitest vs. JUnit: character encoding

I'm using infinitest in Eclipse and I have a strange phenomenon in connection with JUnit.

I have code that uses org.apache.http.HttpResponse.getEntity() and org.apache.http.entity.StringEntity. The JUnit test looks like this:

@Test
public void convertEncodedContentToString() throws UnsupportedEncodingException {
  HttpResponse httpResponseMock = Mockito.mock(HttpResponse.class);

  Mockito.when(httpResponseMock.getEntity()).thenReturn(new StringEntity("huiäöüß@€", HTTP.UTF_8));
  Assert.assertEquals("huiäöüß@€", parser.convertContentToString(httpResponseMock));
}

All source files are stored in UTF-8.

If I let JUnit execute this method, it works fine.

However, if infinitest runs this test it complains that the assertion fails.

ComparisonFailure (expected:<hui[äöüß@€]> but was:<hui[äöüß@€]>) in ResponseBodyParserFactoryTest.convertEncodedContentToString

Obviously there is a character encoding problem.

As infinitest has close to no options I have no idea how to help infinitest to run this test properly. Can anyone please help me out here?

like image 930
sjngm Avatar asked Aug 24 '26 18:08

sjngm


1 Answers

You need to say to infinitest that it must use the UTF-8 charset to run the tests.

Just add a file in your Eclipse project: "infinitest.args". In this file, add the following:

-Dfile.encoding=UTF-8

And so, inifinitest will use UTF-8

User guide: http://infinitest.github.com/doc/user_guide.html specifically the 'Setting JVM Options' section

like image 147
evernat Avatar answered Aug 27 '26 22:08

evernat



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!