From 4e9d795792b8f078cf64fb5267efbe5cdda14ab9 Mon Sep 17 00:00:00 2001 From: Tom Desair Date: Sun, 12 Aug 2018 14:46:05 +0200 Subject: [PATCH] Release version 1.0.0-1.1 --- pom.xml | 2 +- .../server/checksum/ITChecksumExtension.java | 7 ++++++- .../NoUploadLengthOnFinalValidatorTest.java | 12 ++++++++++-- .../validation/ContentLengthValidatorTest.java | 18 +++++++++++++++--- .../validation/ContentTypeValidatorTest.java | 7 ++++++- .../validation/HttpMethodValidatorTest.java | 7 ++++++- .../validation/UploadOffsetValidatorTest.java | 6 +++++- .../PostEmptyRequestValidatorTest.java | 6 +++++- .../validation/PostURIValidatorTest.java | 7 ++++++- .../UploadDeferLengthValidatorTest.java | 6 +++++- 10 files changed, 65 insertions(+), 13 deletions(-) diff --git a/pom.xml b/pom.xml index aee2982..5e24a2a 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ me.desair.tus tus-java-server - 1.0.0-1.1-SNAPSHOT + 1.0.0-1.1 jar ${project.groupId}:${project.artifactId} diff --git a/src/test/java/me/desair/tus/server/checksum/ITChecksumExtension.java b/src/test/java/me/desair/tus/server/checksum/ITChecksumExtension.java index 86d86b4..46b6153 100644 --- a/src/test/java/me/desair/tus/server/checksum/ITChecksumExtension.java +++ b/src/test/java/me/desair/tus/server/checksum/ITChecksumExtension.java @@ -1,6 +1,9 @@ package me.desair.tus.server.checksum; import static org.junit.Assert.fail; +import static org.mockito.Mockito.atLeastOnce; +import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.verify; import me.desair.tus.server.AbstractTusExtensionIntegrationTest; import me.desair.tus.server.HttpHeader; @@ -16,7 +19,7 @@ public class ITChecksumExtension extends AbstractTusExtensionIntegrationTest { @Before public void setUp() throws Exception { - servletRequest = new MockHttpServletRequest(); + servletRequest = spy(new MockHttpServletRequest()); servletResponse = new MockHttpServletResponse(); tusFeature = new ChecksumExtension(); uploadInfo = null; @@ -70,6 +73,8 @@ public void testValidChecksumNormalHeader() throws Exception { servletRequest.setContent(content.getBytes()); executeCall(HttpMethod.PATCH, true); + + verify(servletRequest, atLeastOnce()).getHeader(HttpHeader.UPLOAD_CHECKSUM); } @Test(expected = UploadChecksumMismatchException.class) diff --git a/src/test/java/me/desair/tus/server/concatenation/validation/NoUploadLengthOnFinalValidatorTest.java b/src/test/java/me/desair/tus/server/concatenation/validation/NoUploadLengthOnFinalValidatorTest.java index aa9cfa0..6248949 100644 --- a/src/test/java/me/desair/tus/server/concatenation/validation/NoUploadLengthOnFinalValidatorTest.java +++ b/src/test/java/me/desair/tus/server/concatenation/validation/NoUploadLengthOnFinalValidatorTest.java @@ -65,7 +65,11 @@ public void validateNotFinal1() throws Exception { servletRequest.addHeader(HttpHeader.UPLOAD_LENGTH, "10L"); //When we validate the request - validator.validate(HttpMethod.POST, servletRequest, null, null); + try { + validator.validate(HttpMethod.POST, servletRequest, null, null); + } catch (Exception ex) { + fail(); + } //No Exception is thrown } @@ -76,7 +80,11 @@ public void validateNotFinal2() throws Exception { //servletRequest.addHeader(HttpHeader.UPLOAD_LENGTH, "10L"); //When we validate the request - validator.validate(HttpMethod.POST, servletRequest, null, null); + try { + validator.validate(HttpMethod.POST, servletRequest, null, null); + } catch (Exception ex) { + fail(); + } //No Exception is thrown } diff --git a/src/test/java/me/desair/tus/server/core/validation/ContentLengthValidatorTest.java b/src/test/java/me/desair/tus/server/core/validation/ContentLengthValidatorTest.java index 3f6dbd5..91e6fb3 100644 --- a/src/test/java/me/desair/tus/server/core/validation/ContentLengthValidatorTest.java +++ b/src/test/java/me/desair/tus/server/core/validation/ContentLengthValidatorTest.java @@ -44,7 +44,11 @@ public void validateValidLengthInitialUpload() throws Exception { servletRequest.addHeader(HttpHeader.CONTENT_LENGTH, 10L); //When we validate the request - validator.validate(HttpMethod.PATCH, servletRequest, uploadStorageService, null); + try { + validator.validate(HttpMethod.PATCH, servletRequest, uploadStorageService, null); + } catch (Exception ex) { + fail(); + } //No Exception is thrown } @@ -143,7 +147,11 @@ public void validateMissingContentLength() throws Exception { //servletRequest.addHeader(HttpHeader.CONTENT_LENGTH, 3L); //When we validate the request - validator.validate(HttpMethod.PATCH, servletRequest, uploadStorageService, null); + try { + validator.validate(HttpMethod.PATCH, servletRequest, uploadStorageService, null); + } catch (Exception ex) { + fail(); + } //No Exception is thrown } @@ -155,7 +163,11 @@ public void validateMissingUploadInfo() throws Exception { servletRequest.addHeader(HttpHeader.CONTENT_LENGTH, 3L); //When we validate the request - validator.validate(HttpMethod.PATCH, servletRequest, uploadStorageService, null); + try { + validator.validate(HttpMethod.PATCH, servletRequest, uploadStorageService, null); + } catch (Exception ex) { + fail(); + } //No Exception is thrown } diff --git a/src/test/java/me/desair/tus/server/core/validation/ContentTypeValidatorTest.java b/src/test/java/me/desair/tus/server/core/validation/ContentTypeValidatorTest.java index d05562a..09e6167 100644 --- a/src/test/java/me/desair/tus/server/core/validation/ContentTypeValidatorTest.java +++ b/src/test/java/me/desair/tus/server/core/validation/ContentTypeValidatorTest.java @@ -2,6 +2,7 @@ import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.Assert.fail; import me.desair.tus.server.HttpHeader; import me.desair.tus.server.HttpMethod; @@ -27,7 +28,11 @@ public void setUp() { public void validateValid() throws Exception { servletRequest.addHeader(HttpHeader.CONTENT_TYPE, ContentTypeValidator.APPLICATION_OFFSET_OCTET_STREAM); - validator.validate(HttpMethod.PATCH, servletRequest, null, null); + try { + validator.validate(HttpMethod.PATCH, servletRequest, null, null); + } catch (Exception ex) { + fail(); + } //No exception is thrown } diff --git a/src/test/java/me/desair/tus/server/core/validation/HttpMethodValidatorTest.java b/src/test/java/me/desair/tus/server/core/validation/HttpMethodValidatorTest.java index da04fe0..8a509ca 100644 --- a/src/test/java/me/desair/tus/server/core/validation/HttpMethodValidatorTest.java +++ b/src/test/java/me/desair/tus/server/core/validation/HttpMethodValidatorTest.java @@ -2,6 +2,7 @@ import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.Assert.fail; import me.desair.tus.server.HttpMethod; import me.desair.tus.server.exception.UnsupportedMethodException; @@ -26,7 +27,11 @@ public void setUp() { @Test public void validateValid() throws Exception { - validator.validate(HttpMethod.POST, servletRequest, uploadStorageService, null); + try { + validator.validate(HttpMethod.POST, servletRequest, uploadStorageService, null); + } catch (Exception ex) { + fail(); + } } @Test(expected = UnsupportedMethodException.class) diff --git a/src/test/java/me/desair/tus/server/core/validation/UploadOffsetValidatorTest.java b/src/test/java/me/desair/tus/server/core/validation/UploadOffsetValidatorTest.java index 6a132d8..f5705e5 100644 --- a/src/test/java/me/desair/tus/server/core/validation/UploadOffsetValidatorTest.java +++ b/src/test/java/me/desair/tus/server/core/validation/UploadOffsetValidatorTest.java @@ -44,7 +44,11 @@ public void validateValidOffsetInitialUpload() throws Exception { servletRequest.addHeader(HttpHeader.UPLOAD_OFFSET, 0L); //When we validate the request - validator.validate(HttpMethod.PATCH, servletRequest, uploadStorageService, null); + try { + validator.validate(HttpMethod.PATCH, servletRequest, uploadStorageService, null); + } catch (Exception ex) { + fail(); + } //No Exception is thrown } diff --git a/src/test/java/me/desair/tus/server/creation/validation/PostEmptyRequestValidatorTest.java b/src/test/java/me/desair/tus/server/creation/validation/PostEmptyRequestValidatorTest.java index 4fbb2aa..0b20c9e 100644 --- a/src/test/java/me/desair/tus/server/creation/validation/PostEmptyRequestValidatorTest.java +++ b/src/test/java/me/desair/tus/server/creation/validation/PostEmptyRequestValidatorTest.java @@ -41,7 +41,11 @@ public void validateMissingContentLength() throws Exception { //servletRequest.addHeader(HttpHeader.CONTENT_LENGTH, 3L); //When we validate the request - validator.validate(HttpMethod.POST, servletRequest, null, null); + try { + validator.validate(HttpMethod.POST, servletRequest, null, null); + } catch (Exception ex) { + fail(); + } //No Exception is thrown } diff --git a/src/test/java/me/desair/tus/server/creation/validation/PostURIValidatorTest.java b/src/test/java/me/desair/tus/server/creation/validation/PostURIValidatorTest.java index e4890c6..ffc785c 100644 --- a/src/test/java/me/desair/tus/server/creation/validation/PostURIValidatorTest.java +++ b/src/test/java/me/desair/tus/server/creation/validation/PostURIValidatorTest.java @@ -2,6 +2,7 @@ import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.Assert.fail; import static org.mockito.Mockito.when; import me.desair.tus.server.HttpMethod; @@ -47,7 +48,11 @@ public void validateMatchingUrl() throws Exception { servletRequest.setRequestURI("/test/upload"); when(uploadStorageService.getUploadURI()).thenReturn("/test/upload"); - validator.validate(HttpMethod.POST, servletRequest, uploadStorageService, null); + try { + validator.validate(HttpMethod.POST, servletRequest, uploadStorageService, null); + } catch (Exception ex) { + fail(); + } //No Exception is thrown } diff --git a/src/test/java/me/desair/tus/server/creation/validation/UploadDeferLengthValidatorTest.java b/src/test/java/me/desair/tus/server/creation/validation/UploadDeferLengthValidatorTest.java index f5cf4aa..aa43a6d 100644 --- a/src/test/java/me/desair/tus/server/creation/validation/UploadDeferLengthValidatorTest.java +++ b/src/test/java/me/desair/tus/server/creation/validation/UploadDeferLengthValidatorTest.java @@ -105,7 +105,11 @@ public void validateUploadLengthNotPresentOnFinal() throws Exception { servletRequest.addHeader(HttpHeader.UPLOAD_CONCAT, "final;1234 5678"); //When we validate the request - validator.validate(HttpMethod.POST, servletRequest, null, null); + try { + validator.validate(HttpMethod.POST, servletRequest, null, null); + } catch (Exception ex) { + fail(); + } //No Exception is thrown }