3

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?

Tyler
  • 21,762
  • 11
  • 61
  • 90
sjngm
  • 12,423
  • 14
  • 84
  • 114
  • You might want to look at [Infinitest's issue tracker](https://github.com/infinitest/infinitest/issues) and see if someone has reported a similar issue before, then post it yourself if not. – Tyler Aug 16 '11 at 17:15

1 Answers1

7

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

Owen Delahoy
  • 806
  • 6
  • 22
evernat
  • 1,713
  • 13
  • 18