diff --git a/surefire-api/src/test/java/org/apache/maven/surefire/api/stream/AbstractStreamDecoderTest.java b/surefire-api/src/test/java/org/apache/maven/surefire/api/stream/AbstractStreamDecoderTest.java index 59d7b9b932..96c268ecf2 100644 --- a/surefire-api/src/test/java/org/apache/maven/surefire/api/stream/AbstractStreamDecoderTest.java +++ b/surefire-api/src/test/java/org/apache/maven/surefire/api/stream/AbstractStreamDecoderTest.java @@ -29,7 +29,6 @@ import java.nio.CharBuffer; import java.nio.channels.ReadableByteChannel; import java.nio.charset.CharsetDecoder; -import java.util.Collections; import java.util.HashMap; import java.util.Map; import java.util.concurrent.TimeUnit; @@ -51,6 +50,7 @@ import static java.nio.charset.StandardCharsets.ISO_8859_1; import static java.nio.charset.StandardCharsets.US_ASCII; import static java.nio.charset.StandardCharsets.UTF_8; +import static java.util.Collections.emptyMap; import static java.util.Collections.singletonMap; import static org.apache.maven.surefire.api.booter.Constants.DEFAULT_STREAM_ENCODING; import static org.apache.maven.surefire.api.booter.ForkedProcessEventType.BOOTERCODE_STDOUT; @@ -196,8 +196,7 @@ public void shouldReadInt() throws Exception { Channel channel = new Channel( new byte[] {0x01, 0x02, 0x03, 0x04, ':'}, 1 ); - Mock thread = new Mock( channel, new MockForkNodeArguments(), - Collections.emptyMap() ); + Mock thread = new Mock( channel, new MockForkNodeArguments(), emptyMap() ); Memento memento = thread.new Memento(); @@ -210,8 +209,7 @@ public void shouldReadInteger() throws Exception { Channel channel = new Channel( new byte[] {(byte) 0xff, 0x01, 0x02, 0x03, 0x04, ':'}, 1 ); - Mock thread = new Mock( channel, new MockForkNodeArguments(), - Collections.emptyMap() ); + Mock thread = new Mock( channel, new MockForkNodeArguments(), emptyMap() ); Memento memento = thread.new Memento(); assertThat( thread.readInteger( memento ) ) @@ -223,8 +221,7 @@ public void shouldReadNullInteger() throws Exception { Channel channel = new Channel( new byte[] {(byte) 0x00, ':'}, 1 ); - Mock thread = new Mock( channel, new MockForkNodeArguments(), - Collections.emptyMap() ); + Mock thread = new Mock( channel, new MockForkNodeArguments(), emptyMap() ); Memento memento = thread.new Memento(); assertThat( thread.readInteger( memento ) ) @@ -237,8 +234,7 @@ public void shouldNotReadString() throws Exception Channel channel = new Channel( PATTERN1.getBytes(), PATTERN1.length() ); channel.read( ByteBuffer.allocate( 100 ) ); - Mock thread = new Mock( channel, new MockForkNodeArguments(), - Collections.emptyMap() ); + Mock thread = new Mock( channel, new MockForkNodeArguments(), emptyMap() ); Memento memento = thread.new Memento(); invokeMethod( thread, "readString", memento, 10 ); @@ -249,8 +245,7 @@ public void shouldReadString() throws Exception { Channel channel = new Channel( PATTERN1.getBytes(), PATTERN1.length() ); - Mock thread = new Mock( channel, new MockForkNodeArguments(), - Collections.emptyMap() ); + Mock thread = new Mock( channel, new MockForkNodeArguments(), emptyMap() ); Memento memento = thread.new Memento(); String s = invokeMethod( thread, "readString", memento, 10 ); @@ -271,8 +266,7 @@ public void shouldReadStringOverflowOnNewLine() throws Exception Channel channel = new Channel( s.toString().getBytes( UTF_8 ), s.length() ); - Mock thread = new Mock( channel, new MockForkNodeArguments(), - Collections.emptyMap() ); + Mock thread = new Mock( channel, new MockForkNodeArguments(), emptyMap() ); Memento memento = thread.new Memento(); @@ -296,8 +290,7 @@ public void shouldReadStringOverflowOn4BytesEncodedSymbol() throws Exception Channel channel = new Channel( s.toString().getBytes( UTF_8 ), s.length() ); - Mock thread = new Mock( channel, new MockForkNodeArguments(), - Collections.emptyMap() ); + Mock thread = new Mock( channel, new MockForkNodeArguments(), emptyMap() ); Memento memento = thread.new Memento(); @@ -319,8 +312,7 @@ public void shouldReadStringShiftedBuffer() throws Exception Channel channel = new Channel( s.toString().getBytes( UTF_8 ), s.length() ); - Mock thread = new Mock( channel, new MockForkNodeArguments(), - Collections.emptyMap() ); + Mock thread = new Mock( channel, new MockForkNodeArguments(), emptyMap() ); Memento memento = thread.new Memento(); // whatever position will be compacted to 0 @@ -341,8 +333,7 @@ public void shouldReadStringShiftedInput() throws Exception Channel channel = new Channel( s.toString().getBytes( UTF_8 ), s.length() ); channel.read( ByteBuffer.allocate( 997 ) ); - Mock thread = new Mock( channel, new MockForkNodeArguments(), - Collections.emptyMap() ); + Mock thread = new Mock( channel, new MockForkNodeArguments(), emptyMap() ); Memento memento = thread.new Memento(); assertThat( (String) invokeMethod( thread, "readString", memento, PATTERN1.length() ) ) @@ -362,8 +353,7 @@ public void shouldReadMultipleStringsAndShiftedInput() throws Exception Channel channel = new Channel( s.toString().getBytes( UTF_8 ), s.length() ); channel.read( ByteBuffer.allocate( 1997 ) ); - Mock thread = new Mock( channel, new MockForkNodeArguments(), - Collections.emptyMap() ); + Mock thread = new Mock( channel, new MockForkNodeArguments(), emptyMap() ); Memento memento = thread.new Memento(); // whatever position will be compacted to 0 @@ -391,8 +381,7 @@ public void shouldDecode3BytesEncodedSymbol() throws Exception } Channel channel = new Channel( input, 64 * 1024 ); - Mock thread = new Mock( channel, new MockForkNodeArguments(), - Collections.emptyMap() ); + Mock thread = new Mock( channel, new MockForkNodeArguments(), emptyMap() ); Memento memento = thread.new Memento(); String decodedOutput = invokeMethod( thread, "readString", memento, input.length ); @@ -466,8 +455,7 @@ public void shouldEventTypeReachedMalformedHeader() throws Exception { byte[] stream = ":xxxxx-xxxxxxxx-xxxxx:\u000E:xxx".getBytes( UTF_8 ); Channel channel = new Channel( stream, 1 ); - Mock thread = new Mock( channel, new MockForkNodeArguments(), - Collections.emptyMap() ); + Mock thread = new Mock( channel, new MockForkNodeArguments(), emptyMap() ); Memento memento = thread.new Memento(); memento.setCharset( UTF_8 ); @@ -479,8 +467,7 @@ public void shouldReadEmptyString() throws Exception { byte[] stream = "\u0000\u0000\u0000\u0000::".getBytes( UTF_8 ); Channel channel = new Channel( stream, 1 ); - Mock thread = new Mock( channel, new MockForkNodeArguments(), - Collections.emptyMap() ); + Mock thread = new Mock( channel, new MockForkNodeArguments(), emptyMap() ); Memento memento = thread.new Memento(); memento.setCharset( UTF_8 ); @@ -494,8 +481,7 @@ public void shouldReadNullString() throws Exception { byte[] stream = "\u0000\u0000\u0000\u0001:\u0000:".getBytes( UTF_8 ); Channel channel = new Channel( stream, 1 ); - Mock thread = new Mock( channel, new MockForkNodeArguments(), - Collections.emptyMap() ); + Mock thread = new Mock( channel, new MockForkNodeArguments(), emptyMap() ); Memento memento = thread.new Memento(); memento.setCharset( UTF_8 ); @@ -509,8 +495,7 @@ public void shouldReadSingleCharString() throws Exception { byte[] stream = "\u0000\u0000\u0000\u0001:A:".getBytes( UTF_8 ); Channel channel = new Channel( stream, 1 ); - Mock thread = new Mock( channel, new MockForkNodeArguments(), - Collections.emptyMap() ); + Mock thread = new Mock( channel, new MockForkNodeArguments(), emptyMap() ); Memento memento = thread.new Memento(); memento.setCharset( UTF_8 ); @@ -524,8 +509,7 @@ public void shouldReadThreeCharactersString() throws Exception { byte[] stream = "\u0000\u0000\u0000\u0003:ABC:".getBytes( UTF_8 ); Channel channel = new Channel( stream, 1 ); - Mock thread = new Mock( channel, new MockForkNodeArguments(), - Collections.emptyMap() ); + Mock thread = new Mock( channel, new MockForkNodeArguments(), emptyMap() ); Memento memento = thread.new Memento(); memento.setCharset( UTF_8 ); @@ -539,8 +523,7 @@ public void shouldReadDefaultCharset() throws Exception { byte[] stream = "\u0005:UTF-8:".getBytes( US_ASCII ); Channel channel = new Channel( stream, 1 ); - Mock thread = new Mock( channel, new MockForkNodeArguments(), - Collections.emptyMap() ); + Mock thread = new Mock( channel, new MockForkNodeArguments(), emptyMap() ); Memento memento = thread.new Memento(); memento.setCharset( UTF_8 ); @@ -555,8 +538,7 @@ public void shouldReadNonDefaultCharset() throws Exception { byte[] stream = ( (char) 10 + ":ISO_8859_1:" ).getBytes( US_ASCII ); Channel channel = new Channel( stream, 1 ); - Mock thread = new Mock( channel, new MockForkNodeArguments(), - Collections.emptyMap() ); + Mock thread = new Mock( channel, new MockForkNodeArguments(), emptyMap() ); Memento memento = thread.new Memento(); memento.setCharset( UTF_8 ); @@ -571,10 +553,9 @@ public void shouldSetNonDefaultCharset() { byte[] stream = {}; Channel channel = new Channel( stream, 1 ); - Mock thread = new Mock( channel, new MockForkNodeArguments(), - Collections.emptyMap() ); - Memento memento = thread.new Memento(); + Mock thread = new Mock( channel, new MockForkNodeArguments(), emptyMap() ); + Memento memento = thread.new Memento(); memento.setCharset( ISO_8859_1 ); assertThat( memento.getDecoder().charset() ).isEqualTo( ISO_8859_1 ); @@ -591,8 +572,7 @@ public void malformedCharset() throws Exception { byte[] stream = ( (char) 8 + ":ISO_8859:" ).getBytes( US_ASCII ); Channel channel = new Channel( stream, 1 ); - Mock thread = new Mock( channel, new MockForkNodeArguments(), - Collections.emptyMap() ); + Mock thread = new Mock( channel, new MockForkNodeArguments(), emptyMap() ); Memento memento = thread.new Memento(); memento.setCharset( UTF_8 );