JBoss Portal SVN: r9507 - in modules/portlet/trunk: portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/api and 7 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-01-15 06:34:57 -0500 (Tue, 15 Jan 2008)
New Revision: 9507
Added:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/api/
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/api/event/
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/api/event/SetEventWithNullNameThrowsIAETestCase.java
modules/portlet/trunk/test/src/test/resources/jsr286/api/
modules/portlet/trunk/test/src/test/resources/jsr286/api/event-war/
modules/portlet/trunk/test/src/test/resources/jsr286/api/event-war/WEB-INF/
modules/portlet/trunk/test/src/test/resources/jsr286/api/event-war/WEB-INF/portlet.xml
modules/portlet/trunk/test/src/test/resources/jsr286/api/event-war/WEB-INF/web.xml
Modified:
modules/portlet/trunk/test/src/test/build.xml
modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml
Log:
API test case for setEvent(null, null)
Added: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/api/event/SetEventWithNullNameThrowsIAETestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/api/event/SetEventWithNullNameThrowsIAETestCase.java (rev 0)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/api/event/SetEventWithNullNameThrowsIAETestCase.java 2008-01-15 11:34:57 UTC (rev 9507)
@@ -0,0 +1,150 @@
+/******************************************************************************
+ * 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.api.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.UTP1;
+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.xml.namespace.QName;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+@TestCase
+public class SetEventWithNullNameThrowsIAETestCase
+{
+ public SetEventWithNullNameThrowsIAETestCase(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
+ {
+ try
+ {
+ response.setEvent((String)null, "Foo");
+ fail();
+ }
+ catch (IllegalArgumentException e)
+ {
+ }
+ try
+ {
+ response.setEvent((QName)null, "Foo");
+ fail();
+ }
+ catch (IllegalArgumentException e)
+ {
+ }
+ try
+ {
+ response.setEvent((String)null, null);
+ fail();
+ }
+ catch (IllegalArgumentException e)
+ {
+ }
+ try
+ {
+ response.setEvent((QName)null, null);
+ fail();
+ }
+ catch (IllegalArgumentException e)
+ {
+ }
+ 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
+ {
+ try
+ {
+ response.setEvent((String)null, "Foo");
+ fail();
+ }
+ catch (IllegalArgumentException e)
+ {
+ }
+ try
+ {
+ response.setEvent((QName)null, "Foo");
+ fail();
+ }
+ catch (IllegalArgumentException e)
+ {
+ }
+ try
+ {
+ response.setEvent((String)null, null);
+ fail();
+ }
+ catch (IllegalArgumentException e)
+ {
+ }
+ try
+ {
+ response.setEvent((QName)null, null);
+ fail();
+ }
+ catch (IllegalArgumentException e)
+ {
+ }
+ }
+ });
+ seq.bindAction(1, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
+ {
+ return new EndTestResponse();
+ }
+ });
+ }
+}
\ No newline at end of file
Modified: modules/portlet/trunk/test/src/test/build.xml
===================================================================
--- modules/portlet/trunk/test/src/test/build.xml 2008-01-15 11:03:45 UTC (rev 9506)
+++ modules/portlet/trunk/test/src/test/build.xml 2008-01-15 11:34:57 UTC (rev 9507)
@@ -134,6 +134,13 @@
</sequential>
</macrodef>
+ <macrodef name="package-jsr286-api-test">
+ <attribute name="test"/>
+ <sequential>
+ <package-testsuite testsuiteversion="jsr286" testsuitetype="api" testsuitename="@{test}"/>
+ </sequential>
+ </macrodef>
+
<macrodef name="package-testsuite">
<attribute name="testsuiteversion"/>
<attribute name="testsuitetype"/>
@@ -222,6 +229,8 @@
<package-jsr286-tck-test test="event"/>
<package-jsr286-tck-test test="eventnonamespace"/>
+ <package-jsr286-api-test test="event"/>
+
<jar jarfile="${test.temp.lib}/portlet-test-lib.jar">
<fileset dir="${target}/test-classes"/>
<fileset dir="${target}/classes"/>
Added: modules/portlet/trunk/test/src/test/resources/jsr286/api/event-war/WEB-INF/portlet.xml
===================================================================
--- modules/portlet/trunk/test/src/test/resources/jsr286/api/event-war/WEB-INF/portlet.xml (rev 0)
+++ modules/portlet/trunk/test/src/test/resources/jsr286/api/event-war/WEB-INF/portlet.xml 2008-01-15 11:34:57 UTC (rev 9507)
@@ -0,0 +1,48 @@
+<?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_0.xsd 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>
+ <supported-processing-event>
+ <name>Foo</name>
+ </supported-processing-event>
+ <supported-publishing-event>
+ <name>Foo</name>
+ </supported-publishing-event>
+ </portlet>
+
+ <event-definition>
+ <name>Foo</name>
+ </event-definition>
+
+</portlet-app>
Added: modules/portlet/trunk/test/src/test/resources/jsr286/api/event-war/WEB-INF/web.xml
===================================================================
--- modules/portlet/trunk/test/src/test/resources/jsr286/api/event-war/WEB-INF/web.xml (rev 0)
+++ modules/portlet/trunk/test/src/test/resources/jsr286/api/event-war/WEB-INF/web.xml 2008-01-15 11:34:57 UTC (rev 9507)
@@ -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-15 11:03:45 UTC (rev 9506)
+++ modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml 2008-01-15 11:34:57 UTC (rev 9507)
@@ -164,6 +164,12 @@
<property name="archiveId" value="test-jsr286-tck-eventnonamespace.war"/>
</generic>
+ <!--Spec API Assertions tests-->
+ <generic>
+ <class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
+ <property name="archiveId" value="test-jsr286-api-event.war"/>
+ </generic>
+
<!--Misc Tests-->
<!--
<generic>
18 years, 3 months
JBoss Portal SVN: r9506 - in modules/portlet/trunk: portlet/src/test/java/org/jboss/portal/unit and 2 other directories.
by portal-commits@lists.jboss.org
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>
18 years, 3 months
JBoss Portal SVN: r9505 - modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit.
by portal-commits@lists.jboss.org
Author: bdaw
Date: 2008-01-15 04:52:00 -0500 (Tue, 15 Jan 2008)
New Revision: 9505
Modified:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/Assertion.java
Log:
typo
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 01:41:18 UTC (rev 9504)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/Assertion.java 2008-01-15 09:52:00 UTC (rev 9505)
@@ -479,18 +479,18 @@
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 " +
"deployment descriptor as event name when submitting an event to the portlet."),
- JSR286_143(new TCK(142), "PLT.15.2.4", "The portlet can send events which are not declared in the portlet " +
+ JSR286_142(new TCK(142), "PLT.15.2.4", "The portlet can send events which are not declared in the portlet " +
"deployment descriptor at runtime using the setEvent method on either the ActionResponse or EventResponse."),
- JSR286_144(new TCK(143), "PLT.15.2.5", "Events are valid only in the current client request and the portlet " +
+ JSR286_143(new TCK(143), "PLT.15.2.5", "Events are valid only in the current client request and the portlet " +
"container must therefore deliver all events within the current client request."),
- JSR286_145(new TCK(144), "PLT.15.2.5", "Event distribution must be serialized for a specific portlet window per " +
+ JSR286_144(new TCK(144), "PLT.15.2.5", "Event distribution must be serialized for a specific portlet window per " +
"client request so that at any given time a portlet window is only processing one event in the processEvent " +
"method for the current client request."),
- JSR286_146(new TCK(145), "PLT.15.2.5", "Portlet event processing may occur after the processing of the action, " +
+ JSR286_145(new TCK(145), "PLT.15.2.5", "Portlet event processing may occur after the processing of the action, " +
"if the portlet was target of an action URL, and must be finished before the render phase."),
- JSR286_147(new TCK(146), "PLT.15.2.6", "If a portlet throws an exception in the processEvent method, all operations" +
+ JSR286_146(new TCK(146), "PLT.15.2.6", "If a portlet throws an exception in the processEvent method, all operations" +
" on the EventResponse must be ignored."),
- JSR286_148(new TCK(147), "PLT.15.2.6", "If a permanent unavailability is indicated by the UnavailableException," +
+ JSR286_147(new TCK(147), "PLT.15.2.6", "If a permanent unavailability is indicated by the UnavailableException," +
" the portlet container must remove the portlet from service immediately, call the portlet’s destroy method," +
" and release the portlet object.")
18 years, 3 months
JBoss Portal SVN: r9504 - modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/actions.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-01-14 20:41:18 -0500 (Mon, 14 Jan 2008)
New Revision: 9504
Modified:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/actions/PortletActionTestAction.java
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/PortletRenderTestAction.java
Log:
better reporting of non checked error
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/actions/PortletActionTestAction.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/actions/PortletActionTestAction.java 2008-01-15 01:23:56 UTC (rev 9503)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/actions/PortletActionTestAction.java 2008-01-15 01:41:18 UTC (rev 9504)
@@ -46,8 +46,22 @@
try
{
run(portlet, request, response, context);
+
+ //
return null;
}
+ catch (Exception e)
+ {
+ if (e instanceof PortletException)
+ {
+ throw (PortletException)e;
+ }
+ if (e instanceof IOException)
+ {
+ throw (IOException)e;
+ }
+ return new FailureResponse(Failure.createAssertionFailure(e));
+ }
catch (AssertionError t)
{
return new FailureResponse(Failure.createFailure(t));
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 01:23:56 UTC (rev 9503)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/actions/PortletEventTestAction.java 2008-01-15 01:41:18 UTC (rev 9504)
@@ -46,8 +46,22 @@
try
{
run(portlet, request, response, context);
+
+ //
return null;
}
+ catch (Exception e)
+ {
+ if (e instanceof PortletException)
+ {
+ throw (PortletException)e;
+ }
+ if (e instanceof IOException)
+ {
+ throw (IOException)e;
+ }
+ return new FailureResponse(Failure.createAssertionFailure(e));
+ }
catch (AssertionError t)
{
return new FailureResponse(Failure.createFailure(t));
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/actions/PortletRenderTestAction.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/actions/PortletRenderTestAction.java 2008-01-15 01:23:56 UTC (rev 9503)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/actions/PortletRenderTestAction.java 2008-01-15 01:41:18 UTC (rev 9504)
@@ -48,6 +48,18 @@
{
return run(servlet, request, response, context);
}
+ catch (Exception e)
+ {
+ if (e instanceof PortletException)
+ {
+ throw (PortletException)e;
+ }
+ if (e instanceof IOException)
+ {
+ throw (IOException)e;
+ }
+ return new FailureResponse(Failure.createAssertionFailure(e));
+ }
catch (AssertionError t)
{
return new FailureResponse(Failure.createFailure(t));
18 years, 3 months
JBoss Portal SVN: r9503 - in modules/portlet/trunk: test/src/test/resources/jsr286/tck/event-war/WEB-INF and 1 other directory.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-01-14 20:23:56 -0500 (Mon, 14 Jan 2008)
New Revision: 9503
Added:
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
Modified:
modules/portlet/trunk/test/src/test/resources/jsr286/tck/event-war/WEB-INF/portlet.xml
Log:
- asserted TCK 142 or 143
Added: 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 (rev 0)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/NonDeclaredEventPublicationDuringActionTestCase.java 2008-01-15 01:23:56 UTC (rev 9503)
@@ -0,0 +1,94 @@
+/******************************************************************************
+ * 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.UTP7;
+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 java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+(a)TestCase({Assertion.JSR286_143})
+public class NonDeclaredEventPublicationDuringActionTestCase
+{
+
+ public NonDeclaredEventPublicationDuringActionTestCase(PortletTestCase seq)
+ {
+ seq.bindAction(0, UTP7.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, UTP7.ACTION_JOIN_POINT, new PortletActionTestAction()
+ {
+ protected void run(Portlet portlet, ActionRequest request, ActionResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ // We just test that we can publish it
+ try
+ {
+ response.setEvent("SomeNonDeclaredString", null);
+ }
+ catch (IllegalArgumentException e)
+ {
+ fail(e);
+ }
+ }
+ });
+ seq.bindAction(1, UTP7.EVENT_JOIN_POINT, new PortletEventTestAction()
+ {
+ protected void run(Portlet portlet, EventRequest request, EventResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ }
+ });
+ seq.bindAction(1, UTP7.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
+ {
+ return new EndTestResponse();
+ }
+ });
+ }
+}
\ No newline at end of file
Added: 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 (rev 0)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/NonDeclaredEventPublicationDuringEventTestCase.java 2008-01-15 01:23:56 UTC (rev 9503)
@@ -0,0 +1,97 @@
+/******************************************************************************
+ * 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.UTP7;
+import org.jboss.portal.test.portlet.framework.UTP8;
+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 java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+(a)TestCase({Assertion.JSR286_143})
+public class NonDeclaredEventPublicationDuringEventTestCase
+{
+
+ public NonDeclaredEventPublicationDuringEventTestCase(PortletTestCase seq)
+ {
+ seq.bindAction(0, UTP8.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, UTP8.ACTION_JOIN_POINT, new PortletActionTestAction()
+ {
+ protected void run(Portlet portlet, ActionRequest request, ActionResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ // Use a declared event to jump to the process event
+ response.setEvent("Bar", null);
+ }
+ });
+ seq.bindAction(1, UTP8.EVENT_JOIN_POINT, new PortletEventTestAction()
+ {
+ protected void run(Portlet portlet, EventRequest request, EventResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ // We just test that we can publish it
+ try
+ {
+ response.setEvent("SomeNonDeclaredString", null);
+ }
+ catch (IllegalArgumentException e)
+ {
+ fail(e);
+ }
+ }
+ });
+ seq.bindAction(1, UTP8.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
+ {
+ return new EndTestResponse();
+ }
+ });
+ }
+}
\ 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 01:10:39 UTC (rev 9502)
+++ modules/portlet/trunk/test/src/test/resources/jsr286/tck/event-war/WEB-INF/portlet.xml 2008-01-15 01:23:56 UTC (rev 9503)
@@ -123,6 +123,28 @@
</supported-publishing-event>
</portlet>
+ <portlet>
+ <portlet-name>UniversalTestPortletG</portlet-name>
+ <portlet-class>org.jboss.portal.test.portlet.framework.UTP7</portlet-class>
+ <supports>
+ <mime-type>text/html</mime-type>
+ </supports>
+ </portlet>
+
+ <portlet>
+ <portlet-name>UniversalTestPortletH</portlet-name>
+ <portlet-class>org.jboss.portal.test.portlet.framework.UTP8</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>
18 years, 3 months
JBoss Portal SVN: r9502 - in modules/portlet/trunk: test/src/test/resources/test and 1 other directory.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-01-14 20:10:39 -0500 (Mon, 14 Jan 2008)
New Revision: 9502
Added:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/PublishMultipleEventsDuringActionTestCase.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/PublishMultipleEventsDuringEventTestCase.java
Removed:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/SendMultipleEventsDuringActionTestCase.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/SendMultipleEventsDuringEventTestCase.java
Modified:
modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml
Log:
- renamed test case
- my bad: commented most of jboss unit tests
Copied: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/PublishMultipleEventsDuringActionTestCase.java (from rev 9499, modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/SendMultipleEventsDuringActionTestCase.java)
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/PublishMultipleEventsDuringActionTestCase.java (rev 0)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/PublishMultipleEventsDuringActionTestCase.java 2008-01-15 01:10:39 UTC (rev 9502)
@@ -0,0 +1,103 @@
+/******************************************************************************
+ * 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.UTP4;
+import org.jboss.portal.common.util.Tools;
+import org.jboss.unit.driver.DriverResponse;
+import org.jboss.unit.driver.response.EndTestResponse;
+import static org.jboss.unit.api.Assert.*;
+import static org.jboss.unit.api.Assert.assertEquals;
+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.Set;
+import java.util.HashSet;
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+(a)TestCase({Assertion.JSR286_136})
+public class PublishMultipleEventsDuringActionTestCase
+{
+
+ /** . */
+ private final List<QName> events = new ArrayList<QName>();
+
+ public PublishMultipleEventsDuringActionTestCase(PortletTestCase seq)
+ {
+ seq.bindAction(0, UTP4.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, UTP4.ACTION_JOIN_POINT, new PortletActionTestAction()
+ {
+ protected void run(Portlet portlet, ActionRequest request, ActionResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ events.clear();
+ response.setEvent("Foo", null);
+ response.setEvent(new QName("urn:explicit-namespace", "Foo"), null);
+ }
+ });
+ seq.bindAction(1, UTP4.EVENT_JOIN_POINT, new PortletEventTestAction()
+ {
+ protected void run(Portlet portlet, EventRequest request, EventResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ Event event = request.getEvent();
+ events.add(event.getQName());
+ }
+ });
+ seq.bindAction(1, UTP4.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
+ {
+ assertEquals(2, events.size());
+ assertEquals(Tools.toSet(new QName("urn:default-namespace", "Foo"), new QName("urn:explicit-namespace", "Foo")), new HashSet<QName>(events));
+ return new EndTestResponse();
+ }
+ });
+ }
+}
\ No newline at end of file
Copied: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/PublishMultipleEventsDuringEventTestCase.java (from rev 9499, modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/SendMultipleEventsDuringEventTestCase.java)
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/PublishMultipleEventsDuringEventTestCase.java (rev 0)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/PublishMultipleEventsDuringEventTestCase.java 2008-01-15 01:10:39 UTC (rev 9502)
@@ -0,0 +1,113 @@
+/******************************************************************************
+ * 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.UTP4;
+import org.jboss.portal.test.portlet.framework.UTP5;
+import org.jboss.portal.common.util.Tools;
+import org.jboss.unit.driver.DriverResponse;
+import org.jboss.unit.driver.response.EndTestResponse;
+import static org.jboss.unit.api.Assert.*;
+import static org.jboss.unit.api.Assert.assertEquals;
+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.Set;
+import java.util.HashSet;
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+(a)TestCase({Assertion.JSR286_136})
+public class PublishMultipleEventsDuringEventTestCase
+{
+
+ /** . */
+ private final List<QName> events = new ArrayList<QName>();
+
+ public PublishMultipleEventsDuringEventTestCase(PortletTestCase seq)
+ {
+ seq.bindAction(0, UTP5.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, UTP5.ACTION_JOIN_POINT, new PortletActionTestAction()
+ {
+ protected void run(Portlet portlet, ActionRequest request, ActionResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ events.clear();
+ response.setEvent("Foo", null);
+ }
+ });
+ seq.bindAction(1, UTP5.EVENT_JOIN_POINT, new PortletEventTestAction()
+ {
+ protected void run(Portlet portlet, EventRequest request, EventResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ Event event = request.getEvent();
+
+ //
+ if (events.size() == 0)
+ {
+ response.setEvent("Foo", null);
+ response.setEvent(new QName("urn:explicit-namespace", "Foo"), null);
+ }
+
+ // Add this event too otherwise it would loop forever
+ events.add(event.getQName());
+ }
+ });
+ seq.bindAction(1, UTP5.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
+ {
+ assertEquals(3, events.size());
+ events.remove(0);
+ assertEquals(Tools.toSet(new QName("urn:default-namespace", "Foo"), new QName("urn:explicit-namespace", "Foo")), new HashSet<QName>(events));
+ return new EndTestResponse();
+ }
+ });
+ }
+}
\ No newline at end of file
Deleted: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/SendMultipleEventsDuringActionTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/SendMultipleEventsDuringActionTestCase.java 2008-01-15 00:57:45 UTC (rev 9501)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/SendMultipleEventsDuringActionTestCase.java 2008-01-15 01:10:39 UTC (rev 9502)
@@ -1,103 +0,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. *
- ******************************************************************************/
-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.UTP4;
-import org.jboss.portal.common.util.Tools;
-import org.jboss.unit.driver.DriverResponse;
-import org.jboss.unit.driver.response.EndTestResponse;
-import static org.jboss.unit.api.Assert.*;
-import static org.jboss.unit.api.Assert.assertEquals;
-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.Set;
-import java.util.HashSet;
-import java.util.List;
-import java.util.ArrayList;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 630 $
- */
-(a)TestCase({Assertion.JSR286_136})
-public class SendMultipleEventsDuringActionTestCase
-{
-
- /** . */
- private final List<QName> events = new ArrayList<QName>();
-
- public SendMultipleEventsDuringActionTestCase(PortletTestCase seq)
- {
- seq.bindAction(0, UTP4.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, UTP4.ACTION_JOIN_POINT, new PortletActionTestAction()
- {
- protected void run(Portlet portlet, ActionRequest request, ActionResponse response, PortletTestContext context) throws PortletException, IOException
- {
- events.clear();
- response.setEvent("Foo", null);
- response.setEvent(new QName("urn:explicit-namespace", "Foo"), null);
- }
- });
- seq.bindAction(1, UTP4.EVENT_JOIN_POINT, new PortletEventTestAction()
- {
- protected void run(Portlet portlet, EventRequest request, EventResponse response, PortletTestContext context) throws PortletException, IOException
- {
- Event event = request.getEvent();
- events.add(event.getQName());
- }
- });
- seq.bindAction(1, UTP4.RENDER_JOIN_POINT, new PortletRenderTestAction()
- {
- protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
- {
- assertEquals(2, events.size());
- assertEquals(Tools.toSet(new QName("urn:default-namespace", "Foo"), new QName("urn:explicit-namespace", "Foo")), new HashSet<QName>(events));
- return new EndTestResponse();
- }
- });
- }
-}
\ No newline at end of file
Deleted: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/SendMultipleEventsDuringEventTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/SendMultipleEventsDuringEventTestCase.java 2008-01-15 00:57:45 UTC (rev 9501)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/SendMultipleEventsDuringEventTestCase.java 2008-01-15 01:10:39 UTC (rev 9502)
@@ -1,113 +0,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. *
- ******************************************************************************/
-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.UTP4;
-import org.jboss.portal.test.portlet.framework.UTP5;
-import org.jboss.portal.common.util.Tools;
-import org.jboss.unit.driver.DriverResponse;
-import org.jboss.unit.driver.response.EndTestResponse;
-import static org.jboss.unit.api.Assert.*;
-import static org.jboss.unit.api.Assert.assertEquals;
-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.Set;
-import java.util.HashSet;
-import java.util.List;
-import java.util.ArrayList;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 630 $
- */
-(a)TestCase({Assertion.JSR286_136})
-public class SendMultipleEventsDuringEventTestCase
-{
-
- /** . */
- private final List<QName> events = new ArrayList<QName>();
-
- public SendMultipleEventsDuringEventTestCase(PortletTestCase seq)
- {
- seq.bindAction(0, UTP5.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, UTP5.ACTION_JOIN_POINT, new PortletActionTestAction()
- {
- protected void run(Portlet portlet, ActionRequest request, ActionResponse response, PortletTestContext context) throws PortletException, IOException
- {
- events.clear();
- response.setEvent("Foo", null);
- }
- });
- seq.bindAction(1, UTP5.EVENT_JOIN_POINT, new PortletEventTestAction()
- {
- protected void run(Portlet portlet, EventRequest request, EventResponse response, PortletTestContext context) throws PortletException, IOException
- {
- Event event = request.getEvent();
-
- //
- if (events.size() == 0)
- {
- response.setEvent("Foo", null);
- response.setEvent(new QName("urn:explicit-namespace", "Foo"), null);
- }
-
- // Add this event too otherwise it would loop forever
- events.add(event.getQName());
- }
- });
- seq.bindAction(1, UTP5.RENDER_JOIN_POINT, new PortletRenderTestAction()
- {
- protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
- {
- assertEquals(3, events.size());
- events.remove(0);
- assertEquals(Tools.toSet(new QName("urn:default-namespace", "Foo"), new QName("urn:explicit-namespace", "Foo")), new HashSet<QName>(events));
- return new EndTestResponse();
- }
- });
- }
-}
\ No newline at end of file
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-15 00:57:45 UTC (rev 9501)
+++ modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml 2008-01-15 01:10:39 UTC (rev 9502)
@@ -4,10 +4,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:jboss:jboss-unit:1.0 jboss-unit_1_0.xsd">
-<!--
- -->
-<!--Spec TCK Assertions tests-->
-<!--
+ <!--Spec TCK Assertions tests-->
<generic>
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId" value="test-jsr168-tck-dispatcher.war"/>
@@ -53,9 +50,7 @@
<property name="archiveId" value="test-jsr168-tck-windowstates.war"/>
</generic>
- -->
-<!--API Tests-->
-<!--
+ <!--API Tests-->
<generic>
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId" value="test-jsr168-api-actionrequest.war"/>
@@ -109,9 +104,7 @@
<property name="archiveId" value="test-jsr168-api-windowstate.war"/>
</generic>
- -->
-<!--Ext Tests-->
-<!--
+ <!--Ext Tests-->
<generic>
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId" value="test-jsr168-ext-dispatcher.war"/>
@@ -153,9 +146,7 @@
<property name="archiveId" value="test-jsr168-ext-nocache.war"/>
</generic>
- -->
-<!--Spec TCK Assertions tests-->
-<!--
+ <!--Spec TCK Assertions tests-->
<generic>
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId" value="test-jsr286-tck-portletconfig.war"/>
@@ -164,17 +155,14 @@
<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>
-<!--
<generic>
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId" value="test-jsr286-tck-eventnonamespace.war"/>
</generic>
--->
<!--Misc Tests-->
<!--
18 years, 3 months
JBoss Portal SVN: r9501 - in modules/portlet/trunk: portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event and 4 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-01-14 19:57:45 -0500 (Mon, 14 Jan 2008)
New Revision: 9501
Added:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/EventPayloadTypeConformanceTestCase.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/JAXBSerializable.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/NonJAXBSerializable.java
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/StateAwareResponseImpl.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/base/AbstractUniversalTestPortlet.java
modules/portlet/trunk/test/src/test/build.xml
modules/portlet/trunk/test/src/test/resources/jsr286/tck/event-war/WEB-INF/portlet.xml
modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml
Log:
added TCK assertion for event payload type validation with respect to JAXB
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-14 17:36:22 UTC (rev 9500)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/StateAwareResponseImpl.java 2008-01-15 00:57:45 UTC (rev 9501)
@@ -45,10 +45,6 @@
import javax.portlet.PortletModeException;
import javax.xml.namespace.QName;
import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.datatype.XMLGregorianCalendar;
-import javax.xml.datatype.Duration;
-import javax.xml.transform.Source;
-import javax.activation.DataHandler;
import java.io.Serializable;
import java.util.Map;
import java.util.Set;
@@ -58,7 +54,7 @@
import java.math.BigDecimal;
import java.math.BigInteger;
import java.net.URI;
-import java.awt.*;
+import java.lang.annotation.Annotation;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -216,8 +212,8 @@
}
}
- private static final Set<? extends Class<? extends Serializable>> blah = Tools.toSet(
- Boolean.class, Byte.class, Long.class, Float.class, Double.class, String.class, URI.class, UUID.class
+ private static final Set<? extends Class<? extends Serializable>> acceptedFinalClasses = Tools.toSet(
+ Boolean.class, Integer.class, Byte.class, Long.class, Float.class, Double.class, String.class, URI.class, UUID.class
);
/**
@@ -228,7 +224,8 @@
*/
private boolean requiresJAXBAnnotation(Class<? extends Serializable> clazz)
{
- if (blah.contains(clazz))
+ // Since they are final a equals should be enough
+ if (acceptedFinalClasses.contains(clazz))
{
return false;
}
@@ -236,48 +233,26 @@
//
if (clazz.getName().startsWith("java"))
{
- if (clazz.getName().startsWith("java."))
+ if (BigInteger.class.isAssignableFrom(clazz))
{
- if (BigInteger.class.isAssignableFrom(clazz))
- {
- return false;
- }
- else if (BigDecimal.class.isAssignableFrom(clazz))
- {
- return false;
- }
- else if (Calendar.class.isAssignableFrom(clazz))
- {
- return false;
- }
- else if (Date.class.isAssignableFrom(clazz))
- {
- return false;
- }
+ return false;
}
- else if (clazz.getName().startsWith("javax."))
+ else if (BigDecimal.class.isAssignableFrom(clazz))
{
- if (QName.class.isAssignableFrom(clazz))
- {
- return false;
- }
- else if (XMLGregorianCalendar.class.isAssignableFrom(clazz))
- {
- return false;
- }
- else if (Duration.class.isAssignableFrom(clazz))
- {
- return false;
- }
- else if (DataHandler.class.isAssignableFrom(clazz))
- {
- return false;
- }
- else if (Source.class.isAssignableFrom(clazz))
- {
- return false;
- }
+ return false;
}
+ else if (Calendar.class.isAssignableFrom(clazz))
+ {
+ return false;
+ }
+ else if (Date.class.isAssignableFrom(clazz))
+ {
+ return false;
+ }
+ else if (QName.class.isAssignableFrom(clazz))
+ {
+ return false;
+ }
}
//
@@ -299,9 +274,13 @@
// Check jaxb annotation
if (requiresJAXBAnnotation(valueType))
{
- XmlRootElement annotation = valueType.getAnnotation(XmlRootElement.class);
- if (annotation == null)
+ for (Annotation a : value.getClass().getAnnotations())
{
+ System.out.println("a = " + a);
+ }
+ boolean b = value.getClass().isAnnotationPresent(XmlRootElement.class);
+ if (!b)
+ {
throw new IllegalArgumentException("The provided event value type " + value.getClass().getName() +
" does not have a valid jaxb annotation");
}
Added: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/EventPayloadTypeConformanceTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/EventPayloadTypeConformanceTestCase.java (rev 0)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/EventPayloadTypeConformanceTestCase.java 2008-01-15 00:57:45 UTC (rev 9501)
@@ -0,0 +1,148 @@
+/******************************************************************************
+ * 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.UTP6;
+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 javax.xml.bind.annotation.XmlRootElement;
+import java.io.IOException;
+import java.io.File;
+import java.io.Serializable;
+import java.util.Date;
+import java.util.UUID;
+import java.util.Calendar;
+import java.util.List;
+import java.util.ArrayList;
+import java.net.URI;
+import java.math.BigInteger;
+import java.math.BigDecimal;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+(a)TestCase({Assertion.JSR286_139})
+public class EventPayloadTypeConformanceTestCase
+{
+
+ private static final URI uri = new File("").toURI();
+ private static final UUID uuid = UUID.randomUUID();
+ private static final Calendar calendar = Calendar.getInstance();
+ private static final Date date = new Date();
+ private static final QName name = new QName("foons", "foolocalname");
+
+ private static final List<Serializable> payloads = new ArrayList<Serializable>();
+
+ static
+ {
+ payloads.add(true);
+ payloads.add(1); // int
+ payloads.add((byte)2);
+ payloads.add((long)3);
+ payloads.add((float)4);
+ payloads.add((double)5);
+ payloads.add("somestring");
+ payloads.add(uri);
+ payloads.add(uuid);
+ payloads.add(new BigInteger("6"));
+ payloads.add(new BigDecimal("7"));
+ payloads.add(calendar);
+ payloads.add(date);
+ payloads.add(name);
+ payloads.add(new JAXBSerializable());
+ }
+
+ public EventPayloadTypeConformanceTestCase(PortletTestCase seq)
+ {
+ seq.bindAction(0, UTP6.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, UTP6.ACTION_JOIN_POINT, new PortletActionTestAction()
+ {
+ protected void run(Portlet portlet, ActionRequest request, ActionResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ // Now try with a non JAXB serializable class
+ try
+ {
+ response.setEvent("Bar", new Serializable()
+ {
+ });
+ fail("Was expecting an IAE");
+ }
+ catch (IllegalArgumentException ignore)
+ {
+ }
+
+ // Now try a bunch of classes
+ for (Serializable payload : payloads)
+ {
+ response.setEvent("Bar", payload);
+ }
+ }
+ });
+ seq.bindAction(1, UTP6.EVENT_JOIN_POINT, new PortletEventTestAction()
+ {
+ protected void run(Portlet portlet, EventRequest request, EventResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ Event event = request.getEvent();
+ if ("Bar".equals(event.getName()) && event.getValue() != null)
+ {
+ payloads.remove(event.getValue());
+ }
+ }
+ });
+ seq.bindAction(1, UTP6.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
+ {
+ assertEquals(0, payloads.size());
+ return new EndTestResponse();
+ }
+ });
+ }
+}
\ No newline at end of file
Added: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/JAXBSerializable.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/JAXBSerializable.java (rev 0)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/JAXBSerializable.java 2008-01-15 00:57:45 UTC (rev 9501)
@@ -0,0 +1,35 @@
+/******************************************************************************
+ * 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 javax.xml.bind.annotation.XmlRootElement;
+import java.io.Serializable;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+@XmlRootElement
+public class JAXBSerializable implements Serializable
+{
+}
Added: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/NonJAXBSerializable.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/NonJAXBSerializable.java (rev 0)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/NonJAXBSerializable.java 2008-01-15 00:57:45 UTC (rev 9501)
@@ -0,0 +1,33 @@
+/******************************************************************************
+ * 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 java.io.Serializable;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class NonJAXBSerializable implements Serializable
+{
+}
\ 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-14 17:36:22 UTC (rev 9500)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/base/AbstractUniversalTestPortlet.java 2008-01-15 00:57:45 UTC (rev 9501)
@@ -187,19 +187,22 @@
TestAction action = portletTestCase.getAction(ctx.getRequestCount(), NodeId.locate(), eventJoinPoint);
//
- if (action instanceof PortletEventTestAction == false)
+ if (action != null)
{
- 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);
+ if (!(action instanceof PortletEventTestAction))
+ {
+ 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);
+ //
+ DriverResponse response = ((PortletEventTestAction)action).execute(this, req, resp, ctx);
- //
- ctx.setResponse(response);
+ //
+ ctx.setResponse(response);
+ }
}
}
}
Modified: modules/portlet/trunk/test/src/test/build.xml
===================================================================
--- modules/portlet/trunk/test/src/test/build.xml 2008-01-14 17:36:22 UTC (rev 9500)
+++ modules/portlet/trunk/test/src/test/build.xml 2008-01-15 00:57:45 UTC (rev 9501)
@@ -374,7 +374,6 @@
<path refid="mc.jboss_xb"/>
<path refid="mc.jboss_aop"/>
<path refid="mc.jboss_microcontainer"/>
- <path refid="mc.jaxb-api"/>
</copy>
<mkdir dir="${test.temp.lib}/tomcat-6.0"/>
@@ -522,6 +521,7 @@
<path location="${dependency.log4j.jar}"/>
<path location="${dependency.concurrent.jar}"/>
<path location="${dependency.activation.jar}"/>
+ <path location="${dependency.jaxb-api.jar}"/>
</sharedClasspath>
<configuration>
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-14 17:36:22 UTC (rev 9500)
+++ modules/portlet/trunk/test/src/test/resources/jsr286/tck/event-war/WEB-INF/portlet.xml 2008-01-15 00:57:45 UTC (rev 9501)
@@ -109,6 +109,20 @@
</supported-publishing-event>
</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>Bar</name>
+ </supported-processing-event>
+ <supported-publishing-event>
+ <name>Bar</name>
+ </supported-publishing-event>
+ </portlet>
+
<default-namespace>urn:default-namespace</default-namespace>
<event-definition>
@@ -121,4 +135,8 @@
<value-type>java.lang.String</value-type>
</event-definition>
+ <event-definition>
+ <name>Bar</name>
+ </event-definition>
+
</portlet-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-14 17:36:22 UTC (rev 9500)
+++ modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml 2008-01-15 00:57:45 UTC (rev 9501)
@@ -4,7 +4,10 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:jboss:jboss-unit:1.0 jboss-unit_1_0.xsd">
- <!--Spec TCK Assertions tests-->
+<!--
+ -->
+<!--Spec TCK Assertions tests-->
+<!--
<generic>
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId" value="test-jsr168-tck-dispatcher.war"/>
@@ -50,7 +53,9 @@
<property name="archiveId" value="test-jsr168-tck-windowstates.war"/>
</generic>
- <!--API Tests-->
+ -->
+<!--API Tests-->
+<!--
<generic>
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId" value="test-jsr168-api-actionrequest.war"/>
@@ -104,7 +109,9 @@
<property name="archiveId" value="test-jsr168-api-windowstate.war"/>
</generic>
- <!--Ext Tests-->
+ -->
+<!--Ext Tests-->
+<!--
<generic>
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId" value="test-jsr168-ext-dispatcher.war"/>
@@ -146,7 +153,9 @@
<property name="archiveId" value="test-jsr168-ext-nocache.war"/>
</generic>
- <!--Spec TCK Assertions tests-->
+ -->
+<!--Spec TCK Assertions tests-->
+<!--
<generic>
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId" value="test-jsr286-tck-portletconfig.war"/>
@@ -155,14 +164,17 @@
<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>
+<!--
<generic>
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId" value="test-jsr286-tck-eventnonamespace.war"/>
</generic>
+-->
<!--Misc Tests-->
<!--
18 years, 3 months
JBoss Portal SVN: r9500 - in modules/portlet/trunk: portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/eventnonamespace and 5 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-01-14 12:36:22 -0500 (Mon, 14 Jan 2008)
New Revision: 9500
Added:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/eventnonamespace/
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/eventnonamespace/NonQualifiedEventNameTestCase.java
modules/portlet/trunk/test/src/test/resources/jsr286/tck/eventnonamespace-war/
modules/portlet/trunk/test/src/test/resources/jsr286/tck/eventnonamespace-war/WEB-INF/
modules/portlet/trunk/test/src/test/resources/jsr286/tck/eventnonamespace-war/WEB-INF/portlet.xml
modules/portlet/trunk/test/src/test/resources/jsr286/tck/eventnonamespace-war/WEB-INF/web.xml
Modified:
modules/portlet/trunk/test/src/test/build.xml
modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml
Log:
added TCK assertion for event publishing with a non qualified name and with no default namespace in the DD
Added: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/eventnonamespace/NonQualifiedEventNameTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/eventnonamespace/NonQualifiedEventNameTestCase.java (rev 0)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/eventnonamespace/NonQualifiedEventNameTestCase.java 2008-01-14 17:36:22 UTC (rev 9500)
@@ -0,0 +1,91 @@
+/******************************************************************************
+ * 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.eventnonamespace;
+
+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.UTP1;
+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 javax.xml.XMLConstants;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+(a)TestCase({Assertion.JSR286_138})
+public class NonQualifiedEventNameTestCase
+{
+ public NonQualifiedEventNameTestCase(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
+ {
+ Event event = request.getEvent();
+ assertEquals(new QName(XMLConstants.NULL_NS_URI, "Foo"), event.getQName());
+ assertEquals(null, event.getValue());
+ }
+ });
+ seq.bindAction(1, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
+ {
+ return new EndTestResponse();
+ }
+ });
+ }
+}
\ No newline at end of file
Modified: modules/portlet/trunk/test/src/test/build.xml
===================================================================
--- modules/portlet/trunk/test/src/test/build.xml 2008-01-14 14:33:52 UTC (rev 9499)
+++ modules/portlet/trunk/test/src/test/build.xml 2008-01-14 17:36:22 UTC (rev 9500)
@@ -220,6 +220,7 @@
<package-jsr286-tck-test test="portletconfig"/>
<package-jsr286-tck-test test="portletconfignonamespace"/>
<package-jsr286-tck-test test="event"/>
+ <package-jsr286-tck-test test="eventnonamespace"/>
<jar jarfile="${test.temp.lib}/portlet-test-lib.jar">
<fileset dir="${target}/test-classes"/>
Added: modules/portlet/trunk/test/src/test/resources/jsr286/tck/eventnonamespace-war/WEB-INF/portlet.xml
===================================================================
--- modules/portlet/trunk/test/src/test/resources/jsr286/tck/eventnonamespace-war/WEB-INF/portlet.xml (rev 0)
+++ modules/portlet/trunk/test/src/test/resources/jsr286/tck/eventnonamespace-war/WEB-INF/portlet.xml 2008-01-14 17:36:22 UTC (rev 9500)
@@ -0,0 +1,54 @@
+<?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_0.xsd 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>
+ <supported-processing-event>
+ <name>Foo</name>
+ </supported-processing-event>
+ <supported-publishing-event>
+ <name>Foo</name>
+ </supported-publishing-event>
+ </portlet>
+
+ <event-definition>
+ <name>Foo</name>
+ <value-type>java.lang.String</value-type>
+ </event-definition>
+
+ <event-definition>
+ <qname xmlns:a="urn:explicit-namespace">a:Foo</qname>
+ <value-type>java.lang.String</value-type>
+ </event-definition>
+
+</portlet-app>
Added: modules/portlet/trunk/test/src/test/resources/jsr286/tck/eventnonamespace-war/WEB-INF/web.xml
===================================================================
--- modules/portlet/trunk/test/src/test/resources/jsr286/tck/eventnonamespace-war/WEB-INF/web.xml (rev 0)
+++ modules/portlet/trunk/test/src/test/resources/jsr286/tck/eventnonamespace-war/WEB-INF/web.xml 2008-01-14 17:36:22 UTC (rev 9500)
@@ -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-14 14:33:52 UTC (rev 9499)
+++ modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml 2008-01-14 17:36:22 UTC (rev 9500)
@@ -159,6 +159,10 @@
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId" value="test-jsr286-tck-event.war"/>
</generic>
+ <generic>
+ <class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
+ <property name="archiveId" value="test-jsr286-tck-eventnonamespace.war"/>
+ </generic>
<!--Misc Tests-->
<!--
18 years, 3 months
JBoss Portal SVN: r9499 - in modules/portlet/trunk: portlet/src/test/java/org/jboss/portal/test/portlet/jsr168/tck/portletinterface and 4 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-01-14 09:33:52 -0500 (Mon, 14 Jan 2008)
New Revision: 9499
Added:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/GetEventWithNoValueTestCase.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/GetEventWithValueTestCase.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/NonQualifiedEventNameTestCase.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/SendMultipleEventsDuringActionTestCase.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/SendMultipleEventsDuringEventTestCase.java
Removed:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/EventTestCase.java
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/StateAwareResponseImpl.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr168/tck/portletinterface/InvokeRenderAfterRenderURLTestCase.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/test/resources/jsr286/tck/event-war/WEB-INF/portlet.xml
Log:
3 TCK assertions implemented for eventing
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-14 11:10:14 UTC (rev 9498)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/StateAwareResponseImpl.java 2008-01-14 14:33:52 UTC (rev 9499)
@@ -35,6 +35,7 @@
import org.jboss.portal.portlet.impl.info.ContainerEventInfo;
import org.jboss.portal.Mode;
import org.jboss.portal.common.NotYetImplemented;
+import org.jboss.portal.common.util.Tools;
import org.apache.log4j.Logger;
import javax.portlet.StateAwareResponse;
@@ -44,8 +45,20 @@
import javax.portlet.PortletModeException;
import javax.xml.namespace.QName;
import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.datatype.XMLGregorianCalendar;
+import javax.xml.datatype.Duration;
+import javax.xml.transform.Source;
+import javax.activation.DataHandler;
import java.io.Serializable;
import java.util.Map;
+import java.util.Set;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.UUID;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.net.URI;
+import java.awt.*;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -203,6 +216,74 @@
}
}
+ private static final Set<? extends Class<? extends Serializable>> blah = Tools.toSet(
+ Boolean.class, Byte.class, Long.class, Float.class, Double.class, String.class, URI.class, UUID.class
+ );
+
+ /**
+ * Returns true if the class requires a check of its JAXB annotation.
+ *
+ * @param clazz the class to check
+ * @return true if the class requires the JAXB annotation
+ */
+ private boolean requiresJAXBAnnotation(Class<? extends Serializable> clazz)
+ {
+ if (blah.contains(clazz))
+ {
+ return false;
+ }
+
+ //
+ if (clazz.getName().startsWith("java"))
+ {
+ if (clazz.getName().startsWith("java."))
+ {
+ if (BigInteger.class.isAssignableFrom(clazz))
+ {
+ return false;
+ }
+ else if (BigDecimal.class.isAssignableFrom(clazz))
+ {
+ return false;
+ }
+ else if (Calendar.class.isAssignableFrom(clazz))
+ {
+ return false;
+ }
+ else if (Date.class.isAssignableFrom(clazz))
+ {
+ return false;
+ }
+ }
+ else if (clazz.getName().startsWith("javax."))
+ {
+ if (QName.class.isAssignableFrom(clazz))
+ {
+ return false;
+ }
+ else if (XMLGregorianCalendar.class.isAssignableFrom(clazz))
+ {
+ return false;
+ }
+ else if (Duration.class.isAssignableFrom(clazz))
+ {
+ return false;
+ }
+ else if (DataHandler.class.isAssignableFrom(clazz))
+ {
+ return false;
+ }
+ else if (Source.class.isAssignableFrom(clazz))
+ {
+ return false;
+ }
+ }
+ }
+
+ //
+ return true;
+ }
+
public void setEvent(QName name, Serializable value)
{
if (name == null)
@@ -216,11 +297,14 @@
Class<? extends Serializable> valueType = value.getClass();
// Check jaxb annotation
- XmlRootElement annotation = valueType.getAnnotation(XmlRootElement.class);
- if (annotation == null)
+ if (requiresJAXBAnnotation(valueType))
{
- throw new IllegalArgumentException("The provided event value type " + value.getClass().getName() +
- " does not have a valid jaxb annotation");
+ XmlRootElement annotation = valueType.getAnnotation(XmlRootElement.class);
+ if (annotation == null)
+ {
+ throw new IllegalArgumentException("The provided event value type " + value.getClass().getName() +
+ " does not have a valid jaxb annotation");
+ }
}
//
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr168/tck/portletinterface/InvokeRenderAfterRenderURLTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr168/tck/portletinterface/InvokeRenderAfterRenderURLTestCase.java 2008-01-14 11:10:14 UTC (rev 9498)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr168/tck/portletinterface/InvokeRenderAfterRenderURLTestCase.java 2008-01-14 14:33:52 UTC (rev 9499)
@@ -64,7 +64,7 @@
}
});
- seq.bindAction(1, UTP2.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ seq.bindAction(1, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
{
protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
{
Deleted: 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 2008-01-14 11:10:14 UTC (rev 9498)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/EventTestCase.java 2008-01-14 14:33:52 UTC (rev 9499)
@@ -1,92 +0,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. *
- ******************************************************************************/
-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 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 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);
- response.setRenderParameter("bar", "bar");
- }
- });
- seq.bindAction(1, UTP1.EVENT_JOIN_POINT, new PortletEventTestAction()
- {
- protected void run(Portlet portlet, EventRequest request, EventResponse response, PortletTestContext context) throws PortletException, IOException
- {
- String bar = request.getParameter("bar");
- assertEquals("bar", bar);
- response.setRenderParameter("bar", "juu");
- }
- });
- seq.bindAction(1, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
- {
- protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
- {
- String bar = request.getParameter("bar");
- assertEquals("juu", bar);
- return new EndTestResponse();
- }
- });
- }
-}
Added: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/GetEventWithNoValueTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/GetEventWithNoValueTestCase.java (rev 0)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/GetEventWithNoValueTestCase.java 2008-01-14 14:33:52 UTC (rev 9499)
@@ -0,0 +1,90 @@
+/******************************************************************************
+ * 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.UTP1;
+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;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+(a)TestCase({Assertion.JSR286_133})
+public class GetEventWithNoValueTestCase
+{
+ public GetEventWithNoValueTestCase(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(new QName("urn:explicit-namespace", "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
+ {
+ Event event = request.getEvent();
+ assertEquals(new QName("urn:explicit-namespace", "Foo"), event.getQName());
+ assertEquals(null, event.getValue());
+ }
+ });
+ seq.bindAction(1, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
+ {
+ return new EndTestResponse();
+ }
+ });
+ }
+}
\ No newline at end of file
Added: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/GetEventWithValueTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/GetEventWithValueTestCase.java (rev 0)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/GetEventWithValueTestCase.java 2008-01-14 14:33:52 UTC (rev 9499)
@@ -0,0 +1,90 @@
+/******************************************************************************
+ * 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.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;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+(a)TestCase({Assertion.JSR286_133})
+public class GetEventWithValueTestCase
+{
+ public GetEventWithValueTestCase(PortletTestCase seq)
+ {
+ seq.bindAction(0, UTP2.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, UTP2.ACTION_JOIN_POINT, new PortletActionTestAction()
+ {
+ protected void run(Portlet portlet, ActionRequest request, ActionResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ response.setEvent(new QName("urn:explicit-namespace", "Foo"), "Bar");
+ }
+ });
+ seq.bindAction(1, UTP2.EVENT_JOIN_POINT, new PortletEventTestAction()
+ {
+ protected void run(Portlet portlet, EventRequest request, EventResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ Event event = request.getEvent();
+ assertEquals(new QName("urn:explicit-namespace", "Foo"), event.getQName());
+ assertEquals("Bar", event.getValue());
+ }
+ });
+ seq.bindAction(1, UTP2.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
+ {
+ return new EndTestResponse();
+ }
+ });
+ }
+}
\ No newline at end of file
Added: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/NonQualifiedEventNameTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/NonQualifiedEventNameTestCase.java (rev 0)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/NonQualifiedEventNameTestCase.java 2008-01-14 14:33:52 UTC (rev 9499)
@@ -0,0 +1,90 @@
+/******************************************************************************
+ * 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.UTP3;
+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;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+(a)TestCase({Assertion.JSR286_137})
+public class NonQualifiedEventNameTestCase
+{
+ public NonQualifiedEventNameTestCase(PortletTestCase seq)
+ {
+ seq.bindAction(0, UTP3.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, UTP3.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, UTP3.EVENT_JOIN_POINT, new PortletEventTestAction()
+ {
+ protected void run(Portlet portlet, EventRequest request, EventResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ Event event = request.getEvent();
+ assertEquals(new QName("urn:default-namespace", "Foo"), event.getQName());
+ assertEquals(null, event.getValue());
+ }
+ });
+ seq.bindAction(1, UTP3.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
+ {
+ return new EndTestResponse();
+ }
+ });
+ }
+}
\ No newline at end of file
Added: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/SendMultipleEventsDuringActionTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/SendMultipleEventsDuringActionTestCase.java (rev 0)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/SendMultipleEventsDuringActionTestCase.java 2008-01-14 14:33:52 UTC (rev 9499)
@@ -0,0 +1,103 @@
+/******************************************************************************
+ * 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.UTP4;
+import org.jboss.portal.common.util.Tools;
+import org.jboss.unit.driver.DriverResponse;
+import org.jboss.unit.driver.response.EndTestResponse;
+import static org.jboss.unit.api.Assert.*;
+import static org.jboss.unit.api.Assert.assertEquals;
+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.Set;
+import java.util.HashSet;
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+(a)TestCase({Assertion.JSR286_136})
+public class SendMultipleEventsDuringActionTestCase
+{
+
+ /** . */
+ private final List<QName> events = new ArrayList<QName>();
+
+ public SendMultipleEventsDuringActionTestCase(PortletTestCase seq)
+ {
+ seq.bindAction(0, UTP4.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, UTP4.ACTION_JOIN_POINT, new PortletActionTestAction()
+ {
+ protected void run(Portlet portlet, ActionRequest request, ActionResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ events.clear();
+ response.setEvent("Foo", null);
+ response.setEvent(new QName("urn:explicit-namespace", "Foo"), null);
+ }
+ });
+ seq.bindAction(1, UTP4.EVENT_JOIN_POINT, new PortletEventTestAction()
+ {
+ protected void run(Portlet portlet, EventRequest request, EventResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ Event event = request.getEvent();
+ events.add(event.getQName());
+ }
+ });
+ seq.bindAction(1, UTP4.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
+ {
+ assertEquals(2, events.size());
+ assertEquals(Tools.toSet(new QName("urn:default-namespace", "Foo"), new QName("urn:explicit-namespace", "Foo")), new HashSet<QName>(events));
+ return new EndTestResponse();
+ }
+ });
+ }
+}
\ No newline at end of file
Added: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/SendMultipleEventsDuringEventTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/SendMultipleEventsDuringEventTestCase.java (rev 0)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/SendMultipleEventsDuringEventTestCase.java 2008-01-14 14:33:52 UTC (rev 9499)
@@ -0,0 +1,113 @@
+/******************************************************************************
+ * 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.UTP4;
+import org.jboss.portal.test.portlet.framework.UTP5;
+import org.jboss.portal.common.util.Tools;
+import org.jboss.unit.driver.DriverResponse;
+import org.jboss.unit.driver.response.EndTestResponse;
+import static org.jboss.unit.api.Assert.*;
+import static org.jboss.unit.api.Assert.assertEquals;
+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.Set;
+import java.util.HashSet;
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+(a)TestCase({Assertion.JSR286_136})
+public class SendMultipleEventsDuringEventTestCase
+{
+
+ /** . */
+ private final List<QName> events = new ArrayList<QName>();
+
+ public SendMultipleEventsDuringEventTestCase(PortletTestCase seq)
+ {
+ seq.bindAction(0, UTP5.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, UTP5.ACTION_JOIN_POINT, new PortletActionTestAction()
+ {
+ protected void run(Portlet portlet, ActionRequest request, ActionResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ events.clear();
+ response.setEvent("Foo", null);
+ }
+ });
+ seq.bindAction(1, UTP5.EVENT_JOIN_POINT, new PortletEventTestAction()
+ {
+ protected void run(Portlet portlet, EventRequest request, EventResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ Event event = request.getEvent();
+
+ //
+ if (events.size() == 0)
+ {
+ response.setEvent("Foo", null);
+ response.setEvent(new QName("urn:explicit-namespace", "Foo"), null);
+ }
+
+ // Add this event too otherwise it would loop forever
+ events.add(event.getQName());
+ }
+ });
+ seq.bindAction(1, UTP5.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
+ {
+ assertEquals(3, events.size());
+ events.remove(0);
+ assertEquals(Tools.toSet(new QName("urn:default-namespace", "Foo"), new QName("urn:explicit-namespace", "Foo")), new HashSet<QName>(events));
+ return new EndTestResponse();
+ }
+ });
+ }
+}
\ No newline at end of file
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-14 11:10:14 UTC (rev 9498)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/PortletTestContext.java 2008-01-14 14:33:52 UTC (rev 9499)
@@ -80,7 +80,7 @@
public DriverResponse getResponse()
{
- return responseContext.getResponse();
+ return responseContext != null ? responseContext.getResponse() : null;
}
public int getRequestCount()
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-14 11:10:14 UTC (rev 9498)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/base/AbstractUniversalTestPortlet.java 2008-01-14 14:33:52 UTC (rev 9499)
@@ -187,12 +187,8 @@
TestAction action = portletTestCase.getAction(ctx.getRequestCount(), NodeId.locate(), eventJoinPoint);
//
- if (action == null)
+ if (action instanceof PortletEventTestAction == false)
{
- 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
@@ -234,6 +230,8 @@
reset();
}
+ //
+ boolean invoked = false;
// Get the action
TestAction action = null;
PortletTestCase portletTestCase = getSequence(ctx.getTestName());
@@ -252,7 +250,7 @@
DriverResponse response = ((PortletRenderTestAction)action).execute(this, req, resp, ctx);
// If we have one result it is meant to be returned to the client
- if (response != null)
+ if (ctx.getResponse() == null && response != null)
{
ctx.setResponse(response);
}
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-14 11:10:14 UTC (rev 9498)
+++ modules/portlet/trunk/test/src/test/resources/jsr286/tck/event-war/WEB-INF/portlet.xml 2008-01-14 14:33:52 UTC (rev 9499)
@@ -34,6 +34,34 @@
<mime-type>text/html</mime-type>
</supports>
<supported-processing-event>
+ <qname xmlns:a="urn:explicit-namespace">a:Foo</qname>
+ </supported-processing-event>
+ <supported-publishing-event>
+ <qname xmlns:a="urn:explicit-namespace">a:Foo</qname>
+ </supported-publishing-event>
+ </portlet>
+
+ <portlet>
+ <portlet-name>UniversalTestPortletB</portlet-name>
+ <portlet-class>org.jboss.portal.test.portlet.framework.UTP2</portlet-class>
+ <supports>
+ <mime-type>text/html</mime-type>
+ </supports>
+ <supported-processing-event>
+ <qname xmlns:a="urn:explicit-namespace">a:Foo</qname>
+ </supported-processing-event>
+ <supported-publishing-event>
+ <qname xmlns:a="urn:explicit-namespace">a:Foo</qname>
+ </supported-publishing-event>
+ </portlet>
+
+ <portlet>
+ <portlet-name>UniversalTestPortletC</portlet-name>
+ <portlet-class>org.jboss.portal.test.portlet.framework.UTP3</portlet-class>
+ <supports>
+ <mime-type>text/html</mime-type>
+ </supports>
+ <supported-processing-event>
<name>Foo</name>
</supported-processing-event>
<supported-publishing-event>
@@ -41,8 +69,56 @@
</supported-publishing-event>
</portlet>
+ <portlet>
+ <portlet-name>UniversalTestPortletD</portlet-name>
+ <portlet-class>org.jboss.portal.test.portlet.framework.UTP4</portlet-class>
+ <supports>
+ <mime-type>text/html</mime-type>
+ </supports>
+ <supported-processing-event>
+ <qname xmlns:a="urn:explicit-namespace">a:Foo</qname>
+ </supported-processing-event>
+ <supported-processing-event>
+ <name>Foo</name>
+ </supported-processing-event>
+ <supported-publishing-event>
+ <qname xmlns:a="urn:explicit-namespace">a:Foo</qname>
+ </supported-publishing-event>
+ <supported-publishing-event>
+ <name>Foo</name>
+ </supported-publishing-event>
+ </portlet>
+
+ <portlet>
+ <portlet-name>UniversalTestPortletE</portlet-name>
+ <portlet-class>org.jboss.portal.test.portlet.framework.UTP5</portlet-class>
+ <supports>
+ <mime-type>text/html</mime-type>
+ </supports>
+ <supported-processing-event>
+ <qname xmlns:a="urn:explicit-namespace">a:Foo</qname>
+ </supported-processing-event>
+ <supported-processing-event>
+ <name>Foo</name>
+ </supported-processing-event>
+ <supported-publishing-event>
+ <qname xmlns:a="urn:explicit-namespace">a:Foo</qname>
+ </supported-publishing-event>
+ <supported-publishing-event>
+ <name>Foo</name>
+ </supported-publishing-event>
+ </portlet>
+
+ <default-namespace>urn:default-namespace</default-namespace>
+
<event-definition>
<name>Foo</name>
+ <value-type>java.lang.String</value-type>
</event-definition>
+ <event-definition>
+ <qname xmlns:a="urn:explicit-namespace">a:Foo</qname>
+ <value-type>java.lang.String</value-type>
+ </event-definition>
+
</portlet-app>
18 years, 3 months
JBoss Portal SVN: r9498 - in modules/portlet/trunk: portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168 and 6 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-01-14 06:10:14 -0500 (Mon, 14 Jan 2008)
New Revision: 9498
Added:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/spi/AbstractEventContext.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/TestEventContext.java
Removed:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/RenderResponse.java
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/ProducerCacheInterceptor.java
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/api/EventRequestImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/RenderRequestImpl.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/EventTestCase.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortalNavigationalState.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/WindowNavigationalState.java
modules/portlet/trunk/test/src/test/resources/jsr286/tck/event-war/WEB-INF/portlet.xml
Log:
- early implementation of consumer side event delivery by the portal test
- basic test case for eventing
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/ProducerCacheInterceptor.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/ProducerCacheInterceptor.java 2008-01-14 10:16:55 UTC (rev 9497)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/ProducerCacheInterceptor.java 2008-01-14 11:10:14 UTC (rev 9498)
@@ -29,6 +29,7 @@
import org.jboss.portal.portlet.invocation.PortletInterceptor;
import org.jboss.portal.portlet.invocation.PortletInvocation;
import org.jboss.portal.portlet.invocation.RenderInvocation;
+import org.jboss.portal.portlet.invocation.EventInvocation;
import org.jboss.portal.portlet.invocation.response.FragmentResponse;
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
import org.jboss.portal.portlet.container.PortletContainerInvoker;
@@ -52,6 +53,11 @@
// Invoke
return invocation.invokeNext();
}
+ else if (invocation instanceof EventInvocation)
+ {
+ // Invoke
+ return invocation.invokeNext();
+ }
else if (invocation instanceof RenderInvocation)
{
// Invoke
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-14 10:16:55 UTC (rev 9497)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletContainerImpl.java 2008-01-14 11:10:14 UTC (rev 9498)
@@ -355,6 +355,10 @@
{
return invokeRender((RenderInvocation)invocation);
}
+ else if (invocation instanceof EventInvocation)
+ {
+ return invokeEvent((EventInvocation)invocation);
+ }
else
{
throw new InvocationException("Unexpected invocation " + invocation);
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/EventRequestImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/EventRequestImpl.java 2008-01-14 10:16:55 UTC (rev 9497)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/EventRequestImpl.java 2008-01-14 11:10:14 UTC (rev 9498)
@@ -24,6 +24,9 @@
import org.jboss.portal.portlet.invocation.EventInvocation;
import org.jboss.portal.portlet.spi.EventContext;
+import org.jboss.portal.portlet.spi.PortletInvocationContext;
+import org.jboss.portal.portlet.PortletParametersStateString;
+import org.jboss.portal.portlet.StateString;
import javax.portlet.EventRequest;
import javax.portlet.Event;
@@ -41,6 +44,27 @@
public EventRequestImpl(EventInvocation invocation)
{
super(invocation);
+
+ //
+ PortletInvocationContext context = invocation.getPortletContext();
+
+ // Get the possibly null navigational state
+ StateString navigationalState = context.getNavigationalState();
+
+ //
+ if (navigationalState == null)
+ {
+
+ }
+ else if (navigationalState instanceof PortletParametersStateString)
+ {
+ parameters = ((PortletParametersStateString)navigationalState).getParameters();
+ }
+ else
+ {
+ PortletParametersStateString parametersState = new PortletParametersStateString(navigationalState.getStringValue());
+ parameters = parametersState.getParameters();
+ }
}
public Event getEvent()
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/RenderRequestImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/RenderRequestImpl.java 2008-01-14 10:16:55 UTC (rev 9497)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/RenderRequestImpl.java 2008-01-14 11:10:14 UTC (rev 9498)
@@ -26,6 +26,7 @@
import org.jboss.portal.portlet.StateString;
import org.jboss.portal.portlet.invocation.RenderInvocation;
import org.jboss.portal.portlet.spi.RenderContext;
+import org.jboss.portal.portlet.spi.PortletInvocationContext;
import org.jboss.portal.common.NotYetImplemented;
import javax.portlet.RenderRequest;
@@ -40,18 +41,15 @@
public class RenderRequestImpl extends PortletRequestImpl implements RenderRequest
{
- /** . */
- protected RenderContext renderContext;
-
public RenderRequestImpl(RenderInvocation invocation)
{
super(invocation);
// Get the render context
- renderContext = (RenderContext)invocation.getPortletContext();
+ PortletInvocationContext context = invocation.getPortletContext();
// Get the possibly null navigational state
- StateString navigationalState = renderContext.getNavigationalState();
+ StateString navigationalState = context.getNavigationalState();
//
if (navigationalState == null)
Added: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/spi/AbstractEventContext.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/spi/AbstractEventContext.java (rev 0)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/spi/AbstractEventContext.java 2008-01-14 11:10:14 UTC (rev 9498)
@@ -0,0 +1,72 @@
+/******************************************************************************
+ * 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.impl.spi;
+
+import org.jboss.portal.portlet.spi.RenderContext;
+import org.jboss.portal.portlet.spi.EventContext;
+import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.common.util.MarkupInfo;
+
+import javax.xml.namespace.QName;
+import java.io.Serializable;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class AbstractEventContext extends AbstractPortletInvocationContext implements EventContext
+{
+
+ /** . */
+ protected QName name;
+
+ /** . */
+ protected Serializable payload;
+
+ protected AbstractEventContext(
+ Mode mode,
+ WindowState windowState,
+ StateString navigationalState,
+ MarkupInfo markupInfo,
+ QName name,
+ Serializable payload)
+ {
+ super(mode, windowState, navigationalState, markupInfo);
+
+ //
+ this.name = name;
+ this.payload = payload;
+ }
+
+ public QName getName()
+ {
+ return name;
+ }
+
+ public Serializable getPayload()
+ {
+ return payload;
+ }
+}
\ No newline at end of file
Deleted: 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/RenderResponse.java 2008-01-14 10:16:55 UTC (rev 9497)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/RenderResponse.java 2008-01-14 11:10:14 UTC (rev 9498)
@@ -1,85 +0,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. *
- ******************************************************************************/
-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 RenderResponse 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 RenderResponse()
- {
- 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;
- }
-}
Modified: 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 2008-01-14 10:16:55 UTC (rev 9497)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/EventTestCase.java 2008-01-14 11:10:14 UTC (rev 9498)
@@ -33,6 +33,7 @@
import org.jboss.portal.test.portlet.framework.UTP1;
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;
@@ -66,18 +67,24 @@
protected void run(Portlet portlet, ActionRequest request, ActionResponse response, PortletTestContext context) throws PortletException, IOException
{
response.setEvent("Foo", null);
+ response.setRenderParameter("bar", "bar");
}
});
seq.bindAction(1, UTP1.EVENT_JOIN_POINT, new PortletEventTestAction()
{
protected void run(Portlet portlet, EventRequest request, EventResponse response, PortletTestContext context) throws PortletException, IOException
{
+ String bar = request.getParameter("bar");
+ assertEquals("bar", bar);
+ response.setRenderParameter("bar", "juu");
}
});
seq.bindAction(1, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
{
protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
{
+ String bar = request.getParameter("bar");
+ assertEquals("juu", bar);
return new EndTestResponse();
}
});
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortalNavigationalState.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortalNavigationalState.java 2008-01-14 10:16:55 UTC (rev 9497)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortalNavigationalState.java 2008-01-14 11:10:14 UTC (rev 9498)
@@ -41,11 +41,11 @@
{
/** . */
- private final Map windows = new HashMap();
+ private final Map<String, WindowNavigationalState> windows = new HashMap<String, WindowNavigationalState>();
public WindowNavigationalState getWindow(String windowId)
{
- return (WindowNavigationalState)windows.get(windowId);
+ return windows.get(windowId);
}
public void setWindow(String windowId, WindowNavigationalState window)
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-14 10:16:55 UTC (rev 9497)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java 2008-01-14 11:10:14 UTC (rev 9498)
@@ -27,6 +27,8 @@
import org.jboss.portal.portlet.PortletParametersStateString;
import org.jboss.portal.portlet.PortletParameters;
import org.jboss.portal.portlet.PortletInvokerException;
+import org.jboss.portal.portlet.info.PortletInfo;
+import org.jboss.portal.portlet.info.EventInfo;
import org.jboss.portal.portlet.impl.spi.AbstractRequestContext;
import org.jboss.portal.portlet.impl.spi.AbstractUserContext;
import org.jboss.portal.portlet.impl.spi.AbstractWindowContext;
@@ -39,12 +41,14 @@
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.portlet.invocation.EventInvocation;
import org.jboss.portal.web.IllegalRequestException;
import org.jboss.portal.common.util.ParameterMap;
import org.jboss.portal.common.util.MarkupInfo;
import org.jboss.portal.common.util.MediaType;
import org.jboss.portal.Mode;
import org.jboss.portal.WindowState;
+import org.apache.log4j.Logger;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -52,6 +56,9 @@
import java.io.PrintWriter;
import java.io.IOException;
import java.util.Iterator;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.LinkedList;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -66,8 +73,12 @@
/** . */
private final boolean redirectAfterAction = true;
+ /** . */
+ private final Logger log;
+
public PortletController() throws IllegalRequestException, UnsupportedEncodingException
{
+ log = Logger.getLogger(PortletController.class);
}
private PortletInvocationResponse handle(PortletControllerContext context, Action action) throws PortletInvokerException, IOException
@@ -151,6 +162,55 @@
}
}
+ private PortletInvocationResponse deliverEvent(
+ PortletControllerContext context,
+ Portlet portlet,
+ StateResponse.Event event)
+ {
+ HttpServletRequest req = context.getClientRequest();
+ HttpServletResponse resp = context.getClientResponse();
+ PortalNavigationalState navState = context.getNavigationalState();
+ PortletURLRenderer renderer = new PortletURLRenderer(navState, portlet, req, resp);
+ WindowNavigationalState windowNS = navState.getWindow(portlet.getContext().getId());
+
+ //
+ if (windowNS == null)
+ {
+ windowNS = new WindowNavigationalState();
+ }
+
+ //
+ TestInstanceContext instanceContext = new TestInstanceContext(req, portlet.getContext(), true);
+ TestEventContext actionContext = new TestEventContext(
+ renderer,
+ windowNS.getMode(),
+ windowNS.getWindowState(),
+ windowNS.getPortletNavigationalState(),
+ MARKUP_INFO,
+ event.getName(),
+ event.getPayload());
+ EventInvocation eventInvocation = new EventInvocation(actionContext);
+
+ //
+ eventInvocation.setRequestContext(new AbstractRequestContext(req, resp));
+ eventInvocation.setInstanceContext(instanceContext);
+ eventInvocation.setUserContext(new AbstractUserContext(req));
+ eventInvocation.setWindowContext(new AbstractWindowContext(portlet.getContext().getId()));
+ eventInvocation.setPortalContext(new AbstractPortalContext());
+ eventInvocation.setSecurityContext(new AbstractSecurityContext(req));
+ eventInvocation.setTarget(instanceContext.getTarget());
+
+ //
+ try
+ {
+ return context.invoke(eventInvocation);
+ }
+ catch (PortletInvokerException e)
+ {
+ return null;
+ }
+ }
+
public void process(PortletControllerContext context, Action action) throws PortletInvokerException, IOException
{
HttpServletRequest req = context.getClientRequest();
@@ -163,17 +223,113 @@
PortletInvocationResponse response = handle(context, action);
//
- if (response instanceof StateResponse)
+ if (response instanceof ErrorResponse)
{
+ ErrorResponse error = (ErrorResponse)response;
+
+ //
+ if (error.getCause() != null)
+ {
+ log.error("Portlet action threw an error: " + error.getMessage(), error.getCause());
+ }
+ else
+ {
+ log.error("Portlet action threw an error: " + error.getMessage());
+ }
+
+ //
+ resp.sendError(404, error.getMessage());
+ }
+ else if (response instanceof StateResponse)
+ {
StateResponse stateResponse = (StateResponse)response;
+ // Update portlet NS
+ if (response instanceof UpdateNavigationalStateResponse)
+ {
+ updateNavigationalState(navState, action.portletId, (UpdateNavigationalStateResponse)response);
+ }
+
+ // Create event list and feed it with the events that may have been produced
+ LinkedList<StateResponse.Event> queue = new LinkedList<StateResponse.Event>();
+ queue.addAll(stateResponse.getEvents());
+
//
- for (StateResponse.Event event : stateResponse.getEvents())
+ while (queue.size() > 0)
{
-
+ StateResponse.Event event = queue.removeFirst();
+
+ //
+ List<Portlet> consumers = new ArrayList<Portlet>();
+ for (Portlet portlet : context.getPortlets())
+ {
+ PortletInfo portletInfo = portlet.getInfo();
+
+ //
+ for (EventInfo eventInfo : portletInfo.getEvents().getConsumedEvents())
+ {
+ if (event.getName().equals(eventInfo.getName()))
+ {
+ consumers.add(portlet);
+ }
+ }
+ }
+
+ //
+ for (Portlet consumer : consumers)
+ {
+ PortletInvocationResponse eventResponse = deliverEvent(context, consumer, event);
+
+ //
+ if (eventResponse instanceof UpdateNavigationalStateResponse)
+ {
+ UpdateNavigationalStateResponse update = (UpdateNavigationalStateResponse)eventResponse;
+
+ // Update ns
+ updateNavigationalState(navState, consumer.getContext().getId(), update);
+
+ // Add events if any
+ queue.addAll(update.getEvents());
+ }
+ else if (eventResponse instanceof ErrorResponse)
+ {
+ // Do something here !!!!
+ }
+ else
+ {
+ // Do something here !!!!
+ }
+ }
}
+
+ //
+ if (response instanceof HTTPRedirectionResponse)
+ {
+ HTTPRedirectionResponse redirection = (HTTPRedirectionResponse)response;
+ resp.sendRedirect(redirection.getLocation());
+ return;
+ }
+ else if (response instanceof ErrorResponse)
+ {
+ ErrorResponse error = (ErrorResponse)response;
+ System.out.println("Error " + error.getMessage());
+ if (error.getCause() != null)
+ {
+ error.getCause().printStackTrace();
+ }
+ resp.sendError(404, error.getMessage());
+ return;
+ }
}
+ else
+ {
+ System.out.println("Not yet handled " + response);
+ }
+
+
+
+
/*
if (response instanceof RenderResponse && redirectAfterAction)
{
@@ -197,55 +353,6 @@
response = new HTTPRedirectionResponse(location);
}
*/
-
- //
- if (response instanceof UpdateNavigationalStateResponse)
- {
- UpdateNavigationalStateResponse updateNavigationalState = (UpdateNavigationalStateResponse)response;
- WindowNavigationalState windowNS = navState.getWindow(action.portletId);
-
- //
- if (windowNS == null)
- {
- windowNS = new WindowNavigationalState();
- navState.setWindow(action.portletId, windowNS);
- }
-
- //
- if (updateNavigationalState.getMode() != null)
- {
- windowNS.setMode(updateNavigationalState.getMode());
- }
- if (updateNavigationalState.getWindowState() != null)
- {
- windowNS.setWindowState(updateNavigationalState.getWindowState());
- }
- if (updateNavigationalState.getNavigationalState() != null)
- {
- windowNS.setPortletNavigationalState(updateNavigationalState.getNavigationalState());
- }
- }
- else if (response instanceof HTTPRedirectionResponse)
- {
- HTTPRedirectionResponse redirection = (HTTPRedirectionResponse)response;
- resp.sendRedirect(redirection.getLocation());
- return;
- }
- else if (response instanceof ErrorResponse)
- {
- ErrorResponse error = (ErrorResponse)response;
- System.out.println("Error " + error.getMessage());
- if (error.getCause() != null)
- {
- error.getCause().printStackTrace();
- }
- resp.sendError(404, error.getMessage());
- return;
- }
- else
- {
- System.out.println("Not yet handled " + response);
- }
}
//
@@ -321,6 +428,39 @@
writer.print("</body></html>");
}
+ private void updateNavigationalState(
+ PortalNavigationalState portalNS,
+ String windowId,
+ UpdateNavigationalStateResponse update)
+ {
+ WindowNavigationalState windowNS = portalNS.getWindow(windowId);
+
+ //
+ if (windowNS == null)
+ {
+ windowNS = new WindowNavigationalState();
+ }
+
+ //
+ Mode mode = windowNS.getMode();
+ if (update.getMode() != null)
+ {
+ mode = update.getMode();
+ }
+ WindowState windowState = windowNS.getWindowState();
+ if (update.getWindowState() != null)
+ {
+ windowState = update.getWindowState();
+ }
+ StateString portletNS = windowNS.getPortletNavigationalState();
+ if (update.getNavigationalState() != null)
+ {
+ portletNS = update.getNavigationalState();
+ }
+ windowNS = new WindowNavigationalState(portletNS, mode, windowState);
+ portalNS.setWindow(windowId, windowNS);
+ }
+
static class Action
{
Added: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/TestEventContext.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/TestEventContext.java (rev 0)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/TestEventContext.java 2008-01-14 11:10:14 UTC (rev 9498)
@@ -0,0 +1,87 @@
+/******************************************************************************
+ * 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.test;
+
+import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.PortletURL;
+import org.jboss.portal.portlet.invocation.PortletInvocation;
+import org.jboss.portal.portlet.impl.spi.AbstractRenderContext;
+import org.jboss.portal.portlet.impl.spi.AbstractEventContext;
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.common.util.MarkupInfo;
+import org.jboss.portal.common.invocation.resolver.PrincipalAttributeResolver;
+import org.jboss.portal.common.invocation.resolver.MapAttributeResolver;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.xml.namespace.QName;
+import java.io.Serializable;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestEventContext extends AbstractEventContext
+{
+
+ /** . */
+ private final PortletURLRenderer urlRenderer;
+
+ public TestEventContext(
+ PortletURLRenderer urlRenderer,
+ Mode mode,
+ WindowState windowState,
+ StateString navigationalState,
+ MarkupInfo markupInfo,
+ QName name,
+ Serializable payload)
+ {
+ super(mode, windowState, navigationalState, markupInfo, name, payload);
+
+ //
+ this.urlRenderer = urlRenderer;
+
+ //
+ addResolver(PortletInvocation.PRINCIPAL_SCOPE, new PrincipalAttributeResolver(urlRenderer.clientReq));
+ addResolver(PortletInvocation.INVOCATION_SCOPE, new MapAttributeResolver());
+ addResolver(PortletInvocation.REQUEST_PROPERTIES_SCOPE, new MapAttributeResolver());
+ addResolver(PortletInvocation.RESPONSE_PROPERTIES_SCOPE, new MapAttributeResolver());
+ addResolver(PortletInvocation.REQUEST_SCOPE, new MapAttributeResolver());
+ }
+
+ public HttpServletRequest getClientRequest() throws IllegalStateException
+ {
+ return urlRenderer.clientReq;
+ }
+
+ public HttpServletResponse getClientResponse() throws IllegalStateException
+ {
+ return urlRenderer.clientResp;
+ }
+
+ public String renderURL(PortletURL portletURL, Boolean wantSecure, Boolean wantAuthenticated, boolean relative)
+ {
+ return urlRenderer.renderURL(portletURL, wantSecure, wantAuthenticated, relative);
+ }
+}
\ No newline at end of file
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/WindowNavigationalState.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/WindowNavigationalState.java 2008-01-14 10:16:55 UTC (rev 9497)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/WindowNavigationalState.java 2008-01-14 11:10:14 UTC (rev 9498)
@@ -36,41 +36,40 @@
{
/** . */
- private StateString portletNavigationalState;
+ private final StateString portletNavigationalState;
/** . */
- private Mode mode;
+ private final Mode mode;
/** . */
- private WindowState windowState;
+ private final WindowState windowState;
- public StateString getPortletNavigationalState()
+ public WindowNavigationalState()
{
- return portletNavigationalState;
+ this.portletNavigationalState = null;
+ this.mode = Mode.VIEW;
+ this.windowState = WindowState.NORMAL;
}
- public void setPortletNavigationalState(StateString portletNavigationalState)
+ public WindowNavigationalState(StateString portletNavigationalState, Mode mode, WindowState windowState)
{
this.portletNavigationalState = portletNavigationalState;
+ this.mode = mode;
+ this.windowState = windowState;
}
- public Mode getMode()
+ public StateString getPortletNavigationalState()
{
- return mode;
+ return portletNavigationalState;
}
- public void setMode(Mode mode)
+ public Mode getMode()
{
- this.mode = mode;
+ return mode;
}
public WindowState getWindowState()
{
return windowState;
}
-
- public void setWindowState(WindowState windowState)
- {
- this.windowState = windowState;
- }
}
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-14 10:16:55 UTC (rev 9497)
+++ modules/portlet/trunk/test/src/test/resources/jsr286/tck/event-war/WEB-INF/portlet.xml 2008-01-14 11:10:14 UTC (rev 9498)
@@ -33,6 +33,16 @@
<supports>
<mime-type>text/html</mime-type>
</supports>
+ <supported-processing-event>
+ <name>Foo</name>
+ </supported-processing-event>
+ <supported-publishing-event>
+ <name>Foo</name>
+ </supported-publishing-event>
</portlet>
+ <event-definition>
+ <name>Foo</name>
+ </event-definition>
+
</portlet-app>
18 years, 3 months