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>