|
1 | 1 | /* |
2 | | - * Copyright 2006-2022 the original author or authors. |
| 2 | + * Copyright 2006-2024 the original author or authors. |
3 | 3 | * |
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | 5 | * you may not use this file except in compliance with the License. |
|
21 | 21 | import java.io.BufferedReader; |
22 | 22 |
|
23 | 23 | import org.junit.jupiter.api.Test; |
| 24 | +import org.junit.jupiter.params.ParameterizedTest; |
| 25 | +import org.junit.jupiter.params.provider.ValueSource; |
24 | 26 | import org.springframework.core.io.ByteArrayResource; |
25 | 27 |
|
26 | 28 | /** |
@@ -75,16 +77,27 @@ void testCreateWithLineEndingAtEnd() throws Exception { |
75 | 77 | assertNull(reader.readLine()); |
76 | 78 | } |
77 | 79 |
|
78 | | - @Test |
79 | | - void testCreateWithFalseLineEnding() throws Exception { |
| 80 | + @ParameterizedTest |
| 81 | + @ValueSource(strings = { "||", "|||" }) |
| 82 | + void testCreateWithFalseLineEnding(String lineEnding) throws Exception { |
80 | 83 | SimpleBinaryBufferedReaderFactory factory = new SimpleBinaryBufferedReaderFactory(); |
81 | | - factory.setLineEnding("||"); |
| 84 | + factory.setLineEnding(lineEnding); |
82 | 85 | @SuppressWarnings("resource") |
83 | | - BufferedReader reader = factory.create(new ByteArrayResource("a|b||".getBytes()), "UTF-8"); |
| 86 | + BufferedReader reader = factory.create(new ByteArrayResource(("a|b" + lineEnding).getBytes()), "UTF-8"); |
84 | 87 | assertEquals("a|b", reader.readLine()); |
85 | 88 | assertNull(reader.readLine()); |
86 | 89 | } |
87 | 90 |
|
| 91 | + @Test |
| 92 | + void testCreateWithFalseMixedCharacterLineEnding() throws Exception { |
| 93 | + SimpleBinaryBufferedReaderFactory factory = new SimpleBinaryBufferedReaderFactory(); |
| 94 | + factory.setLineEnding("#@"); |
| 95 | + @SuppressWarnings("resource") |
| 96 | + BufferedReader reader = factory.create(new ByteArrayResource(("a##@").getBytes()), "UTF-8"); |
| 97 | + assertEquals("a#", reader.readLine()); |
| 98 | + assertNull(reader.readLine()); |
| 99 | + } |
| 100 | + |
88 | 101 | @Test |
89 | 102 | void testCreateWithIncompleteLineEnding() throws Exception { |
90 | 103 | SimpleBinaryBufferedReaderFactory factory = new SimpleBinaryBufferedReaderFactory(); |
|
0 commit comments