@@ -88,7 +88,7 @@ public void testExtract() throws IOException {
8888 " inflated: testfile1" + nl +
8989 " inflated: testfile2" + nl ;
9090 rm ("META-INF testfile1 testfile2" );
91- Assertions . assertArrayEquals ( baos . toByteArray (), output . getBytes () );
91+ assertOutputContains ( output );
9292 }
9393
9494 /**
@@ -105,7 +105,7 @@ public void testOverwrite() throws IOException {
105105 " inflated: testfile2" + nl ;
106106 Assertions .assertEquals ("testfile1" , cat ("testfile1" ));
107107 rm ("META-INF testfile1 testfile2" );
108- Assertions . assertArrayEquals ( baos . toByteArray (), output . getBytes () );
108+ assertOutputContains ( output );
109109 }
110110
111111 /**
@@ -123,7 +123,7 @@ public void testKeptOldFile() throws IOException {
123123 Assertions .assertEquals ("" , cat ("testfile1" ));
124124 Assertions .assertEquals ("testfile2" , cat ("testfile2" ));
125125 rm ("META-INF testfile1 testfile2" );
126- Assertions . assertArrayEquals ( baos . toByteArray (), output . getBytes () );
126+ assertOutputContains ( output );
127127 }
128128
129129 /**
@@ -141,7 +141,7 @@ public void testGnuOptionsKeptOldFile() throws IOException {
141141 Assertions .assertEquals ("" , cat ("testfile1" ));
142142 Assertions .assertEquals ("" , cat ("testfile2" ));
143143 rm ("META-INF testfile1 testfile2" );
144- Assertions . assertArrayEquals ( baos . toByteArray (), output . getBytes () );
144+ assertOutputContains ( output );
145145 }
146146
147147 /**
@@ -159,7 +159,7 @@ public void testGnuLongOptionsKeptOldFile() throws IOException {
159159 Assertions .assertEquals ("testfile1" , cat ("testfile1" ));
160160 Assertions .assertEquals ("" , cat ("testfile2" ));
161161 rm ("META-INF testfile1 testfile2" );
162- Assertions . assertArrayEquals ( baos . toByteArray (), output . getBytes () );
162+ assertOutputContains ( output );
163163 }
164164
165165 /**
@@ -175,10 +175,14 @@ public void testWarningOnInvalidKeepOption() throws IOException {
175175 "testfile1" + nl +
176176 "testfile2" + nl ;
177177
178- Assertions . assertArrayEquals ( baos . toByteArray (), output . getBytes () );
178+ assertOutputContains ( output );
179179 Assertions .assertEquals ("Warning: The --keep-old-files/-k/k option is not valid with current usage, will be ignored." + nl , err );
180180 }
181181
182+ private void assertOutputContains (String expected ) {
183+ Assertions .assertTrue (baos .toString ().contains (expected ));
184+ }
185+
182186 private Stream <Path > mkpath (String ... args ) {
183187 return Arrays .stream (args ).map (d -> Path .of ("." , d .split ("/" )));
184188 }
0 commit comments