EncodingIntegrityChecker implements DocumentIntegrityChecker { @Override public void check(String content) throws IntegrityCheckException { if (content.contains(REPLACEMENT_CHARACTER)) { throw new EncodingIntegrityCheckerException("Input does not have a valid encoding (it should be UTF-8)"); } }  @Override boolean supportsExtension(String documentExtension); @Override void check(String content);  }
@Test(expected = IntegrityCheckException.class) public void testEncodingForWrongEncoding() throws IOException { String string = getFileAsString("/xliff-latin.xliff"); EncodingIntegrityChecker encodingIntegrityChecker = new EncodingIntegrityChecker(); encodingIntegrityChecker.check(string); }
@Test(expected = IntegrityCheckException.class) public void testGB18030Encoding() throws IOException { String string = getFileAsString("/xliff-gb18030.xliff"); EncodingIntegrityChecker encodingIntegrityChecker = new EncodingIntegrityChecker(); encodingIntegrityChecker.check(string); }
@Test public void testUTF8Encoding() throws IOException { String string = getFileAsString("/xliff-utf8.xliff"); EncodingIntegrityChecker encodingIntegrityChecker = new EncodingIntegrityChecker(); encodingIntegrityChecker.check(string); }