cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r758823 - in /cxf/trunk/rt/frontend/jaxrs/src: main/java/org/apache/cxf/jaxrs/impl/ResponseBuilderImpl.java test/java/org/apache/cxf/jaxrs/impl/ResponseBuilderImplTest.java
Date Thu, 26 Mar 2009 19:57:51 GMT
Author: sergeyb
Date: Thu Mar 26 19:57:51 2009
New Revision: 758823

URL: http://svn.apache.org/viewvc?rev=758823&view=rev
Log:
Fixes for CXF-2133, CXF-2134

Modified:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseBuilderImpl.java
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/ResponseBuilderImplTest.java

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseBuilderImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseBuilderImpl.java?rev=758823&r1=758822&r2=758823&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseBuilderImpl.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseBuilderImpl.java
Thu Mar 26 19:57:51 2009
@@ -20,6 +20,7 @@
 package org.apache.cxf.jaxrs.impl;
 
 import java.net.URI;
+import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.List;
 import java.util.Locale;
@@ -34,6 +35,8 @@
 import javax.ws.rs.core.Response.ResponseBuilder;
 import javax.ws.rs.core.Variant;
 
+import org.apache.cxf.jaxrs.utils.HttpUtils;
+
 public final class ResponseBuilderImpl extends ResponseBuilder {
     private int status = 200;
     private Object entity;
@@ -117,15 +120,15 @@
     }
 
     @Override
-    public ResponseBuilder expires(Date expires) {
-        metadata.putSingle(HttpHeaders.EXPIRES, expires.toString());
-        return null;
+    public ResponseBuilder expires(Date date) {
+        metadata.putSingle(HttpHeaders.EXPIRES, toHttpDate(date));
+        return this;
     }
 
     @Override
     public ResponseBuilder language(Locale language) {
         metadata.putSingle(HttpHeaders.CONTENT_LANGUAGE, language.toString());
-        return null;
+        return this;
     }
     
     @Override
@@ -177,4 +180,8 @@
         status = 200;
     }
     
+    private String toHttpDate(Date date) {
+        SimpleDateFormat format = HttpUtils.getHttpDateFormat();
+        return format.format(date);
+    }
 }

Modified: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/ResponseBuilderImplTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/ResponseBuilderImplTest.java?rev=758823&r1=758822&r2=758823&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/ResponseBuilderImplTest.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/ResponseBuilderImplTest.java
Thu Mar 26 19:57:51 2009
@@ -20,16 +20,36 @@
 package org.apache.cxf.jaxrs.impl;
 
 import java.net.URI;
+import java.text.SimpleDateFormat;
+import java.util.Date;
 
 import javax.ws.rs.core.Response;
 
+import org.apache.cxf.jaxrs.utils.HttpUtils;
+
 import org.junit.Assert;
 import org.junit.Test;
 
 
 public class ResponseBuilderImplTest extends Assert {
 
-        
+    
+    @Test
+    public void testLanguage() {
+        MetadataMap<String, Object> m = new MetadataMap<String, Object>();
+        m.putSingle("Content-Language", "de");
+        checkBuild(Response.ok().language("de").build(), 200, null, m);
+    }
+    
+    @Test
+    public void testExpires() throws Exception {
+        MetadataMap<String, Object> m = new MetadataMap<String, Object>();
+        m.putSingle("Expires", "Tue, 21 Oct 2008 17:00:00 GMT");
+        SimpleDateFormat format = HttpUtils.getHttpDateFormat();
+        Date date = format.parse("Tue, 21 Oct 2008 17:00:00 GMT");
+        checkBuild(Response.ok().expires(date).build(), 200, null, m);
+    }
+    
     @Test
     public void testOkBuild() {
       



Mime
View raw message