wink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b...@apache.org
Subject svn commit: r939754 - in /incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src: main/java/org/apache/wink/itest/request/ test/java/org/apache/wink/itest/request/
Date Fri, 30 Apr 2010 17:37:47 GMT
Author: bluk
Date: Fri Apr 30 17:37:46 2010
New Revision: 939754

URL: http://svn.apache.org/viewvc?rev=939754&view=rev
Log:
Update Request tests to hopefully simplify

Modified:
    incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/main/java/org/apache/wink/itest/request/RequestResource.java
    incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/request/RequestMethodsTest.java
    incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/request/WinkRequestMethodsTest.java

Modified: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/main/java/org/apache/wink/itest/request/RequestResource.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/main/java/org/apache/wink/itest/request/RequestResource.java?rev=939754&r1=939753&r2=939754&view=diff
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/main/java/org/apache/wink/itest/request/RequestResource.java
(original)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/main/java/org/apache/wink/itest/request/RequestResource.java
Fri Apr 30 17:37:46 2010
@@ -60,7 +60,8 @@ public class RequestResource {
     @GET
     @Path("timezone")
     public String getTimeZone() {
-        return TimeZone.getDefault().getDisplayName(false, TimeZone.SHORT);
+        boolean dst = TimeZone.getDefault().inDaylightTime(new Date());
+        return TimeZone.getDefault().getDisplayName(dst, TimeZone.SHORT);
     }
 
     @GET
@@ -72,10 +73,18 @@ public class RequestResource {
         if (date == null) {
             return Response.serverError().build();
         }
+        System.out.println("GET Date: " + date);
         ResponseBuilder respBuilder = req.evaluatePreconditions(date);
         if (respBuilder != null) {
+            System.out.println("Returning 304");
             return respBuilder.build();
         }
+        System.out.println("Returning 200");
+        SimpleDateFormat rfc1123Format =
+            new SimpleDateFormat(
+                                 "EEE, dd MMM yyyy HH:mm:ss zzz",
+                                 Locale.ENGLISH);
+        rfc1123Format.setTimeZone(TimeZone.getTimeZone("GMT"));
         return Response.ok("the date: " + rfc1123Format.format(date)).lastModified(date).build();
     }
 
@@ -86,7 +95,10 @@ public class RequestResource {
             throw new WebApplicationException();
         }
         try {
-            date = DateFormat.getDateTimeInstance().parse(dateSource);
+            date = new SimpleDateFormat(
+                                                   "EEE, dd MMM yyyy HH:mm:ss zzz",
+                                                   Locale.ENGLISH).parse(dateSource);
+            System.out.println("PUT Date: " + date);
         } catch (ParseException e) {
             throw new WebApplicationException(e);
         }

Modified: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/request/RequestMethodsTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/request/RequestMethodsTest.java?rev=939754&r1=939753&r2=939754&view=diff
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/request/RequestMethodsTest.java
(original)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/request/RequestMethodsTest.java
Fri Apr 30 17:37:46 2010
@@ -142,8 +142,9 @@ public class RequestMethodsTest extends 
         PutMethod putMethod = new PutMethod(getBaseURI() + "/context/request/date");
         Date d2 = new Date(System.currentTimeMillis() - 120000);
         Date d = new Date(System.currentTimeMillis() - 60000);
-        DateFormat dateFormat = DateFormat.getDateTimeInstance();
-        dateFormat.setTimeZone(TimeZone.getTimeZone(serverTimeZone));
+        DateFormat dateFormat = new SimpleDateFormat(
+                                                     "EEE, dd MMM yyyy HH:mm:ss zzz",
+                                                     Locale.ENGLISH); // DateFormat.getDateTimeInstance();
         String date = dateFormat.format(d);
         putMethod.setRequestEntity(new StringRequestEntity(date, "text/string", "UTF-8"));
         try {
@@ -183,8 +184,6 @@ public class RequestMethodsTest extends 
             rfc1123Format.setTimeZone(TimeZone.getTimeZone(serverTimeZone));
             assertEquals("the date: " + rfc1123Format.format(d), getMethod
                 .getResponseBodyAsString());
-            rfc1123Format.setTimeZone(TimeZone.getDefault());
-
             rfc1123Format.setTimeZone(TimeZone.getTimeZone("GMT"));
             assertEquals(rfc1123Format.format(d), getMethod.getResponseHeader("Last-Modified")
                 .getValue());
@@ -222,8 +221,6 @@ public class RequestMethodsTest extends 
             rfc1123Format.setTimeZone(TimeZone.getTimeZone(serverTimeZone));
             assertEquals("the date: " + rfc1123Format.format(d), getMethod
                 .getResponseBodyAsString());
-            rfc1123Format.setTimeZone(TimeZone.getDefault());
-
             rfc1123Format.setTimeZone(TimeZone.getTimeZone("GMT"));
             assertEquals(rfc1123Format.format(d), getMethod.getResponseHeader("Last-Modified")
                 .getValue());
@@ -304,8 +301,9 @@ public class RequestMethodsTest extends 
         PutMethod putMethod = new PutMethod(getBaseURI() + "/context/request/date");
         Date d2 = new Date(System.currentTimeMillis() - 120000);
         Date d = new Date(System.currentTimeMillis() - 60000);
-        DateFormat dateFormat = DateFormat.getDateTimeInstance();
-        dateFormat.setTimeZone(TimeZone.getTimeZone(serverTimeZone));
+        DateFormat dateFormat = new SimpleDateFormat(
+                                                     "EEE, dd MMM yyyy HH:mm:ss zzz",
+                                                     Locale.ENGLISH); // DateFormat.getDateTimeInstance();
         String date = dateFormat.format(d);
         putMethod.setRequestEntity(new StringRequestEntity(date, "text/string", "UTF-8"));
         try {
@@ -354,8 +352,6 @@ public class RequestMethodsTest extends 
             rfc1123Format.setTimeZone(TimeZone.getTimeZone(serverTimeZone));
             assertEquals("the date: " + rfc1123Format.format(d), getMethod
                 .getResponseBodyAsString());
-            rfc1123Format.setTimeZone(TimeZone.getDefault());
-
             rfc1123Format.setTimeZone(TimeZone.getTimeZone("GMT"));
             assertEquals(rfc1123Format.format(d), getMethod.getResponseHeader("Last-Modified")
                 .getValue());

Modified: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/request/WinkRequestMethodsTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/request/WinkRequestMethodsTest.java?rev=939754&r1=939753&r2=939754&view=diff
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/request/WinkRequestMethodsTest.java
(original)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/request/WinkRequestMethodsTest.java
Fri Apr 30 17:37:46 2010
@@ -129,7 +129,7 @@ public class WinkRequestMethodsTest exte
         throws IOException, HttpException {
         Date d2 = new Date(System.currentTimeMillis() - 120000);
         Date d = new Date(System.currentTimeMillis() - 60000);
-       
+
         /*
          * get the time zone for the server
          */
@@ -137,13 +137,13 @@ public class WinkRequestMethodsTest exte
         ClientResponse response = dateResource.get();
         assertEquals(200, response.getStatusCode());
         String serverTimeZone = response.getEntity(String.class);
-        
+
         /*
          * sets a last modified date
          */
         dateResource = client.resource(getBaseURI() + "/context/request/date");
-        DateFormat dateFormat = DateFormat.getDateTimeInstance();
-        dateFormat.setTimeZone(TimeZone.getTimeZone(serverTimeZone));
+        DateFormat dateFormat =
+            new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.ENGLISH); // DateFormat.getDateTimeInstance();
         response = dateResource.contentType("text/string").put(dateFormat.format(d));
         assertEquals(204, response.getStatusCode());
 
@@ -165,8 +165,6 @@ public class WinkRequestMethodsTest exte
         assertEquals(200, response.getStatusCode());
         rfc1123Format.setTimeZone(TimeZone.getTimeZone(serverTimeZone));
         assertEquals("the date: " + rfc1123Format.format(d), response.getEntity(String.class));
-        rfc1123Format.setTimeZone(TimeZone.getDefault());
-
         rfc1123Format.setTimeZone(TimeZone.getTimeZone("GMT"));
         assertEquals(rfc1123Format.format(d), response.getHeaders()
             .getFirst(HttpHeaders.LAST_MODIFIED));
@@ -250,16 +248,16 @@ public class WinkRequestMethodsTest exte
         throws IOException, HttpException {
         Date d2 = new Date(System.currentTimeMillis() - 120000);
         Date d = new Date(System.currentTimeMillis() - 60000);
-        
+
         /*
          * get the time zone for the server
          */
         ClientResponse response = client.resource(getBaseURI() + "/context/request/timezone").get();
         assertEquals(200, response.getStatusCode());
         String serverTimeZone = response.getEntity(String.class);
-        
-        DateFormat dateFormat = DateFormat.getDateTimeInstance();
-        dateFormat.setTimeZone(TimeZone.getTimeZone(serverTimeZone));
+
+        DateFormat dateFormat =
+            new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.ENGLISH); // DateFormat.getDateTimeInstance();
         response =
             client.resource(getBaseURI() + "/context/request/date").contentType("text/string")
                 .put(dateFormat.format(d));



Mime
View raw message