tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hls...@apache.org
Subject svn commit: r280224 - in /jakarta/tapestry/trunk: ./ framework/src/java/org/apache/tapestry/web/ framework/src/test/org/apache/tapestry/web/ portlet/src/java/org/apache/tapestry/portlet/ portlet/src/test/org/apache/tapestry/portlet/
Date Mon, 12 Sep 2005 00:43:48 GMT
Author: hlship
Date: Sun Sep 11 17:43:39 2005
New Revision: 280224

URL: http://svn.apache.org/viewcvs?rev=280224&view=rev
Log:
TAPESTRY-569: WebResponse does not expose a way to set headers

Modified:
    jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/web/ServletWebResponse.java
    jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/web/WebRequest.java
    jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/web/WebResponse.java
    jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/web/TestServletWebResponse.java
    jakarta/tapestry/trunk/portlet/src/java/org/apache/tapestry/portlet/PortletWebResponse.java
    jakarta/tapestry/trunk/portlet/src/test/org/apache/tapestry/portlet/TestPortletWebResponse.java
    jakarta/tapestry/trunk/status.xml

Modified: jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/web/ServletWebResponse.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/web/ServletWebResponse.java?rev=280224&r1=280223&r2=280224&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/web/ServletWebResponse.java
(original)
+++ jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/web/ServletWebResponse.java
Sun Sep 11 17:43:39 2005
@@ -123,4 +123,15 @@
     {
         _servletResponse.setStatus(status);
     }
+
+    public void setHeader(String name, String value)
+    {
+        _servletResponse.setHeader(name, value);
+    }
+
+    public void setIntHeader(String name, int value)
+    {
+        _servletResponse.setIntHeader(name, value);
+    }
+
 }

Modified: jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/web/WebRequest.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/web/WebRequest.java?rev=280224&r1=280223&r2=280224&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/web/WebRequest.java (original)
+++ jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/web/WebRequest.java Sun
Sep 11 17:43:39 2005
@@ -14,6 +14,7 @@
 
 package org.apache.tapestry.web;
 
+import java.security.Principal;
 import java.util.List;
 import java.util.Locale;
 
@@ -21,7 +22,9 @@
 
 /**
  * Contains information about the current request, including URLs, schemes, parameters, properties
- * and attributes.
+ * and attributes. This is essentially a generic version of
+ * {@link javax.servlet.http.HttpServletRequest}. In some cases, certain methods will be
+ * unsupported in some implementations (such as {@link #getHeader(String)} for Portlet Tapestry).
  * 
  * @author Howard M. Lewis Ship
  * @since 4.0
@@ -96,7 +99,7 @@
     /**
      * Returns the host name of the server that received the request. Note that behind a
firewall,
      * this may be obscured (i.e., it may be the name of the firewall server, which is not
-     * necessarily visible to clients outside the firewall.
+     * necessarily visible to clients outside the firewall).
      * 
      * @see org.apache.tapestry.request.IRequestDecoder
      */
@@ -167,7 +170,7 @@
      * @return a java.security.Principal containing the name of the user making this request,
or
      *         null if the user has not been authenticated.
      */
-    public java.security.Principal getUserPrincipal();
+    public Principal getUserPrincipal();
 
     /**
      * * Returns a boolean indicating whether the authenticated user is included in the specified
@@ -179,5 +182,5 @@
      * @return a boolean indicating whether the user making this request belongs to a given
role;
      *         false if the user has not been authenticated.
      */
-    public boolean isUserInRole(java.lang.String role);
+    public boolean isUserInRole(String role);
 }

Modified: jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/web/WebResponse.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/web/WebResponse.java?rev=280224&r1=280223&r2=280224&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/web/WebResponse.java (original)
+++ jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/web/WebResponse.java Sun
Sep 11 17:43:39 2005
@@ -22,7 +22,10 @@
 
 /**
  * Controls the response to the client, and specifically allows for creating the output stream
(or
- * print writer) to which content is sent.
+ * print writer) to which content is sent. This is essentially a generic version of
+ * {@link javax.servlet.http.HttpServletResponse}. Some operations may be unsupported in
some
+ * implementations (for example, the portlet implementation can't handle any of the setHeader
+ * methods).
  * 
  * @author Howard M. Lewis Ship
  * @since 4.0
@@ -39,7 +42,7 @@
     public OutputStream getOutputStream(ContentType contentType) throws IOException;
 
     /**
-     * Returns a {@link PrintWriter}to which output should be sent. This method should be
invoked
+     * Returns a {@link PrintWriter} to which output should be sent. This method should be
invoked
      * once on a response. A second call is expected to be so that an exception page can
be
      * rendered, and the underlying request data is reset.
      */
@@ -74,12 +77,33 @@
     /**
      * Sets a response header as a date.
      * 
-     * @param string
-     *            the name of the header to set.
+     * @param name
+     *            the name of the header to set
      * @param date
-     *            the date value to set, in milliseconds since the epoch.
+     *            the date value to set, in milliseconds since the epoch
      */
-    public void setDateHeader(String string, long date);
+    public void setDateHeader(String name, long date);
+
+    /**
+     * Sets a response header as a string.
+     * 
+     * @param name
+     *            the name of the header to set
+     * @param value
+     *            the value for the named header
+     */
+
+    public void setHeader(String name, String value);
+
+    /**
+     * Sets a response header with the given name and integer value.
+     * 
+     * @param name
+     *            the name of the header to set
+     * @param value
+     *            the value for the named header
+     */
+    public void setIntHeader(String name, int value);
 
     /**
      * Sets the status code for this response.

Modified: jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/web/TestServletWebResponse.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/web/TestServletWebResponse.java?rev=280224&r1=280223&r2=280224&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/web/TestServletWebResponse.java
(original)
+++ jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/web/TestServletWebResponse.java
Sun Sep 11 17:43:39 2005
@@ -24,7 +24,6 @@
 import org.apache.hivemind.ApplicationRuntimeException;
 import org.apache.hivemind.test.HiveMindTestCase;
 import org.apache.tapestry.util.ContentType;
-import org.easymock.MockControl;
 
 /**
  * Tests for {@link org.apache.tapestry.web.ServletWebResponse}.
@@ -43,14 +42,13 @@
 
     public void testGetOutputStream() throws Exception
     {
-        MockControl control = newControl(HttpServletResponse.class);
-        HttpServletResponse response = (HttpServletResponse) control.getMock();
+        HttpServletResponse response = newResponse();
 
         ServletOutputStream stream = new MockServletOutputStream();
 
         response.setContentType("foo/bar");
         response.getOutputStream();
-        control.setReturnValue(stream);
+        getControl(response).setReturnValue(stream);
 
         replayControls();
 
@@ -63,14 +61,13 @@
 
     public void testGetOutputStreamFailure() throws Exception
     {
-        MockControl control = newControl(HttpServletResponse.class);
-        HttpServletResponse response = (HttpServletResponse) control.getMock();
+        HttpServletResponse response = newResponse();
 
         Throwable t = new IOException("Simulated failure.");
 
         response.setContentType("foo/bar");
         response.getOutputStream();
-        control.setThrowable(t);
+        getControl(response).setThrowable(t);
 
         replayControls();
 
@@ -94,12 +91,11 @@
     {
         PrintWriter writer = new PrintWriter(new CharArrayWriter());
 
-        MockControl control = newControl(HttpServletResponse.class);
-        HttpServletResponse response = (HttpServletResponse) control.getMock();
+        HttpServletResponse response = newResponse();
 
         response.setContentType("foo/bar");
         response.getWriter();
-        control.setReturnValue(writer);
+        getControl(response).setReturnValue(writer);
 
         replayControls();
 
@@ -115,12 +111,11 @@
         PrintWriter writer1 = new PrintWriter(new CharArrayWriter());
         PrintWriter writer2 = new PrintWriter(new CharArrayWriter());
 
-        MockControl control = newControl(HttpServletResponse.class);
-        HttpServletResponse response = (HttpServletResponse) control.getMock();
+        HttpServletResponse response = newResponse();
 
         response.setContentType("foo/bar");
         response.getWriter();
-        control.setReturnValue(writer1);
+        getControl(response).setReturnValue(writer1);
 
         replayControls();
 
@@ -133,7 +128,7 @@
         response.reset();
         response.setContentType("zip/zap");
         response.getWriter();
-        control.setReturnValue(writer2);
+        getControl(response).setReturnValue(writer2);
 
         replayControls();
 
@@ -144,14 +139,13 @@
 
     public void testGetPrintWriterFailure() throws Exception
     {
-        MockControl control = newControl(HttpServletResponse.class);
-        HttpServletResponse response = (HttpServletResponse) control.getMock();
+        HttpServletResponse response = newResponse();
 
         Throwable t = new IOException("Simulated failure.");
 
         response.setContentType("foo/bar");
         response.getWriter();
-        control.setThrowable(t);
+        getControl(response).setThrowable(t);
 
         replayControls();
 
@@ -173,8 +167,7 @@
 
     public void testReset()
     {
-        MockControl control = newControl(HttpServletResponse.class);
-        HttpServletResponse response = (HttpServletResponse) control.getMock();
+        HttpServletResponse response = newResponse();
 
         response.reset();
 
@@ -185,6 +178,31 @@
         swr.reset();
 
         verifyControls();
+    }
+
+    private HttpServletResponse newResponse()
+    {
+        return (HttpServletResponse) newMock(HttpServletResponse.class);
+    }
+
+    public void testSetHeaderMethods()
+    {
+        HttpServletResponse response = newResponse();
+
+        response.setHeader("fie", "fie");
+        response.setDateHeader("expires", -1);
+        response.setIntHeader("size", 33);
+
+        replayControls();
+
+        ServletWebResponse swr = new ServletWebResponse(response);
+
+        swr.setHeader("fie", "fie");
+        swr.setDateHeader("expires", -1);
+        swr.setIntHeader("size", 33);
+
+        verifyControls();
+
     }
 
 }

Modified: jakarta/tapestry/trunk/portlet/src/java/org/apache/tapestry/portlet/PortletWebResponse.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/portlet/src/java/org/apache/tapestry/portlet/PortletWebResponse.java?rev=280224&r1=280223&r2=280224&view=diff
==============================================================================
--- jakarta/tapestry/trunk/portlet/src/java/org/apache/tapestry/portlet/PortletWebResponse.java
(original)
+++ jakarta/tapestry/trunk/portlet/src/java/org/apache/tapestry/portlet/PortletWebResponse.java
Sun Sep 11 17:43:39 2005
@@ -98,4 +98,16 @@
         unsupported("setStatus");
     }
 
+    /** Unsupported. */
+    public void setHeader(String name, String value)
+    {
+        unsupported("setHeader");
+    }
+
+    /** Unsupported. */
+    public void setIntHeader(String name, int value)
+    {
+        unsupported("setIntHeader");
+    }
+
 }

Modified: jakarta/tapestry/trunk/portlet/src/test/org/apache/tapestry/portlet/TestPortletWebResponse.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/portlet/src/test/org/apache/tapestry/portlet/TestPortletWebResponse.java?rev=280224&r1=280223&r2=280224&view=diff
==============================================================================
--- jakarta/tapestry/trunk/portlet/src/test/org/apache/tapestry/portlet/TestPortletWebResponse.java
(original)
+++ jakarta/tapestry/trunk/portlet/src/test/org/apache/tapestry/portlet/TestPortletWebResponse.java
Sun Sep 11 17:43:39 2005
@@ -87,6 +87,69 @@
         verifyControls();
     }
 
+    public void testSetDateHeaderUnsupported()
+    {
+        PortletResponse response = newResponse();
+
+        replayControls();
+
+        PortletWebResponse pwr = new PortletWebResponse(response);
+
+        try
+        {
+            pwr.setDateHeader(null, 0);
+            unreachable();
+        }
+        catch (UnsupportedOperationException ex)
+        {
+            // Expected.
+        }
+
+        verifyControls();
+    }
+
+    public void testSetHeaderUnsupported()
+    {
+        PortletResponse response = newResponse();
+
+        replayControls();
+
+        PortletWebResponse pwr = new PortletWebResponse(response);
+
+        try
+        {
+            pwr.setHeader(null, null);
+            unreachable();
+        }
+        catch (UnsupportedOperationException ex)
+        {
+            // Expected.
+        }
+
+        verifyControls();
+    }
+
+    public void testSetIntHeaderUnsupported()
+    {
+        PortletResponse response = newResponse();
+
+        replayControls();
+
+        PortletWebResponse pwr = new PortletWebResponse(response);
+
+        try
+        {
+            pwr.setIntHeader(null, 0);
+            unreachable();
+        }
+        catch (UnsupportedOperationException ex)
+        {
+            // Expected.
+        }
+
+        verifyControls();
+    }
+
     public void testEncodeURL()
     {
         MockControl control = newControl(PortletResponse.class);

Modified: jakarta/tapestry/trunk/status.xml
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/status.xml?rev=280224&r1=280223&r2=280224&view=diff
==============================================================================
--- jakarta/tapestry/trunk/status.xml (original)
+++ jakarta/tapestry/trunk/status.xml Sun Sep 11 17:43:39 2005
@@ -68,6 +68,7 @@
       <action type="fix" dev="MB" fixes-bug="TAPESTRY-484">Document ServiceLink component</action>
       <action type="fix" dev="HLS" fixes-bug="TAPESTRY-579">Using component types with
slashes in the HTML template fails</action>
       <action type="fix" dev="HLS" fixes-bug="TAPESTRY-595">Resource prefixes not honored
inside &lt;page&gt;'s specification-path attribute</action>
+      <action type="fix" dev="HLS" fixes-bug="TAPESTRY-569">WebResponse does not expose
a way to set headers</action>
     </release>
     <release version="4.0-beta-6" date="Sep 7 2005">
       <action type="update" dev="HLS" due-to="Henri Yandell">Convert Tapestry repository
from CVS to SVN</action>



---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org


Mime
View raw message