EndLineCharactersCheck extends DoubleDispatchVisitorCheck implements CharsetAwareVisitor { @VisibleForTesting void setEndLineCharacters(String endLineCharacters) { this.endLineCharacters = endLineCharacters; }  @Override void visitProperties(PropertiesTree tree); @Override void validateParameters(); @Override void setCharset(Charset charset);  }
@Test public void should_find_only_crlf_and_not_raise_any_issues() throws Exception { EndLineCharactersCheck check = new EndLineCharactersCheck(); check.setEndLineCharacters("CRLF"); JavaPropertiesCheckVerifier.issues(check, getTestFileWithProperEndLineCharacters("\r\n")) .noMore(); }
@Test public void should_find_only_cr_and_not_raise_any_issues() throws Exception { EndLineCharactersCheck check = new EndLineCharactersCheck(); check.setEndLineCharacters("CR"); JavaPropertiesCheckVerifier.issues(check, getTestFileWithProperEndLineCharacters("\r")) .noMore(); }
@Test public void should_find_only_lf_and_not_raise_any_issues() throws Exception { EndLineCharactersCheck check = new EndLineCharactersCheck(); check.setEndLineCharacters("LF"); JavaPropertiesCheckVerifier.issues(check, getTestFileWithProperEndLineCharacters("\n")) .noMore(); }
@Test public void crlf_should_find_lf_and_raise_issues() throws Exception { EndLineCharactersCheck check = new EndLineCharactersCheck(); check.setEndLineCharacters("CRLF"); JavaPropertiesCheckVerifier.issues(check, getTestFileWithProperEndLineCharacters("\n")) .next().withMessage("Set all end-line characters to 'CRLF' in this file.") .noMore(); }
@Test public void crlf_should_find_cr_and_raise_issues() throws Exception { EndLineCharactersCheck check = new EndLineCharactersCheck(); check.setEndLineCharacters("CRLF"); JavaPropertiesCheckVerifier.issues(check, getTestFileWithProperEndLineCharacters("\r")) .next().withMessage("Set all end-line characters to 'CRLF' in this file.") .noMore(); }
@Test public void cr_should_find_crlf_and_raise_issues() throws Exception { EndLineCharactersCheck check = new EndLineCharactersCheck(); check.setEndLineCharacters("CR"); JavaPropertiesCheckVerifier.issues(check, getTestFileWithProperEndLineCharacters("\r\n")) .next().withMessage("Set all end-line characters to 'CR' in this file.") .noMore(); }
@Test public void cr_should_find_lf_and_raise_issues() throws Exception { EndLineCharactersCheck check = new EndLineCharactersCheck(); check.setEndLineCharacters("CR"); JavaPropertiesCheckVerifier.issues(check, getTestFileWithProperEndLineCharacters("\n")) .next().withMessage("Set all end-line characters to 'CR' in this file.") .noMore(); }
@Test public void lf_should_find_crlf_and_raise_issues() throws Exception { EndLineCharactersCheck check = new EndLineCharactersCheck(); check.setEndLineCharacters("LF"); JavaPropertiesCheckVerifier.issues(check, getTestFileWithProperEndLineCharacters("\r\n")) .next().withMessage("Set all end-line characters to 'LF' in this file.") .noMore(); }
@Test public void lf_should_find_cr_and_raise_issues() throws Exception { EndLineCharactersCheck check = new EndLineCharactersCheck(); check.setEndLineCharacters("LF"); JavaPropertiesCheckVerifier.issues(check, getTestFileWithProperEndLineCharacters("\r")) .next().withMessage("Set all end-line characters to 'LF' in this file.") .noMore(); }
@Test public void should_throw_an_illegal_state_exception_as_the_endLineCharacters_parameter_is_not_valid() throws Exception { try { EndLineCharactersCheck check = new EndLineCharactersCheck(); check.setEndLineCharacters("abc"); JavaPropertiesCheckVerifier.issues(check, getTestFileWithProperEndLineCharacters("\r")).noMore(); } catch (IllegalStateException e) { assertThat(e.getMessage()).isEqualTo("Check jproperties:end-line-characters (End-line characters should be consistent): " + "endLineCharacters parameter is not valid.\nActual: 'abc'\nExpected: 'CR' or 'CRLF' or 'LF'"); } }