Author: julien(a)jboss.com
Date: 2008-01-15 06:03:45 -0500 (Tue, 15 Jan 2008)
New Revision: 9506
Added:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/ExceptionDiscardChangesDuringEventPhaseTestCase.java
Modified:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/NonDeclaredEventPublicationDuringActionTestCase.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/NonDeclaredEventPublicationDuringEventTestCase.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/Assertion.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/WEB-INF/portlet.xml
Log:
added TCK tests for failures during event phase that force discard of NS changes and event
publishing
Added:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/ExceptionDiscardChangesDuringEventPhaseTestCase.java
===================================================================
---
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/ExceptionDiscardChangesDuringEventPhaseTestCase.java
(rev 0)
+++
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/ExceptionDiscardChangesDuringEventPhaseTestCase.java 2008-01-15
11:03:45 UTC (rev 9506)
@@ -0,0 +1,137 @@
+/******************************************************************************
+ * 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.UTP2;
+import org.jboss.portal.test.portlet.framework.UTP9;
+import org.jboss.unit.driver.DriverResponse;
+import org.jboss.unit.driver.response.EndTestResponse;
+import static org.jboss.unit.api.Assert.*;
+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 javax.portlet.Event;
+import javax.xml.namespace.QName;
+import java.io.IOException;
+import java.util.Collections;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+(a)TestCase({Assertion.JSR286_146})
+public class ExceptionDiscardChangesDuringEventPhaseTestCase
+{
+ public ExceptionDiscardChangesDuringEventPhaseTestCase(PortletTestCase seq)
+ {
+ seq.bindAction(0, UTP9.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, UTP9.ACTION_JOIN_POINT, new PortletActionTestAction()
+ {
+ protected void run(Portlet portlet, ActionRequest request, ActionResponse
response, PortletTestContext context) throws PortletException, IOException
+ {
+ response.setEvent("Bar", null);
+ response.setRenderParameter("foo", "actionbar");
+ }
+ });
+ seq.bindAction(1, UTP9.EVENT_JOIN_POINT, new PortletEventTestAction()
+ {
+ protected void run(Portlet portlet, EventRequest request, EventResponse
response, PortletTestContext context) throws PortletException, IOException
+ {
+ if (request.getEvent().getName().equals("Bar"))
+ {
+ response.setRenderParameter("foo", "eventbar");
+ response.setEvent("Bar", null);
+ throw new PortletException();
+ }
+ else
+ {
+ fail("Should not be here");
+ }
+ }
+ });
+ seq.bindAction(1, UTP9.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request,
RenderResponse response, PortletTestContext context)
+ {
+ assertEquals(1, request.getParameterMap().size());
+ assertTrue(request.getParameterMap().containsKey("foo"));
+ assertEquals(new String[]{"actionbar"},
request.getParameterMap().get("foo"));
+ return new InvokeGetResponse(response.createActionURL().toString());
+ }
+ });
+ seq.bindAction(2, UTP9.ACTION_JOIN_POINT, new PortletActionTestAction()
+ {
+ protected void run(Portlet portlet, ActionRequest request, ActionResponse
response, PortletTestContext context) throws PortletException, IOException
+ {
+ response.setEvent("Bar", null);
+ response.setRenderParameter("foo", "actionbar");
+ }
+ });
+ seq.bindAction(2, UTP9.EVENT_JOIN_POINT, new PortletEventTestAction()
+ {
+ protected void runWithRuntimeException(Portlet portlet, EventRequest request,
EventResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ if (request.getEvent().getName().equals("Bar"))
+ {
+ response.setRenderParameter("foo", "eventbar");
+ response.setEvent("Bar", null);
+ throw new RuntimeException();
+ }
+ else
+ {
+ fail("Should not be here");
+ }
+ }
+ });
+ seq.bindAction(2, UTP9.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request,
RenderResponse response, PortletTestContext context)
+ {
+ assertEquals(1, request.getParameterMap().size());
+ assertTrue(request.getParameterMap().containsKey("foo"));
+ assertEquals(new String[]{"actionbar"},
request.getParameterMap().get("foo"));
+ return new EndTestResponse();
+ }
+ });
+ }
+}
\ No newline at end of file
Modified:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/NonDeclaredEventPublicationDuringActionTestCase.java
===================================================================
---
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/NonDeclaredEventPublicationDuringActionTestCase.java 2008-01-15
09:52:00 UTC (rev 9505)
+++
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/NonDeclaredEventPublicationDuringActionTestCase.java 2008-01-15
11:03:45 UTC (rev 9506)
@@ -49,7 +49,7 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 630 $
*/
-(a)TestCase({Assertion.JSR286_143})
+(a)TestCase({Assertion.JSR286_142})
public class NonDeclaredEventPublicationDuringActionTestCase
{
Modified:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/NonDeclaredEventPublicationDuringEventTestCase.java
===================================================================
---
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/NonDeclaredEventPublicationDuringEventTestCase.java 2008-01-15
09:52:00 UTC (rev 9505)
+++
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/NonDeclaredEventPublicationDuringEventTestCase.java 2008-01-15
11:03:45 UTC (rev 9506)
@@ -50,7 +50,7 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 630 $
*/
-(a)TestCase({Assertion.JSR286_143})
+(a)TestCase({Assertion.JSR286_142})
public class NonDeclaredEventPublicationDuringEventTestCase
{
Modified:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/Assertion.java
===================================================================
---
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/Assertion.java 2008-01-15
09:52:00 UTC (rev 9505)
+++
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/Assertion.java 2008-01-15
11:03:45 UTC (rev 9506)
@@ -474,7 +474,6 @@
JSR286_138(new TCK(138), "PLT.15.2.3", "If no such element is provided
in the portlet deployment descriptor the " +
"XML default namespace javax.xml.XMLConstants.NULL_NS_URI must be
assumed."),
JSR286_139(new TCK(139), "PLT.15.2.3", "Otherwise the setEvent method
on the StateAwareResponse must throw a " +
- "java.lang.IllegalArgumentException. Otherwise the setEvent method on the
StateAwareResponse must throw a " +
"java.lang.IllegalArgumentException."),
JSR286_140(new TCK(140), "PLT.15.2.4.1", "The event definition must
contain an event name."),
JSR286_141(new TCK(141), "PLT.15.2.4.1", "The portlet container must
use the event name entry in the portlet " +
Modified:
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 2008-01-15
09:52:00 UTC (rev 9505)
+++
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/actions/PortletEventTestAction.java 2008-01-15
11:03:45 UTC (rev 9506)
@@ -45,11 +45,23 @@
{
try
{
- run(portlet, request, response, context);
+ runWithRuntimeException(portlet, request, response, context);
//
return null;
}
+ catch (AssertionError t)
+ {
+ return new FailureResponse(Failure.createFailure(t));
+ }
+ }
+
+ protected void runWithRuntimeException(Portlet portlet, EventRequest request,
EventResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ try
+ {
+ run(portlet, request, response, context);
+ }
catch (Exception e)
{
if (e instanceof PortletException)
@@ -60,14 +72,11 @@
{
throw (IOException)e;
}
- return new FailureResponse(Failure.createAssertionFailure(e));
+ throw new AssertionError(e);
}
- catch (AssertionError t)
- {
- return new FailureResponse(Failure.createFailure(t));
- }
}
- protected abstract void run(Portlet portlet, EventRequest request, EventResponse
response, PortletTestContext context) throws PortletException, IOException;
-
+ protected void run(Portlet portlet, EventRequest request, EventResponse response,
PortletTestContext context) throws PortletException, IOException
+ {
+ }
}
\ No newline at end of file
Modified:
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 2008-01-15
09:52:00 UTC (rev 9505)
+++
modules/portlet/trunk/test/src/test/resources/jsr286/tck/event-war/WEB-INF/portlet.xml 2008-01-15
11:03:45 UTC (rev 9506)
@@ -145,6 +145,20 @@
</supported-publishing-event>
</portlet>
+ <portlet>
+ <portlet-name>UniversalTestPortletI</portlet-name>
+
<portlet-class>org.jboss.portal.test.portlet.framework.UTP9</portlet-class>
+ <supports>
+ <mime-type>text/html</mime-type>
+ </supports>
+ <supported-processing-event>
+ <name>Bar</name>
+ </supported-processing-event>
+ <supported-publishing-event>
+ <name>Bar</name>
+ </supported-publishing-event>
+ </portlet>
+
<default-namespace>urn:default-namespace</default-namespace>
<event-definition>