Author: julien(a)jboss.com
Date: 2008-01-13 18:19:42 -0500 (Sun, 13 Jan 2008)
New Revision: 9494
Added:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/UpdateNavigationalStateResponse.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/EventTestCase.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/actions/PortletEventTestAction.java
modules/portlet/trunk/test/src/test/resources/jsr286/tck/event-war/
modules/portlet/trunk/test/src/test/resources/jsr286/tck/event-war/WEB-INF/
modules/portlet/trunk/test/src/test/resources/jsr286/tck/event-war/WEB-INF/portlet.xml
modules/portlet/trunk/test/src/test/resources/jsr286/tck/event-war/WEB-INF/web.xml
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ActionResponseImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/EventResponseImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/StateAwareResponseImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/StateResponse.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/framework/UTP1.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/framework/UTP10.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/framework/UTP11.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/framework/UTP2.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/framework/UTP3.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/framework/UTP4.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/framework/UTP5.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/framework/UTP6.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/framework/UTP7.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/framework/UTP8.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/framework/UTP9.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/JoinPointType.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/PortletTestContext.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/base/AbstractUniversalTestPortlet.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortalServlet.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletControllerContext.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletControllerContextImpl.java
modules/portlet/trunk/test/src/test/build.xml
modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml
Log:
- start to implement basic event testing
- refactored a bit the test portlet controller for improving control flow
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ActionResponseImpl.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ActionResponseImpl.java 2008-01-13
19:41:37 UTC (rev 9493)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ActionResponseImpl.java 2008-01-13
23:19:42 UTC (rev 9494)
@@ -28,7 +28,7 @@
import org.jboss.portal.portlet.invocation.ActionInvocation;
import org.jboss.portal.portlet.invocation.response.HTTPRedirectionResponse;
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
-import org.jboss.portal.portlet.invocation.response.RenderResponse;
+import org.jboss.portal.portlet.invocation.response.UpdateNavigationalStateResponse;
import javax.portlet.ActionResponse;
import java.io.IOException;
@@ -54,7 +54,7 @@
super(invocation, preq);
//
- RenderResponse rr = new RenderResponse();
+ UpdateNavigationalStateResponse rr = new UpdateNavigationalStateResponse();
rr.setNavigationalState(new PortletParametersStateString());
//
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/EventResponseImpl.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/EventResponseImpl.java 2008-01-13
19:41:37 UTC (rev 9493)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/EventResponseImpl.java 2008-01-13
23:19:42 UTC (rev 9494)
@@ -23,7 +23,7 @@
package org.jboss.portal.portlet.impl.jsr168.api;
import org.jboss.portal.portlet.invocation.EventInvocation;
-import org.jboss.portal.portlet.invocation.response.RenderResponse;
+import org.jboss.portal.portlet.invocation.response.UpdateNavigationalStateResponse;
import org.jboss.portal.portlet.spi.PortletInvocationContext;
import javax.portlet.EventResponse;
@@ -55,8 +55,8 @@
PortletInvocationContext context = invocation.getPortletContext();
//
- ((RenderResponse)response).setMode(context.getMode());
- ((RenderResponse)response).setWindowState(context.getWindowState());
- ((RenderResponse)response).setNavigationalState(context.getNavigationalState());
+ ((UpdateNavigationalStateResponse)response).setMode(context.getMode());
+
((UpdateNavigationalStateResponse)response).setWindowState(context.getWindowState());
+
((UpdateNavigationalStateResponse)response).setNavigationalState(context.getNavigationalState());
}
}
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/StateAwareResponseImpl.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/StateAwareResponseImpl.java 2008-01-13
19:41:37 UTC (rev 9493)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/StateAwareResponseImpl.java 2008-01-13
23:19:42 UTC (rev 9494)
@@ -23,7 +23,7 @@
package org.jboss.portal.portlet.impl.jsr168.api;
import org.jboss.portal.portlet.invocation.PortletInvocation;
-import org.jboss.portal.portlet.invocation.response.RenderResponse;
+import org.jboss.portal.portlet.invocation.response.UpdateNavigationalStateResponse;
import org.jboss.portal.portlet.invocation.response.RedirectionResponse;
import org.jboss.portal.portlet.invocation.response.StateResponse;
import org.jboss.portal.portlet.PortletParametersStateString;
@@ -77,7 +77,7 @@
super(invocation, preq);
//
- RenderResponse rr = new RenderResponse();
+ UpdateNavigationalStateResponse rr = new UpdateNavigationalStateResponse();
rr.setNavigationalState(new PortletParametersStateString());
//
@@ -98,7 +98,7 @@
{
throw new WindowStateException("Not supported", windowState);
}
-
((RenderResponse)response).setWindowState(org.jboss.portal.WindowState.create(windowState.toString()));
+
((UpdateNavigationalStateResponse)response).setWindowState(org.jboss.portal.WindowState.create(windowState.toString()));
decision = WANT_RENDER;
}
else
@@ -124,7 +124,7 @@
throw new PortletModeException("Not supported", portletMode);
}
Mode mode = Mode.create(portletMode.toString());
- ((RenderResponse)response).setMode(mode);
+ ((UpdateNavigationalStateResponse)response).setMode(mode);
}
decision = WANT_RENDER;
}
@@ -162,7 +162,7 @@
//
if (decision == WANT_NOTHING || decision == WANT_RENDER)
{
-
((PortletParametersStateString)((RenderResponse)response).getNavigationalState()).replace(map);
+
((PortletParametersStateString)((UpdateNavigationalStateResponse)response).getNavigationalState()).replace(map);
decision = WANT_RENDER;
}
else
@@ -178,7 +178,7 @@
//
if (decision == WANT_NOTHING || decision == WANT_RENDER)
{
-
((PortletParametersStateString)((RenderResponse)response).getNavigationalState()).setValue(name,
value);
+
((PortletParametersStateString)((UpdateNavigationalStateResponse)response).getNavigationalState()).setValue(name,
value);
decision = WANT_RENDER;
}
else
@@ -194,7 +194,7 @@
//
if (decision == WANT_NOTHING || decision == WANT_RENDER)
{
-
((PortletParametersStateString)((RenderResponse)response).getNavigationalState()).setValues(name,
values);
+
((PortletParametersStateString)((UpdateNavigationalStateResponse)response).getNavigationalState()).setValues(name,
values);
decision = WANT_RENDER;
}
else
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/StateResponse.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/StateResponse.java 2008-01-13
19:41:37 UTC (rev 9493)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/StateResponse.java 2008-01-13
23:19:42 UTC (rev 9494)
@@ -25,6 +25,7 @@
import javax.xml.namespace.QName;
import java.util.ArrayList;
import java.util.List;
+import java.util.Collections;
import java.io.Serializable;
/**
@@ -35,7 +36,7 @@
{
/** . */
- private ArrayList<Event> producedEvents;
+ private List<Event> producedEvents = Collections.emptyList();
public void addEvent(Event event)
{
@@ -45,7 +46,7 @@
}
//
- if (producedEvents == null)
+ if (producedEvents.size() == 0)
{
producedEvents = new ArrayList<Event>();
}
Copied:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/UpdateNavigationalStateResponse.java
(from rev 9493,
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/RenderResponse.java)
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/UpdateNavigationalStateResponse.java
(rev 0)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/UpdateNavigationalStateResponse.java 2008-01-13
23:19:42 UTC (rev 9494)
@@ -0,0 +1,85 @@
+/******************************************************************************
+ * 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.portlet.invocation.response;
+
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.portlet.StateString;
+
+/**
+ * Want to be rendered.
+ *
+ * @todo rename to UpdateNavigationalStateResponse
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5477 $
+ */
+public class UpdateNavigationalStateResponse extends StateResponse
+{
+
+ /** The navigational state returned. */
+ protected StateString state;
+
+ /** The new window state requested. */
+ protected WindowState windowState;
+
+ /** The new mode requested. */
+ protected Mode mode;
+
+ public UpdateNavigationalStateResponse()
+ {
+ state = null;
+ windowState = null;
+ mode = null;
+ }
+
+ public Mode getMode()
+ {
+ return mode;
+ }
+
+ public void setMode(Mode mode)
+ {
+ this.mode = mode;
+ }
+
+ public WindowState getWindowState()
+ {
+ return windowState;
+ }
+
+ public void setWindowState(WindowState windowState)
+ {
+ this.windowState = windowState;
+ }
+
+ public StateString getNavigationalState()
+ {
+ return state;
+ }
+
+ public void setNavigationalState(StateString state)
+ {
+ this.state = state;
+ }
+}
Property changes on:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/UpdateNavigationalStateResponse.java
___________________________________________________________________
Name: svn:executable
+
Modified:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/framework/UTP1.java
===================================================================
---
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/framework/UTP1.java 2008-01-13
19:41:37 UTC (rev 9493)
+++
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/framework/UTP1.java 2008-01-13
23:19:42 UTC (rev 9494)
@@ -53,6 +53,8 @@
public final static JoinPoint RENDER_JOIN_POINT = new JoinPoint(NAME,
JoinPointType.PORTLET_RENDER);
+ public final static JoinPoint EVENT_JOIN_POINT = new JoinPoint(NAME,
JoinPointType.PORTLET_EVENT);
+
public final static JoinPoint ACTION_JOIN_POINT = new JoinPoint(NAME,
JoinPointType.PORTLET_ACTION);
/** Resets helper variables */
Modified:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/framework/UTP10.java
===================================================================
---
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/framework/UTP10.java 2008-01-13
19:41:37 UTC (rev 9493)
+++
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/framework/UTP10.java 2008-01-13
23:19:42 UTC (rev 9494)
@@ -40,10 +40,12 @@
public static final String NAME = "Portlet10";
- public final static JoinPoint RENDER_JOIN_POINT = new JoinPoint(UTP10.NAME,
JoinPointType.PORTLET_RENDER);
+ public final static JoinPoint RENDER_JOIN_POINT = new JoinPoint(NAME,
JoinPointType.PORTLET_RENDER);
- public final static JoinPoint ACTION_JOIN_POINT = new JoinPoint(UTP10.NAME,
JoinPointType.PORTLET_ACTION);
+ public final static JoinPoint EVENT_JOIN_POINT = new JoinPoint(NAME,
JoinPointType.PORTLET_EVENT);
+ public final static JoinPoint ACTION_JOIN_POINT = new JoinPoint(NAME,
JoinPointType.PORTLET_ACTION);
+
/** Resets helper variables */
public void reset()
{
Modified:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/framework/UTP11.java
===================================================================
---
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/framework/UTP11.java 2008-01-13
19:41:37 UTC (rev 9493)
+++
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/framework/UTP11.java 2008-01-13
23:19:42 UTC (rev 9494)
@@ -42,6 +42,8 @@
public final static JoinPoint RENDER_JOIN_POINT = new JoinPoint(NAME,
JoinPointType.PORTLET_RENDER);
+ public final static JoinPoint EVENT_JOIN_POINT = new JoinPoint(NAME,
JoinPointType.PORTLET_EVENT);
+
public final static JoinPoint ACTION_JOIN_POINT = new JoinPoint(NAME,
JoinPointType.PORTLET_ACTION);
/** Resets helper variables */
Modified:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/framework/UTP2.java
===================================================================
---
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/framework/UTP2.java 2008-01-13
19:41:37 UTC (rev 9493)
+++
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/framework/UTP2.java 2008-01-13
23:19:42 UTC (rev 9494)
@@ -42,6 +42,8 @@
public final static JoinPoint RENDER_JOIN_POINT = new JoinPoint(NAME,
JoinPointType.PORTLET_RENDER);
+ public final static JoinPoint EVENT_JOIN_POINT = new JoinPoint(NAME,
JoinPointType.PORTLET_EVENT);
+
public final static JoinPoint ACTION_JOIN_POINT = new JoinPoint(NAME,
JoinPointType.PORTLET_ACTION);
/** Resets helper variables */
Modified:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/framework/UTP3.java
===================================================================
---
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/framework/UTP3.java 2008-01-13
19:41:37 UTC (rev 9493)
+++
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/framework/UTP3.java 2008-01-13
23:19:42 UTC (rev 9494)
@@ -40,10 +40,12 @@
public static final String NAME = "Portlet3";
- public final static JoinPoint RENDER_JOIN_POINT = new JoinPoint(UTP3.NAME,
JoinPointType.PORTLET_RENDER);
+ public final static JoinPoint RENDER_JOIN_POINT = new JoinPoint(NAME,
JoinPointType.PORTLET_RENDER);
- public final static JoinPoint ACTION_JOIN_POINT = new JoinPoint(UTP3.NAME,
JoinPointType.PORTLET_ACTION);
+ public final static JoinPoint EVENT_JOIN_POINT = new JoinPoint(NAME,
JoinPointType.PORTLET_EVENT);
+ public final static JoinPoint ACTION_JOIN_POINT = new JoinPoint(NAME,
JoinPointType.PORTLET_ACTION);
+
/** Resets helper variables */
public void reset()
{
Modified:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/framework/UTP4.java
===================================================================
---
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/framework/UTP4.java 2008-01-13
19:41:37 UTC (rev 9493)
+++
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/framework/UTP4.java 2008-01-13
23:19:42 UTC (rev 9494)
@@ -40,10 +40,12 @@
public static final String NAME = "Portlet4";
- public final static JoinPoint RENDER_JOIN_POINT = new JoinPoint(UTP4.NAME,
JoinPointType.PORTLET_RENDER);
+ public final static JoinPoint RENDER_JOIN_POINT = new JoinPoint(NAME,
JoinPointType.PORTLET_RENDER);
- public final static JoinPoint ACTION_JOIN_POINT = new JoinPoint(UTP4.NAME,
JoinPointType.PORTLET_ACTION);
+ public final static JoinPoint EVENT_JOIN_POINT = new JoinPoint(NAME,
JoinPointType.PORTLET_EVENT);
+ public final static JoinPoint ACTION_JOIN_POINT = new JoinPoint(NAME,
JoinPointType.PORTLET_ACTION);
+
/** Resets helper variables */
public void reset()
{
Modified:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/framework/UTP5.java
===================================================================
---
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/framework/UTP5.java 2008-01-13
19:41:37 UTC (rev 9493)
+++
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/framework/UTP5.java 2008-01-13
23:19:42 UTC (rev 9494)
@@ -40,10 +40,12 @@
public static final String NAME = "Portlet5";
- public final static JoinPoint RENDER_JOIN_POINT = new JoinPoint(UTP5.NAME,
JoinPointType.PORTLET_RENDER);
+ public final static JoinPoint RENDER_JOIN_POINT = new JoinPoint(NAME,
JoinPointType.PORTLET_RENDER);
- public final static JoinPoint ACTION_JOIN_POINT = new JoinPoint(UTP5.NAME,
JoinPointType.PORTLET_ACTION);
+ public final static JoinPoint EVENT_JOIN_POINT = new JoinPoint(NAME,
JoinPointType.PORTLET_EVENT);
+ public final static JoinPoint ACTION_JOIN_POINT = new JoinPoint(NAME,
JoinPointType.PORTLET_ACTION);
+
/** Resets helper variables */
public void reset()
{
Modified:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/framework/UTP6.java
===================================================================
---
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/framework/UTP6.java 2008-01-13
19:41:37 UTC (rev 9493)
+++
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/framework/UTP6.java 2008-01-13
23:19:42 UTC (rev 9494)
@@ -40,10 +40,12 @@
public static final String NAME = "Portlet6";
- public final static JoinPoint RENDER_JOIN_POINT = new JoinPoint(UTP6.NAME,
JoinPointType.PORTLET_RENDER);
+ public final static JoinPoint RENDER_JOIN_POINT = new JoinPoint(NAME,
JoinPointType.PORTLET_RENDER);
- public final static JoinPoint ACTION_JOIN_POINT = new JoinPoint(UTP6.NAME,
JoinPointType.PORTLET_ACTION);
+ public final static JoinPoint EVENT_JOIN_POINT = new JoinPoint(NAME,
JoinPointType.PORTLET_EVENT);
+ public final static JoinPoint ACTION_JOIN_POINT = new JoinPoint(NAME,
JoinPointType.PORTLET_ACTION);
+
/** Resets helper variables */
public void reset()
{
Modified:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/framework/UTP7.java
===================================================================
---
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/framework/UTP7.java 2008-01-13
19:41:37 UTC (rev 9493)
+++
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/framework/UTP7.java 2008-01-13
23:19:42 UTC (rev 9494)
@@ -40,10 +40,12 @@
public static final String NAME = "Portlet7";
- public final static JoinPoint RENDER_JOIN_POINT = new JoinPoint(UTP7.NAME,
JoinPointType.PORTLET_RENDER);
+ public final static JoinPoint RENDER_JOIN_POINT = new JoinPoint(NAME,
JoinPointType.PORTLET_RENDER);
- public final static JoinPoint ACTION_JOIN_POINT = new JoinPoint(UTP7.NAME,
JoinPointType.PORTLET_ACTION);
+ public final static JoinPoint EVENT_JOIN_POINT = new JoinPoint(NAME,
JoinPointType.PORTLET_EVENT);
+ public final static JoinPoint ACTION_JOIN_POINT = new JoinPoint(NAME,
JoinPointType.PORTLET_ACTION);
+
/** Resets helper variables */
public void reset()
{
Modified:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/framework/UTP8.java
===================================================================
---
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/framework/UTP8.java 2008-01-13
19:41:37 UTC (rev 9493)
+++
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/framework/UTP8.java 2008-01-13
23:19:42 UTC (rev 9494)
@@ -40,10 +40,12 @@
public static final String NAME = "Portlet8";
- public final static JoinPoint RENDER_JOIN_POINT = new JoinPoint(UTP8.NAME,
JoinPointType.PORTLET_RENDER);
+ public final static JoinPoint RENDER_JOIN_POINT = new JoinPoint(NAME,
JoinPointType.PORTLET_RENDER);
- public final static JoinPoint ACTION_JOIN_POINT = new JoinPoint(UTP8.NAME,
JoinPointType.PORTLET_ACTION);
+ public final static JoinPoint EVENT_JOIN_POINT = new JoinPoint(NAME,
JoinPointType.PORTLET_EVENT);
+ public final static JoinPoint ACTION_JOIN_POINT = new JoinPoint(NAME,
JoinPointType.PORTLET_ACTION);
+
/** Resets helper variables */
public void reset()
{
Modified:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/framework/UTP9.java
===================================================================
---
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/framework/UTP9.java 2008-01-13
19:41:37 UTC (rev 9493)
+++
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/framework/UTP9.java 2008-01-13
23:19:42 UTC (rev 9494)
@@ -40,10 +40,12 @@
public static final String NAME = "Portlet9";
- public final static JoinPoint RENDER_JOIN_POINT = new JoinPoint(UTP9.NAME,
JoinPointType.PORTLET_RENDER);
+ public final static JoinPoint RENDER_JOIN_POINT = new JoinPoint(NAME,
JoinPointType.PORTLET_RENDER);
- public final static JoinPoint ACTION_JOIN_POINT = new JoinPoint(UTP9.NAME,
JoinPointType.PORTLET_ACTION);
+ public final static JoinPoint EVENT_JOIN_POINT = new JoinPoint(NAME,
JoinPointType.PORTLET_EVENT);
+ public final static JoinPoint ACTION_JOIN_POINT = new JoinPoint(NAME,
JoinPointType.PORTLET_ACTION);
+
/** Resets helper variables */
public void reset()
{
Added:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/EventTestCase.java
===================================================================
---
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/EventTestCase.java
(rev 0)
+++
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/EventTestCase.java 2008-01-13
23:19:42 UTC (rev 9494)
@@ -0,0 +1,85 @@
+/******************************************************************************
+ * 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.event;
+
+import org.jboss.portal.unit.annotations.TestCase;
+import org.jboss.portal.unit.Assertion;
+import org.jboss.portal.unit.PortletTestCase;
+import org.jboss.portal.unit.PortletTestContext;
+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.test.portlet.framework.UTP5;
+import org.jboss.portal.test.portlet.framework.UTP1;
+import org.jboss.unit.driver.DriverResponse;
+import org.jboss.unit.driver.response.EndTestResponse;
+import org.jboss.unit.remote.driver.handler.http.response.InvokeGetResponse;
+
+import javax.portlet.RenderRequest;
+import javax.portlet.Portlet;
+import javax.portlet.RenderResponse;
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.PortletException;
+import javax.portlet.EventRequest;
+import javax.portlet.EventResponse;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+(a)TestCase({Assertion.JSR168_1000})
+public class EventTestCase
+{
+ public EventTestCase(PortletTestCase seq)
+ {
+ seq.bindAction(0, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request,
RenderResponse response, PortletTestContext context)
+ {
+ return new InvokeGetResponse(response.createActionURL().toString());
+ }
+ });
+ seq.bindAction(1, UTP1.ACTION_JOIN_POINT, new PortletActionTestAction()
+ {
+ protected void run(Portlet portlet, ActionRequest request, ActionResponse
response, PortletTestContext context) throws PortletException, IOException
+ {
+ response.setEvent("Foo", null);
+ }
+ });
+ seq.bindAction(1, UTP1.EVENT_JOIN_POINT, new PortletEventTestAction()
+ {
+ protected void run(Portlet portlet, EventRequest request, EventResponse
response, PortletTestContext context) throws PortletException, IOException
+ {
+ }
+ });
+ seq.bindAction(1, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request,
RenderResponse response, PortletTestContext context)
+ {
+ return new EndTestResponse();
+ }
+ });
+ }
+}
Modified:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/JoinPointType.java
===================================================================
---
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/JoinPointType.java 2008-01-13
19:41:37 UTC (rev 9493)
+++
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/JoinPointType.java 2008-01-13
23:19:42 UTC (rev 9494)
@@ -30,6 +30,7 @@
{
PORTLET_ACTION("portlet.action"),
+ PORTLET_EVENT("portlet.event"),
PORTLET_RENDER("portlet.render"),
SERVLET_SERVICE("servlet.service");
Modified:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/PortletTestContext.java
===================================================================
---
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/PortletTestContext.java 2008-01-13
19:41:37 UTC (rev 9493)
+++
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/PortletTestContext.java 2008-01-13
23:19:42 UTC (rev 9494)
@@ -78,6 +78,11 @@
responseContext = new ResponseContext(response, new HashMap<String,
Serializable>());
}
+ public DriverResponse getResponse()
+ {
+ return responseContext.getResponse();
+ }
+
public int getRequestCount()
{
return requestContext.getRequestCount();
Added:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/actions/PortletEventTestAction.java
===================================================================
---
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/actions/PortletEventTestAction.java
(rev 0)
+++
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/actions/PortletEventTestAction.java 2008-01-13
23:19:42 UTC (rev 9494)
@@ -0,0 +1,59 @@
+/******************************************************************************
+ * 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.unit.actions;
+
+import org.jboss.portal.unit.PortletTestContext;
+import org.jboss.portal.unit.TestAction;
+import org.jboss.unit.driver.DriverResponse;
+import org.jboss.unit.driver.response.FailureResponse;
+import org.jboss.unit.Failure;
+
+import javax.portlet.Portlet;
+import javax.portlet.PortletException;
+import javax.portlet.EventRequest;
+import javax.portlet.EventResponse;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz@jboss.org">Boleslaw
Dawidowicz</a>
+ * @version $Revision: 7954 $
+ */
+public abstract class PortletEventTestAction extends TestAction
+{
+
+ public DriverResponse execute(Portlet portlet, EventRequest request, EventResponse
response, PortletTestContext context) throws PortletException, IOException
+ {
+ try
+ {
+ run(portlet, request, response, context);
+ return null;
+ }
+ catch (AssertionError t)
+ {
+ return new FailureResponse(Failure.createFailure(t));
+ }
+ }
+
+ protected abstract void run(Portlet portlet, EventRequest request, EventResponse
response, PortletTestContext context) throws PortletException, IOException;
+
+}
\ No newline at end of file
Modified:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/base/AbstractUniversalTestPortlet.java
===================================================================
---
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/base/AbstractUniversalTestPortlet.java 2008-01-13
19:41:37 UTC (rev 9493)
+++
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/base/AbstractUniversalTestPortlet.java 2008-01-13
23:19:42 UTC (rev 9494)
@@ -27,6 +27,7 @@
import org.jboss.portal.unit.PortletTestCase;
import org.jboss.portal.unit.actions.PortletActionTestAction;
import org.jboss.portal.unit.actions.PortletRenderTestAction;
+import org.jboss.portal.unit.actions.PortletEventTestAction;
import org.jboss.portal.unit.TestAction;
import org.jboss.portal.unit.PortletTestContext;
import org.jboss.portal.test.framework.server.NodeId;
@@ -45,6 +46,9 @@
import javax.portlet.PortletSecurityException;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
+import javax.portlet.EventPortlet;
+import javax.portlet.EventRequest;
+import javax.portlet.EventResponse;
import java.io.IOException;
/**
@@ -53,7 +57,7 @@
* @author <a href="mailto:boleslaw.dawidowicz@jboss.com">Boleslaw
Dawidowicz</a>
* @version $Revision: 7954 $
*/
-public abstract class AbstractUniversalTestPortlet implements Portlet
+public abstract class AbstractUniversalTestPortlet implements Portlet, EventPortlet
{
public static String getPortletName()
@@ -74,6 +78,9 @@
/** Joinpoint for render phase. */
private final JoinPoint renderJoinPoint = JoinPoint.createJoinPoint(getClass(),
JoinPointType.PORTLET_RENDER);
+ /** Joinpoint for event phase. */
+ private final JoinPoint eventJoinPoint = JoinPoint.createJoinPoint(getClass(),
JoinPointType.PORTLET_EVENT);
+
/** Joinpoint for action phase. */
private final JoinPoint actionJoinPoint = JoinPoint.createJoinPoint(getClass(),
JoinPointType.PORTLET_ACTION);
@@ -159,6 +166,49 @@
}
}
+ public void processEvent(EventRequest req, EventResponse resp) throws
PortletException, IOException
+ {
+ PortletTestContext ctx = PortletTestDriver.getPortletTestContext();
+
+ //
+ if (ctx.getResponse() == null)
+ {
+ log.debug("JoinPoint '" + eventJoinPoint + "' invoked for
'"
+ + ctx.getTestName() + "' testId and '" +
+ +ctx.getRequestCount() + "' request count");
+
+ //
+ PortletTestCase portletTestCase = getSequence(ctx.getTestName());
+
+ //
+ if (portletTestCase != null)
+ {
+ //
+ TestAction action = portletTestCase.getAction(ctx.getRequestCount(),
NodeId.locate(), eventJoinPoint);
+
+ //
+ if (action == null)
+ {
+ ctx.setResponse(new
FailureResponse(Failure.createAssertionFailure("No action for " +
ctx.getRequestCount() + " " + NodeId.locate() + " " +
eventJoinPoint)));
+ }
+ else if (action instanceof PortletEventTestAction == false)
+ {
+ ctx.setResponse(new
FailureResponse(Failure.createAssertionFailure("Action for " +
ctx.getRequestCount() + " " + NodeId.locate() + " " + actionJoinPoint
+ " is not an instance of " + PortletEventTestAction.class.getName() + "
but is " + action.getClass().getName())));
+ }
+ else
+ {
+ log.debug("Found action for jointpoint " + eventJoinPoint +
" : " + action);
+
+ //
+ DriverResponse response = ((PortletEventTestAction)action).execute(this,
req, resp, ctx);
+
+ //
+ ctx.setResponse(response);
+ }
+ }
+ }
+ }
+
/**
* Invokes current action from Sequence. If failed AssertResult was returned in
previouse portlet action phase it
* will be marshalled.
@@ -184,7 +234,6 @@
reset();
}
-
// Get the action
TestAction action = null;
PortletTestCase portletTestCase = getSequence(ctx.getTestName());
@@ -200,12 +249,12 @@
log.debug("Found action for joinpoint " + renderJoinPoint + " :
" + action);
// Get the result
- DriverResponse sr = ((PortletRenderTestAction)action).execute(this, req, resp,
ctx);
+ DriverResponse response = ((PortletRenderTestAction)action).execute(this, req,
resp, ctx);
// If we have one result it is meant to be returned to the client
- if (sr != null)
+ if (response != null)
{
- ctx.setResponse(sr);
+ ctx.setResponse(response);
}
}
else
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortalServlet.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortalServlet.java 2008-01-13
19:41:37 UTC (rev 9493)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortalServlet.java 2008-01-13
23:19:42 UTC (rev 9494)
@@ -61,12 +61,12 @@
protected void _service(HttpServletRequest req, HttpServletResponse resp) throws
Exception
{
- PortletControllerContext context = new PortletControllerContextImpl(req,
PortletControllerContextImpl.SESSION_SCOPE);
+ PortletControllerContextImpl context = new PortletControllerContextImpl(req, resp,
getServletContext(), PortletControllerContextImpl.SESSION_SCOPE);
//
- PortletController controller = new PortletController(context, getServletContext(),
req);
+ PortletController controller = new PortletController();
//
- controller.process(resp);
+ controller.process(context, context.getRequest());
}
}
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java 2008-01-13
19:41:37 UTC (rev 9493)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java 2008-01-13
23:19:42 UTC (rev 9494)
@@ -29,16 +29,16 @@
import org.jboss.portal.portlet.PortletParameters;
import org.jboss.portal.portlet.PortletInvokerException;
import org.jboss.portal.portlet.PortletInvoker;
-import org.jboss.portal.portlet.RenderURL;
import org.jboss.portal.portlet.impl.spi.AbstractRequestContext;
import org.jboss.portal.portlet.impl.spi.AbstractUserContext;
import org.jboss.portal.portlet.impl.spi.AbstractWindowContext;
import org.jboss.portal.portlet.impl.spi.AbstractPortalContext;
import org.jboss.portal.portlet.impl.spi.AbstractSecurityContext;
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
-import org.jboss.portal.portlet.invocation.response.RenderResponse;
+import org.jboss.portal.portlet.invocation.response.UpdateNavigationalStateResponse;
import org.jboss.portal.portlet.invocation.response.HTTPRedirectionResponse;
import org.jboss.portal.portlet.invocation.response.ErrorResponse;
+import org.jboss.portal.portlet.invocation.response.StateResponse;
import org.jboss.portal.portlet.invocation.ActionInvocation;
import org.jboss.portal.portlet.invocation.RenderInvocation;
import org.jboss.portal.web.IllegalRequestException;
@@ -67,173 +67,172 @@
private MarkupInfo MARKUP_INFO = new MarkupInfo(MediaType.HTML, "UTF8");
/** . */
- private final ServletContext servletContext;
-
- /** . */
- private final HttpServletRequest req;
-
- /** . */
- private final PortletInvoker invoker;
-
- /** . */
- private final PortletControllerContext context;
-
- /** . */
private final boolean redirectAfterAction = true;
- public PortletController(PortletControllerContext context, ServletContext
servletContext, HttpServletRequest req) throws IllegalRequestException,
UnsupportedEncodingException
+ public PortletController() throws IllegalRequestException,
UnsupportedEncodingException
{
- this.context = context;
- this.servletContext = servletContext;
-
- //
- this.req = req;
- this.invoker =
(PortletInvoker)servletContext.getAttribute("ConsumerPortletInvoker");
}
- public void process(HttpServletResponse resp) throws PortletInvokerException,
IOException
+ private PortletInvocationResponse handle(PortletControllerContext context, Action
action) throws PortletInvokerException, IOException
{
+ if (action instanceof PortletRender)
+ {
+ UpdateNavigationalStateResponse updateNavigationalState = new
UpdateNavigationalStateResponse();
+ updateNavigationalState.setMode(action.mode);
+ updateNavigationalState.setWindowState(action.windowState);
+
updateNavigationalState.setNavigationalState(PortletParametersStateString.create(action.queryParameters));
+ return updateNavigationalState;
+ }
+ else
+ {
+ ServletContext servletContext = context.getServletContext();
+ PortletInvoker invoker =
(PortletInvoker)servletContext.getAttribute("ConsumerPortletInvoker");
+ PortletContext target = PortletContext.createPortletContext(action.portletId);
+ Portlet portlet = invoker.getPortlet(target);
+ HttpServletRequest req = context.getClientRequest();
+ HttpServletResponse resp = context.getClientResponse();
+ PortalNavigationalState navState = context.getNavigationalState();
+ PortletURLRenderer renderer = new PortletURLRenderer(navState, portlet, req,
resp);
+ WindowNavigationalState windowNS = navState.getWindow(action.portletId);
- //
- Request request = context.getRequest();
+ //
+ StateString portletNS = null;
+ if (windowNS != null)
+ {
+ portletNS = windowNS.getPortletNavigationalState();
+ }
- //
- PortalNavigationalState navState = context.getNavigationalState();
+ //
+ Mode mode = action.mode;
+ if (mode == null && windowNS != null && windowNS.getMode() !=
null)
+ {
+ mode = windowNS.getMode();
+ }
+ if (mode == null)
+ {
+ mode = Mode.VIEW;
+ }
- //
- if (request != null)
- {
- PortletContext target = PortletContext.createPortletContext(request.portletId);
-
//
- Portlet portlet = invoker.getPortlet(target);
+ WindowState windowState = action.windowState;
+ if (windowState == null && windowNS != null &&
windowNS.getWindowState() != null)
+ {
+ windowState = windowNS.getWindowState();
+ }
+ if (windowState == null)
+ {
+ windowState = WindowState.NORMAL;
+ }
//
- PortletURLRenderer renderer = new PortletURLRenderer(navState, portlet, req,
resp);
+ TestInstanceContext instanceContext = new TestInstanceContext(req,
portlet.getContext(), true);
+ TestActionContext actionContext = new TestActionContext(
+ renderer,
+ mode,
+ windowState,
+ portletNS,
+ MARKUP_INFO,
+ PortletParametersStateString.create(action.queryParameters),
+ action.bodyParameters != null ? new PortletParameters(action.bodyParameters)
: null);
+ ActionInvocation actionInvocation = new ActionInvocation(actionContext);
//
- WindowNavigationalState windowNS = navState.getWindow(request.portletId);
+ actionInvocation.setRequestContext(new AbstractRequestContext(req, resp));
+ actionInvocation.setInstanceContext(instanceContext);
+ actionInvocation.setUserContext(new AbstractUserContext(req));
+ actionInvocation.setWindowContext(new
AbstractWindowContext(portlet.getContext().getId()));
+ actionInvocation.setPortalContext(new AbstractPortalContext());
+ actionInvocation.setSecurityContext(new AbstractSecurityContext(req));
+ actionInvocation.setTarget(instanceContext.getTarget());
//
- PortletInvocationResponse response = null;
-
- if (request instanceof Render)
+ try
{
- RenderResponse render = new RenderResponse();
- render.setMode(request.mode);
- render.setWindowState(request.windowState);
-
render.setNavigationalState(PortletParametersStateString.create(request.queryParameters));
- response = render;
+ return invoker.invoke(actionInvocation);
}
- else
+ catch (PortletInvokerException e)
{
- //
- StateString portletNS = null;
- if (windowNS != null)
- {
- portletNS = windowNS.getPortletNavigationalState();
- }
+ return null;
+ }
+ }
+ }
- //
- Mode mode = request.mode;
- if (mode == null && windowNS != null && windowNS.getMode() !=
null)
- {
- mode = windowNS.getMode();
- }
- if (mode == null)
- {
- mode = Mode.VIEW;
- }
+ public void process(PortletControllerContext context, Action action) throws
PortletInvokerException, IOException
+ {
+ ServletContext servletContext = context.getServletContext();
+ PortletInvoker invoker =
(PortletInvoker)servletContext.getAttribute("ConsumerPortletInvoker");
+ HttpServletRequest req = context.getClientRequest();
+ HttpServletResponse resp = context.getClientResponse();
+ PortalNavigationalState navState = context.getNavigationalState();
- //
- WindowState windowState = request.windowState;
- if (windowState == null && windowNS != null &&
windowNS.getWindowState() != null)
- {
- windowState = windowNS.getWindowState();
- }
- if (windowState == null)
- {
- windowState = WindowState.NORMAL;
- }
+ //
+ if (action != null)
+ {
+ PortletInvocationResponse response = handle(context, action);
- //
- TestInstanceContext instanceContext = new TestInstanceContext(req,
portlet.getContext(), true);
- TestActionContext actionContext = new TestActionContext(
- renderer,
- mode,
- windowState,
- portletNS,
- MARKUP_INFO,
- PortletParametersStateString.create(request.queryParameters),
- request.bodyParameters != null ? new
PortletParameters(request.bodyParameters) : null);
- ActionInvocation action = new ActionInvocation(actionContext);
+ //
+ if (response instanceof StateResponse)
+ {
+ StateResponse stateResponse = (StateResponse)response;
- //
- action.setRequestContext(new AbstractRequestContext(req, resp));
- action.setInstanceContext(instanceContext);
- action.setUserContext(new AbstractUserContext(req));
- action.setWindowContext(new
AbstractWindowContext(portlet.getContext().getId()));
- action.setPortalContext(new AbstractPortalContext());
- action.setSecurityContext(new AbstractSecurityContext(req));
- action.setTarget(instanceContext.getTarget());
+
//
- try
+ for (StateResponse.Event event : stateResponse.getEvents())
{
- response = invoker.invoke(action);
+
}
- catch (PortletInvokerException e)
- {
- e.printStackTrace();
- }
+ }
- //
- if (response instanceof RenderResponse && redirectAfterAction)
+/*
+ if (response instanceof RenderResponse && redirectAfterAction)
+ {
+ PortletURLRenderer renderer = new PortletURLRenderer(navState, portlet, req,
resp);
+ final RenderResponse render = (RenderResponse)response;
+ String location = renderer.renderURL(new RenderURL()
{
- final RenderResponse render = (RenderResponse)response;
- String location = renderer.renderURL(new RenderURL()
+ public StateString getNavigationalState()
{
- public StateString getNavigationalState()
- {
- return render.getNavigationalState();
- }
- public Mode getMode()
- {
- return render.getMode();
- }
- public WindowState getWindowState()
- {
- return render.getWindowState();
- }
- }, null, null, true);
- response = new HTTPRedirectionResponse(location);
- }
+ return render.getNavigationalState();
+ }
+ public Mode getMode()
+ {
+ return render.getMode();
+ }
+ public WindowState getWindowState()
+ {
+ return render.getWindowState();
+ }
+ }, null, null, true);
+ response = new HTTPRedirectionResponse(location);
}
+*/
//
- if (response instanceof RenderResponse)
+ if (response instanceof UpdateNavigationalStateResponse)
{
- RenderResponse render = (RenderResponse)response;
+ UpdateNavigationalStateResponse updateNavigationalState =
(UpdateNavigationalStateResponse)response;
+ WindowNavigationalState windowNS = navState.getWindow(action.portletId);
//
if (windowNS == null)
{
windowNS = new WindowNavigationalState();
- navState.setWindow(portlet.getContext().getId(), windowNS);
+ navState.setWindow(action.portletId, windowNS);
}
//
- if (render.getMode() != null)
+ if (updateNavigationalState.getMode() != null)
{
- windowNS.setMode(render.getMode());
+ windowNS.setMode(updateNavigationalState.getMode());
}
- if (render.getWindowState() != null)
+ if (updateNavigationalState.getWindowState() != null)
{
- windowNS.setWindowState(render.getWindowState());
+ windowNS.setWindowState(updateNavigationalState.getWindowState());
}
- if (render.getNavigationalState() != null)
+ if (updateNavigationalState.getNavigationalState() != null)
{
- windowNS.setPortletNavigationalState(render.getNavigationalState());
+
windowNS.setPortletNavigationalState(updateNavigationalState.getNavigationalState());
}
}
else if (response instanceof HTTPRedirectionResponse)
@@ -332,16 +331,30 @@
writer.print("</body></html>");
}
- static class Request
+ static class Action
{
+ /** . */
final String portletId;
+
+ /** . */
final ParameterMap queryParameters;
+
+ /** . */
final ParameterMap bodyParameters;
+
+ /** . */
final Mode mode;
+
+ /** . */
final WindowState windowState;
- public Request(String portletId, ParameterMap queryParameters, ParameterMap
bodyParameters, Mode mode, WindowState windowState)
+ public Action(
+ String portletId,
+ ParameterMap queryParameters,
+ ParameterMap bodyParameters,
+ Mode mode,
+ WindowState windowState)
{
this.portletId = portletId;
this.queryParameters = queryParameters;
@@ -351,17 +364,27 @@
}
}
- static class Action extends Request
+ static class PortletAction extends Action
{
- public Action(String portletId, ParameterMap queryParameters, ParameterMap
bodyParameters, Mode mode, WindowState windowState)
+ public PortletAction(
+ String portletId,
+ ParameterMap queryParameters,
+ ParameterMap bodyParameters,
+ Mode mode,
+ WindowState windowState)
{
super(portletId, queryParameters, bodyParameters, mode, windowState);
}
}
- static class Render extends Request
+ static class PortletRender extends Action
{
- public Render(String portletId, ParameterMap queryParameters, ParameterMap
bodyParameters, Mode mode, WindowState windowState)
+ public PortletRender(
+ String portletId,
+ ParameterMap queryParameters,
+ ParameterMap bodyParameters,
+ Mode mode,
+ WindowState windowState)
{
super(portletId, queryParameters, bodyParameters, mode, windowState);
}
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletControllerContext.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletControllerContext.java 2008-01-13
19:41:37 UTC (rev 9493)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletControllerContext.java 2008-01-13
23:19:42 UTC (rev 9494)
@@ -22,6 +22,10 @@
******************************************************************************/
package org.jboss.portal.portlet.test;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.ServletContext;
+
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
@@ -31,6 +35,10 @@
PortalNavigationalState getNavigationalState();
- PortletController.Request getRequest();
+ ServletContext getServletContext();
+ HttpServletRequest getClientRequest();
+
+ HttpServletResponse getClientResponse();
+
}
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletControllerContextImpl.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletControllerContextImpl.java 2008-01-13
19:41:37 UTC (rev 9493)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletControllerContextImpl.java 2008-01-13
23:19:42 UTC (rev 9494)
@@ -32,6 +32,8 @@
import org.jboss.portal.WindowState;
import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.ServletContext;
import java.io.IOException;
/**
@@ -48,20 +50,32 @@
public static final int SESSION_SCOPE = 1;
/** . */
+ private final HttpServletRequest req;
+
+ /** . */
+ private final HttpServletResponse resp;
+
+ /** . */
+ private final ServletContext servletContext;
+
+ /** . */
private final PortalNavigationalState navState;
/** . */
- private final PortletController.Request request;
+ private final PortletController.Action action;
- public PortletControllerContextImpl(HttpServletRequest req, int navStateScope)
+ public PortletControllerContextImpl(
+ HttpServletRequest req,
+ HttpServletResponse resp,
+ ServletContext servletContext,
+ int navStateScope)
throws IllegalRequestException, IOException, ClassNotFoundException
{
-
if (navStateScope < NAV_SCOPE || navStateScope > SESSION_SCOPE)
{
throw new IllegalArgumentException();
}
-
+
//
String pathInfo = req.getPathInfo();
String targetId;
@@ -107,7 +121,7 @@
}
//
- PortletController.Request request;
+ PortletController.Action action;
String type = metaParameters.getValue("type");
//
@@ -119,21 +133,27 @@
if ("action".equals(type))
{
- request = new PortletController.Action(targetId, actualParameters,
formParameters, mode, windowState);
+ action = new PortletController.PortletAction(targetId, actualParameters,
formParameters, mode, windowState);
}
else
{
- request = new PortletController.Render(targetId, actualParameters,
formParameters, mode, windowState);
+ action = new PortletController.PortletRender(targetId, actualParameters,
formParameters, mode, windowState);
}
//
this.navState = navState;
- this.request = request;
+ this.action = action;
+ this.req = req;
+ this.resp = resp;
+ this.servletContext = servletContext;
}
else
{
this.navState = new PortalNavigationalState();
- this.request = null;
+ this.action = null;
+ this.req = req;
+ this.resp = resp;
+ this.servletContext = servletContext;
//
if (navStateScope == SESSION_SCOPE)
@@ -143,13 +163,28 @@
}
}
- public PortletController.Request getRequest()
+ public PortletController.Action getRequest()
{
- return request;
+ return action;
}
public PortalNavigationalState getNavigationalState()
{
return navState;
}
+
+ public ServletContext getServletContext()
+ {
+ return servletContext;
+ }
+
+ public HttpServletRequest getClientRequest()
+ {
+ return req;
+ }
+
+ public HttpServletResponse getClientResponse()
+ {
+ return resp;
+ }
}
Modified: modules/portlet/trunk/test/src/test/build.xml
===================================================================
--- modules/portlet/trunk/test/src/test/build.xml 2008-01-13 19:41:37 UTC (rev 9493)
+++ modules/portlet/trunk/test/src/test/build.xml 2008-01-13 23:19:42 UTC (rev 9494)
@@ -220,6 +220,7 @@
<package-jsr286-tck-test test="portletconfig"/>
<package-jsr286-tck-test test="portletconfignonamespace"/>
+ <package-jsr286-tck-test test="event"/>
<jar jarfile="${test.temp.lib}/portlet-test-lib.jar">
<fileset dir="${target}/test-classes"/>
Added:
modules/portlet/trunk/test/src/test/resources/jsr286/tck/event-war/WEB-INF/portlet.xml
===================================================================
---
modules/portlet/trunk/test/src/test/resources/jsr286/tck/event-war/WEB-INF/portlet.xml
(rev 0)
+++
modules/portlet/trunk/test/src/test/resources/jsr286/tck/event-war/WEB-INF/portlet.xml 2008-01-13
23:19:42 UTC (rev 9494)
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ 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. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<portlet-app
xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2...
http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
+ version="2.0">
+
+ <portlet>
+ <portlet-name>UniversalTestPortletA</portlet-name>
+
<portlet-class>org.jboss.portal.test.portlet.framework.UTP1</portlet-class>
+ <supports>
+ <mime-type>text/html</mime-type>
+ </supports>
+ </portlet>
+
+</portlet-app>
Added: modules/portlet/trunk/test/src/test/resources/jsr286/tck/event-war/WEB-INF/web.xml
===================================================================
--- modules/portlet/trunk/test/src/test/resources/jsr286/tck/event-war/WEB-INF/web.xml
(rev 0)
+++
modules/portlet/trunk/test/src/test/resources/jsr286/tck/event-war/WEB-INF/web.xml 2008-01-13
23:19:42 UTC (rev 9494)
@@ -0,0 +1,32 @@
+<?xml version="1.0"?>
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ 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. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<!DOCTYPE web-app PUBLIC
+ "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
+ "http://java.sun.com/dtd/web-app_2_3.dtd">
+<web-app>
+ <listener>
+
<listener-class>org.jboss.portal.unit.PortletTestSuite</listener-class>
+ </listener>
+</web-app>
Modified: modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml
===================================================================
--- modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml 2008-01-13
19:41:37 UTC (rev 9493)
+++ modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml 2008-01-13
23:19:42 UTC (rev 9494)
@@ -155,6 +155,10 @@
<class
name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId"
value="test-jsr286-tck-portletconfignonamespace.war"/>
</generic>
+ <generic>
+ <class
name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
+ <property name="archiveId"
value="test-jsr286-tck-event.war"/>
+ </generic>
<!--Misc Tests-->
<!--