JBoss Portal SVN: r9587 - in modules/portlet/trunk: test/src/test/resources/jsr286/tck/resourceserving-war/WEB-INF and 1 other directory.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-01-23 16:12:05 -0500 (Wed, 23 Jan 2008)
New Revision: 9587
Modified:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/resourceserving/HTTPMethodTestCase.java
modules/portlet/trunk/test/src/test/resources/jsr286/tck/resourceserving-war/WEB-INF/portlet.xml
Log:
- added test case for HTTP method verb within a resource serving
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/resourceserving/HTTPMethodTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/resourceserving/HTTPMethodTestCase.java 2008-01-23 21:02:31 UTC (rev 9586)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/resourceserving/HTTPMethodTestCase.java 2008-01-23 21:12:05 UTC (rev 9587)
@@ -24,21 +24,36 @@
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.UTP4;
import org.jboss.unit.driver.DriverResponse;
+import org.jboss.unit.driver.response.EndTestResponse;
+import org.jboss.unit.remote.driver.handler.http.response.InvokeGetResponse;
+import org.jboss.unit.remote.driver.handler.http.response.InvokePostResponse;
+import org.jboss.unit.remote.http.HttpRequest;
+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;
/**
+ * cxxii:
+ *
+ * The portlet must be able to get the HTTP method with which this request was made, for
+ * example, GET, POST, or PUT, via the getMethod call on the ResourceRequest.
+ *
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 630 $
*/
+@TestCase()
public class HTTPMethodTestCase
{
public HTTPMethodTestCase(PortletTestCase seq)
@@ -47,9 +62,29 @@
{
protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
{
-// ResourceURL resourceURL = response.createResourceURL();
- return null;
+ ResourceURL resourceURL = response.createResourceURL();
+ return new InvokeGetResponse(resourceURL.toString());
}
});
+ seq.bindAction(1, UTP4.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ assertEquals("GET", request.getMethod());
+ ResourceURL resourceURL = response.createResourceURL();
+ InvokePostResponse post = new InvokePostResponse(resourceURL.toString());
+ post.setContentType(InvokePostResponse.APPLICATION_X_WWW_FORM_URLENCODED);
+ post.setBody(new HttpRequest.Form());
+ return post;
+ }
+ });
+ seq.bindAction(2, UTP4.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ assertEquals("POST", request.getMethod());
+ 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 21:02:31 UTC (rev 9586)
+++ modules/portlet/trunk/test/src/test/resources/jsr286/tck/resourceserving-war/WEB-INF/portlet.xml 2008-01-23 21:12:05 UTC (rev 9587)
@@ -51,4 +51,12 @@
</supports>
</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>
+ </portlet>
+
</portlet-app>
18 years, 3 months
JBoss Portal SVN: r9586 - in modules/portlet/trunk: portlet/src/main/java/org/jboss/portal/portlet/impl/spi and 9 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-01-23 16:02:31 -0500 (Wed, 23 Jan 2008)
New Revision: 9586
Added:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/spi/AbstractClientContext.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/spi/ClientContext.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/support/spi/ClientContextSupport.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/resourceserving/HTTPMethodTestCase.java
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ClientDataRequestImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/PortletInvocation.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletrequests/ResourceRequestParametersTestCase.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletrequests/PublicRenderParameterAvailableInLifeCycleMethodTestCase.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/resourceserving/DowngradeCacheabilityTestCase.java
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/unit/actions/PortletResourceTestAction.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java
modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml
Log:
- introduced ClientContext to expose client data (like HTTP method for now)
- improved PortletResourceTestAction to send a response if no response has been sent during the resource action
- update jboss unit xml test def
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ClientDataRequestImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ClientDataRequestImpl.java 2008-01-23 20:07:37 UTC (rev 9585)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ClientDataRequestImpl.java 2008-01-23 21:02:31 UTC (rev 9586)
@@ -25,6 +25,7 @@
import org.jboss.portal.portlet.invocation.ActionInvocation;
import org.jboss.portal.portlet.invocation.ResourceInvocation;
import org.jboss.portal.portlet.spi.RequestContext;
+import org.jboss.portal.portlet.spi.ClientContext;
import org.jboss.portal.common.NotYetImplemented;
import javax.portlet.ClientDataRequest;
@@ -43,12 +44,16 @@
/** . */
protected final RequestContext requestContext;
+ /** . */
+ protected final ClientContext clientContext;
+
public ClientDataRequestImpl(ActionInvocation invocation)
{
super(invocation);
//
this.requestContext = invocation.getRequestContext();
+ this.clientContext = invocation.getClientContext();
}
public ClientDataRequestImpl(ResourceInvocation invocation)
@@ -57,6 +62,7 @@
//
this.requestContext = invocation.getRequestContext();
+ this.clientContext = invocation.getClientContext();
}
public InputStream getPortletInputStream() throws IOException
@@ -101,6 +107,6 @@
public String getMethod()
{
- throw new NotYetImplemented();
+ return clientContext.getMethod();
}
}
Added: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/spi/AbstractClientContext.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/spi/AbstractClientContext.java (rev 0)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/spi/AbstractClientContext.java 2008-01-23 21:02:31 UTC (rev 9586)
@@ -0,0 +1,48 @@
+/******************************************************************************
+ * 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.ClientContext;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class AbstractClientContext implements ClientContext
+{
+
+ /** . */
+ private final String method;
+
+ public AbstractClientContext(HttpServletRequest request)
+ {
+ this.method = request.getMethod();
+ }
+
+ public String getMethod()
+ {
+ return method;
+ }
+}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/PortletInvocation.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/PortletInvocation.java 2008-01-23 20:07:37 UTC (rev 9585)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/PortletInvocation.java 2008-01-23 21:02:31 UTC (rev 9586)
@@ -31,6 +31,7 @@
import org.jboss.portal.portlet.spi.SecurityContext;
import org.jboss.portal.portlet.spi.UserContext;
import org.jboss.portal.portlet.spi.WindowContext;
+import org.jboss.portal.portlet.spi.ClientContext;
import org.jboss.portal.portlet.PortletContext;
import javax.servlet.http.HttpServletRequest;
@@ -66,6 +67,9 @@
/** The portal context. */
protected PortalContext portalContext;
+ /** The client context. */
+ protected ClientContext clientContext;
+
/** The server context. */
protected ServerContext serverContext;
@@ -198,6 +202,16 @@
this.portalContext = portalContext;
}
+ public ClientContext getClientContext()
+ {
+ return clientContext;
+ }
+
+ public void setClientContext(ClientContext clientContext)
+ {
+ this.clientContext = clientContext;
+ }
+
public ServerContext getServerContext()
{
return serverContext;
Added: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/spi/ClientContext.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/spi/ClientContext.java (rev 0)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/spi/ClientContext.java 2008-01-23 21:02:31 UTC (rev 9586)
@@ -0,0 +1,34 @@
+/******************************************************************************
+ * 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.spi;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public interface ClientContext
+{
+
+ String getMethod();
+
+}
Added: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/support/spi/ClientContextSupport.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/support/spi/ClientContextSupport.java (rev 0)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/support/spi/ClientContextSupport.java 2008-01-23 21:02:31 UTC (rev 9586)
@@ -0,0 +1,37 @@
+/******************************************************************************
+ * 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.support.spi;
+
+import org.jboss.portal.portlet.spi.ClientContext;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class ClientContextSupport implements ClientContext
+{
+ public String getMethod()
+ {
+ throw new UnsupportedOperationException();
+ }
+}
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletrequests/ResourceRequestParametersTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletrequests/ResourceRequestParametersTestCase.java 2008-01-23 20:07:37 UTC (rev 9585)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletrequests/ResourceRequestParametersTestCase.java 2008-01-23 21:02:31 UTC (rev 9586)
@@ -89,11 +89,6 @@
assertParameterMap(expectedPageParameters, request);
//
- response.setContentType("text/html");
- Writer writer = response.getWriter();
- writer.close();
-
- //
ResourceURL resourceURL = response.createResourceURL();
resourceURL.setCacheability(ResourceURL.PORTLET);
resourceURL.setParameter("foo", new String[]{"resource_foo_value3","resource_foo_value4"});
@@ -109,11 +104,6 @@
assertParameterMap(expectedPageParameters, request);
//
- response.setContentType("text/html");
- Writer writer = response.getWriter();
- writer.close();
-
- //
return new EndTestResponse();
}
});
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletrequests/PublicRenderParameterAvailableInLifeCycleMethodTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletrequests/PublicRenderParameterAvailableInLifeCycleMethodTestCase.java 2008-01-23 20:07:37 UTC (rev 9585)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletrequests/PublicRenderParameterAvailableInLifeCycleMethodTestCase.java 2008-01-23 21:02:31 UTC (rev 9586)
@@ -200,12 +200,6 @@
assertEquals(expectedPublicMap, request.getPublicParameterMap());
//
- response.setContentType("text/html");
- PrintWriter writer = response.getWriter();
- writer.print("foo");
- writer.close();
-
- //
return new EndTestResponse();
}
});
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/resourceserving/DowngradeCacheabilityTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/resourceserving/DowngradeCacheabilityTestCase.java 2008-01-23 20:07:37 UTC (rev 9585)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/resourceserving/DowngradeCacheabilityTestCase.java 2008-01-23 21:02:31 UTC (rev 9586)
@@ -83,9 +83,6 @@
{
protected DriverResponse run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
{
- sendEmptyResponse(response);
-
- //
assertEquals(ResourceURL.PORTLET, request.getCacheability());
//
@@ -135,9 +132,6 @@
{
protected DriverResponse run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
{
- sendEmptyResponse(response);
-
- //
assertEquals(ResourceURL.PORTLET, request.getCacheability());
ResourceURL resourceURL = response.createResourceURL();
assertEquals(ResourceURL.PORTLET, resourceURL.getCacheability());
@@ -150,9 +144,6 @@
{
protected DriverResponse run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
{
- sendEmptyResponse(response);
-
- //
assertEquals(ResourceURL.FULL, request.getCacheability());
//
@@ -213,9 +204,6 @@
{
protected DriverResponse run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
{
- sendEmptyResponse(response);
-
- //
assertEquals(ResourceURL.FULL, request.getCacheability());
ResourceURL resourceURL = response.createResourceURL();
assertEquals(ResourceURL.FULL, resourceURL.getCacheability());
Added: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/resourceserving/HTTPMethodTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/resourceserving/HTTPMethodTestCase.java (rev 0)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/resourceserving/HTTPMethodTestCase.java 2008-01-23 21:02:31 UTC (rev 9586)
@@ -0,0 +1,55 @@
+/******************************************************************************
+ * 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.actions.PortletRenderTestAction;
+import org.jboss.portal.test.portlet.framework.UTP4;
+import org.jboss.unit.driver.DriverResponse;
+
+import javax.portlet.Portlet;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.PortletException;
+import javax.portlet.ResourceURL;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class HTTPMethodTestCase
+{
+ public HTTPMethodTestCase(PortletTestCase seq)
+ {
+ seq.bindAction(0, UTP4.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+// ResourceURL resourceURL = response.createResourceURL();
+ return null;
+ }
+ });
+ }
+}
Modified: 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 2008-01-23 20:07:37 UTC (rev 9585)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/resourceserving/ResourceIDTestCase.java 2008-01-23 21:02:31 UTC (rev 9586)
@@ -68,9 +68,8 @@
});
seq.bindAction(1, UTP3.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
{
- public DriverResponse execute(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
+ protected DriverResponse run(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");
@@ -79,9 +78,8 @@
});
seq.bindAction(2, UTP3.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
{
- public DriverResponse execute(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
+ protected DriverResponse run(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/portlet/src/test/java/org/jboss/portal/unit/actions/PortletResourceTestAction.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/actions/PortletResourceTestAction.java 2008-01-23 20:07:37 UTC (rev 9585)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/actions/PortletResourceTestAction.java 2008-01-23 21:02:31 UTC (rev 9586)
@@ -25,6 +25,7 @@
import org.jboss.portal.unit.TestAction;
import org.jboss.portal.unit.PortletTestContext;
import org.jboss.portal.common.NotYetImplemented;
+import org.jboss.portal.common.io.IOTools;
import org.jboss.unit.driver.DriverResponse;
import org.jboss.unit.driver.response.FailureResponse;
import org.jboss.unit.Failure;
@@ -36,6 +37,8 @@
import javax.portlet.ResourceResponse;
import java.io.IOException;
import java.io.PrintWriter;
+import java.io.Writer;
+import java.io.OutputStream;
/**
* @author <a href="mailto:boleslaw.dawidowicz@jboss.org">Boleslaw Dawidowicz</a>
@@ -44,19 +47,59 @@
public abstract class PortletResourceTestAction extends TestAction
{
+ /**
+ * This field is used to determine if the action will attempt to send a response after the action has been executed.
+ * The attempt to send a response will be done if:
+ * <ul>
+ * <li>this field has a value equals to true</li>
+ * <li>no content type has been set on the response during the execution of the action</li>
+ * <li>the execution of the action is succesfull or is a failure (i.e it will not be done on Errors other than
+ * <code>java.lang.AssertionError</code></li>
+ * </ul>
+ */
+ private final boolean attemptToSendResponse;
+
+ protected PortletResourceTestAction(boolean attemptToSendResponse)
+ {
+ this.attemptToSendResponse = attemptToSendResponse;
+ }
+
+ protected PortletResourceTestAction()
+ {
+ this(true);
+ }
+
public DriverResponse execute(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
{
+ // We attempty to do it
+ boolean sendResponse = false;
+
+ //
try
{
- return runWithRuntimeException(portlet, request, response, context);
+ DriverResponse driverResponse = runWithRuntimeException(portlet, request, response, context);
+ sendResponse = attemptToSendResponse;
+ return driverResponse;
}
catch (AssertionError t)
{
getLogger().error("The test case failed", t);
+ // We will send a response
+ sendResponse = attemptToSendResponse;
+
//
return new FailureResponse(Failure.createFailure(t));
}
+ finally
+ {
+ if (sendResponse && response.getContentType() == null)
+ {
+ response.setContentType("text/html");
+ Writer writer = response.getWriter();
+ IOTools.safeClose(writer);
+ }
+ }
}
protected DriverResponse runWithRuntimeException(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
@@ -83,11 +126,4 @@
{
throw new NotYetImplemented();
}
-
- protected final void sendEmptyResponse(ResourceResponse response) throws IOException
- {
- response.setContentType("text/html");
- PrintWriter writer = response.getWriter();
- writer.close();
- }
}
\ No newline at end of file
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-23 20:07:37 UTC (rev 9585)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java 2008-01-23 21:02:31 UTC (rev 9586)
@@ -37,6 +37,7 @@
import org.jboss.portal.portlet.impl.spi.AbstractPortalContext;
import org.jboss.portal.portlet.impl.spi.AbstractSecurityContext;
import org.jboss.portal.portlet.impl.spi.AbstractRequestContext;
+import org.jboss.portal.portlet.impl.spi.AbstractClientContext;
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
import org.jboss.portal.portlet.invocation.response.UpdateNavigationalStateResponse;
import org.jboss.portal.portlet.invocation.response.HTTPRedirectionResponse;
@@ -156,6 +157,7 @@
ActionInvocation actionInvocation = new ActionInvocation(actionContext);
//
+ actionInvocation.setClientContext(new AbstractClientContext(req));
actionInvocation.setServerContext(new AbstractServerContext(req, resp));
actionInvocation.setInstanceContext(instanceContext);
actionInvocation.setUserContext(new AbstractUserContext(req));
@@ -250,6 +252,7 @@
ResourceInvocation resourceInvocation = new ResourceInvocation(resourceInvocationContext);
//
+ resourceInvocation.setClientContext(new AbstractClientContext(req));
resourceInvocation.setServerContext(new AbstractServerContext(req, resp));
resourceInvocation.setInstanceContext(instanceContext);
resourceInvocation.setUserContext(new AbstractUserContext(req));
@@ -305,6 +308,7 @@
EventInvocation eventInvocation = new EventInvocation(actionContext);
//
+ eventInvocation.setClientContext(new AbstractClientContext(req));
eventInvocation.setServerContext(new AbstractServerContext(req, resp));
eventInvocation.setInstanceContext(instanceContext);
eventInvocation.setUserContext(new AbstractUserContext(req));
@@ -600,6 +604,7 @@
RenderInvocation render = new RenderInvocation(renderContext);
//
+ render.setClientContext(new AbstractClientContext(req));
render.setServerContext(new AbstractServerContext(req, resp));
render.setInstanceContext(instanceContext);
render.setUserContext(new AbstractUserContext(req));
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-23 20:07:37 UTC (rev 9585)
+++ modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml 2008-01-23 21:02:31 UTC (rev 9586)
@@ -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"/>
@@ -140,7 +133,6 @@
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId" value="test-jsr168-ext-session.war"/>
</generic>
--->
<!--
<generic>
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
@@ -155,11 +147,8 @@
<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"/>
@@ -180,7 +169,6 @@
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId" value="test-jsr286-tck-stateawareresponse.war"/>
</generic>
--->
<generic>
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId" value="test-jsr286-tck-portletrequests.war"/>
@@ -191,12 +179,10 @@
</generic>
<!--Spec API Assertions tests-->
-<!--
<generic>
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId" value="test-jsr286-api-event.war"/>
</generic>
--->
<!--Ext Assertions tests-->
<generic>
18 years, 3 months
JBoss Portal SVN: r9585 - in modules/portlet/trunk: portlet/src/main/java/org/jboss/portal/portlet/invocation and 1 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-01-23 15:07:37 -0500 (Wed, 23 Jan 2008)
New Revision: 9585
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ClientDataRequestImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/ActionInvocation.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/PortletInvocation.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/ResourceInvocation.java
modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml
Log:
moved RequestContext on PortletInvocation and ResourceInvocation and removed it from PortletInvocation (since it can be used only in processAction or serveResource
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ClientDataRequestImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ClientDataRequestImpl.java 2008-01-23 17:40:03 UTC (rev 9584)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ClientDataRequestImpl.java 2008-01-23 20:07:37 UTC (rev 9585)
@@ -22,7 +22,8 @@
******************************************************************************/
package org.jboss.portal.portlet.impl.jsr168.api;
-import org.jboss.portal.portlet.invocation.PortletInvocation;
+import org.jboss.portal.portlet.invocation.ActionInvocation;
+import org.jboss.portal.portlet.invocation.ResourceInvocation;
import org.jboss.portal.portlet.spi.RequestContext;
import org.jboss.portal.common.NotYetImplemented;
@@ -42,7 +43,7 @@
/** . */
protected final RequestContext requestContext;
- public ClientDataRequestImpl(PortletInvocation invocation)
+ public ClientDataRequestImpl(ActionInvocation invocation)
{
super(invocation);
@@ -50,6 +51,14 @@
this.requestContext = invocation.getRequestContext();
}
+ public ClientDataRequestImpl(ResourceInvocation invocation)
+ {
+ super(invocation);
+
+ //
+ this.requestContext = invocation.getRequestContext();
+ }
+
public InputStream getPortletInputStream() throws IOException
{
if ("application/x-www-form-urlencoded".equals(requestContext.getContentType()))
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/ActionInvocation.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/ActionInvocation.java 2008-01-23 17:40:03 UTC (rev 9584)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/ActionInvocation.java 2008-01-23 20:07:37 UTC (rev 9585)
@@ -23,6 +23,7 @@
package org.jboss.portal.portlet.invocation;
import org.jboss.portal.portlet.spi.ActionContext;
+import org.jboss.portal.portlet.spi.RequestContext;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -34,6 +35,9 @@
/** . */
private final ActionContext ctx;
+ /** The request context. */
+ protected RequestContext requestContext;
+
public ActionInvocation(ActionContext ctx) throws IllegalArgumentException
{
super(ctx);
@@ -46,4 +50,14 @@
{
return ctx;
}
+
+ public RequestContext getRequestContext()
+ {
+ return requestContext;
+ }
+
+ public void setRequestContext(RequestContext requestContext)
+ {
+ this.requestContext = requestContext;
+ }
}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/PortletInvocation.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/PortletInvocation.java 2008-01-23 17:40:03 UTC (rev 9584)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/PortletInvocation.java 2008-01-23 20:07:37 UTC (rev 9585)
@@ -23,7 +23,6 @@
package org.jboss.portal.portlet.invocation;
import org.jboss.portal.common.invocation.Invocation;
-import org.jboss.portal.common.invocation.InvocationContext;
import org.jboss.portal.common.invocation.Scope;
import org.jboss.portal.portlet.spi.InstanceContext;
import org.jboss.portal.portlet.spi.PortalContext;
@@ -32,7 +31,6 @@
import org.jboss.portal.portlet.spi.SecurityContext;
import org.jboss.portal.portlet.spi.UserContext;
import org.jboss.portal.portlet.spi.WindowContext;
-import org.jboss.portal.portlet.spi.RequestContext;
import org.jboss.portal.portlet.PortletContext;
import javax.servlet.http.HttpServletRequest;
@@ -83,9 +81,6 @@
/** The window context. */
protected WindowContext windowContext;
- /** The request context. */
- protected RequestContext requestContext;
-
/** The window states this portlet can accept. */
protected Set supportedWindowStates;
@@ -105,6 +100,7 @@
* Create an invocation to a portlet.
*
* @param ctx the portlet invocation context
+ * @throws IllegalArgumentException if the provided context is null
*/
protected PortletInvocation(PortletInvocationContext ctx) throws IllegalArgumentException
{
@@ -152,25 +148,41 @@
this.supportedModes = supportedModes;
}
- /** Return the dispatched http servlet request. */
+ /**
+ * Returns the dispatched http servlet request.
+ *
+ * @return the dispatched response
+ */
public HttpServletResponse getDispatchedResponse()
{
return dresp;
}
- /** Set the dispatched http servlet request. */
+ /**
+ * Set the dispatched http servlet request.
+ *
+ * @param dresp the dispatched response
+ */
public void setDispatchedResponse(HttpServletResponse dresp)
{
this.dresp = dresp;
}
- /** Return the dispatched http servlet request. */
+ /**
+ * Returns the dispatched http servlet request.
+ *
+ * @return the dispatched request
+ */
public HttpServletRequest getDispatchedRequest()
{
return dreq;
}
- /** Set the dispatched http servlet request. */
+ /**
+ * Set the dispatched http servlet request.
+ *
+ * @param dreq the dispatched request
+ */
public void setDispatchedRequest(HttpServletRequest dreq)
{
this.dreq = dreq;
@@ -235,14 +247,4 @@
{
this.windowContext = windowContext;
}
-
- public RequestContext getRequestContext()
- {
- return requestContext;
- }
-
- public void setRequestContext(RequestContext requestContext)
- {
- this.requestContext = requestContext;
- }
}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/ResourceInvocation.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/ResourceInvocation.java 2008-01-23 17:40:03 UTC (rev 9584)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/ResourceInvocation.java 2008-01-23 20:07:37 UTC (rev 9585)
@@ -23,6 +23,7 @@
package org.jboss.portal.portlet.invocation;
import org.jboss.portal.portlet.spi.ResourceInvocationContext;
+import org.jboss.portal.portlet.spi.RequestContext;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -34,6 +35,9 @@
/** . */
private final ResourceInvocationContext ctx;
+ /** The request context. */
+ protected RequestContext requestContext;
+
public ResourceInvocation(ResourceInvocationContext ctx) throws IllegalArgumentException
{
super(ctx);
@@ -46,4 +50,14 @@
{
return ctx;
}
+
+ public RequestContext getRequestContext()
+ {
+ return requestContext;
+ }
+
+ public void setRequestContext(RequestContext requestContext)
+ {
+ this.requestContext = requestContext;
+ }
}
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-23 17:40:03 UTC (rev 9584)
+++ modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml 2008-01-23 20:07:37 UTC (rev 9585)
@@ -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"/>
@@ -133,6 +140,7 @@
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId" value="test-jsr168-ext-session.war"/>
</generic>
+-->
<!--
<generic>
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
@@ -147,8 +155,11 @@
<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"/>
@@ -169,6 +180,7 @@
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId" value="test-jsr286-tck-stateawareresponse.war"/>
</generic>
+-->
<generic>
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId" value="test-jsr286-tck-portletrequests.war"/>
@@ -179,10 +191,12 @@
</generic>
<!--Spec API Assertions tests-->
+<!--
<generic>
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId" value="test-jsr286-api-event.war"/>
</generic>
+-->
<!--Ext Assertions tests-->
<generic>
18 years, 3 months
JBoss Portal SVN: r9584 - in modules/portlet/trunk: portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/resourceserving and 1 other directories.
by portal-commits@lists.jboss.org
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>
18 years, 3 months
JBoss Portal SVN: r9583 - branches/JBoss_Portal_Branch_2_6/core-admin/src/resources/portal-admin-war/WEB-INF/jsf.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2008-01-23 12:02:22 -0500 (Wed, 23 Jan 2008)
New Revision: 9583
Modified:
branches/JBoss_Portal_Branch_2_6/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/instances.xhtml
Log:
It is the instance name really
Modified: branches/JBoss_Portal_Branch_2_6/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/instances.xhtml
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/instances.xhtml 2008-01-23 16:57:42 UTC (rev 9582)
+++ branches/JBoss_Portal_Branch_2_6/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/instances.xhtml 2008-01-23 17:02:22 UTC (rev 9583)
@@ -16,7 +16,7 @@
<thead class="portlet-section-header">
<tr>
<th>Instance id</th>
- <th>Portlet name</th>
+ <th>Instance name</th>
<th>Actions</th>
</tr>
</thead>
18 years, 3 months
JBoss Portal SVN: r9582 - in branches/JBoss_Portal_Branch_2_6: core-samples/src/resources/portal-weather-samples-war/WEB-INF/classes and 1 other directory.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2008-01-23 11:57:42 -0500 (Wed, 23 Jan 2008)
New Revision: 9582
Modified:
branches/JBoss_Portal_Branch_2_6/core-samples/src/resources/portal-weather-samples-war/WEB-INF/classes/WeatherResource.properties
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/model/instance/metadata/InstanceMetaData.java
Log:
Fixing instance metadata bug
Modified: branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/model/instance/metadata/InstanceMetaData.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/model/instance/metadata/InstanceMetaData.java 2008-01-23 16:39:54 UTC (rev 9581)
+++ branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/model/instance/metadata/InstanceMetaData.java 2008-01-23 16:57:42 UTC (rev 9582)
@@ -184,7 +184,7 @@
}
// Set display name
- if (pwa != null)
+ if (localizedStringMD.getValues().isEmpty())
{
ResourceBundleManager bundleMgr = MetaDataResourceBundleFactory.createResourceBundleManager(pwa.getClassLoader(), supportedLocales, resourceBundle);
LocalizedString localizedString = bundleMgr.getLocalizedValue("org.jboss.portal.instance.name." + instanceName, instanceName);
Modified: branches/JBoss_Portal_Branch_2_6/core-samples/src/resources/portal-weather-samples-war/WEB-INF/classes/WeatherResource.properties
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core-samples/src/resources/portal-weather-samples-war/WEB-INF/classes/WeatherResource.properties 2008-01-23 16:39:54 UTC (rev 9581)
+++ branches/JBoss_Portal_Branch_2_6/core-samples/src/resources/portal-weather-samples-war/WEB-INF/classes/WeatherResource.properties 2008-01-23 16:57:42 UTC (rev 9582)
@@ -23,4 +23,6 @@
javax.portlet.preference.name.RssXml=RSS feed URL
javax.portlet.preference.name.expires=Expiration time
-org.jboss.portal.object.name.Weather=Weather
\ No newline at end of file
+org.jboss.portal.object.name.Weather=Weather
+
+org.jboss.portal.instance.name.WeatherPortletInstance=Weather Portlet
18 years, 3 months
JBoss Portal SVN: r9581 - in modules/portlet/trunk: portlet/src/test/java/org/jboss/portal/test/portlet/framework and 3 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-01-23 11:39:54 -0500 (Wed, 23 Jan 2008)
New Revision: 9581
Added:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/resourceserving/DowngradeCacheabilityTestCase.java
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ResourceResponseImpl.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/framework/UTP2.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/actions/PortletResourceTestAction.java
modules/portlet/trunk/test/src/test/resources/jsr286/tck/resourceserving-war/WEB-INF/portlet.xml
Log:
- added resource serving cacheability test case
- implement createActionURL and createRenderURL throw ISE when cacheability is != than PAGE
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ResourceResponseImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ResourceResponseImpl.java 2008-01-23 16:07:45 UTC (rev 9580)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ResourceResponseImpl.java 2008-01-23 16:39:54 UTC (rev 9581)
@@ -23,8 +23,11 @@
package org.jboss.portal.portlet.impl.jsr168.api;
import org.jboss.portal.portlet.invocation.PortletInvocation;
+import org.jboss.portal.portlet.invocation.ResourceInvocation;
+import org.jboss.portal.portlet.CacheabilityType;
import javax.portlet.ResourceResponse;
+import javax.portlet.PortletURL;
import java.util.Locale;
/**
@@ -34,9 +37,15 @@
public class ResourceResponseImpl extends MimeResponseImpl implements ResourceResponse
{
- public ResourceResponseImpl(PortletInvocation invocation, PortletRequestImpl preq)
+ /** . */
+ private final CacheabilityType cacheability;
+
+ public ResourceResponseImpl(ResourceInvocation invocation, PortletRequestImpl preq)
{
super(invocation, preq);
+
+ //
+ this.cacheability = invocation.getContext().getCacheability();
}
public void setLocale(Locale locale)
@@ -53,4 +62,28 @@
{
throw new UnsupportedOperationException();
}
+
+ public PortletURL createActionURL()
+ {
+ if (cacheability != CacheabilityType.PAGE)
+ {
+ throw new IllegalStateException("Cannot create action URL because the current cache level " + cacheability +
+ " is not " + CacheabilityType.PAGE);
+ }
+
+ //
+ return super.createActionURL();
+ }
+
+ public PortletURL createRenderURL()
+ {
+ if (cacheability != CacheabilityType.PAGE)
+ {
+ throw new IllegalStateException("Cannot create render URL because the current cache level " + cacheability +
+ " is not " + CacheabilityType.PAGE);
+ }
+
+ //
+ return super.createRenderURL();
+ }
}
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/framework/UTP2.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/framework/UTP2.java 2008-01-23 16:07:45 UTC (rev 9580)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/framework/UTP2.java 2008-01-23 16:39:54 UTC (rev 9581)
@@ -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/DowngradeCacheabilityTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/resourceserving/DowngradeCacheabilityTestCase.java (rev 0)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/resourceserving/DowngradeCacheabilityTestCase.java 2008-01-23 16:39:54 UTC (rev 9581)
@@ -0,0 +1,226 @@
+/******************************************************************************
+ * 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.UTP2;
+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;
+
+/**
+ * cxxx:
+ * Only URLs with a cache level FULL are allowed in the response of the
+ * serveResource call triggered via a ResourceURL with a cache level FULL. The
+ * same restriction is true for all downstream URLs that result from this
+ * serveResource call. Setting a cachability different from must result in an
+ * IllegalStateException.
+ *
+ * cxxxi:
+ * Attempts to create URLs that are not of type FULL
+ * or are not resource URLs in the current or a downstream response must result in
+ * an IllegalStateException25
+ *
+ * cxxxii:
+ * Creating other URLs, e.g. resource URLs of type or
+ * action or render URLs, must result in an IllegalStateException
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+@TestCase()
+public class DowngradeCacheabilityTestCase
+{
+ public DowngradeCacheabilityTestCase(PortletTestCase seq)
+ {
+ seq.bindAction(0, UTP2.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ ResourceURL resourceURL = response.createResourceURL();
+ assertEquals(ResourceURL.PAGE, resourceURL.getCacheability());
+ resourceURL.setCacheability(ResourceURL.PORTLET);
+ assertEquals(ResourceURL.PORTLET, resourceURL.getCacheability());
+ return new InvokeGetResponse(resourceURL.toString());
+ }
+ });
+ seq.bindAction(1, UTP2.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ sendEmptyResponse(response);
+
+ //
+ assertEquals(ResourceURL.PORTLET, request.getCacheability());
+
+ //
+ try
+ {
+ response.createActionURL();
+ fail();
+ }
+ catch (IllegalStateException ignore)
+ {
+ }
+
+ //
+ try
+ {
+ response.createRenderURL();
+ fail();
+ }
+ catch (IllegalStateException ignore)
+ {
+ }
+
+ //
+ ResourceURL resourceURL = response.createResourceURL();
+ assertEquals(ResourceURL.PORTLET, resourceURL.getCacheability());
+
+ //
+ try
+ {
+ resourceURL.setCacheability(ResourceURL.PAGE);
+ fail();
+ }
+ catch (IllegalStateException ignore)
+ {
+ }
+ assertEquals(ResourceURL.PORTLET, resourceURL.getCacheability());
+
+ //
+ resourceURL.setCacheability(ResourceURL.PORTLET);
+ assertEquals(ResourceURL.PORTLET, resourceURL.getCacheability());
+
+ //
+ return new InvokeGetResponse(resourceURL.toString());
+ }
+ });
+ seq.bindAction(2, UTP2.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ sendEmptyResponse(response);
+
+ //
+ assertEquals(ResourceURL.PORTLET, request.getCacheability());
+ ResourceURL resourceURL = response.createResourceURL();
+ assertEquals(ResourceURL.PORTLET, resourceURL.getCacheability());
+ resourceURL.setCacheability(ResourceURL.FULL);
+ assertEquals(ResourceURL.FULL, resourceURL.getCacheability());
+ return new InvokeGetResponse(resourceURL.toString());
+ }
+ });
+ seq.bindAction(3, UTP2.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ sendEmptyResponse(response);
+
+ //
+ assertEquals(ResourceURL.FULL, request.getCacheability());
+
+ //
+ try
+ {
+ response.createActionURL();
+ fail();
+ }
+ catch (IllegalStateException ignore)
+ {
+ }
+
+ //
+ try
+ {
+ response.createRenderURL();
+ fail();
+ }
+ catch (IllegalStateException ignore)
+ {
+ }
+
+ //
+ ResourceURL resourceURL = response.createResourceURL();
+ assertEquals(ResourceURL.FULL, resourceURL.getCacheability());
+
+ //
+ try
+ {
+ resourceURL.setCacheability(ResourceURL.PORTLET);
+ fail();
+ }
+ catch (IllegalStateException ignore)
+ {
+ }
+ assertEquals(ResourceURL.FULL, resourceURL.getCacheability());
+
+ //
+ try
+ {
+ resourceURL.setCacheability(ResourceURL.PAGE);
+ fail();
+ }
+ catch (IllegalStateException ignore)
+ {
+ }
+ assertEquals(ResourceURL.FULL, resourceURL.getCacheability());
+
+ //
+ resourceURL.setCacheability(ResourceURL.FULL);
+ assertEquals(ResourceURL.FULL, resourceURL.getCacheability());
+
+ //
+ return new InvokeGetResponse(resourceURL.toString());
+ }
+ });
+ seq.bindAction(4, UTP2.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ sendEmptyResponse(response);
+
+ //
+ assertEquals(ResourceURL.FULL, request.getCacheability());
+ ResourceURL resourceURL = response.createResourceURL();
+ assertEquals(ResourceURL.FULL, resourceURL.getCacheability());
+ return new EndTestResponse();
+ }
+ });
+ }
+}
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/actions/PortletResourceTestAction.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/actions/PortletResourceTestAction.java 2008-01-23 16:07:45 UTC (rev 9580)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/actions/PortletResourceTestAction.java 2008-01-23 16:39:54 UTC (rev 9581)
@@ -35,6 +35,7 @@
import javax.portlet.ResourceRequest;
import javax.portlet.ResourceResponse;
import java.io.IOException;
+import java.io.PrintWriter;
/**
* @author <a href="mailto:boleslaw.dawidowicz@jboss.org">Boleslaw Dawidowicz</a>
@@ -82,4 +83,11 @@
{
throw new NotYetImplemented();
}
+
+ protected final void sendEmptyResponse(ResourceResponse response) throws IOException
+ {
+ response.setContentType("text/html");
+ PrintWriter writer = response.getWriter();
+ writer.close();
+ }
}
\ No newline at end of file
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 16:07:45 UTC (rev 9580)
+++ modules/portlet/trunk/test/src/test/resources/jsr286/tck/resourceserving-war/WEB-INF/portlet.xml 2008-01-23 16:39:54 UTC (rev 9581)
@@ -35,4 +35,12 @@
</supports>
</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>
+ </portlet>
+
</portlet-app>
18 years, 3 months
JBoss Portal SVN: r9580 - modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-01-23 11:07:45 -0500 (Wed, 23 Jan 2008)
New Revision: 9580
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletControllerContextImpl.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletURLRenderer.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/URLParameterConstants.java
Log:
added javadoc on various constants.
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletControllerContextImpl.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletControllerContextImpl.java 2008-01-23 15:58:49 UTC (rev 9579)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletControllerContextImpl.java 2008-01-23 16:07:45 UTC (rev 9580)
@@ -206,7 +206,7 @@
}
else
{
- Map<String, String[]> publicNavigationalStateChanges = (Map<String, String[]>)IOTools.unserialize(Tools.fromHexString(req.getParameter(PAGE_NAVIGATIONAL_STATE_CHANGES)));
+ Map<String, String[]> publicNavigationalStateChanges = (Map<String, String[]>)IOTools.unserialize(Tools.fromHexString(req.getParameter(PUBLIC_NAVIGATIONAL_STATE_CHANGES)));
//
request = new PortletController.PortletRenderRequest(
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletURLRenderer.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletURLRenderer.java 2008-01-23 15:58:49 UTC (rev 9579)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletURLRenderer.java 2008-01-23 16:07:45 UTC (rev 9580)
@@ -175,7 +175,7 @@
HashMap<String, String[]> serialiableChanges = new HashMap<String, String[]>(changes);
byte[] bytes = IOTools.serialize(serialiableChanges);
String ns = Tools.toHexString(bytes);
- parameters.put(PAGE_NAVIGATIONAL_STATE_CHANGES, ns);
+ parameters.put(PUBLIC_NAVIGATIONAL_STATE_CHANGES, ns);
}
catch (IOException e)
{
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/URLParameterConstants.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/URLParameterConstants.java 2008-01-23 15:58:49 UTC (rev 9579)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/URLParameterConstants.java 2008-01-23 16:07:45 UTC (rev 9580)
@@ -33,22 +33,70 @@
{
}
+ /**
+ * The life cycle type of the invocation. The values accepted are <code>ACTION_LIFECYCLE</code>,
+ * <code>RENDER_LIFECYCLE</code> and <code>RESOURCE_LIFECYCLE</code>.
+ */
public static final String LIFECYCLE_TYPE = "type";
+ /**
+ * The portlet mode.
+ */
public static final String MODE = "mode";
+
+ /**
+ * The window state.
+ */
public static final String WINDOW_STATE = "windowstate";
+
+ /**
+ * The portlet navigational state for any type of lifecycle.
+ */
public static final String NAVIGATIONAL_STATE = "navigationalstate";
+
+ /**
+ * The portlet resource state for lifecycle of type <code>RENDER_LIFECYCLE</code>.
+ */
public static final String RESOURCE_STATE = "resourcestate";
+
+ /**
+ * The portlet interaction state for lifecycle of type <code>ACTION_LIFECYCLE</code>.
+ */
public static final String INTERACTION_STATE = "interactionstate";
+ /**
+ * The page state for any kind of lifecycle.
+ */
public static final String PAGE_STATE = "pagestate";
- public static final String PAGE_NAVIGATIONAL_STATE_CHANGES = "pagenavigationalstatechanges";
- public static final String RESOURCE_ID = "id";
+ /**
+ * The public navigational state changes of a portlet for lifecycle of type <code>RENDER_LIFECYCLE</code>.
+ */
+ public static final String PUBLIC_NAVIGATIONAL_STATE_CHANGES = "publicnavigationalstatechanges";
+
+ /**
+ * The resource id for lifecycle of type <code>RESOURCE_LIFECYCLE</code>.
+ */
+ public static final String RESOURCE_ID = "resourceid";
+
+ /**
+ * The resource cacheability for lifecycle of type <code>RENDER_LIFECYCLE</code>.
+ */
public static final String RESOURCE_CACHEABILITY = "resourcecacheability";
+ /**
+ * Denotes an action lifecycle operation.
+ */
public static final String ACTION_LIFECYCLE = "action";
+
+ /**
+ * Denotes a render lifecycle operation.
+ */
public static final String RENDER_LIFECYCLE = "render";
+
+ /**
+ * Denotes a resource lifecycle operation.
+ */
public static final String RESOURCE_LIFECYCLE = "resource";
}
18 years, 3 months
JBoss Portal SVN: r9579 - modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-01-23 10:58:49 -0500 (Wed, 23 Jan 2008)
New Revision: 9579
Added:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/URLParameterConstants.java
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletControllerContextImpl.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletURLRenderer.java
Log:
- added constant class for URL parameter constants
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletControllerContextImpl.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletControllerContextImpl.java 2008-01-23 15:35:57 UTC (rev 9578)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletControllerContextImpl.java 2008-01-23 15:58:49 UTC (rev 9579)
@@ -39,6 +39,7 @@
import org.jboss.portal.web.Body;
import org.jboss.portal.web.IllegalRequestException;
import org.jboss.portal.web.WebRequest;
+import static org.jboss.portal.portlet.test.URLParameterConstants.*;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
@@ -100,7 +101,7 @@
WebRequest ri = new WebRequest(req);
// Unmarshall portal navigational state if it is provided
- String context = req.getParameter("context");
+ String context = req.getParameter(PAGE_STATE);
if (context != null)
{
byte[] bytes = Tools.fromHexString(context);
@@ -109,20 +110,20 @@
//
Mode mode = null;
- if (req.getParameter("mode") != null)
+ if (req.getParameter(MODE) != null)
{
- mode = Mode.create(req.getParameter("mode"));
+ mode = Mode.create(req.getParameter(MODE));
}
//
WindowState windowState = null;
- if (req.getParameter("windowstate") != null)
+ if (req.getParameter(WINDOW_STATE) != null)
{
- windowState = WindowState.create(req.getParameter("windowstate"));
+ windowState = WindowState.create(req.getParameter(WINDOW_STATE));
}
//
- String navigationalStateString = req.getParameter("navigationalstate");
+ String navigationalStateString = req.getParameter(NAVIGATIONAL_STATE);
StateString navigationalState = null;
if (navigationalStateString != null)
{
@@ -130,11 +131,11 @@
}
//
- String type = req.getParameter("type");
- if ("resource".equals(type))
+ String type = req.getParameter(LIFECYCLE_TYPE);
+ if (RESOURCE_LIFECYCLE.equals(type))
{
- StateString resourceState = ParametersStateString.create(req.getParameter("resourcestate"));
- String resourceId = req.getParameter("id");
+ StateString resourceState = ParametersStateString.create(req.getParameter(RESOURCE_STATE));
+ String resourceId = req.getParameter(RESOURCE_ID);
//
@@ -145,7 +146,7 @@
}
//
- CacheabilityType resourceCacheabilityType = CacheabilityType.valueOf(req.getParameter("cacheability"));
+ CacheabilityType resourceCacheabilityType = CacheabilityType.valueOf(req.getParameter(RESOURCE_CACHEABILITY));
//
switch (resourceCacheabilityType)
@@ -182,7 +183,7 @@
}
else
{
- if ("action".equals(type))
+ if (ACTION_LIFECYCLE.equals(type))
{
ParameterMap formParameters = null;
if (ri.getBody() instanceof Body.Form)
@@ -191,7 +192,7 @@
}
//
- StateString interactionState = ParametersStateString.create(req.getParameter("interactionstate"));
+ StateString interactionState = ParametersStateString.create(req.getParameter(INTERACTION_STATE));
//
request = new PortletController.PortletActionRequest(
@@ -205,11 +206,9 @@
}
else
{
+ Map<String, String[]> publicNavigationalStateChanges = (Map<String, String[]>)IOTools.unserialize(Tools.fromHexString(req.getParameter(PAGE_NAVIGATIONAL_STATE_CHANGES)));
//
- Map<String, String[]> publicNavigationalStateChanges = (Map<String, String[]>)IOTools.unserialize(Tools.fromHexString(req.getParameter("publicnavigationalstatechanges")));
-
- //
request = new PortletController.PortletRenderRequest(
targetId,
navigationalState,
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletURLRenderer.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletURLRenderer.java 2008-01-23 15:35:57 UTC (rev 9578)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletURLRenderer.java 2008-01-23 15:58:49 UTC (rev 9579)
@@ -34,6 +34,7 @@
import org.jboss.portal.common.text.FastURLEncoder;
import org.jboss.portal.common.util.Tools;
import org.jboss.portal.common.io.IOTools;
+import static org.jboss.portal.portlet.test.URLParameterConstants.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -96,29 +97,29 @@
String type;
if (containerURL instanceof ActionURL)
{
- type = "action";
+ type = ACTION_LIFECYCLE;
}
else if (containerURL instanceof RenderURL)
{
- type = "render";
+ type = RENDER_LIFECYCLE;
}
else if (containerURL instanceof ResourceURL)
{
- type = "resource";
+ type = RESOURCE_LIFECYCLE;
}
else
{
throw new Error();
}
- parameters.put("type", type);
+ parameters.put(LIFECYCLE_TYPE, type);
//
- String context;
+ String pageState;
try
{
byte[] bytes = PageNavigationalState.serialize(pageNS);
String ns = Tools.toHexString(bytes);
- context = ns;
+ pageState = ns;
}
catch (IOException e)
{
@@ -132,17 +133,17 @@
if (portletURL.getMode() != null)
{
- parameters.put("mode", portletURL.getMode().toString());
+ parameters.put(MODE, portletURL.getMode().toString());
}
//
if (portletURL.getWindowState() != null)
{
- parameters.put("windowstate", portletURL.getWindowState().toString());
+ parameters.put(WINDOW_STATE, portletURL.getWindowState().toString());
}
//
- parameters.put("context", context);
+ parameters.put(PAGE_STATE, pageState);
//
if (containerURL instanceof ActionURL)
@@ -155,13 +156,13 @@
StateString portletNS = windowNS.getPortletNavigationalState();
if (portletNS != null)
{
- parameters.put("navigationalstate", windowNS.getPortletNavigationalState().getStringValue());
+ parameters.put(NAVIGATIONAL_STATE, windowNS.getPortletNavigationalState().getStringValue());
}
}
//
StateString interactionState = actionURL.getInteractionState();
- parameters.put("interactionstate", interactionState.getStringValue());
+ parameters.put(INTERACTION_STATE, interactionState.getStringValue());
}
else
{
@@ -174,7 +175,7 @@
HashMap<String, String[]> serialiableChanges = new HashMap<String, String[]>(changes);
byte[] bytes = IOTools.serialize(serialiableChanges);
String ns = Tools.toHexString(bytes);
- parameters.put("publicnavigationalstatechanges", ns);
+ parameters.put(PAGE_NAVIGATIONAL_STATE_CHANGES, ns);
}
catch (IOException e)
{
@@ -183,7 +184,7 @@
//
StateString navigationalState = renderURL.getNavigationalState();
- parameters.put("navigationalstate", navigationalState.getStringValue());
+ parameters.put(NAVIGATIONAL_STATE, navigationalState.getStringValue());
}
}
else
@@ -192,18 +193,18 @@
//
StateString resourceState = resourceURL.getResourceState();
- parameters.put("resourcestate", resourceState.getStringValue());
+ parameters.put(RESOURCE_STATE, resourceState.getStringValue());
//
String resourceId = resourceURL.getResourceId();
if (resourceId != null)
{
- parameters.put("id", resourceId);
+ parameters.put(RESOURCE_ID, resourceId);
}
//
CacheabilityType cacheability = resourceURL.getCacheability();
- parameters.put("cacheability", cacheability.name());
+ parameters.put(RESOURCE_CACHEABILITY, cacheability.name());
//
if (cacheability != CacheabilityType.FULL)
@@ -213,19 +214,19 @@
StateString portletNS = windowNS.getPortletNavigationalState();
if (portletNS != null)
{
- parameters.put("navigationalstate", windowNS.getPortletNavigationalState().getStringValue());
+ parameters.put(NAVIGATIONAL_STATE, windowNS.getPortletNavigationalState().getStringValue());
}
//
- parameters.put("mode", windowNS.getMode().toString());
+ parameters.put(MODE, windowNS.getMode().toString());
//
- parameters.put("windowstate", windowNS.getWindowState().toString());
+ parameters.put(WINDOW_STATE, windowNS.getWindowState().toString());
//
if (cacheability == CacheabilityType.PAGE)
{
- parameters.put("context", context);
+ parameters.put(PAGE_STATE, pageState);
}
}
}
Added: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/URLParameterConstants.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/URLParameterConstants.java (rev 0)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/URLParameterConstants.java 2008-01-23 15:58:49 UTC (rev 9579)
@@ -0,0 +1,54 @@
+/******************************************************************************
+ * 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;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public final class URLParameterConstants
+{
+
+ private URLParameterConstants()
+ {
+ }
+
+ public static final String LIFECYCLE_TYPE = "type";
+
+ public static final String MODE = "mode";
+ public static final String WINDOW_STATE = "windowstate";
+ public static final String NAVIGATIONAL_STATE = "navigationalstate";
+ public static final String RESOURCE_STATE = "resourcestate";
+ public static final String INTERACTION_STATE = "interactionstate";
+
+ public static final String PAGE_STATE = "pagestate";
+ public static final String PAGE_NAVIGATIONAL_STATE_CHANGES = "pagenavigationalstatechanges";
+
+ public static final String RESOURCE_ID = "id";
+ public static final String RESOURCE_CACHEABILITY = "resourcecacheability";
+
+ public static final String ACTION_LIFECYCLE = "action";
+ public static final String RENDER_LIFECYCLE = "render";
+ public static final String RESOURCE_LIFECYCLE = "resource";
+
+}
18 years, 3 months
JBoss Portal SVN: r9578 - modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletrequests.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-01-23 10:35:57 -0500 (Wed, 23 Jan 2008)
New Revision: 9578
Modified:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletrequests/PublicRenderParameterAvailableInLifeCycleMethodTestCase.java
Log:
- fixed a test case where the resource serving was not servicing and providing no content making the test case fail
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletrequests/PublicRenderParameterAvailableInLifeCycleMethodTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletrequests/PublicRenderParameterAvailableInLifeCycleMethodTestCase.java 2008-01-23 15:23:47 UTC (rev 9577)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletrequests/PublicRenderParameterAvailableInLifeCycleMethodTestCase.java 2008-01-23 15:35:57 UTC (rev 9578)
@@ -51,6 +51,7 @@
import javax.portlet.ResourceRequest;
import javax.portlet.ResourceResponse;
import java.io.IOException;
+import java.io.PrintWriter;
import java.util.Map;
import java.util.HashMap;
import java.util.Collections;
@@ -197,6 +198,14 @@
assertParameterMap(expectedClientDataMap, request);
assertEquals(expectedClientDataPrivateMap, request.getPrivateParameterMap());
assertEquals(expectedPublicMap, request.getPublicParameterMap());
+
+ //
+ response.setContentType("text/html");
+ PrintWriter writer = response.getWriter();
+ writer.print("foo");
+ writer.close();
+
+ //
return new EndTestResponse();
}
});
18 years, 3 months