55import java .nio .charset .StandardCharsets ;
66import java .util .function .Function ;
77
8- import org .junit .Assert ;
9- import org .junit .Assume ;
10- import org .junit .Test ;
8+ import org .junit .jupiter .api .Test ;
9+
10+ import static org .junit .jupiter .api .Assertions .assertEquals ;
11+ import static org .junit .jupiter .api .Assertions .assertThrows ;
12+ import static org .junit .jupiter .api .Assumptions .assumeTrue ;
1113
1214public class LineRedirectOutputStreamTest {
1315
@@ -26,9 +28,9 @@ public void givenExtendedUnicodeCharacterOutput_whenRedirectingWithIso8859Charse
2628 @ Test
2729 public void givenExtendedUnicodeCharacterOutput_whenRedirectingWithCp1252_thenShouldDecodeProperly ()
2830 throws IOException {
29- Assume . assumeTrue (
30- "The JVM does not contain the cp -1252 charset" ,
31- Charset . availableCharsets (). containsKey ( "windows -1252" ) );
31+ assumeTrue (
32+ Charset . availableCharsets (). containsKey ( "windows -1252" ) ,
33+ "The JVM does not contain the cp -1252 charset" );
3234 internalTestForCharset (Charset .forName ("windows-1252" ));
3335 }
3436
@@ -44,14 +46,14 @@ public void givenExtendedUnicodeCharacterOutput_whenRedirectingWithCharsetUnspec
4446 internalTestForCharset (sb -> new LineRedirectOutputStream (sb ::append ), Charset .defaultCharset ());
4547 }
4648
47- @ Test ( expected = NullPointerException . class )
49+ @ Test
4850 public void givenNullCharset_whenInstantiating_thenShouldThrow () {
49- new LineRedirectOutputStream (new StringBuilder ()::append , null );
51+ assertThrows ( NullPointerException . class , () -> new LineRedirectOutputStream (new StringBuilder ()::append , null ) );
5052 }
5153
52- @ Test ( expected = NullPointerException . class )
54+ @ Test
5355 public void givenNullStringConsumer_whenInstantiating_thenShouldThrow () {
54- new LineRedirectOutputStream (null , Charset .defaultCharset ());
56+ assertThrows ( NullPointerException . class , () -> new LineRedirectOutputStream (null , Charset .defaultCharset () ));
5557 }
5658
5759 private void internalTestForCharset (Charset charset ) throws IOException {
@@ -72,6 +74,6 @@ private void internalTestForCharset(
7274
7375 // The String to bytes to String is required here because StringCoding uses the Charset.defaultCharset()
7476 // internally so it would make the test fail when testing for different charsets.
75- Assert . assertEquals (new String (expectedString .getBytes (charset ), charset ), sb .toString ());
77+ assertEquals (new String (expectedString .getBytes (charset ), charset ), sb .toString ());
7678 }
7779}
0 commit comments