JBoss Portal SVN: r9748 - in modules/portlet/trunk/test/src/main/java/org/jboss/portal: portlet/test/controller and 1 other directories.
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2008-02-04 14:06:09 -0500 (Mon, 04 Feb 2008)
New Revision: 9748
Added:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/ControllerResponse.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/ErrorControllerResponse.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/FragmentRenderer.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PageRenderControllerResponse.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/RedirectControllerResponse.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/RenderControllerResponse.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/ResourceRenderControllerResponse.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/SimpleFragmentRenderer.java
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortalServlet.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/controller/PortletController.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletRequestHandler.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletResourceRequestHandler.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/RequestHandler.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/ViewRequestHandler.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/simple/SimplePortalServlet.java
Log:
- Move response/rendering to ControllerResponse hierarchy.
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortalServlet.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortalServlet.java 2008-02-04 18:24:07 UTC (rev 9747)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortalServlet.java 2008-02-04 19:06:09 UTC (rev 9748)
@@ -22,6 +22,7 @@
******************************************************************************/
package org.jboss.portal.portlet.test;
+import org.jboss.portal.portlet.test.controller.ControllerResponse;
import org.jboss.portal.portlet.test.controller.PortletController;
import org.jboss.portal.portlet.test.controller.PortletControllerContextImpl;
@@ -69,7 +70,7 @@
//
PortletController controller = new PortletController();
- //
- controller.process(context.getRequest());
+ ControllerResponse response = controller.process(context.getRequest());
+ response.render(context);
}
}
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-02-04 18:24:07 UTC (rev 9747)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletURLRenderer.java 2008-02-04 19:06:09 UTC (rev 9748)
@@ -22,26 +22,26 @@
******************************************************************************/
package org.jboss.portal.portlet.test;
+import org.jboss.portal.common.io.IOTools;
+import org.jboss.portal.common.text.CharBuffer;
+import org.jboss.portal.common.text.FastURLEncoder;
+import org.jboss.portal.common.util.Tools;
+import org.jboss.portal.portlet.ActionURL;
+import org.jboss.portal.portlet.ContainerURL;
import org.jboss.portal.portlet.Portlet;
import org.jboss.portal.portlet.PortletURL;
import org.jboss.portal.portlet.RenderURL;
-import org.jboss.portal.portlet.ActionURL;
-import org.jboss.portal.portlet.StateString;
import org.jboss.portal.portlet.ResourceURL;
-import org.jboss.portal.portlet.ContainerURL;
+import org.jboss.portal.portlet.StateString;
import org.jboss.portal.portlet.cache.CacheLevel;
-import org.jboss.portal.common.text.CharBuffer;
-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 org.jboss.portal.portlet.test.controller.PageNavigationalState;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import java.util.Map;
-import java.util.HashMap;
import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -119,8 +119,7 @@
try
{
byte[] bytes = PageNavigationalState.serialize(pageNS);
- String ns = Tools.toHexString(bytes);
- pageState = ns;
+ pageState = Tools.toHexString(bytes);
}
catch (IOException e)
{
@@ -235,7 +234,7 @@
//
boolean first = true;
- for (Map.Entry<String,String> entry : parameters.entrySet())
+ for (Map.Entry<String, String> entry : parameters.entrySet())
{
String name = entry.getKey();
String value = entry.getValue();
Added: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/ControllerResponse.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/ControllerResponse.java (rev 0)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/ControllerResponse.java 2008-02-04 19:06:09 UTC (rev 9748)
@@ -0,0 +1,41 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, 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.controller;
+
+import java.io.IOException;
+
+/**
+ * Must be used as base class for high level response provided by the controller that will be translated into something
+ * at the portal level. The goal is to avoid to manipulate the HTTP response directly.
+ * <p/>
+ * The test bed will of course use the HTTP response but the Presentation Framework will work differently.
+ * <p/>
+ * So we really need to abstract everything done with the HttpServletResponse and *never* use it in the controller.
+ * <p/>
+ * Typical usage should be : ControllerResponse response = controller.invoker(ControllerRequest request);
+ */
+public interface ControllerResponse
+{
+ void render(PortletControllerContext context) throws IOException;
+}
Property changes on: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/ControllerResponse.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/ErrorControllerResponse.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/ErrorControllerResponse.java (rev 0)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/ErrorControllerResponse.java 2008-02-04 19:06:09 UTC (rev 9748)
@@ -0,0 +1,60 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, 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.controller;
+
+import org.apache.log4j.Logger;
+import org.jboss.portal.portlet.invocation.response.ErrorResponse;
+
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ * @version $Revision$
+ */
+public class ErrorControllerResponse implements ControllerResponse
+{
+ private ErrorResponse error;
+ private static final Logger log = Logger.getLogger(ErrorControllerResponse.class);
+
+ public ErrorControllerResponse(ErrorResponse error)
+ {
+ this.error = error;
+ }
+
+ public void render(PortletControllerContext context) throws IOException
+ {
+ //
+ if (error.getCause() != null)
+ {
+ log.error("Portlet action threw an error: " + error.getMessage(), error.getCause());
+ }
+ else
+ {
+ log.error("Portlet action threw an error: " + error.getMessage());
+ }
+
+ //
+ context.getClientResponse().sendError(404, error.getMessage());
+ }
+}
Property changes on: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/ErrorControllerResponse.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/FragmentRenderer.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/FragmentRenderer.java (rev 0)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/FragmentRenderer.java 2008-02-04 19:06:09 UTC (rev 9748)
@@ -0,0 +1,38 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, 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.controller;
+
+import org.jboss.portal.portlet.invocation.response.ErrorResponse;
+import org.jboss.portal.portlet.invocation.response.FragmentResponse;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ * @version $Revision$
+ */
+public interface FragmentRenderer
+{
+ String renderPortlet(FragmentResponse fragment);
+
+ String renderError(ErrorResponse error);
+}
Property changes on: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/FragmentRenderer.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PageRenderControllerResponse.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PageRenderControllerResponse.java (rev 0)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PageRenderControllerResponse.java 2008-02-04 19:06:09 UTC (rev 9748)
@@ -0,0 +1,245 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, 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.controller;
+
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.common.util.MultiValuedPropertyMap;
+import org.jboss.portal.common.util.ParameterMap;
+import org.jboss.portal.common.xml.XMLTools;
+import org.jboss.portal.portlet.Portlet;
+import org.jboss.portal.portlet.PortletInvokerException;
+import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.impl.spi.AbstractClientContext;
+import org.jboss.portal.portlet.impl.spi.AbstractSecurityContext;
+import org.jboss.portal.portlet.impl.spi.AbstractServerContext;
+import org.jboss.portal.portlet.impl.spi.AbstractUserContext;
+import org.jboss.portal.portlet.impl.spi.AbstractWindowContext;
+import org.jboss.portal.portlet.invocation.RenderInvocation;
+import org.jboss.portal.portlet.invocation.response.ErrorResponse;
+import org.jboss.portal.portlet.invocation.response.FragmentResponse;
+import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
+import org.jboss.portal.portlet.invocation.response.ResponseProperties;
+import org.jboss.portal.portlet.test.PortletURLRenderer;
+import org.jboss.portal.portlet.test.TestInstanceContext;
+import org.jboss.portal.portlet.test.TestRenderContext;
+import org.jboss.portal.portlet.test.WindowNavigationalState;
+import org.w3c.dom.Element;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ * @version $Revision$
+ */
+public class PageRenderControllerResponse extends RenderControllerResponse
+{
+ private FragmentRenderer fragmentRenderer = new SimpleFragmentRenderer();
+ private List<FragmentResponse> fragments;
+ private List<ErrorResponse> errors;
+ private PageNavigationalState pageState;
+
+ public PageRenderControllerResponse(ResponseProperties properties, PageNavigationalState pageState)
+ {
+ super(properties);
+ this.pageState = pageState;
+ }
+
+ public void setFragmentRenderer(FragmentRenderer fragmentRenderer)
+ {
+ this.fragmentRenderer = fragmentRenderer;
+ }
+
+ protected void renderContent(HttpServletResponse resp) throws IOException
+ {
+ //
+ resp.setContentType("text/html");
+ PrintWriter writer = resp.getWriter();
+ writer.print("<html>");
+
+ // Render the head contributions
+ writer.print("<head>");
+ MultiValuedPropertyMap<Element> markupHeaders = properties.getMarkupHeaders();
+ List<Element> headElement = markupHeaders.getValues("javax.portlet.markup.head.element");
+ if (headElement != null)
+ {
+ for (Element headerValue : headElement)
+ {
+ try
+ {
+ String serializedElement = XMLTools.toString(headerValue);
+ writer.print(serializedElement);
+ }
+ catch (Exception e)
+ {
+ // todo
+ e.printStackTrace();
+ }
+ }
+ }
+ writer.print("</head>");
+
+
+ writer.print("<body>");
+ for (FragmentResponse fragment : fragments)
+ {
+ writer.print(fragmentRenderer.renderPortlet(fragment));
+
+ }
+
+ for (ErrorResponse error : errors)
+ {
+ writer.print(fragmentRenderer.renderError(error));
+ }
+
+ writer.print("</body></html>");
+ }
+
+ protected void prepareRendering(PortletControllerContext context)
+ {
+
+ // What we collect during the different renders
+ // we don't reuse the render properties argument since we want to avoid that
+ // a portlet rendition affects another rendition of a portlet on the same page
+ ResponseProperties renderProperties = new ResponseProperties();
+
+ //
+ try
+ {
+ Collection<Portlet> portlets = context.getPortlets();
+
+ int capacity = portlets.size();
+ fragments = new ArrayList<FragmentResponse>(capacity);
+ errors = new ArrayList<ErrorResponse>(capacity);
+
+ for (Portlet portlet : portlets)
+ {
+ WindowNavigationalState windowNS = pageState.getWindowNavigationalState(portlet.getContext().getId());
+
+ //
+ Mode mode = Mode.VIEW;
+ WindowState windowState = WindowState.NORMAL;
+ StateString portletNS = null;
+
+ //
+ if (windowNS != null)
+ {
+ if (windowNS.getMode() != null)
+ {
+ mode = windowNS.getMode();
+ }
+ if (windowNS.getWindowState() != null)
+ {
+ windowState = windowNS.getWindowState();
+ }
+ if (windowNS.getPortletNavigationalState() != null)
+ {
+ portletNS = windowNS.getPortletNavigationalState();
+ }
+ }
+
+ //
+ ParameterMap publicNS = pageState.getPublicNavigationalState(portlet);
+
+ RenderInvocation render = createRenderInvocation(context, properties, pageState, portlet, windowNS, mode, windowState, portletNS, publicNS);
+
+ //
+ try
+ {
+ PortletInvocationResponse response = context.invoke(render);
+
+ if (response instanceof FragmentResponse)
+ {
+ FragmentResponse fragment = (FragmentResponse)response;
+
+ //
+ fragments.add(fragment);
+
+ //
+ ResponseProperties fragmentProperties = fragment.getProperties();
+ if (fragmentProperties != null)
+ {
+ renderProperties.append(fragmentProperties);
+ }
+ }
+ else if (response instanceof ErrorResponse)
+ {
+ ErrorResponse error = (ErrorResponse)response;
+ errors.add(error);
+ }
+
+ }
+ catch (PortletInvokerException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+ catch (PortletInvokerException e)
+ {
+ // todo
+ e.printStackTrace();
+ }
+
+ // Now we combine the render properties with the page properties
+ properties.append(renderProperties);
+ }
+
+ protected RenderInvocation createRenderInvocation(
+ PortletControllerContext context, ResponseProperties pageProperties, PageNavigationalState pageNS, Portlet portlet,
+ WindowNavigationalState windowNS, Mode mode, WindowState windowState, StateString portletNS, ParameterMap publicNS)
+ {
+ HttpServletRequest req = context.getClientRequest();
+ HttpServletResponse resp = context.getClientResponse();
+
+ //
+ PortletURLRenderer renderer = new PortletURLRenderer(pageNS, windowNS, portlet, req, resp);
+ //
+ TestInstanceContext instanceContext = new TestInstanceContext(req, portlet.getContext(), false);
+
+ TestRenderContext renderContext = new TestRenderContext(renderer, PortletController.MARKUP_INFO);
+
+ //
+ RenderInvocation render = new RenderInvocation(renderContext);
+ render.setClientContext(new AbstractClientContext(req, pageProperties.getCookies()));
+ render.setServerContext(new AbstractServerContext(req, resp));
+ render.setInstanceContext(instanceContext);
+ render.setUserContext(new AbstractUserContext(req));
+ render.setWindowContext(new AbstractWindowContext(portlet.getContext().getId()));
+ render.setPortalContext(PortletController.getPortalContext());
+ render.setSecurityContext(new AbstractSecurityContext(req));
+ render.setTarget(instanceContext.getTarget());
+ render.setMode(mode);
+ render.setWindowState(windowState);
+ render.setNavigationalState(portletNS);
+ render.setPublicNavigationalState(publicNS);
+ return render;
+ }
+}
Property changes on: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PageRenderControllerResponse.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletController.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletController.java 2008-02-04 18:24:07 UTC (rev 9747)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletController.java 2008-02-04 19:06:09 UTC (rev 9748)
@@ -22,48 +22,18 @@
******************************************************************************/
package org.jboss.portal.portlet.test.controller;
-import org.jboss.portal.Mode;
-import org.jboss.portal.WindowState;
import org.jboss.portal.common.util.MarkupInfo;
import org.jboss.portal.common.util.MediaType;
-import org.jboss.portal.common.util.MultiValuedPropertyMap;
import org.jboss.portal.common.util.ParameterMap;
-import org.jboss.portal.common.xml.XMLTools;
-import org.jboss.portal.portlet.Portlet;
import org.jboss.portal.portlet.PortletInvokerException;
import org.jboss.portal.portlet.StateString;
import org.jboss.portal.portlet.cache.CacheLevel;
-import org.jboss.portal.portlet.impl.spi.AbstractClientContext;
import org.jboss.portal.portlet.impl.spi.AbstractPortalContext;
-import org.jboss.portal.portlet.impl.spi.AbstractSecurityContext;
-import org.jboss.portal.portlet.impl.spi.AbstractServerContext;
-import org.jboss.portal.portlet.impl.spi.AbstractUserContext;
-import org.jboss.portal.portlet.impl.spi.AbstractWindowContext;
-import org.jboss.portal.portlet.invocation.RenderInvocation;
-import org.jboss.portal.portlet.invocation.response.ErrorResponse;
-import org.jboss.portal.portlet.invocation.response.FragmentResponse;
-import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
-import org.jboss.portal.portlet.invocation.response.ResponseProperties;
import org.jboss.portal.portlet.spi.PortalContext;
-import org.jboss.portal.portlet.test.controller.PageNavigationalState;
-import org.jboss.portal.portlet.test.PortletURLRenderer;
-import org.jboss.portal.portlet.test.TestInstanceContext;
-import org.jboss.portal.portlet.test.TestRenderContext;
import org.jboss.portal.portlet.test.WindowNavigationalState;
-import org.jboss.portal.web.IllegalRequestException;
-import org.w3c.dom.Element;
-import javax.servlet.http.Cookie;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.UnsupportedEncodingException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
import java.util.HashMap;
-import java.util.List;
import java.util.Map;
/**
@@ -77,20 +47,17 @@
static final MarkupInfo MARKUP_INFO = new MarkupInfo(MediaType.HTML, "UTF8");
/** . */
- // private final boolean redirectAfterAction = true;
+ static final PortalContext portalContext;
- /** . */
- private final PortalContext portalContext;
-
- public PortletController() throws IllegalRequestException, UnsupportedEncodingException
+ static
{
Map<String, String> portalProperties = new HashMap<String, String>();
portalProperties.put("javax.portlet.markup.head.element.support", "true");
- this.portalContext = new AbstractPortalContext(portalProperties);
+ portalContext = new AbstractPortalContext(portalProperties);
}
- public void process(ControllerRequest controllerRequest) throws IOException, PortletInvokerException
+ public ControllerResponse process(ControllerRequest controllerRequest) throws IOException, PortletInvokerException
{
RequestHandler handler;
@@ -111,231 +78,14 @@
throw new PortletInvokerException("Unknown request type: " + controllerRequest.getClass().getName());
}
- handler.handle(controllerRequest);
+ return handler.handle(controllerRequest);
}
- /**
- * @param context
- * @param pageProperties properties that needs to be rendered on this page
- * @param pageNS
- * @throws IOException
- */
- void render(PortletControllerContext context, ResponseProperties pageProperties, PageNavigationalState pageNS) throws IOException
+ static PortalContext getPortalContext()
{
- HttpServletRequest req = context.getClientRequest();
- HttpServletResponse resp = context.getClientResponse();
-
- List<FragmentResponse> fragments = Collections.emptyList();
- List<ErrorResponse> errors = Collections.emptyList();
-
- // What we collect during the different renders
- // we don't reuse the render properties argument since we want to avoid that
- // a portlet rendition affects another rendition of a portlet on the same page
- ResponseProperties renderProperties = new ResponseProperties();
-
- //
- try
- {
- Collection<Portlet> portlets = context.getPortlets();
-
- int capacity = portlets.size();
- fragments = new ArrayList<FragmentResponse>(capacity);
- errors = new ArrayList<ErrorResponse>(capacity);
-
- for (Portlet portlet : portlets)
- {
- WindowNavigationalState windowNS = pageNS.getWindowNavigationalState(portlet.getContext().getId());
-
- //
- PortletURLRenderer renderer = new PortletURLRenderer(pageNS, windowNS, portlet, req, resp);
-
- //
- Mode mode = Mode.VIEW;
- WindowState windowState = WindowState.NORMAL;
- StateString portletNS = null;
-
- //
- if (windowNS != null)
- {
- if (windowNS.getMode() != null)
- {
- mode = windowNS.getMode();
- }
- if (windowNS.getWindowState() != null)
- {
- windowState = windowNS.getWindowState();
- }
- if (windowNS.getPortletNavigationalState() != null)
- {
- portletNS = windowNS.getPortletNavigationalState();
- }
- }
-
- //
- ParameterMap publicNS = pageNS.getPublicNavigationalState(portlet);
-
- //
- TestInstanceContext instanceContext = new TestInstanceContext(req, portlet.getContext(), false);
- TestRenderContext renderContext = new TestRenderContext(renderer, MARKUP_INFO);
-
- //
- RenderInvocation render = new RenderInvocation(renderContext);
-
- //
- render.setMode(mode);
- render.setWindowState(windowState);
- render.setNavigationalState(portletNS);
- render.setPublicNavigationalState(publicNS);
-
- //
- render.setClientContext(new AbstractClientContext(req, pageProperties.getCookies()));
- render.setServerContext(new AbstractServerContext(req, resp));
- render.setInstanceContext(instanceContext);
- render.setUserContext(new AbstractUserContext(req));
- render.setWindowContext(new AbstractWindowContext(portlet.getContext().getId()));
- render.setPortalContext(getPortalContext());
- render.setSecurityContext(new AbstractSecurityContext(req));
- render.setTarget(instanceContext.getTarget());
-
- //
- try
- {
- PortletInvocationResponse response = context.invoke(render);
-
- if (response instanceof FragmentResponse)
- {
- FragmentResponse fragment = (FragmentResponse)response;
-
- //
- fragments.add(fragment);
-
- //
- ResponseProperties fragmentProperties = fragment.getProperties();
- if (fragmentProperties != null)
- {
- renderProperties.append(fragmentProperties);
- }
- }
- else if (response instanceof ErrorResponse)
- {
- ErrorResponse error = (ErrorResponse)response;
- errors.add(error);
- }
-
- }
- catch (PortletInvokerException e)
- {
- e.printStackTrace();
- }
- }
- }
- catch (PortletInvokerException e)
- {
- // todo
- e.printStackTrace();
- }
-
- // Now we combine the render properties with the page properties
- pageProperties.append(renderProperties);
-
- // Render the headers and cookies
- renderTransportHeaders(pageProperties, resp);
- renderCookies(pageProperties, resp);
-
- //
- resp.setContentType("text/html");
- PrintWriter writer = resp.getWriter();
- writer.print("<html>");
-
- // Render the head contributions
- writer.print("<head>");
- MultiValuedPropertyMap<Element> markupHeaders = pageProperties.getMarkupHeaders();
- List<Element> headElement = markupHeaders.getValues("javax.portlet.markup.head.element");
- if (headElement != null)
- {
- for (Element headerValue : headElement)
- {
- try
- {
- String serializedElement = XMLTools.toString(headerValue);
- writer.print(serializedElement);
- }
- catch (Exception e)
- {
- // todo
- e.printStackTrace();
- }
- }
- }
- writer.print("</head>");
-
-
- writer.print("<body>");
- for (FragmentResponse fragment : fragments)
- {
- if (fragment.getType() != FragmentResponse.TYPE_EMPTY)
- {
- writer.print("<div class=\"portlet\">");
- writer.print(fragment.getBuffer().getContent());
- writer.print("</div>");
- }
- else
- {
- writer.print("<div/>");
- }
- }
-
- for (ErrorResponse error : errors)
- {
- writer.print("<div class='error'>");
- writer.print(error.toHTML());
- writer.print("</div>");
- }
-
- writer.print("</body></html>");
- }
-
- void renderCookies(ResponseProperties pageProperties, HttpServletResponse resp)
- {
- List<Cookie> cookies = pageProperties.getCookies();
- for (Cookie cookie : cookies)
- {
- resp.addCookie(cookie);
- }
- }
-
- void renderTransportHeaders(ResponseProperties pageProperties, HttpServletResponse resp)
- {
- MultiValuedPropertyMap<String> transportHeaders = pageProperties.getTransportHeaders();
- for (String headerName : transportHeaders.keySet())
- {
- for (String headerValue : transportHeaders.getValues(headerName))
- {
- resp.addHeader(headerName, headerValue);
- }
- }
- }
-
- PortalContext getPortalContext()
- {
return portalContext;
}
- /**
- * Must be used as base class for high level response provided by the controller that will be translated into
- * something at the portal level. The goal is to avoid to manipulate the HTTP response directly.
- * <p/>
- * The test bed will of course use the HTTP response but the Presentation Framework will work differently.
- * <p/>
- * So we really need to abstract everything done with the HttpServletResponse and *never* use it in the controller.
- * <p/>
- * Typical usage should be : ControllerResponse response = controller.invoker(ControllerRequest request);
- */
- static class ControllerResponse
- {
-
- }
-
static class ControllerRequest
{
/** . */
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletRequestHandler.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletRequestHandler.java 2008-02-04 18:24:07 UTC (rev 9747)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletRequestHandler.java 2008-02-04 19:06:09 UTC (rev 9748)
@@ -65,7 +65,7 @@
return (PortletRequest)request;
}
- void processResponse(PortletRequest portletRequest, PortletInvocationResponse response) throws IOException, PortletInvokerException
+ ControllerResponse processResponse(PortletRequest portletRequest, PortletInvocationResponse response) throws IOException, PortletInvokerException
{
PortletControllerContext context = portletRequest.controllerContext;
@@ -83,35 +83,19 @@
//
if (response instanceof ErrorResponse)
{
- ErrorResponse error = (ErrorResponse)response;
-
- //
- if (error.getCause() != null)
- {
- log.error("Portlet action threw an error: " + error.getMessage(), error.getCause());
- }
- else
- {
- log.error("Portlet action threw an error: " + error.getMessage());
- }
-
- //
- context.getClientResponse().sendError(404, error.getMessage());
+ return new ErrorControllerResponse((ErrorResponse)response);
}
else if (response instanceof UpdateNavigationalStateResponse)
{
// Update portlet NS
- if (response instanceof UpdateNavigationalStateResponse)
- {
- UpdateNavigationalStateResponse updateResponse = (UpdateNavigationalStateResponse)response;
- updateNavigationalState(context, portletRequest.portletId, updateResponse, pageState);
+ UpdateNavigationalStateResponse updateResponse = (UpdateNavigationalStateResponse)response;
+ updateNavigationalState(context, portletRequest.portletId, updateResponse, pageState);
- //
- ResponseProperties update = updateResponse.getProperties();
- if (update != null)
- {
- requestProperties.append(update);
- }
+ //
+ ResponseProperties update = updateResponse.getProperties();
+ if (update != null)
+ {
+ requestProperties.append(update);
}
//
@@ -138,13 +122,13 @@
//
if (eventResponse instanceof UpdateNavigationalStateResponse)
{
- UpdateNavigationalStateResponse update = (UpdateNavigationalStateResponse)eventResponse;
+ UpdateNavigationalStateResponse eventStateResponse = (UpdateNavigationalStateResponse)eventResponse;
// Update ns
- updateNavigationalState(context, event.getPortletContext().getId(), update, pageState);
+ updateNavigationalState(context, event.getPortletContext().getId(), eventStateResponse, pageState);
// Add events if any
- for (UpdateNavigationalStateResponse.Event portletEvent : update.getEvents())
+ for (UpdateNavigationalStateResponse.Event portletEvent : eventStateResponse.getEvents())
{
Event producedEvent = new Event(portletEvent.getName(), portletEvent.getPayload(), portletContext);
List<Event> consumedEvents = eventCC.getConsumedEvents(producedEvent);
@@ -152,7 +136,7 @@
}
//
- ResponseProperties updateProperties = update.getProperties();
+ ResponseProperties updateProperties = eventStateResponse.getProperties();
if (updateProperties != null)
{
requestProperties.append(updateProperties);
@@ -170,41 +154,14 @@
}
else if (response instanceof HTTPRedirectionResponse)
{
- HTTPRedirectionResponse redirection = (HTTPRedirectionResponse)response;
- context.getClientResponse().sendRedirect(redirection.getLocation());
- return;
+ return new RedirectControllerResponse((HTTPRedirectionResponse)response);
}
else
{
System.out.println("Not yet handled " + response);
}
- /*
- if (response instanceof RenderResponse && redirectAfterAction)
- {
- PortletURLRenderer renderer = new PortletURLRenderer(navState, portlet, req, resp);
- final RenderResponse render = (RenderResponse)response;
- String location = renderer.renderURL(new RenderURL()
- {
- public StateString getNavigationalState()
- {
- return render.getNavigationalState();
- }
- public Mode getMode()
- {
- return render.getMode();
- }
- public WindowState getWindowState()
- {
- return render.getWindowState();
- }
- }, null, null, true);
- response = new HTTPRedirectionResponse(location);
- }
- */
-
- //
- controller.render(context, requestProperties, pageState);
+ return new PageRenderControllerResponse(requestProperties, pageState);
}
PortletInvocationResponse invoke(PortletRequest portletRequest) throws PortletInvokerException
@@ -275,7 +232,7 @@
actionInvocation.setInstanceContext(instanceContext);
actionInvocation.setUserContext(new AbstractUserContext(req));
actionInvocation.setWindowContext(new AbstractWindowContext(portlet.getContext().getId()));
- actionInvocation.setPortalContext(controller.getPortalContext());
+ actionInvocation.setPortalContext(getPortalContext());
actionInvocation.setSecurityContext(new AbstractSecurityContext(req));
actionInvocation.setRequestContext(new AbstractRequestContext(req));
actionInvocation.setTarget(instanceContext.getTarget());
@@ -330,7 +287,7 @@
eventInvocation.setInstanceContext(instanceContext);
eventInvocation.setUserContext(new AbstractUserContext(req));
eventInvocation.setWindowContext(new AbstractWindowContext(portlet.getContext().getId()));
- eventInvocation.setPortalContext(controller.getPortalContext());
+ eventInvocation.setPortalContext(getPortalContext());
eventInvocation.setSecurityContext(new AbstractSecurityContext(req));
eventInvocation.setTarget(instanceContext.getTarget());
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletResourceRequestHandler.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletResourceRequestHandler.java 2008-02-04 18:24:07 UTC (rev 9747)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletResourceRequestHandler.java 2008-02-04 19:06:09 UTC (rev 9748)
@@ -25,7 +25,6 @@
import org.jboss.portal.Mode;
import org.jboss.portal.WindowState;
-import org.jboss.portal.common.io.IOTools;
import org.jboss.portal.common.util.ParameterMap;
import org.jboss.portal.portlet.Portlet;
import org.jboss.portal.portlet.PortletInvokerException;
@@ -38,22 +37,19 @@
import org.jboss.portal.portlet.impl.spi.AbstractUserContext;
import org.jboss.portal.portlet.impl.spi.AbstractWindowContext;
import org.jboss.portal.portlet.invocation.ResourceInvocation;
+import org.jboss.portal.portlet.invocation.response.ErrorResponse;
import org.jboss.portal.portlet.invocation.response.FragmentResponse;
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
-import org.jboss.portal.portlet.invocation.response.ResponseProperties;
import org.jboss.portal.portlet.spi.ResourceInvocationContext;
-import org.jboss.portal.portlet.test.controller.PageNavigationalState;
import org.jboss.portal.portlet.test.PortletURLRenderer;
import org.jboss.portal.portlet.test.ResourceTestContext;
import org.jboss.portal.portlet.test.TestInstanceContext;
import org.jboss.portal.portlet.test.WindowNavigationalState;
import static org.jboss.portal.portlet.test.controller.PortletController.*;
-import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
-import java.io.Writer;
/**
* @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
@@ -66,69 +62,21 @@
super(controller);
}
- void processResponse(PortletResourceRequest request, PortletInvocationResponse response) throws IOException, PortletInvokerException
+ ControllerResponse processResponse(PortletResourceRequest request, PortletInvocationResponse response) throws IOException, PortletInvokerException
{
- HttpServletResponse resp = request.controllerContext.getClientResponse();
-
//
if (response instanceof FragmentResponse)
{
FragmentResponse fragment = (FragmentResponse)response;
- ResponseProperties props = fragment.getProperties();
- //
- if (props != null)
- {
- controller.renderTransportHeaders(props, resp);
- controller.renderCookies(props, resp);
- }
-
- //
- if (fragment.getType() == FragmentResponse.TYPE_EMPTY)
- {
- resp.setStatus(HttpServletResponse.SC_NO_CONTENT);
- }
- else
- {
- String contentType = fragment.getContentType();
- if (contentType != null)
- {
- resp.setContentType(contentType);
- }
-
- //
- if (fragment.getType() == FragmentResponse.TYPE_BYTES)
- {
- ServletOutputStream out = null;
- try
- {
- out = resp.getOutputStream();
- out.write(fragment.getBytes().toByteArray());
- }
- finally
- {
- IOTools.safeClose(out);
- }
- }
- else
- {
- Writer writer = null;
- try
- {
- writer = resp.getWriter();
- writer.write(fragment.getChars().toString());
- }
- finally
- {
- writer.close();
- }
- }
- }
+ return new ResourceRenderControllerResponse(fragment.getProperties(), fragment);
}
else
{
// todo
}
+
+ return new ErrorControllerResponse(new ErrorResponse("Couldn't handle resource request"));
}
PortletInvocationResponse invoke(PortletResourceRequest portletResourceRequest) throws PortletInvokerException
@@ -198,7 +146,7 @@
TestInstanceContext instanceContext = new TestInstanceContext(req, portlet.getContext(), true);
ResourceInvocationContext resourceInvocationContext = new ResourceTestContext(renderer, MARKUP_INFO);
ResourceInvocation resourceInvocation = new ResourceInvocation(resourceInvocationContext);
-
+
//
resourceInvocation.setResourceId(portletResourceRequest.resourceId);
resourceInvocation.setCacheLevel(cacheability);
@@ -215,7 +163,7 @@
resourceInvocation.setInstanceContext(instanceContext);
resourceInvocation.setUserContext(new AbstractUserContext(req));
resourceInvocation.setWindowContext(new AbstractWindowContext(portlet.getContext().getId()));
- resourceInvocation.setPortalContext(controller.getPortalContext());
+ resourceInvocation.setPortalContext(getPortalContext());
resourceInvocation.setSecurityContext(new AbstractSecurityContext(req));
resourceInvocation.setRequestContext(new AbstractRequestContext(req));
resourceInvocation.setTarget(instanceContext.getTarget());
Added: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/RedirectControllerResponse.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/RedirectControllerResponse.java (rev 0)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/RedirectControllerResponse.java 2008-02-04 19:06:09 UTC (rev 9748)
@@ -0,0 +1,47 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, 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.controller;
+
+import org.jboss.portal.portlet.invocation.response.HTTPRedirectionResponse;
+
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ * @version $Revision$
+ */
+public class RedirectControllerResponse implements ControllerResponse
+{
+ private HTTPRedirectionResponse redirection;
+
+ public RedirectControllerResponse(HTTPRedirectionResponse redirection)
+ {
+ this.redirection = redirection;
+ }
+
+ public void render(PortletControllerContext context) throws IOException
+ {
+ context.getClientResponse().sendRedirect(redirection.getLocation());
+ }
+}
Property changes on: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/RedirectControllerResponse.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/RenderControllerResponse.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/RenderControllerResponse.java (rev 0)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/RenderControllerResponse.java 2008-02-04 19:06:09 UTC (rev 9748)
@@ -0,0 +1,91 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, 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.controller;
+
+import org.jboss.portal.common.util.MultiValuedPropertyMap;
+import org.jboss.portal.portlet.invocation.response.ResponseProperties;
+
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ * @version $Revision$
+ */
+public abstract class RenderControllerResponse implements ControllerResponse
+{
+ protected ResponseProperties properties = new ResponseProperties();
+
+ protected RenderControllerResponse(ResponseProperties properties)
+ {
+ this.properties = properties;
+ }
+
+ public void render(PortletControllerContext context) throws IOException
+ {
+ prepareRendering(context);
+ HttpServletResponse resp = context.getClientResponse();
+
+ // Render the headers and cookies
+ if (properties != null)
+ {
+ renderTransportHeaders(properties, resp);
+ renderCookies(properties, resp);
+ }
+
+ renderContent(resp);
+ }
+
+ protected abstract void renderContent(HttpServletResponse resp)
+ throws IOException;
+
+ private void renderCookies(ResponseProperties pageProperties, HttpServletResponse resp)
+ {
+ List<Cookie> cookies = pageProperties.getCookies();
+ for (Cookie cookie : cookies)
+ {
+ resp.addCookie(cookie);
+ }
+ }
+
+ private void renderTransportHeaders(ResponseProperties pageProperties, HttpServletResponse resp)
+ {
+ MultiValuedPropertyMap<String> transportHeaders = pageProperties.getTransportHeaders();
+ for (String headerName : transportHeaders.keySet())
+ {
+ for (String headerValue : transportHeaders.getValues(headerName))
+ {
+ resp.addHeader(headerName, headerValue);
+ }
+ }
+ }
+
+ protected void prepareRendering(PortletControllerContext context)
+ {
+ // default behavior does nothing
+ return;
+ }
+}
Property changes on: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/RenderControllerResponse.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/RequestHandler.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/RequestHandler.java 2008-02-04 18:24:07 UTC (rev 9747)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/RequestHandler.java 2008-02-04 19:06:09 UTC (rev 9748)
@@ -26,15 +26,15 @@
this.controller = controller;
}
- public void handle(ControllerRequest request) throws PortletInvokerException, IOException
+ public ControllerResponse handle(ControllerRequest request) throws PortletInvokerException, IOException
{
T req = downcastRequest(request);
PortletInvocationResponse response = invoke(req);
- processResponse(req, response);
+ return processResponse(req, response);
}
- abstract void processResponse(T request, PortletInvocationResponse response) throws IOException, PortletInvokerException;
+ abstract ControllerResponse processResponse(T request, PortletInvocationResponse response) throws IOException, PortletInvokerException;
abstract PortletInvocationResponse invoke(T controllerRequest) throws PortletInvokerException;
Added: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/ResourceRenderControllerResponse.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/ResourceRenderControllerResponse.java (rev 0)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/ResourceRenderControllerResponse.java 2008-02-04 19:06:09 UTC (rev 9748)
@@ -0,0 +1,93 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, 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.controller;
+
+import org.jboss.portal.common.io.IOTools;
+import org.jboss.portal.portlet.invocation.response.FragmentResponse;
+import org.jboss.portal.portlet.invocation.response.ResponseProperties;
+
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.Writer;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ * @version $Revision$
+ */
+public class ResourceRenderControllerResponse extends RenderControllerResponse
+{
+ private FragmentResponse fragment;
+
+ public ResourceRenderControllerResponse(ResponseProperties properties, FragmentResponse fragment)
+ {
+ super(properties);
+ this.fragment = fragment;
+ }
+
+ protected void renderContent(HttpServletResponse resp) throws IOException
+ {
+ //
+ if (fragment.getType() == FragmentResponse.TYPE_EMPTY)
+ {
+ resp.setStatus(HttpServletResponse.SC_NO_CONTENT);
+ }
+ else
+ {
+ String contentType = fragment.getContentType();
+ if (contentType != null)
+ {
+ resp.setContentType(contentType);
+ }
+
+ //
+ if (fragment.getType() == FragmentResponse.TYPE_BYTES)
+ {
+ ServletOutputStream out = null;
+ try
+ {
+ out = resp.getOutputStream();
+ out.write(fragment.getBytes().toByteArray());
+ }
+ finally
+ {
+ IOTools.safeClose(out);
+ }
+ }
+ else
+ {
+ Writer writer = null;
+ try
+ {
+ writer = resp.getWriter();
+ writer.write(fragment.getChars().toString());
+ }
+ finally
+ {
+ writer.close();
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
Property changes on: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/ResourceRenderControllerResponse.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/SimpleFragmentRenderer.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/SimpleFragmentRenderer.java (rev 0)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/SimpleFragmentRenderer.java 2008-02-04 19:06:09 UTC (rev 9748)
@@ -0,0 +1,69 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, 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.controller;
+
+import org.jboss.portal.portlet.invocation.response.ErrorResponse;
+import org.jboss.portal.portlet.invocation.response.FragmentResponse;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ * @version $Revision$
+ */
+public class SimpleFragmentRenderer implements FragmentRenderer
+{
+ public String renderPortlet(FragmentResponse fragment)
+ {
+
+ if (fragment.getType() != FragmentResponse.TYPE_EMPTY)
+ {
+ String frag;
+
+ //
+ if (fragment.getType() == FragmentResponse.TYPE_BYTES)
+ {
+ frag = fragment.getBytes().toString();
+ }
+ else
+ {
+ frag = fragment.getChars().toString();
+ }
+
+ StringBuilder builder = new StringBuilder(frag.length() + 50);
+ builder.append("<div class=\"portlet\">").append(frag).append("</div>");
+ return builder.toString();
+ }
+ else
+ {
+ return "<div/>";
+ }
+ }
+
+ public String renderError(ErrorResponse error)
+ {
+ String html = error.toHTML();
+ StringBuilder builder = new StringBuilder(html + 50);
+ builder.append("<div class='error'>").append(html).append("</div>");
+ return builder.toString();
+ }
+}
Property changes on: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/SimpleFragmentRenderer.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/ViewRequestHandler.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/ViewRequestHandler.java 2008-02-04 18:24:07 UTC (rev 9747)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/ViewRequestHandler.java 2008-02-04 19:06:09 UTC (rev 9748)
@@ -26,7 +26,6 @@
import org.jboss.portal.portlet.PortletInvokerException;
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
import org.jboss.portal.portlet.invocation.response.ResponseProperties;
-import org.jboss.portal.portlet.test.controller.PageNavigationalState;
import static org.jboss.portal.portlet.test.controller.PortletController.ControllerRequest;
import static org.jboss.portal.portlet.test.controller.PortletController.ViewRequest;
@@ -43,9 +42,9 @@
super(controller);
}
- void processResponse(ViewRequest request, PortletInvocationResponse response) throws IOException, PortletInvokerException
+ ControllerResponse processResponse(ViewRequest request, PortletInvocationResponse response) throws IOException, PortletInvokerException
{
- controller.render(request.controllerContext, new ResponseProperties(), new PageNavigationalState());
+ return new PageRenderControllerResponse(new ResponseProperties(), new PageNavigationalState());
}
PortletInvocationResponse invoke(ViewRequest controllerRequest) throws PortletInvokerException
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/simple/SimplePortalServlet.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/simple/SimplePortalServlet.java 2008-02-04 18:24:07 UTC (rev 9747)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/simple/SimplePortalServlet.java 2008-02-04 19:06:09 UTC (rev 9748)
@@ -22,6 +22,7 @@
******************************************************************************/
package org.jboss.portal.simple;
+import org.jboss.portal.portlet.test.controller.ControllerResponse;
import org.jboss.portal.portlet.test.controller.PortletController;
import org.jboss.portal.portlet.test.controller.PortletControllerContextImpl;
@@ -70,6 +71,7 @@
PortletController controller = new PortletController();
//
- controller.process(context.getRequest());
+ ControllerResponse response = controller.process(context.getRequest());
+ response.render(context);
}
}
\ No newline at end of file
16 years, 4 months
JBoss Portal SVN: r9747 - in modules/portlet/trunk: portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletcontext and 1 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-02-04 13:24:07 -0500 (Mon, 04 Feb 2008)
New Revision: 9747
Added:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletcontext/ScopeEvictionTestCase.java
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/RequestAttributeConversationInterceptor.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletcontext/ClearScopeTestCase.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletcontext/EventPhaseCreateNewScopeForRenderedScopesTestCase.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletcontext/RefreshScopedRenderPhaseTestCase.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletcontext/RenderURLCreateNewScopeTestCase.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletcontext/ScopePropagationToEventPhaseTestCase.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletcontext/ScopePropagationToRenderPhaseTestCase.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletcontext/ScopePropagationToResourcePhaseTestCase.java
modules/portlet/trunk/test/src/test/resources/jsr286/ext/portletcontext-war/WEB-INF/portlet.xml
Log:
implemented and tested scope eviction
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/RequestAttributeConversationInterceptor.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/RequestAttributeConversationInterceptor.java 2008-02-04 16:27:04 UTC (rev 9746)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/RequestAttributeConversationInterceptor.java 2008-02-04 18:24:07 UTC (rev 9747)
@@ -44,6 +44,10 @@
import java.util.Map;
import java.util.HashMap;
import java.util.Collections;
+import java.util.List;
+import java.util.Enumeration;
+import java.util.LinkedList;
+import java.util.Comparator;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -65,18 +69,36 @@
ContainerOptionInfo scopingOption = options.get("javax.portlet.actionScopedRequestAttributes");
//
- boolean active = scopingOption != null && "true".equals(scopingOption.getValues().get(0));
+ int maxScope = 0;
+ if (scopingOption != null && "true".equals(scopingOption.getValues().get(0)))
+ {
+ maxScope = 10;
+ //
+ List<String> values = scopingOption.getValues();
+ if (values.size() >= 3 && "numberOfCachedScopes".equals(values.get(1)))
+ {
+ try
+ {
+ maxScope = Integer.parseInt(values.get(2));
+ }
+ catch (NumberFormatException e)
+ {
+ // Log that
+ }
+ }
+ }
+
//
- if (active)
+ if (maxScope > 0)
{
if (invocation instanceof ActionInvocation)
{
- return invoke((ActionInvocation)invocation);
+ return invoke(maxScope, (ActionInvocation)invocation);
}
else if (invocation instanceof EventInvocation)
{
- return invoke((EventInvocation)invocation);
+ return invoke(maxScope, (EventInvocation)invocation);
}
else if (invocation instanceof RenderInvocation)
{
@@ -97,12 +119,12 @@
}
}
- private Object invoke(ActionInvocation actionInvocation) throws Exception, InvocationException
+ private Object invoke(int maxScope, ActionInvocation actionInvocation) throws Exception, InvocationException
{
- return invokeWithConversation(new Conversation(), actionInvocation);
+ return invokeWithConversation(maxScope, new Conversation(), actionInvocation);
}
- private Object invoke(EventInvocation eventInvocation) throws Exception, InvocationException
+ private Object invoke(int maxScope, EventInvocation eventInvocation) throws Exception, InvocationException
{
Conversation conversation = loadConversation(eventInvocation);
@@ -113,7 +135,7 @@
}
//
- return invokeWithConversation(conversation, eventInvocation);
+ return invokeWithConversation(maxScope, conversation, eventInvocation);
}
private Object invoke(RenderInvocation renderInvocation) throws Exception, InvocationException
@@ -126,7 +148,7 @@
conversation.rendered = true;
//
- return invokeWithConversation(conversation, renderInvocation);
+ return invokeWithConversation(Integer.MAX_VALUE, conversation, renderInvocation);
}
else
{
@@ -141,7 +163,7 @@
//
if (conversation != null)
{
- return invokeWithConversation(conversation, resourceInvocation);
+ return invokeWithConversation(Integer.MAX_VALUE, conversation, resourceInvocation);
}
else
{
@@ -161,10 +183,8 @@
//
if (id != null)
{
- // Get the http session
+ // Get the http session if any
HttpServletRequest request = invocation.getDispatchedRequest();
-
- // No need to create an unnecessary session
HttpSession session = request.getSession(false);
//
@@ -183,7 +203,10 @@
return null;
}
- private Object invokeWithConversation(Conversation conversation, PortletInvocation invocation) throws Exception, InvocationException
+ private Object invokeWithConversation(
+ int maxScope,
+ Conversation conversation,
+ PortletInvocation invocation) throws Exception, InvocationException
{
invocation.setAttributes(conversation.getAttributes());
@@ -217,18 +240,57 @@
conversation.setAttributes(attributes);
//
- if (!conversation.stored)
+ if (!conversation.stored && maxScope > 0)
{
// Get the http session
HttpServletRequest request = invocation.getDispatchedRequest();
-
- //
HttpSession session = request.getSession();
+ // Make a first can
+ int size = 0;
+ for (Enumeration e = session.getAttributeNames();e.hasMoreElements();)
+ {
+ String name = (String)e.nextElement();
+ if (name.startsWith("org.jboss.portal.portlet.conversation."))
+ {
+ size++;
+ }
+ }
+
+ // Destroy existing conversations if needed
+ if (size >= maxScope)
+ {
+ LinkedList<Conversation> allConversations = null;
+ for (Enumeration e = session.getAttributeNames();e.hasMoreElements();)
+ {
+ String name = (String)e.nextElement();
+ if (name.startsWith("org.jboss.portal.portlet.conversation."))
+ {
+ if (allConversations == null)
+ {
+ allConversations = new LinkedList<Conversation>();
+ }
+ allConversations.add((Conversation)session.getAttribute(name));
+ }
+ }
+
+ //
+ if (allConversations != null)
+ {
+ Collections.sort(allConversations, evictor);
+
+ // Remove until we have something satisfactory
+ while (allConversations.size() >= maxScope)
+ {
+ Conversation toRemove = allConversations.removeLast();
+ String key = "org.jboss.portal.portlet.conversation." + toRemove.id;
+ session.removeAttribute(key);
+ }
+ }
+ }
+
//
String key = "org.jboss.portal.portlet.conversation." + conversation.id;
-
- //
session.setAttribute(key, conversation);
}
}
@@ -238,14 +300,10 @@
{
// Get the http session
HttpServletRequest request = invocation.getDispatchedRequest();
-
- //
HttpSession session = request.getSession();
//
String key = "org.jboss.portal.portlet.conversation." + conversation.id;
-
- //
session.removeAttribute(key);
}
}
@@ -258,36 +316,34 @@
private static class Conversation implements HttpSessionBindingListener
{
+ /** . */
private static final Map<String, Object> EMPTY_ATTRIBUTES = Collections.emptyMap();
/** . */
- private final String id = generator.generateKey();
+ private Map<String, Object> attributes;
/** . */
- private boolean rendered;
+ private Map<String, Object> unmodifiableAttributes;
/** . */
-// private long lastModifiedMillis;
+ private final String id = generator.generateKey();
/** . */
- private Map<String, Object> attributes;
+ private boolean rendered = false;
/** . */
- private Map<String, Object> unmodifiableAttributes;
+ private final long creationDateMillis = System.currentTimeMillis();
- /** . */
private boolean stored;
private Conversation()
{
- this.rendered = false;
this.attributes = null;
this.unmodifiableAttributes = EMPTY_ATTRIBUTES;
}
private Conversation(Map<String, Object> attributes)
{
- this.rendered = false;
this.attributes = new HashMap<String, Object>(attributes);
this.unmodifiableAttributes = Collections.unmodifiableMap(attributes);
}
@@ -313,12 +369,31 @@
public void valueBound(HttpSessionBindingEvent event)
{
- this.stored = true;
+ stored = true;
}
public void valueUnbound(HttpSessionBindingEvent event)
{
- this.stored = false;
+ stored = false;
}
}
+
+ private static final Comparator<Conversation> evictor = new Comparator<Conversation>()
+ {
+ public int compare(Conversation o1, Conversation o2)
+ {
+ if (o1.creationDateMillis > o2.creationDateMillis)
+ {
+ return -1;
+ }
+ else if (o1.creationDateMillis == o2.creationDateMillis)
+ {
+ return 0;
+ }
+ else
+ {
+ return 1;
+ }
+ }
+ };
}
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletcontext/ClearScopeTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletcontext/ClearScopeTestCase.java 2008-02-04 16:27:04 UTC (rev 9746)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletcontext/ClearScopeTestCase.java 2008-02-04 18:24:07 UTC (rev 9747)
@@ -49,7 +49,7 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 630 $
*/
-@TestCase
+//@TestCase
public class ClearScopeTestCase
{
public ClearScopeTestCase(PortletTestCase seq)
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletcontext/EventPhaseCreateNewScopeForRenderedScopesTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletcontext/EventPhaseCreateNewScopeForRenderedScopesTestCase.java 2008-02-04 16:27:04 UTC (rev 9746)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletcontext/EventPhaseCreateNewScopeForRenderedScopesTestCase.java 2008-02-04 18:24:07 UTC (rev 9747)
@@ -50,7 +50,7 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 630 $
*/
-@TestCase
+//@TestCase
public class EventPhaseCreateNewScopeForRenderedScopesTestCase
{
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletcontext/RefreshScopedRenderPhaseTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletcontext/RefreshScopedRenderPhaseTestCase.java 2008-02-04 16:27:04 UTC (rev 9746)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletcontext/RefreshScopedRenderPhaseTestCase.java 2008-02-04 18:24:07 UTC (rev 9747)
@@ -50,7 +50,7 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 630 $
*/
-@TestCase
+//@TestCase
public class RefreshScopedRenderPhaseTestCase
{
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletcontext/RenderURLCreateNewScopeTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletcontext/RenderURLCreateNewScopeTestCase.java 2008-02-04 16:27:04 UTC (rev 9746)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletcontext/RenderURLCreateNewScopeTestCase.java 2008-02-04 18:24:07 UTC (rev 9747)
@@ -46,7 +46,7 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 630 $
*/
-@TestCase
+//@TestCase
public class RenderURLCreateNewScopeTestCase
{
Added: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletcontext/ScopeEvictionTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletcontext/ScopeEvictionTestCase.java (rev 0)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletcontext/ScopeEvictionTestCase.java 2008-02-04 18:24:07 UTC (rev 9747)
@@ -0,0 +1,176 @@
+/******************************************************************************
+ * 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.ext.portletcontext;
+
+import org.jboss.portal.unit.annotations.TestCase;
+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.portal.test.portlet.framework.UTP3;
+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.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.PortletRequest;
+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 $
+ */
+@TestCase
+public class ScopeEvictionTestCase
+{
+
+ /** . */
+ private String scopeURL1 = null;
+
+ /** . */
+ private String scopeURL2 = null;
+
+ /** . */
+ private boolean scopeValidity1 = false;
+
+ public ScopeEvictionTestCase(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
+ {
+ 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
+ {
+ request.setAttribute("foo", "foo1");
+ }
+ });
+ seq.bindAction(1, UTP3.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ return new InvokeGetResponse(response.createActionURL().toString());
+ }
+ });
+ seq.bindAction(1, UTP2.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ scopeURL1 = response.createRenderURL().toString();
+
+ //
+ return null;
+ }
+ });
+
+ //
+ seq.bindAction(2, UTP3.ACTION_JOIN_POINT, new PortletActionTestAction()
+ {
+ protected void run(Portlet portlet, ActionRequest request, ActionResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ request.setAttribute("foo", "foo2");
+ }
+ });
+ seq.bindAction(2, UTP3.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ return new InvokeGetResponse(response.createActionURL().toString());
+ }
+ });
+ seq.bindAction(2, UTP2.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ scopeURL2 = response.createRenderURL().toString();
+
+ //
+ return null;
+ }
+ });
+
+ //
+ seq.bindAction(3, UTP3.ACTION_JOIN_POINT, new PortletActionTestAction()
+ {
+ protected void run(Portlet portlet, ActionRequest request, ActionResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ request.setAttribute("foo", "foo3");
+ }
+ });
+ seq.bindAction(3, UTP3.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ return new InvokeGetResponse(scopeURL1);
+ }
+ });
+
+ //
+ seq.bindAction(4, UTP3.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ scopeValidity1 = "foo1".equals(request.getAttribute("foo"));
+ return new InvokeGetResponse(scopeURL2);
+ }
+ });
+
+ //
+ seq.bindAction(5, UTP3.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ boolean scopeValidity2 = "foo2".equals(request.getAttribute("foo"));
+
+ if (scopeValidity1)
+ {
+ assertFalse(scopeValidity2);
+ }
+ else
+ {
+ assertTrue(scopeValidity2);
+ }
+
+ //
+ return new EndTestResponse();
+ }
+ });
+ }
+}
\ No newline at end of file
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletcontext/ScopePropagationToEventPhaseTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletcontext/ScopePropagationToEventPhaseTestCase.java 2008-02-04 16:27:04 UTC (rev 9746)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletcontext/ScopePropagationToEventPhaseTestCase.java 2008-02-04 18:24:07 UTC (rev 9747)
@@ -49,7 +49,7 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 630 $
*/
-@TestCase
+//@TestCase
public class ScopePropagationToEventPhaseTestCase
{
public ScopePropagationToEventPhaseTestCase(PortletTestCase seq)
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletcontext/ScopePropagationToRenderPhaseTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletcontext/ScopePropagationToRenderPhaseTestCase.java 2008-02-04 16:27:04 UTC (rev 9746)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletcontext/ScopePropagationToRenderPhaseTestCase.java 2008-02-04 18:24:07 UTC (rev 9747)
@@ -46,7 +46,7 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 630 $
*/
-@TestCase
+//@TestCase
public class ScopePropagationToRenderPhaseTestCase
{
public ScopePropagationToRenderPhaseTestCase(PortletTestCase seq)
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletcontext/ScopePropagationToResourcePhaseTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletcontext/ScopePropagationToResourcePhaseTestCase.java 2008-02-04 16:27:04 UTC (rev 9746)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletcontext/ScopePropagationToResourcePhaseTestCase.java 2008-02-04 18:24:07 UTC (rev 9747)
@@ -50,7 +50,7 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 630 $
*/
-@TestCase
+//@TestCase
public class ScopePropagationToResourcePhaseTestCase
{
Modified: modules/portlet/trunk/test/src/test/resources/jsr286/ext/portletcontext-war/WEB-INF/portlet.xml
===================================================================
--- modules/portlet/trunk/test/src/test/resources/jsr286/ext/portletcontext-war/WEB-INF/portlet.xml 2008-02-04 16:27:04 UTC (rev 9746)
+++ modules/portlet/trunk/test/src/test/resources/jsr286/ext/portletcontext-war/WEB-INF/portlet.xml 2008-02-04 18:24:07 UTC (rev 9747)
@@ -56,6 +56,20 @@
</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>
+ <container-runtime-option>
+ <name>javax.portlet.actionScopedRequestAttributes</name>
+ <value>true</value>
+ <value>numberOfCachedScopes</value>
+ <value>2</value>
+ </container-runtime-option>
+ </portlet>
+
<event-definition>
<name>Event</name>
</event-definition>
16 years, 4 months
JBoss Portal SVN: r9746 - in modules/portlet/trunk/portlet/src: test/java/org/jboss/portal/test/portlet/jsr286/ext/portletcontext and 1 other directory.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-02-04 11:27:04 -0500 (Mon, 04 Feb 2008)
New Revision: 9746
Added:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletcontext/ScopePropagationToResourcePhaseTestCase.java
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/RequestAttributeConversationInterceptor.java
Log:
implementation of request scoped action attributes for resource serving
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/RequestAttributeConversationInterceptor.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/RequestAttributeConversationInterceptor.java 2008-02-04 16:04:08 UTC (rev 9745)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/RequestAttributeConversationInterceptor.java 2008-02-04 16:27:04 UTC (rev 9746)
@@ -136,7 +136,17 @@
private Object invoke(ResourceInvocation resourceInvocation) throws Exception, InvocationException
{
- return resourceInvocation.invokeNext();
+ Conversation conversation = loadConversation(resourceInvocation);
+
+ //
+ if (conversation != null)
+ {
+ return invokeWithConversation(conversation, resourceInvocation);
+ }
+ else
+ {
+ return resourceInvocation.invokeNext();
+ }
}
private Conversation loadConversation(PortletInvocation invocation)
Added: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletcontext/ScopePropagationToResourcePhaseTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletcontext/ScopePropagationToResourcePhaseTestCase.java (rev 0)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletcontext/ScopePropagationToResourcePhaseTestCase.java 2008-02-04 16:27:04 UTC (rev 9746)
@@ -0,0 +1,115 @@
+/******************************************************************************
+ * 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.ext.portletcontext;
+
+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.PortletActionTestAction;
+import org.jboss.portal.unit.actions.PortletResourceTestAction;
+import org.jboss.portal.test.portlet.framework.UTP1;
+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.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.PortletRequest;
+import javax.portlet.ResourceRequest;
+import javax.portlet.ResourceResponse;
+import javax.portlet.ResourceURL;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+@TestCase
+public class ScopePropagationToResourcePhaseTestCase
+{
+
+ /** . */
+ private String scopeId;
+
+ public ScopePropagationToResourcePhaseTestCase(PortletTestCase seq)
+ {
+ seq.bindAction(0, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ assertNull(request.getParameter(PortletRequest.ACTION_SCOPE_ID));
+ 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
+ {
+ assertNull(request.getParameter(PortletRequest.ACTION_SCOPE_ID));
+ request.setAttribute("foo", "bar");
+ }
+ });
+ seq.bindAction(1, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ scopeId = assertNotNull(request.getParameter(PortletRequest.ACTION_SCOPE_ID));
+ Object bar = request.getAttribute("foo");
+ assertEquals("bar", bar);
+ return new InvokeGetResponse(response.createResourceURL().toString());
+ }
+ });
+ seq.bindAction(2, UTP1.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ assertEquals(scopeId, request.getParameter(PortletRequest.ACTION_SCOPE_ID));
+ Object bar = request.getAttribute("foo");
+ assertEquals("bar", bar);
+
+ //
+ ResourceURL url = response.createResourceURL();
+ url.setCacheability(ResourceURL.PORTLET);
+ return new InvokeGetResponse(url.toString());
+ }
+ });
+ seq.bindAction(3, UTP1.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ assertEquals(scopeId, request.getParameter(PortletRequest.ACTION_SCOPE_ID));
+ Object bar = request.getAttribute("foo");
+ assertEquals("bar", bar);
+
+ //
+ return new EndTestResponse();
+ }
+ });
+ }
+}
\ No newline at end of file
16 years, 4 months
JBoss Portal SVN: r9745 - in modules/portlet/trunk: portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext and 8 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-02-04 11:04:08 -0500 (Mon, 04 Feb 2008)
New Revision: 9745
Added:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/RequestAttributeConversationInterceptor.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletcontext/
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletcontext/ClearScopeTestCase.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletcontext/EventPhaseCreateNewScopeForRenderedScopesTestCase.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletcontext/RefreshScopedRenderPhaseTestCase.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletcontext/RenderURLCreateNewScopeTestCase.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletcontext/ScopePropagationToEventPhaseTestCase.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletcontext/ScopePropagationToRenderPhaseTestCase.java
modules/portlet/trunk/test/src/test/resources/jsr286/ext/portletcontext-war/
modules/portlet/trunk/test/src/test/resources/jsr286/ext/portletcontext-war/WEB-INF/
modules/portlet/trunk/test/src/test/resources/jsr286/ext/portletcontext-war/WEB-INF/portlet.xml
modules/portlet/trunk/test/src/test/resources/jsr286/ext/portletcontext-war/WEB-INF/web.xml
Modified:
modules/portlet/trunk/test/src/test/build.xml
modules/portlet/trunk/test/src/test/resources/portlet-test-war/WEB-INF/jboss-beans.xml
modules/portlet/trunk/test/src/test/resources/simple-portal-war/WEB-INF/jboss-beans.xml
modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml
Log:
implementation of request scoped action attributes
Added: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/RequestAttributeConversationInterceptor.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/RequestAttributeConversationInterceptor.java (rev 0)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/RequestAttributeConversationInterceptor.java 2008-02-04 16:04:08 UTC (rev 9745)
@@ -0,0 +1,314 @@
+/******************************************************************************
+ * 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.aspects.portlet;
+
+import org.jboss.portal.portlet.invocation.PortletInterceptor;
+import org.jboss.portal.portlet.invocation.PortletInvocation;
+import org.jboss.portal.portlet.invocation.ActionInvocation;
+import org.jboss.portal.portlet.invocation.RenderInvocation;
+import org.jboss.portal.portlet.invocation.EventInvocation;
+import org.jboss.portal.portlet.invocation.ResourceInvocation;
+import org.jboss.portal.portlet.invocation.response.UpdateNavigationalStateResponse;
+import org.jboss.portal.portlet.container.PortletContainer;
+import org.jboss.portal.portlet.container.PortletContainerInvoker;
+import org.jboss.portal.portlet.impl.info.ContainerPortletInfo;
+import org.jboss.portal.portlet.impl.info.ContainerOptionInfo;
+import org.jboss.portal.portlet.ParametersStateString;
+import org.jboss.portal.common.invocation.InvocationException;
+import org.jboss.portal.common.util.UUIDGenerator;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+import javax.servlet.http.HttpSessionBindingListener;
+import javax.servlet.http.HttpSessionBindingEvent;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Collections;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class RequestAttributeConversationInterceptor extends PortletInterceptor
+{
+
+ /** . */
+ private static final UUIDGenerator generator = new UUIDGenerator();
+
+ protected Object invoke(PortletInvocation invocation) throws Exception, InvocationException
+ {
+ PortletContainer container = (PortletContainer)invocation.getAttribute(PortletInvocation.INVOCATION_SCOPE, PortletContainerInvoker.PORTLET_CONTAINER);
+ ContainerPortletInfo containerInfo = (ContainerPortletInfo)container.getInfo();
+
+ //
+ Map<String, ContainerOptionInfo> options = containerInfo.getOptions();
+ ContainerOptionInfo scopingOption = options.get("javax.portlet.actionScopedRequestAttributes");
+
+ //
+ boolean active = scopingOption != null && "true".equals(scopingOption.getValues().get(0));
+
+ //
+ if (active)
+ {
+ if (invocation instanceof ActionInvocation)
+ {
+ return invoke((ActionInvocation)invocation);
+ }
+ else if (invocation instanceof EventInvocation)
+ {
+ return invoke((EventInvocation)invocation);
+ }
+ else if (invocation instanceof RenderInvocation)
+ {
+ return invoke((RenderInvocation)invocation);
+ }
+ else if (invocation instanceof ResourceInvocation)
+ {
+ return invoke((ResourceInvocation)invocation);
+ }
+ else
+ {
+ return invocation.invokeNext();
+ }
+ }
+ else
+ {
+ return invocation.invokeNext();
+ }
+ }
+
+ private Object invoke(ActionInvocation actionInvocation) throws Exception, InvocationException
+ {
+ return invokeWithConversation(new Conversation(), actionInvocation);
+ }
+
+ private Object invoke(EventInvocation eventInvocation) throws Exception, InvocationException
+ {
+ Conversation conversation = loadConversation(eventInvocation);
+
+ //
+ if (conversation == null || conversation.rendered)
+ {
+ conversation = new Conversation();
+ }
+
+ //
+ return invokeWithConversation(conversation, eventInvocation);
+ }
+
+ private Object invoke(RenderInvocation renderInvocation) throws Exception, InvocationException
+ {
+ Conversation conversation = loadConversation(renderInvocation);
+
+ //
+ if (conversation != null)
+ {
+ conversation.rendered = true;
+
+ //
+ return invokeWithConversation(conversation, renderInvocation);
+ }
+ else
+ {
+ return renderInvocation.invokeNext();
+ }
+ }
+
+ private Object invoke(ResourceInvocation resourceInvocation) throws Exception, InvocationException
+ {
+ return resourceInvocation.invokeNext();
+ }
+
+ private Conversation loadConversation(PortletInvocation invocation)
+ {
+ ParametersStateString parameters = (ParametersStateString)invocation.getNavigationalState();
+
+ //
+ if (parameters != null)
+ {
+ String id = parameters.getValue("javax.portlet.as");
+
+ //
+ if (id != null)
+ {
+ // Get the http session
+ HttpServletRequest request = invocation.getDispatchedRequest();
+
+ // No need to create an unnecessary session
+ HttpSession session = request.getSession(false);
+
+ //
+ if (session != null)
+ {
+ // Generate key
+ String key = "org.jboss.portal.portlet.conversation." + id;
+
+ // Get attributes
+ return (Conversation)session.getAttribute(key);
+ }
+ }
+ }
+
+ //
+ return null;
+ }
+
+ private Object invokeWithConversation(Conversation conversation, PortletInvocation invocation) throws Exception, InvocationException
+ {
+ invocation.setAttributes(conversation.getAttributes());
+
+ // Set the id parameter
+ ParametersStateString inNS = (ParametersStateString)invocation.getNavigationalState();
+ if (inNS == null)
+ {
+ inNS = ParametersStateString.create();
+ invocation.setNavigationalState(inNS);
+ }
+ inNS.setValue("javax.portlet.as", conversation.id);
+
+ //
+ Object response = invocation.invokeNext();
+
+ //
+ if (response instanceof UpdateNavigationalStateResponse)
+ {
+ UpdateNavigationalStateResponse update = (UpdateNavigationalStateResponse)response;
+
+ //
+ Map<String, Object> attributes = update.getAttributes();
+
+ //
+ if (attributes != null && attributes.size() > 0)
+ {
+ ParametersStateString outNS = (ParametersStateString)update.getNavigationalState();
+ outNS.setValue("javax.portlet.as", conversation.id);
+
+ //
+ conversation.setAttributes(attributes);
+
+ //
+ if (!conversation.stored)
+ {
+ // Get the http session
+ HttpServletRequest request = invocation.getDispatchedRequest();
+
+ //
+ HttpSession session = request.getSession();
+
+ //
+ String key = "org.jboss.portal.portlet.conversation." + conversation.id;
+
+ //
+ session.setAttribute(key, conversation);
+ }
+ }
+ else
+ {
+ if (conversation.stored)
+ {
+ // Get the http session
+ HttpServletRequest request = invocation.getDispatchedRequest();
+
+ //
+ HttpSession session = request.getSession();
+
+ //
+ String key = "org.jboss.portal.portlet.conversation." + conversation.id;
+
+ //
+ session.removeAttribute(key);
+ }
+ }
+ }
+
+ //
+ return response;
+ }
+
+ private static class Conversation implements HttpSessionBindingListener
+ {
+
+ private static final Map<String, Object> EMPTY_ATTRIBUTES = Collections.emptyMap();
+
+ /** . */
+ private final String id = generator.generateKey();
+
+ /** . */
+ private boolean rendered;
+
+ /** . */
+// private long lastModifiedMillis;
+
+ /** . */
+ private Map<String, Object> attributes;
+
+ /** . */
+ private Map<String, Object> unmodifiableAttributes;
+
+ /** . */
+ private boolean stored;
+
+ private Conversation()
+ {
+ this.rendered = false;
+ this.attributes = null;
+ this.unmodifiableAttributes = EMPTY_ATTRIBUTES;
+ }
+
+ private Conversation(Map<String, Object> attributes)
+ {
+ this.rendered = false;
+ this.attributes = new HashMap<String, Object>(attributes);
+ this.unmodifiableAttributes = Collections.unmodifiableMap(attributes);
+ }
+
+ public Map<String, Object> getAttributes()
+ {
+ return unmodifiableAttributes;
+ }
+
+ public void setAttributes(Map<String, Object> attributes)
+ {
+ if (this.attributes == null)
+ {
+ this.attributes = new HashMap<String, Object>(attributes);
+ this.unmodifiableAttributes = Collections.unmodifiableMap(this.attributes);
+ }
+ else
+ {
+ this.attributes.clear();
+ this.attributes.putAll(attributes);
+ }
+ }
+
+ public void valueBound(HttpSessionBindingEvent event)
+ {
+ this.stored = true;
+ }
+
+ public void valueUnbound(HttpSessionBindingEvent event)
+ {
+ this.stored = false;
+ }
+ }
+}
Added: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletcontext/ClearScopeTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletcontext/ClearScopeTestCase.java (rev 0)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletcontext/ClearScopeTestCase.java 2008-02-04 16:04:08 UTC (rev 9745)
@@ -0,0 +1,115 @@
+/******************************************************************************
+ * 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.ext.portletcontext;
+
+import org.jboss.portal.unit.annotations.TestCase;
+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 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.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.PortletRequest;
+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 $
+ */
+@TestCase
+public class ClearScopeTestCase
+{
+ public ClearScopeTestCase(PortletTestCase seq)
+ {
+ seq.bindAction(0, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ assertNull(request.getParameter(PortletRequest.ACTION_SCOPE_ID));
+ 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
+ {
+ assertNull(request.getParameter(PortletRequest.ACTION_SCOPE_ID));
+ request.setAttribute("foo", "foo");
+ request.removeAttribute("foo");
+ }
+ });
+ seq.bindAction(1, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ assertEquals(null, request.getAttribute("foo"));
+ assertEquals(null, request.getParameter(PortletRequest.ACTION_SCOPE_ID));
+
+ //
+ return new InvokeGetResponse(response.createActionURL().toString());
+ }
+ });
+ seq.bindAction(2, UTP1.ACTION_JOIN_POINT, new PortletActionTestAction()
+ {
+ protected void run(Portlet portlet, ActionRequest request, ActionResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ assertNull(request.getParameter(PortletRequest.ACTION_SCOPE_ID));
+ request.setAttribute("foo", "foo");
+ response.setEvent("Event", null);
+ }
+ });
+ seq.bindAction(2, UTP1.EVENT_JOIN_POINT, new PortletEventTestAction()
+ {
+ protected void run(Portlet portlet, EventRequest request, EventResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ assertNotNull(request.getParameter(PortletRequest.ACTION_SCOPE_ID));
+ assertEquals("foo", request.getAttribute("foo"));
+ request.removeAttribute("foo");
+ }
+ });
+ seq.bindAction(2, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ assertEquals(null, request.getAttribute("foo"));
+ assertEquals(null, request.getParameter(PortletRequest.ACTION_SCOPE_ID));
+
+ //
+ return new EndTestResponse();
+ }
+ });
+ }
+}
Added: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletcontext/EventPhaseCreateNewScopeForRenderedScopesTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletcontext/EventPhaseCreateNewScopeForRenderedScopesTestCase.java (rev 0)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletcontext/EventPhaseCreateNewScopeForRenderedScopesTestCase.java 2008-02-04 16:04:08 UTC (rev 9745)
@@ -0,0 +1,133 @@
+/******************************************************************************
+ * 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.ext.portletcontext;
+
+import org.jboss.portal.unit.annotations.TestCase;
+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.unit.PortletTestContext;
+import org.jboss.portal.unit.PortletTestCase;
+import org.jboss.portal.test.portlet.framework.UTP1;
+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.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.EventRequest;
+import javax.portlet.EventResponse;
+import javax.portlet.PortletRequest;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+@TestCase
+public class EventPhaseCreateNewScopeForRenderedScopesTestCase
+{
+
+ /** . */
+ private String scopedId1;
+
+ /** . */
+ private String scopedId2;
+
+ public EventPhaseCreateNewScopeForRenderedScopesTestCase(PortletTestCase seq)
+ {
+ seq.bindAction(0, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ assertNull(request.getParameter(PortletRequest.ACTION_SCOPE_ID));
+ 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
+ {
+ assertNull(request.getParameter(PortletRequest.ACTION_SCOPE_ID));
+ request.setAttribute("foo", "foo_1");
+ }
+ });
+ seq.bindAction(1, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ scopedId1 = assertNotNull(request.getParameter(PortletRequest.ACTION_SCOPE_ID));
+ assertEquals("foo_1", request.getAttribute("foo"));
+
+ //
+ return null;
+ }
+ });
+ seq.bindAction(1, UTP2.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ assertNull(request.getParameter(PortletRequest.ACTION_SCOPE_ID));
+ return new InvokeGetResponse(response.createActionURL().toString());
+ }
+ });
+ seq.bindAction(2, UTP2.ACTION_JOIN_POINT, new PortletActionTestAction()
+ {
+ protected void run(Portlet portlet, ActionRequest request, ActionResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ // Send an event to UTP1 which should create a new scope
+ assertNull(request.getParameter(PortletRequest.ACTION_SCOPE_ID));
+ response.setEvent("Event", null);
+ }
+ });
+ seq.bindAction(2, UTP1.EVENT_JOIN_POINT, new PortletEventTestAction()
+ {
+ protected void run(Portlet portlet, EventRequest request, EventResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ scopedId2 = assertNotNull(request.getParameter(PortletRequest.ACTION_SCOPE_ID));
+ assertNotEquals(scopedId1, scopedId2);
+ assertEquals(null, request.getAttribute("foo"));
+
+ //
+ request.setAttribute("foo", "foo_2");
+ }
+ });
+ seq.bindAction(2, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ assertEquals(scopedId2, request.getParameter(PortletRequest.ACTION_SCOPE_ID));
+ assertEquals("foo_2", request.getAttribute("foo"));
+
+ //
+ return new EndTestResponse();
+ }
+ });
+ }
+}
Added: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletcontext/RefreshScopedRenderPhaseTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletcontext/RefreshScopedRenderPhaseTestCase.java (rev 0)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletcontext/RefreshScopedRenderPhaseTestCase.java 2008-02-04 16:04:08 UTC (rev 9745)
@@ -0,0 +1,161 @@
+/******************************************************************************
+ * 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.ext.portletcontext;
+
+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.PortletActionTestAction;
+import org.jboss.portal.unit.actions.PortletEventTestAction;
+import org.jboss.portal.test.portlet.framework.UTP1;
+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.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.EventRequest;
+import javax.portlet.EventResponse;
+import javax.portlet.PortletRequest;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+@TestCase
+public class RefreshScopedRenderPhaseTestCase
+{
+
+ /** . */
+ private String scopedId1;
+
+ /** . */
+ private String scopedId2;
+
+ /** . */
+ private String refresh1;
+
+ /** . */
+ private String refresh2;
+
+ public RefreshScopedRenderPhaseTestCase(PortletTestCase seq)
+ {
+ seq.bindAction(0, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ assertNull(request.getParameter(PortletRequest.ACTION_SCOPE_ID));
+ 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
+ {
+ assertNull(request.getParameter(PortletRequest.ACTION_SCOPE_ID));
+ request.setAttribute("foo", "foo_1");
+ }
+ });
+ seq.bindAction(1, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ scopedId1 = assertNotNull(request.getParameter(PortletRequest.ACTION_SCOPE_ID));
+ assertEquals("foo_1", request.getAttribute("foo"));
+
+ //
+ return new InvokeGetResponse(response.createActionURL().toString());
+ }
+ });
+ seq.bindAction(1, UTP2.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ refresh1 = response.createRenderURL().toString();
+
+ //
+ return null;
+ }
+ });
+ seq.bindAction(2, UTP1.ACTION_JOIN_POINT, new PortletActionTestAction()
+ {
+ protected void run(Portlet portlet, ActionRequest request, ActionResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ assertNull(request.getParameter(PortletRequest.ACTION_SCOPE_ID));
+ request.setAttribute("foo", "foo_2");
+ }
+ });
+ seq.bindAction(2, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ scopedId2 = assertNotNull(request.getParameter(PortletRequest.ACTION_SCOPE_ID));
+ assertNotEquals(scopedId1, scopedId2);
+ assertEquals("foo_2", request.getAttribute("foo"));
+
+ //
+ return new InvokeGetResponse(refresh1);
+ }
+ });
+ seq.bindAction(2, UTP2.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ refresh2 = response.createRenderURL().toString();
+
+ //
+ return null;
+ }
+ });
+ seq.bindAction(3, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ assertEquals(scopedId1, request.getParameter(PortletRequest.ACTION_SCOPE_ID));
+ assertEquals("foo_1", request.getAttribute("foo"));
+
+ //
+ return new InvokeGetResponse(refresh2);
+ }
+ });
+ seq.bindAction(4, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ assertEquals(scopedId2, request.getParameter(PortletRequest.ACTION_SCOPE_ID));
+ assertEquals("foo_2", request.getAttribute("foo"));
+
+ //
+ return new EndTestResponse();
+ }
+ });
+ }
+}
\ No newline at end of file
Added: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletcontext/RenderURLCreateNewScopeTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletcontext/RenderURLCreateNewScopeTestCase.java (rev 0)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletcontext/RenderURLCreateNewScopeTestCase.java 2008-02-04 16:04:08 UTC (rev 9745)
@@ -0,0 +1,94 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.portlet.jsr286.ext.portletcontext;
+
+import org.jboss.portal.unit.annotations.TestCase;
+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.test.portlet.framework.UTP1;
+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.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.PortletRequest;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+@TestCase
+public class RenderURLCreateNewScopeTestCase
+{
+
+ public RenderURLCreateNewScopeTestCase(PortletTestCase seq)
+ {
+ seq.bindAction(0, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ assertNull(request.getParameter(PortletRequest.ACTION_SCOPE_ID));
+ 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
+ {
+ assertNull(request.getParameter(PortletRequest.ACTION_SCOPE_ID));
+ request.setAttribute("foo", "foo_1");
+ }
+ });
+ seq.bindAction(1, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ assertNotNull(request.getParameter(PortletRequest.ACTION_SCOPE_ID));
+ assertEquals("foo_1", request.getAttribute("foo"));
+
+ //
+ return new InvokeGetResponse(response.createRenderURL().toString());
+ }
+ });
+ seq.bindAction(2, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ assertNull(request.getParameter(PortletRequest.ACTION_SCOPE_ID));
+ assertEquals(null, request.getAttribute("foo"));
+
+ //
+ return new EndTestResponse();
+ }
+ });
+ }
+}
Added: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletcontext/ScopePropagationToEventPhaseTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletcontext/ScopePropagationToEventPhaseTestCase.java (rev 0)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletcontext/ScopePropagationToEventPhaseTestCase.java 2008-02-04 16:04:08 UTC (rev 9745)
@@ -0,0 +1,129 @@
+/******************************************************************************
+ * 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.ext.portletcontext;
+
+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.PortletActionTestAction;
+import org.jboss.portal.unit.actions.PortletEventTestAction;
+import org.jboss.portal.test.portlet.framework.UTP1;
+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.ActionRequest;
+import javax.portlet.ActionResponse;
+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 $
+ */
+@TestCase
+public class ScopePropagationToEventPhaseTestCase
+{
+ public ScopePropagationToEventPhaseTestCase(PortletTestCase seq)
+ {
+ seq.bindAction(0, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ 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
+ {
+ request.setAttribute("action_attr1", "action_attr1_action_value");
+ request.setAttribute("action_attr2", "action_attr2_action_value");
+ request.setAttribute("action_attr3", "action_attr3_action_value");
+ request.setAttribute("action_attr4", "action_attr4_action_value");
+ response.setEvent("Event", null);
+ }
+ });
+ seq.bindAction(1, UTP1.EVENT_JOIN_POINT, new PortletEventTestAction()
+ {
+ protected void run(Portlet portlet, EventRequest request, EventResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ if (request.getEvent().getValue() == null)
+ {
+ assertEquals("action_attr1_action_value", request.getAttribute("action_attr1"));
+ assertEquals("action_attr2_action_value", request.getAttribute("action_attr2"));
+ assertEquals("action_attr3_action_value", request.getAttribute("action_attr3"));
+ assertEquals("action_attr4_action_value", request.getAttribute("action_attr4"));
+
+ //
+ request.setAttribute("action_attr2", "action_attr2_event0_value");
+ request.setAttribute("action_attr3", "action_attr3_event0_value");
+ request.setAttribute("event_attr1", "event_attr1_event0_value");
+ request.setAttribute("event_attr2", "event_attr2_event0_value");
+
+ //
+ response.setEvent("Event", "this string is a non null object");
+ }
+ else
+ {
+ assertEquals("action_attr1_action_value", request.getAttribute("action_attr1"));
+ assertEquals("action_attr2_event0_value", request.getAttribute("action_attr2"));
+ assertEquals("action_attr3_event0_value", request.getAttribute("action_attr3"));
+ assertEquals("action_attr4_action_value", request.getAttribute("action_attr4"));
+ assertEquals("event_attr1_event0_value", request.getAttribute("event_attr1"));
+ assertEquals("event_attr2_event0_value", request.getAttribute("event_attr2"));
+
+ //
+ request.setAttribute("action_attr3", "action_attr3_event1_value");
+ request.setAttribute("action_attr4", "action_attr3_event1_value");
+ request.setAttribute("event_attr2", "event_attr2_event1_value");
+ request.setAttribute("event_attr3", "event_attr3_event1_value");
+ }
+ }
+ });
+ seq.bindAction(1, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ assertEquals("action_attr1_action_value", request.getAttribute("action_attr1"));
+ assertEquals("action_attr2_event0_value", request.getAttribute("action_attr2"));
+ assertEquals("action_attr3_event1_value", request.getAttribute("action_attr3"));
+ assertEquals("action_attr3_event1_value", request.getAttribute("action_attr4"));
+ assertEquals("event_attr1_event0_value", request.getAttribute("event_attr1"));
+ assertEquals("event_attr2_event1_value", request.getAttribute("event_attr2"));
+ assertEquals("event_attr3_event1_value", request.getAttribute("event_attr3"));
+
+ //
+ return new EndTestResponse();
+ }
+ });
+ }
+}
\ No newline at end of file
Added: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletcontext/ScopePropagationToRenderPhaseTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletcontext/ScopePropagationToRenderPhaseTestCase.java (rev 0)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletcontext/ScopePropagationToRenderPhaseTestCase.java 2008-02-04 16:04:08 UTC (rev 9745)
@@ -0,0 +1,81 @@
+/******************************************************************************
+ * 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.ext.portletcontext;
+
+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.PortletActionTestAction;
+import org.jboss.portal.test.portlet.framework.UTP1;
+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.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.PortletRequest;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+@TestCase
+public class ScopePropagationToRenderPhaseTestCase
+{
+ public ScopePropagationToRenderPhaseTestCase(PortletTestCase seq)
+ {
+ seq.bindAction(0, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ assertNull(request.getParameter(PortletRequest.ACTION_SCOPE_ID));
+ 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
+ {
+ assertNull(request.getParameter(PortletRequest.ACTION_SCOPE_ID));
+ request.setAttribute("foo", "bar");
+ }
+ });
+ seq.bindAction(1, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ assertNotNull(request.getParameter(PortletRequest.ACTION_SCOPE_ID));
+ Object bar = request.getAttribute("foo");
+ assertEquals("bar", bar);
+ return new EndTestResponse();
+ }
+ });
+ }
+}
Modified: modules/portlet/trunk/test/src/test/build.xml
===================================================================
--- modules/portlet/trunk/test/src/test/build.xml 2008-02-04 14:05:42 UTC (rev 9744)
+++ modules/portlet/trunk/test/src/test/build.xml 2008-02-04 16:04:08 UTC (rev 9745)
@@ -375,6 +375,7 @@
<package-jsr286-ext-test test="portletfilter"/>
<package-jsr286-ext-test test="portletresponses"/>
<package-jsr286-ext-test test="dispatcher"/>
+ <package-jsr286-ext-test test="portletcontext"/>
<!-- -->
<jar jarfile="${test.temp.lib}/portlet-test-lib.jar">
Added: modules/portlet/trunk/test/src/test/resources/jsr286/ext/portletcontext-war/WEB-INF/portlet.xml
===================================================================
--- modules/portlet/trunk/test/src/test/resources/jsr286/ext/portletcontext-war/WEB-INF/portlet.xml (rev 0)
+++ modules/portlet/trunk/test/src/test/resources/jsr286/ext/portletcontext-war/WEB-INF/portlet.xml 2008-02-04 16:04:08 UTC (rev 9745)
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ JBoss, a division of Red Hat ~
+ ~ Copyright 2006, Red Hat Middleware, LLC, and individual ~
+ ~ contributors as indicated by the @authors tag. See the ~
+ ~ copyright.txt in the distribution for a full listing of ~
+ ~ individual contributors. ~
+ ~ ~
+ ~ This is free software; you can redistribute it and/or modify it ~
+ ~ under the terms of the GNU Lesser General Public License as ~
+ ~ published by the Free Software Foundation; either version 2.1 of ~
+ ~ the License, or (at your option) any later version. ~
+ ~ ~
+ ~ This software is distributed in the hope that it will be useful, ~
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of ~
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ~
+ ~ Lesser General Public License for more details. ~
+ ~ ~
+ ~ You should have received a copy of the GNU Lesser General Public ~
+ ~ License along with this software; if not, write to the Free ~
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA ~
+ ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
+ version="2.0">
+
+ <portlet>
+ <portlet-name>UniversalTestPortletA</portlet-name>
+ <portlet-class>org.jboss.portal.test.portlet.framework.UTP1</portlet-class>
+ <supports>
+ <mime-type>text/html</mime-type>
+ </supports>
+ <supported-processing-event>
+ <name>Event</name>
+ </supported-processing-event>
+ <supported-publishing-event>
+ <name>Event</name>
+ </supported-publishing-event>
+ <container-runtime-option>
+ <name>javax.portlet.actionScopedRequestAttributes</name>
+ <value>true</value>
+ </container-runtime-option>
+ </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-publishing-event>
+ <name>Event</name>
+ </supported-publishing-event>
+ </portlet>
+
+ <event-definition>
+ <name>Event</name>
+ </event-definition>
+
+</portlet-app>
Added: modules/portlet/trunk/test/src/test/resources/jsr286/ext/portletcontext-war/WEB-INF/web.xml
===================================================================
--- modules/portlet/trunk/test/src/test/resources/jsr286/ext/portletcontext-war/WEB-INF/web.xml (rev 0)
+++ modules/portlet/trunk/test/src/test/resources/jsr286/ext/portletcontext-war/WEB-INF/web.xml 2008-02-04 16:04:08 UTC (rev 9745)
@@ -0,0 +1,32 @@
+<?xml version="1.0"?>
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ JBoss, a division of Red Hat ~
+ ~ Copyright 2006, Red Hat Middleware, LLC, and individual ~
+ ~ contributors as indicated by the @authors tag. See the ~
+ ~ copyright.txt in the distribution for a full listing of ~
+ ~ individual contributors. ~
+ ~ ~
+ ~ This is free software; you can redistribute it and/or modify it ~
+ ~ under the terms of the GNU Lesser General Public License as ~
+ ~ published by the Free Software Foundation; either version 2.1 of ~
+ ~ the License, or (at your option) any later version. ~
+ ~ ~
+ ~ This software is distributed in the hope that it will be useful, ~
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of ~
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ~
+ ~ Lesser General Public License for more details. ~
+ ~ ~
+ ~ You should have received a copy of the GNU Lesser General Public ~
+ ~ License along with this software; if not, write to the Free ~
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA ~
+ ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<!DOCTYPE web-app PUBLIC
+ "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
+ "http://java.sun.com/dtd/web-app_2_3.dtd">
+<web-app>
+ <listener>
+ <listener-class>org.jboss.portal.unit.PortletTestSuite</listener-class>
+ </listener>
+</web-app>
Modified: modules/portlet/trunk/test/src/test/resources/portlet-test-war/WEB-INF/jboss-beans.xml
===================================================================
--- modules/portlet/trunk/test/src/test/resources/portlet-test-war/WEB-INF/jboss-beans.xml 2008-02-04 14:05:42 UTC (rev 9744)
+++ modules/portlet/trunk/test/src/test/resources/portlet-test-war/WEB-INF/jboss-beans.xml 2008-02-04 16:04:08 UTC (rev 9745)
@@ -83,6 +83,7 @@
<property name="servletContainerFactory"><inject bean="ServletContainerFactory"/></property>
</bean>
<bean name="ProducerCacheInterceptor" class="org.jboss.portal.portlet.aspects.portlet.ProducerCacheInterceptor"/>
+ <bean name="RequestAttributeConversationInterceptor" class="org.jboss.portal.portlet.aspects.portlet.RequestAttributeConversationInterceptor"/>
<bean name="ContainerStackFactory" class="org.jboss.portal.portlet.test.InterceptorStackFactoryImpl">
<property name="interceptors">
<array>
@@ -90,6 +91,7 @@
<inject bean="SecureTransportInterceptor"/>
<inject bean="ContextDispatcherInterceptor"/>
<inject bean="ProducerCacheInterceptor"/>
+ <inject bean="RequestAttributeConversationInterceptor"/>
</array>
</property>
</bean>
Modified: modules/portlet/trunk/test/src/test/resources/simple-portal-war/WEB-INF/jboss-beans.xml
===================================================================
--- modules/portlet/trunk/test/src/test/resources/simple-portal-war/WEB-INF/jboss-beans.xml 2008-02-04 14:05:42 UTC (rev 9744)
+++ modules/portlet/trunk/test/src/test/resources/simple-portal-war/WEB-INF/jboss-beans.xml 2008-02-04 16:04:08 UTC (rev 9745)
@@ -71,6 +71,7 @@
<property name="servletContainerFactory"><inject bean="ServletContainerFactory"/></property>
</bean>
<bean name="ProducerCacheInterceptor" class="org.jboss.portal.portlet.aspects.portlet.ProducerCacheInterceptor"/>
+ <bean name="RequestAttributeConversationInterceptor" class="org.jboss.portal.portlet.aspects.portlet.RequestAttributeConversationInterceptor"/>
<bean name="ContainerStackFactory" class="org.jboss.portal.portlet.test.InterceptorStackFactoryImpl">
<property name="interceptors">
<array>
@@ -78,6 +79,7 @@
<inject bean="SecureTransportInterceptor"/>
<inject bean="ContextDispatcherInterceptor"/>
<inject bean="ProducerCacheInterceptor"/>
+ <inject bean="RequestAttributeConversationInterceptor"/>
</array>
</property>
</bean>
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-02-04 14:05:42 UTC (rev 9744)
+++ modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml 2008-02-04 16:04:08 UTC (rev 9745)
@@ -215,6 +215,10 @@
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId" value="test-jsr286-ext-portletfilter.war"/>
</generic>
+ <generic>
+ <class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
+ <property name="archiveId" value="test-jsr286-ext-portletcontext.war"/>
+ </generic>
<!--Misc Tests-->
<!--
16 years, 4 months
JBoss Portal SVN: r9744 - in modules/portlet/trunk/portlet/src/main: java/org/jboss/portal/portlet/impl/jsr168/taglib and 3 other directories.
by portal-commits@lists.jboss.org
Author: bdaw
Date: 2008-02-04 09:05:42 -0500 (Mon, 04 Feb 2008)
New Revision: 9744
Added:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr286/
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr286/taglib/
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr286/taglib/DefineObjects286Tag.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr286/taglib/DefineObjects286TagTEI.java
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/taglib/DefineObjectsTag.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/taglib/DefineObjectsTagTEI.java
modules/portlet/trunk/portlet/src/main/resources/org/jboss/portal/portlet/portlet_2_0.tld
Log:
make 286 taglib impl separate from 168
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/taglib/DefineObjectsTag.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/taglib/DefineObjectsTag.java 2008-02-04 13:53:04 UTC (rev 9743)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/taglib/DefineObjectsTag.java 2008-02-04 14:05:42 UTC (rev 9744)
@@ -59,41 +59,13 @@
public int doEndTag() throws JspException
{
- RenderRequest rreq = getRenderRequest();
- RenderResponse rresp = getRenderResponse();
- ActionRequest areq = getActionRequest();
- ActionResponse aresp = getActionResponse();
- EventRequest ereq = getEventRequest();
- EventResponse eresp = getEventResponse();
- ResourceRequest rsreq = getResourceRequest();
- ResourceResponse rsresp = getResourceResponse();
+
+ RenderRequest rreq = (RenderRequest)getPortletRequest();
+ RenderResponse rresp = (RenderResponse)getPortletResponse();
PortletConfig portletConfig = getConfig();
- PortletSession portletSession = getSession();
- Map<String, Object> portletSessionScope = getPortletSessionScope();
- PortletPreferences portletPreferences = getPortletPreferences();
- Map<String, String[]> portletPreferencesValues = getPortletPreferenceValues();
pageContext.setAttribute(DefineObjectsTagTEI.renderRequestVariableName, rreq);
pageContext.setAttribute(DefineObjectsTagTEI.renderResponseVariableName, rresp);
- pageContext.setAttribute(DefineObjectsTagTEI.actionRequestVariableName, areq);
- pageContext.setAttribute(DefineObjectsTagTEI.actionResponseVariableName, aresp);
- pageContext.setAttribute(DefineObjectsTagTEI.eventRequestVariableName, ereq);
- pageContext.setAttribute(DefineObjectsTagTEI.eventResponseVariableName, eresp);
- pageContext.setAttribute(DefineObjectsTagTEI.resourceRequestVariableName, rsreq);
- pageContext.setAttribute(DefineObjectsTagTEI.resourceResponseVariableName, rsresp);
pageContext.setAttribute(DefineObjectsTagTEI.portletConfigVariableName, portletConfig);
- pageContext.setAttribute(DefineObjectsTagTEI.portletSessionVariableName, portletSession);
- pageContext.setAttribute(DefineObjectsTagTEI.portletSessionScopeVariableName, portletSessionScope);
- pageContext.setAttribute(DefineObjectsTagTEI.portletPreferencesVariableName, portletPreferences);
- pageContext.setAttribute(DefineObjectsTagTEI.portletPreferencesValuesVariableName, portletPreferencesValues);
-
-
-// RenderRequest rreq = (RenderRequest)getPortletRequest();
-// RenderResponse rresp = (RenderResponse)getPortletResponse();
-// PortletConfig portletConfig = getConfig();
-// pageContext.setAttribute(DefineObjectsTagTEI.renderRequestVariableName, rreq);
-// pageContext.setAttribute(DefineObjectsTagTEI.renderResponseVariableName, rresp);
-// pageContext.setAttribute(DefineObjectsTagTEI.portletConfigVariableName, portletConfig);
-
return EVAL_PAGE;
}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/taglib/DefineObjectsTagTEI.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/taglib/DefineObjectsTagTEI.java 2008-02-04 13:53:04 UTC (rev 9743)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/taglib/DefineObjectsTagTEI.java 2008-02-04 14:05:42 UTC (rev 9744)
@@ -51,16 +51,6 @@
public static final String portletConfigVariableName = "portletConfig";
public static final String renderRequestVariableName = "renderRequest";
public static final String renderResponseVariableName = "renderResponse";
- public static final String actionRequestVariableName = "actionRequest";
- public static final String actionResponseVariableName = "actionResponse";
- public static final String resourceRequestVariableName = "resourceRequest";
- public static final String resourceResponseVariableName = "resourceResponse";
- public static final String eventRequestVariableName = "eventRequest";
- public static final String eventResponseVariableName = "eventResponse";
- public static final String portletSessionVariableName = "portletSession";
- public static final String portletSessionScopeVariableName = "portletSessionScope";
- public static final String portletPreferencesVariableName = "portletPreferences";
- public static final String portletPreferencesValuesVariableName = "portletPreferencesValues";
public VariableInfo[] getVariableInfo(TagData data)
{
@@ -70,30 +60,9 @@
RenderRequest.class.getName(), true, VariableInfo.AT_END);
VariableInfo info3 = new VariableInfo(renderResponseVariableName,
RenderResponse.class.getName(), true, VariableInfo.AT_END);
- VariableInfo info4 = new VariableInfo(actionRequestVariableName,
- ActionRequest.class.getName(), true, VariableInfo.AT_END);
- VariableInfo info5 = new VariableInfo(actionResponseVariableName,
- ActionResponse.class.getName(), true, VariableInfo.AT_END);
- VariableInfo info6 = new VariableInfo(resourceRequestVariableName,
- ResourceRequest.class.getName(), true, VariableInfo.AT_END);
- VariableInfo info7 = new VariableInfo(resourceResponseVariableName,
- ResourceResponse.class.getName(), true, VariableInfo.AT_END);
- VariableInfo info8 = new VariableInfo(eventRequestVariableName,
- EventRequest.class.getName(), true, VariableInfo.AT_END);
- VariableInfo info9 = new VariableInfo(eventResponseVariableName,
- EventResponse.class.getName(), true, VariableInfo.AT_END);
- VariableInfo info10 = new VariableInfo(portletSessionVariableName,
- PortletSession.class.getName(), true, VariableInfo.AT_END);
- VariableInfo info11 = new VariableInfo(portletSessionScopeVariableName,
- Map.class.getName(), true, VariableInfo.AT_END);
- VariableInfo info12 = new VariableInfo(portletPreferencesVariableName,
- PortletPreferences.class.getName(), true, VariableInfo.AT_END);
- VariableInfo info13 = new VariableInfo(portletPreferencesValuesVariableName,
- Map.class.getName(), true, VariableInfo.AT_END);
-
- VariableInfo[] info = {info1, info2, info3, info4, info5, info6, info7, info8, info9, info10, info11, info12, info13};
+ VariableInfo[] info = {info1, info2, info3};
return info;
}
}
Added: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr286/taglib/DefineObjects286Tag.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr286/taglib/DefineObjects286Tag.java (rev 0)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr286/taglib/DefineObjects286Tag.java 2008-02-04 14:05:42 UTC (rev 9744)
@@ -0,0 +1,86 @@
+/*
+* 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.jsr286.taglib;
+
+import org.jboss.portal.portlet.impl.jsr168.taglib.PortletTag;
+
+import javax.servlet.jsp.JspException;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.EventRequest;
+import javax.portlet.EventResponse;
+import javax.portlet.ResourceRequest;
+import javax.portlet.ResourceResponse;
+import javax.portlet.PortletConfig;
+import javax.portlet.PortletSession;
+import javax.portlet.PortletPreferences;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:boleslaw dot dawidowicz at redhat anotherdot com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class DefineObjects286Tag extends PortletTag
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = -8640865649772583292L;
+
+ public int doStartTag() throws JspException
+ {
+ return SKIP_BODY;
+ }
+
+ public int doEndTag() throws JspException
+ {
+ RenderRequest rreq = getRenderRequest();
+ RenderResponse rresp = getRenderResponse();
+ ActionRequest areq = getActionRequest();
+ ActionResponse aresp = getActionResponse();
+ EventRequest ereq = getEventRequest();
+ EventResponse eresp = getEventResponse();
+ ResourceRequest rsreq = getResourceRequest();
+ ResourceResponse rsresp = getResourceResponse();
+ PortletConfig portletConfig = getConfig();
+ PortletSession portletSession = getSession();
+ Map<String, Object> portletSessionScope = getPortletSessionScope();
+ PortletPreferences portletPreferences = getPortletPreferences();
+ Map<String, String[]> portletPreferencesValues = getPortletPreferenceValues();
+ pageContext.setAttribute(DefineObjects286TagTEI.renderRequestVariableName, rreq);
+ pageContext.setAttribute(DefineObjects286TagTEI.renderResponseVariableName, rresp);
+ pageContext.setAttribute(DefineObjects286TagTEI.actionRequestVariableName, areq);
+ pageContext.setAttribute(DefineObjects286TagTEI.actionResponseVariableName, aresp);
+ pageContext.setAttribute(DefineObjects286TagTEI.eventRequestVariableName, ereq);
+ pageContext.setAttribute(DefineObjects286TagTEI.eventResponseVariableName, eresp);
+ pageContext.setAttribute(DefineObjects286TagTEI.resourceRequestVariableName, rsreq);
+ pageContext.setAttribute(DefineObjects286TagTEI.resourceResponseVariableName, rsresp);
+ pageContext.setAttribute(DefineObjects286TagTEI.portletConfigVariableName, portletConfig);
+ pageContext.setAttribute(DefineObjects286TagTEI.portletSessionVariableName, portletSession);
+ pageContext.setAttribute(DefineObjects286TagTEI.portletSessionScopeVariableName, portletSessionScope);
+ pageContext.setAttribute(DefineObjects286TagTEI.portletPreferencesVariableName, portletPreferences);
+ pageContext.setAttribute(DefineObjects286TagTEI.portletPreferencesValuesVariableName, portletPreferencesValues);
+
+ return EVAL_PAGE;
+ }
+}
Added: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr286/taglib/DefineObjects286TagTEI.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr286/taglib/DefineObjects286TagTEI.java (rev 0)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr286/taglib/DefineObjects286TagTEI.java 2008-02-04 14:05:42 UTC (rev 9744)
@@ -0,0 +1,95 @@
+/*
+* 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.jsr286.taglib;
+
+import javax.servlet.jsp.tagext.VariableInfo;
+import javax.servlet.jsp.tagext.TagData;
+import javax.servlet.jsp.tagext.TagExtraInfo;
+import javax.portlet.PortletConfig;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.ResourceRequest;
+import javax.portlet.ResourceResponse;
+import javax.portlet.EventRequest;
+import javax.portlet.EventResponse;
+import javax.portlet.PortletSession;
+import javax.portlet.PortletPreferences;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:boleslaw dot dawidowicz at redhat anotherdot com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class DefineObjects286TagTEI extends TagExtraInfo
+{
+ public static final String portletConfigVariableName = "portletConfig";
+ public static final String renderRequestVariableName = "renderRequest";
+ public static final String renderResponseVariableName = "renderResponse";
+ public static final String actionRequestVariableName = "actionRequest";
+ public static final String actionResponseVariableName = "actionResponse";
+ public static final String resourceRequestVariableName = "resourceRequest";
+ public static final String resourceResponseVariableName = "resourceResponse";
+ public static final String eventRequestVariableName = "eventRequest";
+ public static final String eventResponseVariableName = "eventResponse";
+ public static final String portletSessionVariableName = "portletSession";
+ public static final String portletSessionScopeVariableName = "portletSessionScope";
+ public static final String portletPreferencesVariableName = "portletPreferences";
+ public static final String portletPreferencesValuesVariableName = "portletPreferencesValues";
+
+ public VariableInfo[] getVariableInfo(TagData data)
+ {
+ VariableInfo info1 = new VariableInfo(portletConfigVariableName,
+ PortletConfig.class.getName(), true, VariableInfo.AT_END);
+ VariableInfo info2 = new VariableInfo(renderRequestVariableName,
+ RenderRequest.class.getName(), true, VariableInfo.AT_END);
+ VariableInfo info3 = new VariableInfo(renderResponseVariableName,
+ RenderResponse.class.getName(), true, VariableInfo.AT_END);
+ VariableInfo info4 = new VariableInfo(actionRequestVariableName,
+ ActionRequest.class.getName(), true, VariableInfo.AT_END);
+ VariableInfo info5 = new VariableInfo(actionResponseVariableName,
+ ActionResponse.class.getName(), true, VariableInfo.AT_END);
+ VariableInfo info6 = new VariableInfo(resourceRequestVariableName,
+ ResourceRequest.class.getName(), true, VariableInfo.AT_END);
+ VariableInfo info7 = new VariableInfo(resourceResponseVariableName,
+ ResourceResponse.class.getName(), true, VariableInfo.AT_END);
+ VariableInfo info8 = new VariableInfo(eventRequestVariableName,
+ EventRequest.class.getName(), true, VariableInfo.AT_END);
+ VariableInfo info9 = new VariableInfo(eventResponseVariableName,
+ EventResponse.class.getName(), true, VariableInfo.AT_END);
+ VariableInfo info10 = new VariableInfo(portletSessionVariableName,
+ PortletSession.class.getName(), true, VariableInfo.AT_END);
+ VariableInfo info11 = new VariableInfo(portletSessionScopeVariableName,
+ Map.class.getName(), true, VariableInfo.AT_END);
+ VariableInfo info12 = new VariableInfo(portletPreferencesVariableName,
+ PortletPreferences.class.getName(), true, VariableInfo.AT_END);
+ VariableInfo info13 = new VariableInfo(portletPreferencesValuesVariableName,
+ Map.class.getName(), true, VariableInfo.AT_END);
+
+
+
+ VariableInfo[] info = {info1, info2, info3, info4, info5, info6, info7, info8, info9, info10, info11, info12, info13};
+ return info;
+ }
+}
Modified: modules/portlet/trunk/portlet/src/main/resources/org/jboss/portal/portlet/portlet_2_0.tld
===================================================================
--- modules/portlet/trunk/portlet/src/main/resources/org/jboss/portal/portlet/portlet_2_0.tld 2008-02-04 13:53:04 UTC (rev 9743)
+++ modules/portlet/trunk/portlet/src/main/resources/org/jboss/portal/portlet/portlet_2_0.tld 2008-02-04 14:05:42 UTC (rev 9744)
@@ -63,8 +63,8 @@
<tag>
<name>defineObjects</name>
- <tag-class>org.jboss.portal.portlet.impl.jsr168.taglib.DefineObjectsTag</tag-class>
- <tei-class>org.jboss.portal.portlet.impl.jsr168.taglib.DefineObjectsTagTEI</tei-class>
+ <tag-class>org.jboss.portal.portlet.impl.jsr286.taglib.DefineObjects286Tag</tag-class>
+ <tei-class>org.jboss.portal.portlet.impl.jsr286.taglib.DefineObjects286TagTEI</tei-class>
<body-content>empty</body-content>
</tag>
16 years, 4 months
JBoss Portal SVN: r9743 - in modules/portlet/trunk: portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/taglib and 8 other directories.
by portal-commits@lists.jboss.org
Author: bdaw
Date: 2008-02-04 08:53:04 -0500 (Mon, 04 Feb 2008)
New Revision: 9743
Added:
modules/portlet/trunk/portlet/src/main/resources/org/jboss/portal/portlet/portlet_2_0.tld
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/taglib/
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/taglib/DefineObjectsTestCase.java
modules/portlet/trunk/test/src/test/resources/jsr286/tck/taglib-war/
modules/portlet/trunk/test/src/test/resources/jsr286/tck/taglib-war/WEB-INF/
modules/portlet/trunk/test/src/test/resources/jsr286/tck/taglib-war/WEB-INF/portlet.xml
modules/portlet/trunk/test/src/test/resources/jsr286/tck/taglib-war/WEB-INF/web.xml
modules/portlet/trunk/test/src/test/resources/jsr286/tck/taglib-war/taglib.jsp
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletSessionImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/taglib/DefineObjectsTag.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/taglib/DefineObjectsTagTEI.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/taglib/GenerateURLTag.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/taglib/NamespaceTag.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/taglib/PortletTag.java
modules/portlet/trunk/test/src/test/build.xml
modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml
Log:
- strart of Portlet 2.0 taglib
- defineObjects tag and testcase
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletSessionImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletSessionImpl.java 2008-02-04 12:27:00 UTC (rev 9742)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletSessionImpl.java 2008-02-04 13:53:04 UTC (rev 9743)
@@ -33,6 +33,7 @@
import java.util.Map;
import java.util.Collections;
import java.util.ArrayList;
+import java.util.HashMap;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -206,12 +207,19 @@
public Map<String, Object> getAttributeMap()
{
- throw new NotYetImplemented();
+ return getAttributeMap(PortletSession.PORTLET_SCOPE);
}
public Map<String, Object> getAttributeMap(int i)
{
- throw new NotYetImplemented();
+ Enumeration attributes = getAttributeNames(i);
+ Map<String, Object> attrs = new HashMap<String, Object>();
+ while (attributes.hasMoreElements())
+ {
+ String name = (String)attributes.nextElement();
+ attrs.put(name, getAttribute(name));
+ }
+ return Collections.unmodifiableMap(attrs);
}
/**
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/taglib/DefineObjectsTag.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/taglib/DefineObjectsTag.java 2008-02-04 12:27:00 UTC (rev 9742)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/taglib/DefineObjectsTag.java 2008-02-04 13:53:04 UTC (rev 9743)
@@ -25,12 +25,24 @@
import javax.portlet.PortletConfig;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
+import javax.portlet.PortletRequest;
+import javax.portlet.PortletResponse;
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.EventResponse;
+import javax.portlet.EventRequest;
+import javax.portlet.ResourceResponse;
+import javax.portlet.ResourceRequest;
+import javax.portlet.PortletSession;
+import javax.portlet.PortletPreferences;
import javax.servlet.jsp.JspException;
+import java.util.Map;
/**
* The defineObjects tag for the JSR 168 Portlet specification.
*
* @author <a href="mailto:sgwood@ix.netcom.com">Sherman Wood</a>
+ * @author <a href="mailto:boleslaw dot dawidowicz at redhat anotherdot com">Boleslaw Dawidowicz</a>
* @version $Revision: 5448 $
* @jsp.tag name="defineObjects" body-content="empty" tei-class="org.jboss.portal.portlet.impl.jsr168.taglib.DefineObjectsTagTEI"
*/
@@ -47,12 +59,42 @@
public int doEndTag() throws JspException
{
- RenderRequest rreq = getRequest();
- RenderResponse rresp = getResponse();
+ RenderRequest rreq = getRenderRequest();
+ RenderResponse rresp = getRenderResponse();
+ ActionRequest areq = getActionRequest();
+ ActionResponse aresp = getActionResponse();
+ EventRequest ereq = getEventRequest();
+ EventResponse eresp = getEventResponse();
+ ResourceRequest rsreq = getResourceRequest();
+ ResourceResponse rsresp = getResourceResponse();
PortletConfig portletConfig = getConfig();
+ PortletSession portletSession = getSession();
+ Map<String, Object> portletSessionScope = getPortletSessionScope();
+ PortletPreferences portletPreferences = getPortletPreferences();
+ Map<String, String[]> portletPreferencesValues = getPortletPreferenceValues();
pageContext.setAttribute(DefineObjectsTagTEI.renderRequestVariableName, rreq);
pageContext.setAttribute(DefineObjectsTagTEI.renderResponseVariableName, rresp);
+ pageContext.setAttribute(DefineObjectsTagTEI.actionRequestVariableName, areq);
+ pageContext.setAttribute(DefineObjectsTagTEI.actionResponseVariableName, aresp);
+ pageContext.setAttribute(DefineObjectsTagTEI.eventRequestVariableName, ereq);
+ pageContext.setAttribute(DefineObjectsTagTEI.eventResponseVariableName, eresp);
+ pageContext.setAttribute(DefineObjectsTagTEI.resourceRequestVariableName, rsreq);
+ pageContext.setAttribute(DefineObjectsTagTEI.resourceResponseVariableName, rsresp);
pageContext.setAttribute(DefineObjectsTagTEI.portletConfigVariableName, portletConfig);
+ pageContext.setAttribute(DefineObjectsTagTEI.portletSessionVariableName, portletSession);
+ pageContext.setAttribute(DefineObjectsTagTEI.portletSessionScopeVariableName, portletSessionScope);
+ pageContext.setAttribute(DefineObjectsTagTEI.portletPreferencesVariableName, portletPreferences);
+ pageContext.setAttribute(DefineObjectsTagTEI.portletPreferencesValuesVariableName, portletPreferencesValues);
+
+
+// RenderRequest rreq = (RenderRequest)getPortletRequest();
+// RenderResponse rresp = (RenderResponse)getPortletResponse();
+// PortletConfig portletConfig = getConfig();
+// pageContext.setAttribute(DefineObjectsTagTEI.renderRequestVariableName, rreq);
+// pageContext.setAttribute(DefineObjectsTagTEI.renderResponseVariableName, rresp);
+// pageContext.setAttribute(DefineObjectsTagTEI.portletConfigVariableName, portletConfig);
+
+
return EVAL_PAGE;
}
}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/taglib/DefineObjectsTagTEI.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/taglib/DefineObjectsTagTEI.java 2008-02-04 12:27:00 UTC (rev 9742)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/taglib/DefineObjectsTagTEI.java 2008-02-04 13:53:04 UTC (rev 9743)
@@ -25,14 +25,25 @@
import javax.portlet.PortletConfig;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.ResourceRequest;
+import javax.portlet.ResourceResponse;
+import javax.portlet.EventRequest;
+import javax.portlet.EventResponse;
+import javax.portlet.PortletSession;
+import javax.portlet.PortletPreferences;
import javax.servlet.jsp.tagext.TagData;
import javax.servlet.jsp.tagext.TagExtraInfo;
import javax.servlet.jsp.tagext.VariableInfo;
+import java.util.Map;
+import java.util.HashMap;
/**
* The additional variable definitions for the defineObjects tag for the JSR 168 Portlet specification.
*
* @author <a href="mailto:sgwood@ix.netcom.com">Sherman Wood</a>
+ * @author <a href="mailto:boleslaw dot dawidowicz at redhat anotherdot com">Boleslaw Dawidowicz</a>
* @version $Revision: 5448 $
*/
public class DefineObjectsTagTEI extends TagExtraInfo
@@ -40,6 +51,16 @@
public static final String portletConfigVariableName = "portletConfig";
public static final String renderRequestVariableName = "renderRequest";
public static final String renderResponseVariableName = "renderResponse";
+ public static final String actionRequestVariableName = "actionRequest";
+ public static final String actionResponseVariableName = "actionResponse";
+ public static final String resourceRequestVariableName = "resourceRequest";
+ public static final String resourceResponseVariableName = "resourceResponse";
+ public static final String eventRequestVariableName = "eventRequest";
+ public static final String eventResponseVariableName = "eventResponse";
+ public static final String portletSessionVariableName = "portletSession";
+ public static final String portletSessionScopeVariableName = "portletSessionScope";
+ public static final String portletPreferencesVariableName = "portletPreferences";
+ public static final String portletPreferencesValuesVariableName = "portletPreferencesValues";
public VariableInfo[] getVariableInfo(TagData data)
{
@@ -49,7 +70,30 @@
RenderRequest.class.getName(), true, VariableInfo.AT_END);
VariableInfo info3 = new VariableInfo(renderResponseVariableName,
RenderResponse.class.getName(), true, VariableInfo.AT_END);
- VariableInfo[] info = {info1, info2, info3};
+ VariableInfo info4 = new VariableInfo(actionRequestVariableName,
+ ActionRequest.class.getName(), true, VariableInfo.AT_END);
+ VariableInfo info5 = new VariableInfo(actionResponseVariableName,
+ ActionResponse.class.getName(), true, VariableInfo.AT_END);
+ VariableInfo info6 = new VariableInfo(resourceRequestVariableName,
+ ResourceRequest.class.getName(), true, VariableInfo.AT_END);
+ VariableInfo info7 = new VariableInfo(resourceResponseVariableName,
+ ResourceResponse.class.getName(), true, VariableInfo.AT_END);
+ VariableInfo info8 = new VariableInfo(eventRequestVariableName,
+ EventRequest.class.getName(), true, VariableInfo.AT_END);
+ VariableInfo info9 = new VariableInfo(eventResponseVariableName,
+ EventResponse.class.getName(), true, VariableInfo.AT_END);
+ VariableInfo info10 = new VariableInfo(portletSessionVariableName,
+ PortletSession.class.getName(), true, VariableInfo.AT_END);
+ VariableInfo info11 = new VariableInfo(portletSessionScopeVariableName,
+ Map.class.getName(), true, VariableInfo.AT_END);
+ VariableInfo info12 = new VariableInfo(portletPreferencesVariableName,
+ PortletPreferences.class.getName(), true, VariableInfo.AT_END);
+ VariableInfo info13 = new VariableInfo(portletPreferencesValuesVariableName,
+ Map.class.getName(), true, VariableInfo.AT_END);
+
+
+
+ VariableInfo[] info = {info1, info2, info3, info4, info5, info6, info7, info8, info9, info10, info11, info12, info13};
return info;
}
}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/taglib/GenerateURLTag.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/taglib/GenerateURLTag.java 2008-02-04 12:27:00 UTC (rev 9742)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/taglib/GenerateURLTag.java 2008-02-04 13:53:04 UTC (rev 9743)
@@ -24,6 +24,7 @@
import org.jboss.portal.portlet.impl.jsr168.api.RenderRequestImpl;
import org.jboss.portal.portlet.impl.jsr168.api.PortletURLImpl;
+import org.jboss.portal.portlet.impl.jsr168.api.PortletRequestImpl;
import javax.portlet.PortletMode;
import javax.portlet.PortletModeException;
@@ -31,6 +32,7 @@
import javax.portlet.PortletURL;
import javax.portlet.WindowState;
import javax.portlet.WindowStateException;
+import javax.portlet.RenderRequest;
import javax.servlet.jsp.JspException;
import java.util.ArrayList;
import java.util.HashMap;
@@ -186,7 +188,7 @@
*/
private PortletURL getBasePortletEnvironmentAndURL()
{
- RenderRequestImpl preq = getRequest();
+ PortletRequestImpl preq = (PortletRequestImpl)getPortletRequest();
// Create the URL
if ("action".equals(getTypeValue()))
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/taglib/NamespaceTag.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/taglib/NamespaceTag.java 2008-02-04 12:27:00 UTC (rev 9742)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/taglib/NamespaceTag.java 2008-02-04 13:53:04 UTC (rev 9743)
@@ -23,6 +23,7 @@
package org.jboss.portal.portlet.impl.jsr168.taglib;
import javax.portlet.RenderResponse;
+import javax.portlet.PortletResponse;
import javax.servlet.jsp.JspException;
import java.io.IOException;
@@ -54,7 +55,7 @@
{
try
{
- RenderResponse resp = getResponse();
+ PortletResponse resp = getPortletResponse();
String namespace = resp.getNamespace();
pageContext.getOut().print(namespace);
}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/taglib/PortletTag.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/taglib/PortletTag.java 2008-02-04 12:27:00 UTC (rev 9742)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/taglib/PortletTag.java 2008-02-04 13:53:04 UTC (rev 9743)
@@ -28,9 +28,23 @@
import javax.portlet.PortletConfig;
import javax.portlet.RenderResponse;
+import javax.portlet.PortletRequest;
+import javax.portlet.PortletResponse;
+import javax.portlet.RenderRequest;
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.EventRequest;
+import javax.portlet.EventResponse;
+import javax.portlet.ResourceRequest;
+import javax.portlet.ResourceResponse;
+import javax.portlet.PortletSession;
+import javax.portlet.PortletPreferences;
import javax.servlet.ServletRequest;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.tagext.TagSupport;
+import java.util.Map;
+import java.util.Collections;
+import java.util.HashMap;
/**
* Superclass of the portlet tags for the JSR 168 Portlet specification.
@@ -38,6 +52,7 @@
* Provides hooks into the portlet environment
*
* @author <a href="mailto:sgwood@ix.netcom.com">Sherman Wood</a>
+ * @author <a href="mailto:boleslaw dot dawidowicz at redhat anotherdot com">Boleslaw Dawidowicz</a>
* @version $Revision: 5448 $
*/
public class PortletTag extends TagSupport
@@ -52,16 +67,16 @@
return invocation.getDispatchedRequest();
}
- protected RenderRequestImpl getRequest()
+ protected PortletRequest getPortletRequest()
{
HttpServletRequest dreq = getDispatchedRequest();
- return (RenderRequestImpl)dreq.getAttribute("javax.portlet.request");
+ return (PortletRequest)dreq.getAttribute("javax.portlet.request");
}
- protected RenderResponse getResponse()
+ protected PortletResponse getPortletResponse()
{
HttpServletRequest dreq = getDispatchedRequest();
- return (RenderResponse)dreq.getAttribute("javax.portlet.response");
+ return (PortletResponse)dreq.getAttribute("javax.portlet.response");
}
protected PortletConfig getConfig()
@@ -70,6 +85,128 @@
return (PortletConfig)dreq.getAttribute("javax.portlet.config");
}
+ protected RenderRequest getRenderRequest()
+ {
+ if (getPortletRequest() instanceof RenderRequest)
+ {
+ return (RenderRequest)getPortletRequest();
+ }
+ else
+ {
+ return null;
+ }
+ }
+ protected RenderResponse getRenderResponse()
+ {
+ if (getPortletResponse() instanceof RenderResponse)
+ {
+ return (RenderResponse)getPortletResponse();
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ protected ActionRequest getActionRequest()
+ {
+ if (getPortletRequest() instanceof ActionRequest)
+ {
+ return (ActionRequest)getPortletRequest();
+ }
+ else
+ {
+ return null;
+ }
+ }
+ protected ActionResponse getActionResponse()
+ {
+ if (getPortletResponse() instanceof ActionResponse)
+ {
+ return (ActionResponse)getPortletResponse();
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ protected EventRequest getEventRequest()
+ {
+ if (getPortletRequest() instanceof EventRequest)
+ {
+ return (EventRequest)getPortletRequest();
+ }
+ else
+ {
+ return null;
+ }
+ }
+ protected EventResponse getEventResponse()
+ {
+ if (getPortletResponse() instanceof EventResponse)
+ {
+ return (EventResponse)getPortletResponse();
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ protected ResourceRequest getResourceRequest()
+ {
+ if (getPortletRequest() instanceof ResourceRequest)
+ {
+ return (ResourceRequest)getPortletRequest();
+ }
+ else
+ {
+ return null;
+ }
+ }
+ protected ResourceResponse getResourceResponse()
+ {
+ if (getPortletResponse() instanceof ResourceResponse)
+ {
+ return (ResourceResponse)getPortletResponse();
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+
+
+
+ protected PortletSession getSession()
+ {
+ return getPortletRequest().getPortletSession(false);
+ }
+
+ protected Map<String, Object> getPortletSessionScope()
+ {
+ if (getSession() != null)
+ {
+ return getSession().getAttributeMap();
+ }
+ else
+ {
+ return new HashMap<String, Object>();
+ }
+ }
+
+ protected PortletPreferences getPortletPreferences()
+ {
+ return getPortletRequest().getPreferences();
+ }
+
+ protected Map<String, String[]> getPortletPreferenceValues()
+ {
+ return getPortletPreferences().getMap();
+ }
+
/**
* Set up the environment for accessing the portlat environment
*
Added: modules/portlet/trunk/portlet/src/main/resources/org/jboss/portal/portlet/portlet_2_0.tld
===================================================================
--- modules/portlet/trunk/portlet/src/main/resources/org/jboss/portal/portlet/portlet_2_0.tld (rev 0)
+++ modules/portlet/trunk/portlet/src/main/resources/org/jboss/portal/portlet/portlet_2_0.tld 2008-02-04 13:53:04 UTC (rev 9743)
@@ -0,0 +1,108 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+ <taglib xmlns="http://java.sun.com/xml/ns/j2ee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
+ version="2.0">
+
+ <description>Portlet 2.0 Tag Library</description>
+ <display-name>Portlet 2.0 Tags</display-name>
+ <tlib-version>2.0</tlib-version>
+ <short-name>portlet</short-name>
+ <uri>http://java.sun.com/portlet_2_0</uri>
+
+ <tag>
+
+ <name>param</name>
+ <tag-class>org.jboss.portal.portlet.impl.jsr168.taglib.URLParameterTag</tag-class>
+ <body-content>empty</body-content>
+
+ <attribute>
+ <name>name</name>
+ <required>true</required>
+ <rtexprvalue>true</rtexprvalue>
+
+ </attribute>
+ <attribute>
+ <name>value</name>
+ <required>true</required>
+ <rtexprvalue>true</rtexprvalue>
+
+ </attribute>
+
+ </tag>
+ <tag>
+
+ <name>renderURL</name>
+ <tag-class>org.jboss.portal.portlet.impl.jsr168.taglib.RenderURLTag</tag-class>
+ <tei-class>org.jboss.portal.portlet.impl.jsr168.taglib.GenerateURLTagTEI</tei-class>
+ <body-content>JSP</body-content>
+
+ <attribute>
+ <name>portletMode</name>
+ <rtexprvalue>true</rtexprvalue>
+
+ </attribute>
+ <attribute>
+ <name>secure</name>
+ <rtexprvalue>true</rtexprvalue>
+
+ </attribute>
+ <attribute>
+ <name>var</name>
+ <rtexprvalue>true</rtexprvalue>
+
+ </attribute>
+ <attribute>
+ <name>windowState</name>
+ <rtexprvalue>true</rtexprvalue>
+
+ </attribute>
+
+ </tag>
+ <tag>
+
+ <name>defineObjects</name>
+ <tag-class>org.jboss.portal.portlet.impl.jsr168.taglib.DefineObjectsTag</tag-class>
+ <tei-class>org.jboss.portal.portlet.impl.jsr168.taglib.DefineObjectsTagTEI</tei-class>
+ <body-content>empty</body-content>
+
+ </tag>
+ <tag>
+
+ <name>actionURL</name>
+ <tag-class>org.jboss.portal.portlet.impl.jsr168.taglib.ActionURLTag</tag-class>
+ <tei-class>org.jboss.portal.portlet.impl.jsr168.taglib.GenerateURLTagTEI</tei-class>
+ <body-content>JSP</body-content>
+
+ <attribute>
+ <name>portletMode</name>
+ <rtexprvalue>true</rtexprvalue>
+
+ </attribute>
+ <attribute>
+ <name>secure</name>
+ <rtexprvalue>true</rtexprvalue>
+
+ </attribute>
+ <attribute>
+ <name>var</name>
+ <rtexprvalue>true</rtexprvalue>
+
+ </attribute>
+ <attribute>
+ <name>windowState</name>
+ <rtexprvalue>true</rtexprvalue>
+
+ </attribute>
+
+ </tag>
+ <tag>
+
+ <name>namespace</name>
+ <tag-class>org.jboss.portal.portlet.impl.jsr168.taglib.NamespaceTag</tag-class>
+ <body-content>empty</body-content>
+
+ </tag>
+
+</taglib>
Added: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/taglib/DefineObjectsTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/taglib/DefineObjectsTestCase.java (rev 0)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/taglib/DefineObjectsTestCase.java 2008-02-04 13:53:04 UTC (rev 9743)
@@ -0,0 +1,148 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+
+package org.jboss.portal.test.portlet.jsr286.tck.taglib;
+
+import org.jboss.portal.unit.PortletTestCase;
+import org.jboss.portal.unit.PortletTestContext;
+import org.jboss.portal.unit.Assertion;
+import org.jboss.portal.unit.annotations.TestCase;
+import org.jboss.portal.unit.base.AbstractUniversalTestPortlet;
+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.unit.actions.PortletResourceTestAction;
+import org.jboss.portal.test.portlet.framework.UTP1;
+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.PortletRequestDispatcher;
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.EventRequest;
+import javax.portlet.EventResponse;
+import javax.portlet.ResourceRequest;
+import javax.portlet.ResourceResponse;
+import java.io.IOException;
+import java.io.Writer;
+
+/**
+ * @author <a href="mailto:boleslaw dot dawidowicz at redhat anotherdot com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+@TestCase({
+ Assertion.JSR286_113
+ })
+public class DefineObjectsTestCase
+{
+
+ //TODO: doesn't test include from action/event - the actionRequest/actionResponse/eventRequest/eventResponse objects
+
+ private String startTag;
+ private String endTag;
+
+ public DefineObjectsTestCase(PortletTestCase seq)
+ {
+ seq.bindAction(0, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
+ {
+ response.setContentType("text/html");
+ PortletRequestDispatcher dispatcher = ((AbstractUniversalTestPortlet)portlet).getPortletContext().getRequestDispatcher("/taglib.jsp");
+
+ startTag = "<div id=" + response.getNamespace() + ">";
+ endTag = "</div>";
+
+ Writer writer = response.getWriter();
+
+ writer.write(startTag);
+ dispatcher.include(request, response);
+ writer.write(endTag);
+
+
+ return new InvokeGetResponse(response.createRenderURL().toString());
+ }
+ });
+
+
+
+ seq.bindAction(1, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
+ {
+ response.setContentType("text/html");
+
+ String prevResponse = new String(context.getResponseBody());
+
+ String portletResp = prevResponse.substring(prevResponse.indexOf(startTag) + startTag.length(), prevResponse.indexOf(endTag));
+
+ assertEquals("jspDispatch,renderRequest,renderResponse,portletConfig,portletSession,portletSessionScope," +
+ "portletPreferences,portletPreferencesValues", portletResp.trim());
+
+ return new InvokeGetResponse(response.createResourceURL().toString());
+ }
+ });
+
+ seq.bindAction(2, UTP1.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws IOException, PortletException
+ {
+ response.setContentType("text/html");
+ PortletRequestDispatcher dispatcher = ((AbstractUniversalTestPortlet)portlet).getPortletContext().getRequestDispatcher("/taglib.jsp");
+
+ startTag = "<div id=" + response.getNamespace() + ">";
+ endTag = "</div>";
+
+ Writer writer = response.getWriter();
+
+ writer.write(startTag);
+ dispatcher.include(request, response);
+ writer.write(endTag);
+
+ return new InvokeGetResponse(response.createRenderURL().toString());
+ }
+ });
+
+ seq.bindAction(3, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
+ {
+ response.setContentType("text/html");
+
+ String prevResponse = new String(context.getResponseBody());
+
+ String portletResp = prevResponse.substring(prevResponse.indexOf(startTag) + startTag.length(), prevResponse.indexOf(endTag));
+
+ assertEquals("jspDispatch,resourceRequest,resourceResponse,portletConfig,portletSession,portletSessionScope," +
+ "portletPreferences,portletPreferencesValues", portletResp.trim());
+
+ return new EndTestResponse();
+ }
+ });
+ }
+}
Modified: modules/portlet/trunk/test/src/test/build.xml
===================================================================
--- modules/portlet/trunk/test/src/test/build.xml 2008-02-04 12:27:00 UTC (rev 9742)
+++ modules/portlet/trunk/test/src/test/build.xml 2008-02-04 13:53:04 UTC (rev 9743)
@@ -304,6 +304,10 @@
src="${dependency.portal-portlet.jar}"
includes="org/jboss/portal/portlet/portlet.tld"
fullpath="META-INF/portlet.tld"/>
+ <zipfileset
+ src="${dependency.portal-portlet.jar}"
+ includes="org/jboss/portal/portlet/portlet_2_0.tld"
+ fullpath="META-INF/portlet_2_0.tld"/>
</jar>
<!--<jar jarfile="${test.temp.lib}/test-info.jar">-->
@@ -365,6 +369,7 @@
<package-jsr286-tck-test test="resourceserving"/>
<package-jsr286-tck-test test="portleturl"/>
<package-jsr286-tck-test test="portletfilter"/>
+ <package-jsr286-tck-test test="taglib"/>
<package-jsr286-api-test test="event"/>
<package-jsr286-ext-test test="portletrequests"/>
<package-jsr286-ext-test test="portletfilter"/>
@@ -607,7 +612,7 @@
<configuration>
<property name="cargo.servlet.port" value="8080"/>
<property name="cargo.logging" value="high"/>
- <!--<property name="cargo.jvmargs" value="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000"/>-->
+ <!--<property name="cargo.jvmargs" value="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=9000"/>-->
<deployable type="war" file="${test.temp.lib}/manager.war"/>
<deployable type="war" file="${test.temp.lib}/tomcat-6.0/portlet-test.war"/>
</configuration>
Added: modules/portlet/trunk/test/src/test/resources/jsr286/tck/taglib-war/WEB-INF/portlet.xml
===================================================================
--- modules/portlet/trunk/test/src/test/resources/jsr286/tck/taglib-war/WEB-INF/portlet.xml (rev 0)
+++ modules/portlet/trunk/test/src/test/resources/jsr286/tck/taglib-war/WEB-INF/portlet.xml 2008-02-04 13:53:04 UTC (rev 9743)
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ JBoss, a division of Red Hat ~
+ ~ Copyright 2006, Red Hat Middleware, LLC, and individual ~
+ ~ contributors as indicated by the @authors tag. See the ~
+ ~ copyright.txt in the distribution for a full listing of ~
+ ~ individual contributors. ~
+ ~ ~
+ ~ This is free software; you can redistribute it and/or modify it ~
+ ~ under the terms of the GNU Lesser General Public License as ~
+ ~ published by the Free Software Foundation; either version 2.1 of ~
+ ~ the License, or (at your option) any later version. ~
+ ~ ~
+ ~ This software is distributed in the hope that it will be useful, ~
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of ~
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ~
+ ~ Lesser General Public License for more details. ~
+ ~ ~
+ ~ You should have received a copy of the GNU Lesser General Public ~
+ ~ License along with this software; if not, write to the Free ~
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA ~
+ ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
+ version="2.0">
+
+ <portlet>
+ <portlet-name>UniversalTestPortletA</portlet-name>
+ <portlet-class>org.jboss.portal.test.portlet.framework.UTP1</portlet-class>
+ <supports>
+ <mime-type>text/html</mime-type>
+ </supports>
+ </portlet>
+
+</portlet-app>
Added: modules/portlet/trunk/test/src/test/resources/jsr286/tck/taglib-war/WEB-INF/web.xml
===================================================================
--- modules/portlet/trunk/test/src/test/resources/jsr286/tck/taglib-war/WEB-INF/web.xml (rev 0)
+++ modules/portlet/trunk/test/src/test/resources/jsr286/tck/taglib-war/WEB-INF/web.xml 2008-02-04 13:53:04 UTC (rev 9743)
@@ -0,0 +1,32 @@
+<?xml version="1.0"?>
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ JBoss, a division of Red Hat ~
+ ~ Copyright 2006, Red Hat Middleware, LLC, and individual ~
+ ~ contributors as indicated by the @authors tag. See the ~
+ ~ copyright.txt in the distribution for a full listing of ~
+ ~ individual contributors. ~
+ ~ ~
+ ~ This is free software; you can redistribute it and/or modify it ~
+ ~ under the terms of the GNU Lesser General Public License as ~
+ ~ published by the Free Software Foundation; either version 2.1 of ~
+ ~ the License, or (at your option) any later version. ~
+ ~ ~
+ ~ This software is distributed in the hope that it will be useful, ~
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of ~
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ~
+ ~ Lesser General Public License for more details. ~
+ ~ ~
+ ~ You should have received a copy of the GNU Lesser General Public ~
+ ~ License along with this software; if not, write to the Free ~
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA ~
+ ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<!DOCTYPE web-app PUBLIC
+ "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
+ "http://java.sun.com/dtd/web-app_2_3.dtd">
+<web-app>
+ <listener>
+ <listener-class>org.jboss.portal.unit.PortletTestSuite</listener-class>
+ </listener>
+</web-app>
Added: modules/portlet/trunk/test/src/test/resources/jsr286/tck/taglib-war/taglib.jsp
===================================================================
--- modules/portlet/trunk/test/src/test/resources/jsr286/tck/taglib-war/taglib.jsp (rev 0)
+++ modules/portlet/trunk/test/src/test/resources/jsr286/tck/taglib-war/taglib.jsp 2008-02-04 13:53:04 UTC (rev 9743)
@@ -0,0 +1,73 @@
+<%@ page import="org.jboss.unit.api.Assert" %>
+<%@ page import="javax.portlet.RenderRequest" %>
+<%@ page import="javax.portlet.RenderResponse" %>
+<%@ page import="javax.portlet.ActionRequest" %>
+<%@ page import="javax.portlet.ActionResponse" %>
+<%@ page import="javax.portlet.EventRequest" %>
+<%@ page import="javax.portlet.EventResponse" %>
+<%@ page import="javax.portlet.ResourceRequest" %>
+<%@ page import="javax.portlet.ResourceResponse" %>
+<%@ page import="javax.portlet.PortletConfig" %>
+<%@ page import="javax.portlet.PortletSession" %>
+<%@ page import="java.util.Map" %>
+<%@ page import="javax.portlet.PortletPreferences" %>
+<%@ page language="java" %>
+<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
+<portlet:defineObjects/>
+<%
+ out.print("jspDispatch");
+
+ if (renderRequest != null && renderRequest instanceof RenderRequest)
+ {
+ out.print(",renderRequest");
+ }
+ if (renderResponse != null && renderResponse instanceof RenderResponse)
+ {
+ out.print(",renderResponse");
+ }
+ if (actionRequest != null && actionRequest instanceof ActionRequest)
+ {
+ out.print(",actionRequest");
+ }
+ if (actionResponse != null && actionResponse instanceof ActionResponse)
+ {
+ out.print(",actionResponse");
+ }
+ if (eventRequest != null && eventRequest instanceof EventRequest)
+ {
+ out.print(",eventRequest");
+ }
+ if (eventResponse != null && eventResponse instanceof EventResponse)
+ {
+ out.print(",eventResponse");
+ }
+ if (resourceRequest != null && resourceRequest instanceof ResourceRequest)
+ {
+ out.print(",resourceRequest");
+ }
+ if (resourceResponse != null && resourceResponse instanceof ResourceResponse)
+ {
+ out.print(",resourceResponse");
+ }
+ if (portletConfig != null && portletConfig instanceof PortletConfig)
+ {
+ out.print(",portletConfig");
+ }
+ if (portletSession != null && portletSession instanceof PortletSession)
+ {
+ out.print(",portletSession");
+ }
+ if (portletSessionScope != null && portletSessionScope instanceof Map)
+ {
+ out.print(",portletSessionScope");
+ }
+ if (portletPreferences != null && portletPreferences instanceof PortletPreferences)
+ {
+ out.print(",portletPreferences");
+ }
+ if (portletPreferencesValues != null && portletPreferencesValues instanceof Map)
+ {
+ out.print(",portletPreferencesValues");
+ }
+
+%>
\ No newline at end of file
Modified: modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml
===================================================================
--- modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml 2008-02-04 12:27:00 UTC (rev 9742)
+++ modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml 2008-02-04 13:53:04 UTC (rev 9743)
@@ -187,6 +187,10 @@
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId" value="test-jsr286-tck-portletfilter.war"/>
</generic>
+ <generic>
+ <class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
+ <property name="archiveId" value="test-jsr286-tck-taglib.war"/>
+ </generic>
<!--Spec API Assertions tests-->
<generic>
16 years, 4 months
JBoss Portal SVN: r9742 - modules/portlet/branches/JBP_PORTLET_BRANCH_1_0/build.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2008-02-04 07:27:00 -0500 (Mon, 04 Feb 2008)
New Revision: 9742
Modified:
modules/portlet/branches/JBP_PORTLET_BRANCH_1_0/build/
Log:
minor
Property changes on: modules/portlet/branches/JBP_PORTLET_BRANCH_1_0/build
___________________________________________________________________
Name: svn:ignore
+ local.properties
16 years, 4 months
JBoss Portal SVN: r9741 - docs/branches/JBoss_Portal_Branch_2_6/referenceGuide/en/modules.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2008-02-04 07:26:03 -0500 (Mon, 04 Feb 2008)
New Revision: 9741
Modified:
docs/branches/JBoss_Portal_Branch_2_6/referenceGuide/en/modules/installation.xml
docs/branches/JBoss_Portal_Branch_2_6/referenceGuide/en/modules/supported.xml
Log:
minor
Modified: docs/branches/JBoss_Portal_Branch_2_6/referenceGuide/en/modules/installation.xml
===================================================================
--- docs/branches/JBoss_Portal_Branch_2_6/referenceGuide/en/modules/installation.xml 2008-02-04 11:31:55 UTC (rev 9740)
+++ docs/branches/JBoss_Portal_Branch_2_6/referenceGuide/en/modules/installation.xml 2008-02-04 12:26:03 UTC (rev 9741)
@@ -82,7 +82,7 @@
<warning>
<title>Use the JBoss EAP and JBoss AS zip file</title>
<para>
- Only use the JBoss EAP and JBoss AS zip file versions. <emphasis role="bold">DO NOT ATTEMPT to deploy JBoss Portal on the installer version of JBoss EAP or JBoss AS.</emphasis> We are currently working on aligning the Application installer with JBoss Portal.
+ Only use the JBoss EAP and JBoss AS zip file versions. <emphasis role="bold">DO NOT ATTEMPT to deploy JBoss Portal on the installer version of JBoss EAP or JBoss AS.</emphasis>
</para>
</warning>
</sect3>
Modified: docs/branches/JBoss_Portal_Branch_2_6/referenceGuide/en/modules/supported.xml
===================================================================
--- docs/branches/JBoss_Portal_Branch_2_6/referenceGuide/en/modules/supported.xml 2008-02-04 11:31:55 UTC (rev 9740)
+++ docs/branches/JBoss_Portal_Branch_2_6/referenceGuide/en/modules/supported.xml 2008-02-04 12:26:03 UTC (rev 9741)
@@ -37,7 +37,7 @@
</sect1>
<sect1>
<title>JBoss Application Server</title>
- <para>JBoss Portal 2.6.3 is tested with JBoss Application Server (AS) 4.2.1, JBoss AS 4.2.2, and JBoss Enterprise Application Platform (EAP) 4.2. It is highly recommended that customers who have access to the <ulink url="https://support.redhat.com/portal/login.html">JBoss Customer Support Portal (CSP)</ulink> use JBoss EAP 4.2. Customers who do not have access to the JBoss CSP should use <ulink url="http://labs.jboss.com/jbossas/">JBoss AS</ulink>.
+ <para>JBoss Portal 2.6.4 is tested with JBoss Application Server (AS) 4.2.1, JBoss AS 4.2.2, JBoss Enterprise Application Platform (EAP) 4.2 and JBoss EAP 4.3. It is highly recommended that customers who have access to the <ulink url="https://support.redhat.com/portal/login.html">JBoss Customer Support Portal (CSP)</ulink> use JBoss EAP 4.3. Customers who do not have access to the JBoss CSP should use <ulink url="http://labs.jboss.com/jbossas/">JBoss AS</ulink>.
</para>
<warning>
<para>JBoss AS versions 4.0.<replaceable>x</replaceable> are not supported.</para>
16 years, 4 months
JBoss Portal SVN: r9740 - in modules/portlet/trunk: test/src/main/java/org/jboss/portal/portlet/test and 1 other directories.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2008-02-04 06:31:55 -0500 (Mon, 04 Feb 2008)
New Revision: 9740
Added:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletUtilsTestCase.java
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletUtils.java
modules/portlet/trunk/test/src/test/resources/test/local-jboss-unit.xml
Log:
JBPORTAL-1875: RenderResponse.getNamespace() generates a not correct value
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletUtils.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletUtils.java 2008-02-04 11:26:00 UTC (rev 9739)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletUtils.java 2008-02-04 11:31:55 UTC (rev 9740)
@@ -109,7 +109,8 @@
for (int i = 0; i < windowId.length(); i++)
{
char c = windowId.charAt(i);
- if (Character.isLetterOrDigit(c))
+ int charVal = c;
+ if ((charVal >= 65 && charVal <= 90) || (charVal >= 97 && charVal <= 122) || (charVal >=48 && charVal <= 57) || (charVal == 95) || charVal == 36)
{
tmp.append(c);
}
Added: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletUtilsTestCase.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletUtilsTestCase.java (rev 0)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletUtilsTestCase.java 2008-02-04 11:31:55 UTC (rev 9740)
@@ -0,0 +1,21 @@
+package org.jboss.portal.portlet.test;
+
+import org.jboss.portal.portlet.impl.jsr168.PortletUtils;
+
+import static org.jboss.unit.api.Assert.*;
+
+public class PortletUtilsTestCase {
+
+ public void testgenerateNamespaceFrom()
+ {
+ String name = "_09azAZ$";
+ assertEquals(PortletUtils.PREFIX + name + PortletUtils.SUFFIX, PortletUtils.generateNamespaceFrom(name));
+
+ name = "_";
+ assertEquals(PortletUtils.PREFIX + "_" + PortletUtils.SUFFIX, PortletUtils.generateNamespaceFrom(name));
+
+ name = "_é";
+ assertEquals(PortletUtils.PREFIX + "__e9" + PortletUtils.SUFFIX, PortletUtils.generateNamespaceFrom(name));
+ }
+
+}
Modified: modules/portlet/trunk/test/src/test/resources/test/local-jboss-unit.xml
===================================================================
--- modules/portlet/trunk/test/src/test/resources/test/local-jboss-unit.xml 2008-02-04 11:26:00 UTC (rev 9739)
+++ modules/portlet/trunk/test/src/test/resources/test/local-jboss-unit.xml 2008-02-04 11:31:55 UTC (rev 9740)
@@ -5,6 +5,10 @@
xsi:schemaLocation="urn:jboss:jboss-unit:1.0 jboss-unit_1_0.xsd">
<pojo>
<test>
+ <class name="org.jboss.portal.portlet.test.PortletUtilsTestCase">
+ </class>
+ </test>
+ <test>
<class name="org.jboss.portal.portlet.test.url.DecoderTestCase">
</class>
</test>
16 years, 4 months
JBoss Portal SVN: r9739 - in modules/portlet/tags/JBP_PORTLET_1_0_2: test and 1 other directories.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2008-02-04 06:26:00 -0500 (Mon, 04 Feb 2008)
New Revision: 9739
Added:
modules/portlet/tags/JBP_PORTLET_1_0_2/test/src/main/org/jboss/portal/portlet/test/PortletUtilsTestCase.java
Modified:
modules/portlet/tags/JBP_PORTLET_1_0_2/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletUtils.java
modules/portlet/tags/JBP_PORTLET_1_0_2/test/build.xml
Log:
JBPORTAL-1875: RenderResponse.getNamespace() generates a not correct value
Modified: modules/portlet/tags/JBP_PORTLET_1_0_2/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletUtils.java
===================================================================
--- modules/portlet/tags/JBP_PORTLET_1_0_2/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletUtils.java 2008-02-04 11:20:20 UTC (rev 9738)
+++ modules/portlet/tags/JBP_PORTLET_1_0_2/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletUtils.java 2008-02-04 11:26:00 UTC (rev 9739)
@@ -192,7 +192,8 @@
for (int i = 0; i < windowId.length(); i++)
{
char c = windowId.charAt(i);
- if (Character.isLetterOrDigit(c))
+ int charVal = c;
+ if ((charVal >= 65 && charVal <= 90) || (charVal >= 97 && charVal <= 122) || (charVal >=48 && charVal <= 57) || (charVal == 95) || charVal == 36)
{
tmp.append(c);
}
Modified: modules/portlet/tags/JBP_PORTLET_1_0_2/test/build.xml
===================================================================
--- modules/portlet/tags/JBP_PORTLET_1_0_2/test/build.xml 2008-02-04 11:20:20 UTC (rev 9738)
+++ modules/portlet/tags/JBP_PORTLET_1_0_2/test/build.xml 2008-02-04 11:26:00 UTC (rev 9739)
@@ -717,6 +717,7 @@
<target name="tests.local" depends="init">
<execute-tests>
<x-test>
+ <test todir="${test.reports}" name="org.jboss.portal.portlet.test.PortletUtilsTestCase"/>
<test todir="${test.reports}" name="org.jboss.portal.portlet.test.url.EncoderTestCase"/>
<test todir="${test.reports}" name="org.jboss.portal.portlet.test.url.DecoderTestCase"/>
<test todir="${test.reports}" name="org.jboss.portal.portlet.test.StringCodecTestCase"/>
Added: modules/portlet/tags/JBP_PORTLET_1_0_2/test/src/main/org/jboss/portal/portlet/test/PortletUtilsTestCase.java
===================================================================
--- modules/portlet/tags/JBP_PORTLET_1_0_2/test/src/main/org/jboss/portal/portlet/test/PortletUtilsTestCase.java (rev 0)
+++ modules/portlet/tags/JBP_PORTLET_1_0_2/test/src/main/org/jboss/portal/portlet/test/PortletUtilsTestCase.java 2008-02-04 11:26:00 UTC (rev 9739)
@@ -0,0 +1,21 @@
+package org.jboss.portal.portlet.test;
+
+import org.jboss.portal.portlet.impl.jsr168.PortletUtils;
+
+import junit.framework.TestCase;
+
+public class PortletUtilsTestCase extends TestCase {
+
+ public void testgenerateNamespaceFrom()
+ {
+ String name = "_09azAZ$";
+ assertEquals(PortletUtils.PREFIX + name + PortletUtils.SUFFIX, PortletUtils.generateNamespaceFrom(name));
+
+ name = "_";
+ assertEquals(PortletUtils.PREFIX + "_" + PortletUtils.SUFFIX, PortletUtils.generateNamespaceFrom(name));
+
+ name = "_é";
+ assertEquals(PortletUtils.PREFIX + "__e9" + PortletUtils.SUFFIX, PortletUtils.generateNamespaceFrom(name));
+ }
+
+}
16 years, 4 months