Author: julien(a)jboss.com
Date: 2008-01-31 08:38:03 -0500 (Thu, 31 Jan 2008)
New Revision: 9685
Added:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletrequests/LifeCyclePhaseRequestAttributeTestCase.java
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/APIConstants.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletContainerImpl.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletrequests/WindowIDTestCase.java
modules/portlet/trunk/test/src/test/resources/jsr286/tck/portletrequests-war/WEB-INF/portlet.xml
Log:
- implemented request life cycle attribute
- added test case for request life cycle attribute
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/APIConstants.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/APIConstants.java 2008-01-31
13:17:54 UTC (rev 9684)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/APIConstants.java 2008-01-31
13:38:03 UTC (rev 9685)
@@ -28,33 +28,24 @@
*/
public interface APIConstants
{
- /**
- *
- */
+ /** . */
String JAVAX_PORTLET_TITLE = "javax.portlet.title";
- /**
- *
- */
+ /** . */
String JAVAX_PORTLET_SHORT_TITLE = "javax.portlet.short-title";
- /**
- *
- */
+ /** . */
String JAVAX_PORTLET_KEYWORDS = "javax.portlet.keywords";
- /**
- *
- */
+ /** . */
String JAVAX_PORTLET_CONFIG = "javax.portlet.config";
- /**
- *
- */
+ /** . */
String JAVAX_PORTLET_REQUEST = "javax.portlet.request";
- /**
- *
- */
+ /** . */
String JAVAX_PORTLET_RESPONSE = "javax.portlet.response";
+
+ /** . */
+ String JAVAX_PORTLET_LIFECYCLE_PHASE = "javax.portlet.lifecycle_phase";
}
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletContainerImpl.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletContainerImpl.java 2008-01-31
13:17:54 UTC (rev 9684)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletContainerImpl.java 2008-01-31
13:38:03 UTC (rev 9685)
@@ -417,6 +417,7 @@
dreq.setAttribute(APIConstants.JAVAX_PORTLET_CONFIG, config);
dreq.setAttribute(APIConstants.JAVAX_PORTLET_REQUEST, req);
dreq.setAttribute(APIConstants.JAVAX_PORTLET_RESPONSE, resp);
+ dreq.setAttribute(APIConstants.JAVAX_PORTLET_LIFECYCLE_PHASE,
"ACTION_PHASE");
dreq.setAttribute(ContextDispatcherInterceptor.REQ_ATT_COMPONENT_INVOCATION,
invocation);
portlet.processAction(req, resp);
}
@@ -425,6 +426,7 @@
dreq.removeAttribute(APIConstants.JAVAX_PORTLET_CONFIG);
dreq.removeAttribute(APIConstants.JAVAX_PORTLET_REQUEST);
dreq.removeAttribute(APIConstants.JAVAX_PORTLET_RESPONSE);
+ dreq.removeAttribute(APIConstants.JAVAX_PORTLET_LIFECYCLE_PHASE);
dreq.removeAttribute(ContextDispatcherInterceptor.REQ_ATT_COMPONENT_INVOCATION);
}
@@ -442,6 +444,7 @@
dreq.setAttribute(APIConstants.JAVAX_PORTLET_CONFIG, config);
dreq.setAttribute(APIConstants.JAVAX_PORTLET_REQUEST, req);
dreq.setAttribute(APIConstants.JAVAX_PORTLET_RESPONSE, resp);
+ dreq.setAttribute(APIConstants.JAVAX_PORTLET_LIFECYCLE_PHASE,
"RENDER_PHASE");
dreq.setAttribute(ContextDispatcherInterceptor.REQ_ATT_COMPONENT_INVOCATION,
invocation);
portlet.render(req, resp);
}
@@ -450,6 +453,7 @@
dreq.removeAttribute(APIConstants.JAVAX_PORTLET_CONFIG);
dreq.removeAttribute(APIConstants.JAVAX_PORTLET_REQUEST);
dreq.removeAttribute(APIConstants.JAVAX_PORTLET_RESPONSE);
+ dreq.removeAttribute(APIConstants.JAVAX_PORTLET_LIFECYCLE_PHASE);
dreq.removeAttribute(ContextDispatcherInterceptor.REQ_ATT_COMPONENT_INVOCATION);
}
return resp.getResponse();
@@ -470,6 +474,7 @@
dreq.setAttribute(APIConstants.JAVAX_PORTLET_CONFIG, config);
dreq.setAttribute(APIConstants.JAVAX_PORTLET_REQUEST, ereq);
dreq.setAttribute(APIConstants.JAVAX_PORTLET_RESPONSE, eresp);
+ dreq.setAttribute(APIConstants.JAVAX_PORTLET_LIFECYCLE_PHASE,
"EVENT_PHASE");
dreq.setAttribute(ContextDispatcherInterceptor.REQ_ATT_COMPONENT_INVOCATION,
invocation);
eventPortlet.processEvent(ereq, eresp);
}
@@ -478,6 +483,7 @@
dreq.removeAttribute(APIConstants.JAVAX_PORTLET_CONFIG);
dreq.removeAttribute(APIConstants.JAVAX_PORTLET_REQUEST);
dreq.removeAttribute(APIConstants.JAVAX_PORTLET_RESPONSE);
+ dreq.removeAttribute(APIConstants.JAVAX_PORTLET_LIFECYCLE_PHASE);
dreq.removeAttribute(ContextDispatcherInterceptor.REQ_ATT_COMPONENT_INVOCATION);
}
return eresp.getResponse();
@@ -498,6 +504,7 @@
dreq.setAttribute(APIConstants.JAVAX_PORTLET_CONFIG, config);
dreq.setAttribute(APIConstants.JAVAX_PORTLET_REQUEST, req);
dreq.setAttribute(APIConstants.JAVAX_PORTLET_RESPONSE, resp);
+ dreq.setAttribute(APIConstants.JAVAX_PORTLET_LIFECYCLE_PHASE,
"RESOURCE_SERVING_PHASE");
dreq.setAttribute(ContextDispatcherInterceptor.REQ_ATT_COMPONENT_INVOCATION,
invocation);
eventPortlet.serveResource(req, resp);
}
@@ -506,6 +513,7 @@
dreq.removeAttribute(APIConstants.JAVAX_PORTLET_CONFIG);
dreq.removeAttribute(APIConstants.JAVAX_PORTLET_REQUEST);
dreq.removeAttribute(APIConstants.JAVAX_PORTLET_RESPONSE);
+ dreq.removeAttribute(APIConstants.JAVAX_PORTLET_LIFECYCLE_PHASE);
dreq.removeAttribute(ContextDispatcherInterceptor.REQ_ATT_COMPONENT_INVOCATION);
}
Added:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletrequests/LifeCyclePhaseRequestAttributeTestCase.java
===================================================================
---
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletrequests/LifeCyclePhaseRequestAttributeTestCase.java
(rev 0)
+++
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletrequests/LifeCyclePhaseRequestAttributeTestCase.java 2008-01-31
13:38:03 UTC (rev 9685)
@@ -0,0 +1,107 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.portlet.jsr286.tck.portletrequests;
+
+import org.jboss.portal.unit.PortletTestCase;
+import org.jboss.portal.unit.PortletTestContext;
+import org.jboss.portal.unit.Assertion;
+import org.jboss.portal.unit.annotations.TestCase;
+import org.jboss.portal.unit.actions.PortletRenderTestAction;
+import org.jboss.portal.unit.actions.PortletActionTestAction;
+import org.jboss.portal.unit.actions.PortletEventTestAction;
+import org.jboss.portal.unit.actions.PortletResourceTestAction;
+import org.jboss.portal.test.portlet.framework.UTP6;
+import org.jboss.unit.driver.DriverResponse;
+import org.jboss.unit.driver.response.EndTestResponse;
+import org.jboss.unit.remote.driver.handler.http.response.InvokeGetResponse;
+import static org.jboss.unit.api.Assert.*;
+
+import javax.portlet.Portlet;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.PortletException;
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.PortletRequest;
+import javax.portlet.EventRequest;
+import javax.portlet.EventResponse;
+import javax.portlet.ResourceRequest;
+import javax.portlet.ResourceResponse;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+(a)TestCase(Assertion.JSR286_90)
+public class LifeCyclePhaseRequestAttributeTestCase
+{
+
+ public LifeCyclePhaseRequestAttributeTestCase(PortletTestCase seq)
+ {
+ seq.bindAction(0, UTP6.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request,
RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ return new InvokeGetResponse(response.createActionURL().toString());
+ }
+ });
+ seq.bindAction(1, UTP6.ACTION_JOIN_POINT, new PortletActionTestAction()
+ {
+ protected void run(Portlet portlet, ActionRequest request, ActionResponse
response, PortletTestContext context) throws PortletException, IOException
+ {
+ assertEquals("ACTION_PHASE",
request.getAttribute(PortletRequest.LIFECYCLE_PHASE));
+
+ //
+ response.setEvent("Event", null);
+ }
+ });
+ seq.bindAction(1, UTP6.EVENT_JOIN_POINT, new PortletEventTestAction()
+ {
+ protected void run(Portlet portlet, EventRequest request, EventResponse
response, PortletTestContext context) throws PortletException, IOException
+ {
+ assertEquals("EVENT_PHASE",
request.getAttribute(PortletRequest.LIFECYCLE_PHASE));
+ }
+ });
+ seq.bindAction(1, UTP6.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request,
RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ assertEquals("RENDER_PHASE",
request.getAttribute(PortletRequest.LIFECYCLE_PHASE));
+
+ //
+ return new InvokeGetResponse(response.createResourceURL().toString());
+ }
+ });
+ seq.bindAction(2, UTP6.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, ResourceRequest request,
ResourceResponse response, PortletTestContext context) throws PortletException,
IOException
+ {
+ assertEquals("RESOURCE_SERVING_PHASE",
request.getAttribute(PortletRequest.LIFECYCLE_PHASE));
+
+ //
+ return new EndTestResponse();
+ }
+ });
+ }
+}
Modified:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletrequests/WindowIDTestCase.java
===================================================================
---
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletrequests/WindowIDTestCase.java 2008-01-31
13:17:54 UTC (rev 9684)
+++
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletrequests/WindowIDTestCase.java 2008-01-31
13:38:03 UTC (rev 9685)
@@ -27,7 +27,7 @@
import org.jboss.portal.unit.Assertion;
import org.jboss.portal.unit.actions.PortletRenderTestAction;
import org.jboss.portal.unit.annotations.TestCase;
-import org.jboss.portal.test.portlet.framework.UTP5;
+import org.jboss.portal.test.portlet.framework.UTP6;
import org.jboss.unit.driver.DriverResponse;
import org.jboss.unit.driver.response.EndTestResponse;
import static org.jboss.unit.api.Assert.*;
@@ -50,7 +50,7 @@
public WindowIDTestCase(PortletTestCase seq)
{
- seq.bindAction(0, UTP5.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ seq.bindAction(0, UTP6.RENDER_JOIN_POINT, new PortletRenderTestAction()
{
protected DriverResponse run(Portlet portlet, RenderRequest request,
RenderResponse response, PortletTestContext context) throws PortletException, IOException
{
Modified:
modules/portlet/trunk/test/src/test/resources/jsr286/tck/portletrequests-war/WEB-INF/portlet.xml
===================================================================
---
modules/portlet/trunk/test/src/test/resources/jsr286/tck/portletrequests-war/WEB-INF/portlet.xml 2008-01-31
13:17:54 UTC (rev 9684)
+++
modules/portlet/trunk/test/src/test/resources/jsr286/tck/portletrequests-war/WEB-INF/portlet.xml 2008-01-31
13:38:03 UTC (rev 9685)
@@ -82,6 +82,20 @@
<supported-public-render-parameter>daa</supported-public-render-parameter>
</portlet>
+ <portlet>
+ <portlet-name>UniversalTestPortletF</portlet-name>
+
<portlet-class>org.jboss.portal.test.portlet.framework.UTP6</portlet-class>
+ <supports>
+ <mime-type>text/html</mime-type>
+ </supports>
+ <supported-processing-event>
+ <name>Event</name>
+ </supported-processing-event>
+ <supported-publishing-event>
+ <name>Event</name>
+ </supported-publishing-event>
+ </portlet>
+
<event-definition>
<name>Event</name>
</event-definition>