struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lukaszlen...@apache.org
Subject [04/50] [abbrv] struts git commit: make test passed for people not using GMT.
Date Fri, 15 Jul 2016 13:18:31 GMT
make test passed for people not using GMT.


Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/49a7fe14
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/49a7fe14
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/49a7fe14

Branch: refs/heads/master
Commit: 49a7fe14d57c5dd607dee9d99d94a796f0b37c11
Parents: cee303a
Author: donghui <hui.dong@hpe.com>
Authored: Mon Jan 4 11:23:51 2016 +0800
Committer: Lukasz Lenart <lukasz.lenart@gmail.com>
Committed: Tue Jan 19 16:17:09 2016 +0100

----------------------------------------------------------------------
 .../apache/struts2/rest/DefaultHttpHeadersTest.java | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/struts/blob/49a7fe14/plugins/rest/src/test/java/org/apache/struts2/rest/DefaultHttpHeadersTest.java
----------------------------------------------------------------------
diff --git a/plugins/rest/src/test/java/org/apache/struts2/rest/DefaultHttpHeadersTest.java
b/plugins/rest/src/test/java/org/apache/struts2/rest/DefaultHttpHeadersTest.java
index 57e9d67..d800536 100644
--- a/plugins/rest/src/test/java/org/apache/struts2/rest/DefaultHttpHeadersTest.java
+++ b/plugins/rest/src/test/java/org/apache/struts2/rest/DefaultHttpHeadersTest.java
@@ -27,6 +27,8 @@ import org.springframework.mock.web.MockHttpServletResponse;
 
 import java.text.SimpleDateFormat;
 import java.util.Date;
+import java.util.Locale;
+import java.util.TimeZone;
 
 import static javax.servlet.http.HttpServletResponse.*;
 
@@ -130,7 +132,7 @@ public class DefaultHttpHeadersTest extends TestCase {
         Date now = new Date();
         DefaultHttpHeaders headers = new DefaultHttpHeaders()
                 .lastModified(now);
-        mockRequest.addHeader("If-Modified-Since", new SimpleDateFormat("EEE, dd MMM yyyy
HH:mm:ss zzz").format(now));
+        mockRequest.addHeader("If-Modified-Since", getGMTDateFormat().format(now));
         headers.apply(mockRequest, mockResponse, new Object());
 
         assertEquals(SC_NOT_MODIFIED, mockResponse.getStatus());
@@ -149,7 +151,7 @@ public class DefaultHttpHeadersTest extends TestCase {
     public void testLastModifiedSince() {
         Date now = new Date();
         DefaultHttpHeaders headers = new DefaultHttpHeaders().lastModified(now);
-        mockRequest.addHeader("If-Modified-Since", new SimpleDateFormat("EEE, dd MMM yyyy
HH:mm:ss zzz").format(now));
+        mockRequest.addHeader("If-Modified-Since", getGMTDateFormat().format(now));
         headers.apply(mockRequest, mockResponse, new Object());
 
         assertEquals(SC_NOT_MODIFIED, mockResponse.getStatus());
@@ -158,7 +160,7 @@ public class DefaultHttpHeadersTest extends TestCase {
     public void testLastModifiedSinceIsOlder() {
         Date now = new Date();
         DefaultHttpHeaders headers = new DefaultHttpHeaders().lastModified(now);
-        mockRequest.addHeader("If-Modified-Since", new SimpleDateFormat("EEE, dd MMM yyyy
HH:mm:ss zzz").format(new Date(now.getTime() - 1000 * 60 * 60)));
+        mockRequest.addHeader("If-Modified-Since", getGMTDateFormat().format(new Date(now.getTime()
- 1000 * 60 * 60)));
         headers.apply(mockRequest, mockResponse, new Object());
 
         assertEquals(SC_NOT_MODIFIED, mockResponse.getStatus());
@@ -170,7 +172,7 @@ public class DefaultHttpHeadersTest extends TestCase {
                 .lastModified(now)
                 .withETag("asdf");
         mockRequest.addHeader("If-None-Match", "asdf");
-        mockRequest.addHeader("If-Modified-Since", new SimpleDateFormat("EEE, dd MMM yyyy
HH:mm:ss zzz").format(now));
+        mockRequest.addHeader("If-Modified-Since", getGMTDateFormat().format(now));
         headers.apply(mockRequest, mockResponse, new Object());
 
         assertEquals(SC_NOT_MODIFIED, mockResponse.getStatus());
@@ -216,4 +218,10 @@ public class DefaultHttpHeadersTest extends TestCase {
         assertEquals(SC_OK, mockResponse.getStatus());
 
     }
+    
+    private SimpleDateFormat getGMTDateFormat() {
+        SimpleDateFormat format = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US);
+        format.setTimeZone(TimeZone.getTimeZone("GMT"));
+        return format;
+    }
 }


Mime
View raw message