input1 = new FileInputStream(file1); input2 = new FileInputStream(file2); return StreamUtil.compare(input1, input2); } finally { StreamUtil.close(input1);
input1 = new FileInputStream(one); input2 = new FileInputStream(two); return StreamUtil.compare(input1, input2); } finally { StreamUtil.close(input1);
@Test void testCompareWithReaderInstances_ExpectedNoSuccessfulCompare() throws Exception { final String text_1 = "jodd and german umlauts öäü"; final String text_2 = new String(text_1.getBytes(),Charset.forName("ISO-8859-1")); boolean actual; try (StringReader reader_1 = new StringReader(text_1); StringReader reader_2 = new StringReader(text_2)) { actual = StreamUtil.compare(reader_1, reader_2); } // asserts assertFalse(actual); }
@Test void testCompareWithReaderInstances_ExpectedSuccessfulCompare() throws Exception { final String text = new String("jodd and german umlauts öäü".getBytes(),Charset.forName("ISO-8859-1")); boolean actual; try (StringReader reader_1 = new StringReader(text); StringReader reader_2 = new StringReader(text)) { actual = StreamUtil.compare(reader_1, reader_2); } // asserts assertTrue(actual); }
@Test void testCompareWithInputStreams_ExpectedNoSuccessfulCompare(TestInfo testInfo) throws Exception { final String text = "jodd makes fun!"; final File file = new File(StreamUtilTest.BASE_DIR, testInfo.getTestMethod().get().getName() + ".txt"); FileUtil.writeString(file, " " + text, "UTF-8"); boolean actual; try (ByteArrayInputStream in1 = new ByteArrayInputStream(text.getBytes()); FileInputStream in2 = new FileInputStream(file)) { actual = StreamUtil.compare(in1, in2); } // asserts assertFalse(actual); }
@Test void testCompareWithInputStreams_ExpectedSuccessfulCompare(TestInfo testInfo) throws Exception { final String text = "jodd makes fun!" + System.lineSeparator(); final File file = new File(StreamUtilTest.BASE_DIR, testInfo.getTestMethod().get().getName() + ".txt"); FileUtil.writeString(file, text, "UTF-8"); boolean actual; try (ByteArrayInputStream in1 = new ByteArrayInputStream(text.getBytes()); FileInputStream in2 = new FileInputStream(file)) { actual = StreamUtil.compare(in1, in2); } // asserts assertTrue(actual); }
input1 = new FileInputStream(one); input2 = new FileInputStream(two); return StreamUtil.compare(input1, input2); } finally { StreamUtil.close(input1);