-
Notifications
You must be signed in to change notification settings - Fork 2
UFAL/Failing BE tests #1301
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dtq-dev
Are you sure you want to change the base?
UFAL/Failing BE tests #1301
Changes from all commits
fad8b33
75d3bb0
adfbe7f
a63f5bd
73b1294
10e1450
dadcfbf
6ee34ad
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,17 +7,17 @@ | |
| */ | ||
| package org.dspace.app.rest; | ||
|
|
||
| import static org.junit.Assert.assertArrayEquals; | ||
| import static org.junit.Assert.assertEquals; | ||
| import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; | ||
| import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; | ||
| import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; | ||
|
|
||
| import java.io.ByteArrayOutputStream; | ||
| import java.io.ByteArrayInputStream; | ||
| import java.io.InputStream; | ||
| import java.util.zip.Deflater; | ||
|
|
||
| import org.apache.commons.codec.CharEncoding; | ||
| import org.apache.commons.compress.archivers.zip.ZipArchiveEntry; | ||
| import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream; | ||
| import org.apache.commons.compress.archivers.zip.ZipArchiveInputStream; | ||
| import org.apache.commons.io.IOUtils; | ||
| import org.dspace.app.rest.model.ItemRest; | ||
| import org.dspace.app.rest.test.AbstractControllerIntegrationTest; | ||
|
|
@@ -78,23 +78,22 @@ public void setUp() throws Exception { | |
|
|
||
| @Test | ||
| public void downloadAllZip() throws Exception { | ||
| ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); | ||
| ZipArchiveOutputStream zip = new ZipArchiveOutputStream(byteArrayOutputStream); | ||
| zip.setCreateUnicodeExtraFields(ZipArchiveOutputStream.UnicodeExtraFieldPolicy.ALWAYS); | ||
| zip.setLevel(Deflater.NO_COMPRESSION); | ||
| ZipArchiveEntry ze = new ZipArchiveEntry(bts.getName()); | ||
| zip.putArchiveEntry(ze); | ||
| InputStream is = bitstreamService.retrieve(context, bts); | ||
| org.apache.commons.compress.utils.IOUtils.copy(is, zip); | ||
| zip.closeArchiveEntry(); | ||
| is.close(); | ||
| zip.close(); | ||
| String bitstreamContent = "ThisIsSomeDummyText"; | ||
|
|
||
|
Comment on lines
+81
to
82
|
||
| String token = getAuthToken(admin.getEmail(), password); | ||
| getClient(token).perform(get(METADATABITSTREAM_ENDPOINT + "/" + publicItem.getID() + | ||
| byte[] responseBytes = getClient(token).perform(get(METADATABITSTREAM_ENDPOINT + "/" + publicItem.getID() + | ||
| "/" + ALL_ZIP_PATH).param(HANDLE_PARAM, publicItem.getHandle())) | ||
| .andExpect(status().isOk()) | ||
| .andExpect(content().bytes(byteArrayOutputStream.toByteArray())); | ||
| .andReturn().getResponse().getContentAsByteArray(); | ||
|
|
||
| // Verify the ZIP content by extracting and comparing the entry | ||
| try (ZipArchiveInputStream zipIn = new ZipArchiveInputStream(new ByteArrayInputStream(responseBytes))) { | ||
| ZipArchiveEntry entry = zipIn.getNextZipEntry(); | ||
| // Verify entry name matches bitstream name | ||
| assertEquals(bts.getName(), entry.getName()); | ||
| // Verify uncompressed content matches the original bitstream content | ||
|
Comment on lines
+90
to
+94
|
||
| byte[] extractedBytes = org.apache.commons.compress.utils.IOUtils.toByteArray(zipIn); | ||
| assertArrayEquals(bitstreamContent.getBytes(CharEncoding.UTF_8), extractedBytes); | ||
| } | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DEFAULT_AMOUNT_FORMATS is no longer a constant (it’s assigned in @before), but it’s still named like a constant (ALL_CAPS). Rename it to a regular field name (e.g., defaultAmountFormats/initialAmountFormats) to match Java conventions and reduce confusion.