From 2e0208f0542a822e20f40dc2dda777b5b482983b Mon Sep 17 00:00:00 2001 From: Kai Zimmermann Date: Wed, 24 Aug 2016 11:35:02 +0200 Subject: [PATCH] Fixed test after merge Signed-off-by: Kai Zimmermann --- .../resource/DdiArtifactDownloadTest.java | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiArtifactDownloadTest.java b/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiArtifactDownloadTest.java index 81be97b7c..c618fa667 100644 --- a/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiArtifactDownloadTest.java +++ b/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiArtifactDownloadTest.java @@ -21,9 +21,12 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.nio.charset.StandardCharsets; +import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Arrays; +import java.util.Date; import java.util.List; +import java.util.TimeZone; import org.apache.commons.lang3.RandomUtils; import org.eclipse.hawkbit.repository.eventbus.event.DownloadProgressEvent; @@ -35,6 +38,7 @@ import org.eclipse.hawkbit.repository.model.LocalArtifact; import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.test.util.WithUser; import org.eclipse.hawkbit.rest.AbstractRestIntegrationTestWithMongoDB; +import org.junit.Before; import org.junit.Test; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -69,6 +73,13 @@ public class DdiArtifactDownloadTest extends AbstractRestIntegrationTestWithMong private volatile long shippedBytes = 0; private volatile long shippedBytesTotal = 0; + private final SimpleDateFormat dateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz"); + + @Before + public void setup() { + dateFormat.setTimeZone(TimeZone.getTimeZone("GMT")); + } + @Autowired private EventBus eventBus; @@ -273,7 +284,7 @@ public class DdiArtifactDownloadTest extends AbstractRestIntegrationTestWithMong ds.findFirstModuleByType(osType).getId(), artifact.getFilename())) .andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_OCTET_STREAM)) .andExpect(header().string("Accept-Ranges", "bytes")) - .andExpect(header().longValue("Last-Modified", artifact.getCreatedAt())) + .andExpect(header().string("Last-Modified", dateFormat.format(new Date(artifact.getCreatedAt())))) .andExpect(header().string("Content-Disposition", "attachment;filename=" + artifact.getFilename())) .andReturn(); @@ -386,7 +397,7 @@ public class DdiArtifactDownloadTest extends AbstractRestIntegrationTestWithMong .andExpect(status().isOk()).andExpect(header().string("ETag", artifact.getSha1Hash())) .andExpect(content().contentType(MediaType.APPLICATION_OCTET_STREAM)) .andExpect(header().string("Accept-Ranges", "bytes")) - .andExpect(header().longValue("Last-Modified", artifact.getCreatedAt())) + .andExpect(header().string("Last-Modified", dateFormat.format(new Date(artifact.getCreatedAt())))) .andExpect(header().string("Content-Disposition", "attachment;filename=file1")).andReturn(); assertTrue("The same file that was uploaded is expected when downloaded", @@ -444,7 +455,7 @@ public class DdiArtifactDownloadTest extends AbstractRestIntegrationTestWithMong .andExpect(status().isPartialContent()).andExpect(header().string("ETag", artifact.getSha1Hash())) .andExpect(content().contentType(MediaType.APPLICATION_OCTET_STREAM)) .andExpect(header().string("Accept-Ranges", "bytes")) - .andExpect(header().longValue("Last-Modified", artifact.getCreatedAt())) + .andExpect(header().string("Last-Modified", dateFormat.format(new Date(artifact.getCreatedAt())))) .andExpect(header().longValue("Content-Length", range)) .andExpect(header().string("Content-Range", "bytes " + rangeString + "/" + resultLength)) .andExpect(header().string("Content-Disposition", "attachment;filename=file1")).andReturn(); @@ -461,7 +472,7 @@ public class DdiArtifactDownloadTest extends AbstractRestIntegrationTestWithMong .andExpect(status().isPartialContent()).andExpect(header().string("ETag", artifact.getSha1Hash())) .andExpect(content().contentType(MediaType.APPLICATION_OCTET_STREAM)) .andExpect(header().string("Accept-Ranges", "bytes")) - .andExpect(header().longValue("Last-Modified", artifact.getCreatedAt())) + .andExpect(header().string("Last-Modified", dateFormat.format(new Date(artifact.getCreatedAt())))) .andExpect(header().longValue("Content-Length", 1000)) .andExpect(header().string("Content-Range", "bytes " + (resultLength - 1000) + "-" + (resultLength - 1) + "/" + resultLength)) @@ -477,7 +488,7 @@ public class DdiArtifactDownloadTest extends AbstractRestIntegrationTestWithMong .andExpect(status().isPartialContent()).andExpect(header().string("ETag", artifact.getSha1Hash())) .andExpect(content().contentType(MediaType.APPLICATION_OCTET_STREAM)) .andExpect(header().string("Accept-Ranges", "bytes")) - .andExpect(header().longValue("Last-Modified", artifact.getCreatedAt())) + .andExpect(header().string("Last-Modified", dateFormat.format(new Date(artifact.getCreatedAt())))) .andExpect(header().longValue("Content-Length", resultLength - 1000)) .andExpect(header().string("Content-Range", "bytes " + 1000 + "-" + (resultLength - 1) + "/" + resultLength)) @@ -493,7 +504,7 @@ public class DdiArtifactDownloadTest extends AbstractRestIntegrationTestWithMong .andExpect(status().isPartialContent()).andExpect(header().string("ETag", artifact.getSha1Hash())) .andExpect(content().contentType("multipart/byteranges; boundary=THIS_STRING_SEPARATES_MULTIPART")) .andExpect(header().string("Accept-Ranges", "bytes")) - .andExpect(header().longValue("Last-Modified", artifact.getCreatedAt())) + .andExpect(header().string("Last-Modified", dateFormat.format(new Date(artifact.getCreatedAt())))) .andExpect(header().string("Content-Disposition", "attachment;filename=file1")).andReturn(); outputStream.reset();