1- package sjsonnet ;
2-
3- import static org .junit .Assert .assertEquals ;
4- import static org .junit .Assert .assertTrue ;
1+ package sjsonnet .client ;
52
63import org .junit .Test ;
7- import sjsonnet .client .ProxyOutputStream ;
8- import sjsonnet .client .ProxyStreamPumper ;
9- import sjsonnet .client .Util ;
104
115import java .io .ByteArrayInputStream ;
126import java .io .ByteArrayOutputStream ;
137import java .io .OutputStream ;
14- import java .util .*;
8+ import java .util .Arrays ;
9+ import java .util .Objects ;
10+ import java .util .Random ;
11+
12+ import static org .junit .Assert .*;
1513
1614public class ClientTests {
1715 @ Test
@@ -27,7 +25,7 @@ public void readWriteInt() throws Exception{
2725 ByteArrayInputStream i = new ByteArrayInputStream (o .toByteArray ());
2826 int s = Util .readInt (i );
2927 assertEquals (example , s );
30- assertEquals (i .available (), 0 );
28+ assertEquals (0 , i .available ());
3129 }
3230 }
3331 }
@@ -48,8 +46,8 @@ public void readWriteString() throws Exception{
4846 @ Test
4947 public void readWriteBigString () throws Exception {
5048 int [] lengths = {0 , 1 , 126 , 127 , 128 , 254 , 255 , 256 , 1024 , 99999 , 1234567 };
51- for ( int i = 0 ; i < lengths . length ; i ++) {
52- final char [] bigChars = new char [lengths [ i ] ];
49+ for ( final int length : lengths ) {
50+ final char [] bigChars = new char [length ];
5351 Arrays .fill (bigChars , 'X' );
5452 checkStringRoundTrip (new String (bigChars ));
5553 }
@@ -61,14 +59,14 @@ public void checkStringRoundTrip(String example) throws Exception{
6159 ByteArrayInputStream i = new ByteArrayInputStream (o .toByteArray ());
6260 String s = Util .readString (i );
6361 assertEquals (example , s );
64- assertEquals (i .available (), 0 );
62+ assertEquals (0 , i .available ());
6563 }
6664
6765 public byte [] readSamples (String ...samples ) throws Exception {
6866 ByteArrayOutputStream out = new ByteArrayOutputStream ();
6967 for (String sample : samples ) {
7068 byte [] bytes = java .nio .file .Files .readAllBytes (
71- java .nio .file .Paths .get (getClass ().getResource (sample ).getFile ())
69+ java .nio .file .Paths .get (Objects . requireNonNull ( getClass ().getResource (sample ) ).getFile ())
7270 );
7371 out .write (bytes );
7472 }
@@ -147,8 +145,8 @@ public void proxyInputOutputStreams(byte[] samples1,
147145 dest1 , dest2
148146 );
149147 pumper .run ();
150- assertTrue ( Arrays . equals ( samples1 , dest1 .toByteArray () ));
151- assertTrue ( Arrays . equals ( samples2 , dest2 .toByteArray () ));
148+ assertArrayEquals ( samples1 , dest1 .toByteArray ());
149+ assertArrayEquals ( samples2 , dest2 .toByteArray ());
152150 }
153151
154152}
0 commit comments