I have written a unit test, which controls if there are any encoding problems with german letters( ?,?,?,etc.)
@Test
public void testBodyWithDefaultCharset() throws UnsupportedEncodingException {
when(backendDefinition.getProperty(BackendDetailsEnum.MAIL_CHARSET.getName())).thenReturn(null);
Charset defaultCharset = Charset.defaultCharset();
when(packet.getPayload()).thenReturn(defaultCharset.encode("??ü??ü?").array());
final String mailText = classUnderTest.prepareMailText(backendDefinition, packet);
assertThat(mailText, is(equalTo("??ü??ü?")));
}
This test passes in windows pc but fails on jenkins, which is a linux environment. The error message is as follows;
Expected: is "??ü??ü?"
but: was "???????"
My question is, is it wrong to compare mailText with "??ü??ü?"? I thougt I don't need to state any encoding when I compare two strings.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…