Skip to content

Commit

Permalink
inspect zipfile
Browse files Browse the repository at this point in the history
Signed-off-by: Antoine MAZEAS <[email protected]>
  • Loading branch information
antoinemzs committed Jan 3, 2025
1 parent 547406f commit dd11c34
Showing 1 changed file with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@
import io.openbas.utils.fixtures.composers.*;
import io.openbas.utils.mockUser.WithMockAdminUser;
import jakarta.annotation.Resource;
import java.io.FileOutputStream;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;
import java.io.ByteArrayInputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import org.junit.jupiter.api.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.MockMvc;
Expand Down Expand Up @@ -99,8 +98,16 @@ public void test_export() throws Exception {
.getResponse()
.getContentAsByteArray();

FileOutputStream outputStream = new FileOutputStream("/home/antoinemzs/export.zip");
outputStream.write(response);
outputStream.close();
try (ZipInputStream zis = new ZipInputStream(new ByteArrayInputStream(response))) {
ZipEntry entry;
while ((entry = zis.getNextEntry()) != null) {
if (entry.getName().equals("%s.json".formatted(EXERCISE.getName()))) {
// force exit of test since we have found the correct entry
return;
}
}
// no zip entry corresponding to expected json
Assertions.fail();
}
}
}

0 comments on commit dd11c34

Please sign in to comment.