BAEL-7131 - reapplied Baeldung Formatter, code changes from PR.
This commit is contained in:
parent
ed1e58c45e
commit
9178b53dc9
|
@ -17,9 +17,9 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.io.TempDir;
|
||||
|
||||
public class InputStreamUnitTest {
|
||||
@Test
|
||||
public void givenAStringWrittenToFile_whenReadWithFileInputStream_thenItShouldExitsInTheInputStream(@TempDir Path tempDir) throws IOException {
|
||||
|
@ -41,14 +41,9 @@ public class InputStreamUnitTest {
|
|||
String fileAbsolutePath = sampleOut.toFile()
|
||||
.getAbsolutePath();
|
||||
try (FileInputStream fis = new FileInputStream(fileAbsolutePath)) {
|
||||
int content;
|
||||
int availableBytes = fis.available();
|
||||
Assert.assertTrue(availableBytes > 0);
|
||||
StringBuilder actualReadText = new StringBuilder();
|
||||
while ((content = fis.read()) != -1) {
|
||||
actualReadText.append((char) content);
|
||||
}
|
||||
assertThat(actualReadText.toString()).contains(expectedText);
|
||||
assertThat(availableBytes > 0);
|
||||
assertThat(readString(fis)).contains(expectedText);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -59,6 +54,7 @@ public class InputStreamUnitTest {
|
|||
assertThat(readString(bais)).isEqualTo("hello");
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenKeyValuePairsWrittenInAFile_whenPassedInOutputStreams_thenThePairsShouldExistsInObjectInputStreams(@TempDir Path tempDir) throws IOException, ClassNotFoundException {
|
||||
Path sampleOut = tempDir.resolve("sample-out.txt");
|
||||
|
|
|
@ -14,10 +14,10 @@ import java.util.List;
|
|||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.io.TempDir;
|
||||
|
||||
public class InputStreamReaderUnitTest {
|
||||
@Test
|
||||
public void givenAStringWrittenToAFile_whenReadByInputStreamReader_thenShouldMatchWhenRead(@TempDir Path tempDir) throws IOException {
|
||||
boolean isMatched = false;
|
||||
String sampleTxt = "Good day. This is just a test. Good bye.";
|
||||
Path sampleOut = tempDir.resolve("sample-out.txt");
|
||||
List<String> lines = Arrays.asList(sampleTxt);
|
||||
|
@ -25,6 +25,7 @@ public class InputStreamReaderUnitTest {
|
|||
String absolutePath = String.valueOf(sampleOut.toAbsolutePath());
|
||||
try (BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(absolutePath), StandardCharsets.UTF_8))) {
|
||||
String ln;
|
||||
boolean isMatched = false;
|
||||
while ((ln = br.readLine()) != null) {
|
||||
if (ln.contains(sampleTxt)) {
|
||||
isMatched = true;
|
||||
|
|
Loading…
Reference in New Issue