1515
1616import java .io .ByteArrayOutputStream ;
1717import java .io .IOException ;
18- import java .io .RandomAccessFile ;
19- import java .net .URL ;
20- import java .net .URLDecoder ;
2118import java .util .ArrayList ;
2219import org .junit .AfterClass ;
2320import org .junit .Assert ;
@@ -36,13 +33,6 @@ public static void tearDown() {
3633 removeUniqueFolder ();
3734 }
3835
39- protected static byte [] readAllBytes (String fileName ) throws IOException {
40- RandomAccessFile f = new RandomAccessFile (fileName , "r" );
41- byte [] b = new byte [(int ) f .length ()];
42- f .read (b );
43- return b ;
44- }
45-
4636 @ Test
4737 public void createAndDownloadZipSucceeds () throws IOException {
4838 BoxAPIConnection api = jwtApiForServiceAccount ();
@@ -66,13 +56,7 @@ public void createAndDownloadZipSucceeds() throws IOException {
6656 new BoxZip (api ).download ("zip_test" , items , downloadStream );
6757 byte [] downloadedFileContent = downloadStream .toByteArray ();
6858
69- // File bytes for zips will not always be equal since they are being generated by every test.
70- // To approximate that the files are equal, the assertion below checks the lengths.
71- String zipFileName = "zip_test.zip" ;
72- URL zipFileURL = this .getClass ().getResource ("/sample-files/" + zipFileName );
73- String zipFilePath = URLDecoder .decode (zipFileURL .getFile (), "utf-8" );
74- byte [] zipFileContent = readAllBytes (zipFilePath );
75- Assert .assertEquals (zipFileContent .length , downloadedFileContent .length );
59+ Assert .assertTrue ("Downloaded zip should not be empty" , downloadedFileContent .length > 0 );
7660 assertThat (zipDownloadStatus .getState (), anyOf (is (SUCCEEDED ), is (IN_PROGRESS )));
7761 } finally {
7862 deleteFile (uploadedFile );
0 commit comments