Author: julien(a)jboss.com
Date: 2008-01-23 12:40:03 -0500 (Wed, 23 Jan 2008)
New Revision: 9584
Added:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/resourceserving/ResourceIDTestCase.java
Modified:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/framework/UTP3.java
modules/portlet/trunk/test/src/test/resources/jsr286/tck/resourceserving-war/WEB-INF/portlet.xml
Log:
added test case for resource ID value
Modified:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/framework/UTP3.java
===================================================================
---
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/framework/UTP3.java 2008-01-23
17:02:22 UTC (rev 9583)
+++
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/framework/UTP3.java 2008-01-23
17:40:03 UTC (rev 9584)
@@ -46,6 +46,8 @@
public final static JoinPoint ACTION_JOIN_POINT = new JoinPoint(NAME,
JoinPointType.PORTLET_ACTION);
+ public final static JoinPoint RESOURCE_JOIN_POINT = new JoinPoint(NAME,
JoinPointType.PORTLET_RESOURCE);
+
/** Resets helper variables */
public void reset()
{
Added:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/resourceserving/ResourceIDTestCase.java
===================================================================
---
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/resourceserving/ResourceIDTestCase.java
(rev 0)
+++
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/resourceserving/ResourceIDTestCase.java 2008-01-23
17:40:03 UTC (rev 9584)
@@ -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.resourceserving;
+
+import org.jboss.portal.unit.PortletTestCase;
+import org.jboss.portal.unit.PortletTestContext;
+import org.jboss.portal.unit.annotations.TestCase;
+import org.jboss.portal.unit.actions.PortletRenderTestAction;
+import org.jboss.portal.unit.actions.PortletResourceTestAction;
+import org.jboss.portal.test.portlet.framework.UTP3;
+import org.jboss.unit.driver.DriverResponse;
+import org.jboss.unit.driver.response.EndTestResponse;
+import org.jboss.unit.remote.driver.handler.http.response.InvokeGetResponse;
+import static org.jboss.unit.api.Assert.*;
+
+import javax.portlet.Portlet;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.PortletException;
+import javax.portlet.ResourceURL;
+import javax.portlet.ResourceRequest;
+import javax.portlet.ResourceResponse;
+import java.io.IOException;
+
+/**
+ * cxxiv:
+ *
+ * The portlet must be able to get the resource ID that was set on the resource URL with
the
+ * setResourceID method via the getResourceID method from the resource request. cxxiii
If
+ * no resource ID was set on the resource URL the getResourceID method must return
+ * null.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+@TestCase()
+public class ResourceIDTestCase
+{
+ public ResourceIDTestCase(PortletTestCase seq)
+ {
+ seq.bindAction(0, UTP3.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request,
RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ ResourceURL resourceURL = response.createResourceURL();
+ return new InvokeGetResponse(resourceURL.toString());
+ }
+ });
+ seq.bindAction(1, UTP3.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
+ {
+ public DriverResponse execute(Portlet portlet, ResourceRequest request,
ResourceResponse response, PortletTestContext context) throws PortletException,
IOException
+ {
+ sendEmptyResponse(response);
+ assertNull(request.getResourceID());
+ ResourceURL resourceURL = response.createResourceURL();
+ resourceURL.setResourceID("foo_resource_id");
+ return new InvokeGetResponse(resourceURL.toString());
+ }
+ });
+ seq.bindAction(2, UTP3.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
+ {
+ public DriverResponse execute(Portlet portlet, ResourceRequest request,
ResourceResponse response, PortletTestContext context) throws PortletException,
IOException
+ {
+ sendEmptyResponse(response);
+ assertEquals("foo_resource_id", request.getResourceID());
+ return new EndTestResponse();
+ }
+ });
+ }
+}
Modified:
modules/portlet/trunk/test/src/test/resources/jsr286/tck/resourceserving-war/WEB-INF/portlet.xml
===================================================================
---
modules/portlet/trunk/test/src/test/resources/jsr286/tck/resourceserving-war/WEB-INF/portlet.xml 2008-01-23
17:02:22 UTC (rev 9583)
+++
modules/portlet/trunk/test/src/test/resources/jsr286/tck/resourceserving-war/WEB-INF/portlet.xml 2008-01-23
17:40:03 UTC (rev 9584)
@@ -43,4 +43,12 @@
</supports>
</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>
+ </portlet>
+
</portlet-app>