Author: julien(a)jboss.com
Date: 2008-01-13 07:04:18 -0500 (Sun, 13 Jan 2008)
New Revision: 9489
Added:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletconfig/NoPublicRenderParameterTestCase.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletconfig/PublicRenderParameterTestCase.java
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerInfoBuilder.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerPortletInfo.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletConfigImpl.java
modules/portlet/trunk/test/src/test/resources/jsr286/tck/portletconfig-war/WEB-INF/portlet.xml
modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml
Log:
implement public render parameters from PortletConfig and test cases for it
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerInfoBuilder.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerInfoBuilder.java 2008-01-13
01:34:39 UTC (rev 9488)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerInfoBuilder.java 2008-01-13
12:04:18 UTC (rev 9489)
@@ -174,6 +174,10 @@
{
portletMD.setInitParams(new ArrayList<InitParamMetaData>());
}
+ if (portletMD.getSupportedPublicRenderParameters() == null)
+ {
+ portletMD.setSupportedPublicRenderParameters(new ArrayList<String>());
+ }
for (PortletPreferenceMetaData portletPreferenceMD :
portletMD.getPortletPreferences().getPortletPreferences().values())
{
if (portletPreferenceMD.getValue() == null)
@@ -343,6 +347,12 @@
}
//
+ for (String renderParameter : portletMD.getSupportedPublicRenderParameters())
+ {
+ containerPortletInfo.addRenderParameter(renderParameter);
+ }
+
+ //
return containerPortletInfo;
}
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerPortletInfo.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerPortletInfo.java 2008-01-13
01:34:39 UTC (rev 9488)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerPortletInfo.java 2008-01-13
12:04:18 UTC (rev 9489)
@@ -25,10 +25,10 @@
import org.jboss.portal.portlet.info.PortletInfo;
import org.jboss.portal.common.i18n.ResourceBundleManager;
-import javax.xml.XMLConstants;
import java.util.Map;
import java.util.HashMap;
import java.util.Set;
+import java.util.LinkedHashSet;
/**
* For now implementation that use the portlet container directly.
@@ -71,6 +71,9 @@
private final Map<String, String> initParameters;
/** . */
+ private final Set<String> renderParameterNames;
+
+ /** . */
private final Boolean remotable;
/** . */
@@ -98,6 +101,7 @@
this.name = name;
this.className = className;
this.initParameters = new HashMap<String, String>();
+ this.renderParameterNames = new LinkedHashSet<String>();
this.remotable = remotable;
this.bundleManager = bundleManager;
}
@@ -125,6 +129,7 @@
this.name = name;
this.className = className;
this.initParameters = new HashMap<String, String>();
+ this.renderParameterNames = new LinkedHashSet<String>();
this.remotable = remotable;
this.bundleManager = bundleManager;
}
@@ -159,6 +164,16 @@
return initParameters.get(name);
}
+ public void addRenderParameter(String parameterName)
+ {
+ renderParameterNames.add(parameterName);
+ }
+
+ public Set<String> getRenderParameterNames()
+ {
+ return renderParameterNames;
+ }
+
public ContainerCapabilitiesInfo getCapabilities()
{
return capabilities;
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletConfigImpl.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletConfigImpl.java 2008-01-13
01:34:39 UTC (rev 9488)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletConfigImpl.java 2008-01-13
12:04:18 UTC (rev 9489)
@@ -24,7 +24,6 @@
import org.jboss.portal.common.i18n.ResourceBundleManager;
import org.jboss.portal.common.NotYetImplemented;
-import org.jboss.portal.common.util.Tools;
import org.jboss.portal.portlet.impl.info.ContainerPortletInfo;
import org.jboss.portal.portlet.impl.info.ContainerPortletApplicationInfo;
import org.jboss.portal.portlet.info.EventInfo;
@@ -127,7 +126,7 @@
public Enumeration<String> getPublicRenderParameterNames()
{
- throw new NotYetImplemented();
+ return Collections.enumeration(portletInfo.getRenderParameterNames());
}
public String getDefaultNamespace()
@@ -137,21 +136,22 @@
public Enumeration<QName> getPublishingEventQNames()
{
- return Tools.toEnumeration(publishingEventQNames.iterator());
+ return Collections.enumeration(publishingEventQNames);
}
public Enumeration<QName> getProcessingEventQNames()
{
- return Tools.toEnumeration(processingEventQNames.iterator());
+ return Collections.enumeration(processingEventQNames);
}
public Enumeration<Locale> getSupportedLocales()
{
- throw new NotYetImplemented();
+ return Collections.enumeration(portletInfo.getCapabilities().getAllLocales());
}
public Map<String, String[]> getContainerRuntimeOptions()
{
- throw new NotYetImplemented();
+ // For now we support no container runtime options
+ return Collections.emptyMap();
}
}
Added:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletconfig/NoPublicRenderParameterTestCase.java
===================================================================
---
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletconfig/NoPublicRenderParameterTestCase.java
(rev 0)
+++
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletconfig/NoPublicRenderParameterTestCase.java 2008-01-13
12:04:18 UTC (rev 9489)
@@ -0,0 +1,67 @@
+/******************************************************************************
+ * 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.portletconfig;
+
+import org.jboss.portal.unit.annotations.TestCase;
+import org.jboss.portal.unit.Assertion;
+import org.jboss.portal.unit.PortletTestCase;
+import org.jboss.portal.unit.PortletTestContext;
+import org.jboss.portal.unit.base.AbstractUniversalTestPortlet;
+import org.jboss.portal.unit.actions.PortletRenderTestAction;
+import org.jboss.portal.test.portlet.framework.UTP6;
+import org.jboss.unit.driver.DriverResponse;
+import org.jboss.unit.driver.response.EndTestResponse;
+import static org.jboss.unit.api.Assert.*;
+
+import javax.portlet.PortletConfig;
+import javax.portlet.Portlet;
+import javax.portlet.RenderResponse;
+import javax.portlet.RenderRequest;
+import java.util.Enumeration;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+(a)TestCase({Assertion.JSR168_1000})
+public class NoPublicRenderParameterTestCase
+{
+ public NoPublicRenderParameterTestCase(PortletTestCase seq)
+ {
+ seq.bindAction(0, UTP6.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request,
RenderResponse response, PortletTestContext context)
+ {
+ PortletConfig cfg =
((AbstractUniversalTestPortlet)portlet).getPortletConfig();
+
+ //
+ Enumeration<String> names = cfg.getPublicRenderParameterNames();
+ assertNotNull(names);
+ assertFalse(names.hasMoreElements());
+
+ //
+ return new EndTestResponse();
+ }
+ });
+ }
+}
Added:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletconfig/PublicRenderParameterTestCase.java
===================================================================
---
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletconfig/PublicRenderParameterTestCase.java
(rev 0)
+++
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletconfig/PublicRenderParameterTestCase.java 2008-01-13
12:04:18 UTC (rev 9489)
@@ -0,0 +1,72 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.portlet.jsr286.tck.portletconfig;
+
+import org.jboss.portal.unit.annotations.TestCase;
+import org.jboss.portal.unit.Assertion;
+import org.jboss.portal.unit.PortletTestCase;
+import org.jboss.portal.unit.PortletTestContext;
+import org.jboss.portal.unit.base.AbstractUniversalTestPortlet;
+import org.jboss.portal.unit.actions.PortletRenderTestAction;
+import org.jboss.portal.test.portlet.framework.UTP7;
+import org.jboss.portal.common.util.Tools;
+import org.jboss.unit.driver.DriverResponse;
+import org.jboss.unit.driver.response.EndTestResponse;
+import static org.jboss.unit.api.Assert.*;
+
+import javax.portlet.PortletConfig;
+import javax.portlet.Portlet;
+import javax.portlet.RenderResponse;
+import javax.portlet.RenderRequest;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.HashSet;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+(a)TestCase({Assertion.JSR168_1000})
+public class PublicRenderParameterTestCase
+{
+ public PublicRenderParameterTestCase(PortletTestCase seq)
+ {
+ seq.bindAction(0, UTP7.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request,
RenderResponse response, PortletTestContext context)
+ {
+ PortletConfig cfg =
((AbstractUniversalTestPortlet)portlet).getPortletConfig();
+
+ //
+ Enumeration<String> names = cfg.getPublicRenderParameterNames();
+ assertNotNull(names);
+ List<String> list = Tools.toList(names);
+ assertEquals(2, list.size());
+ assertEquals(Tools.toSet("render_param1",
"render_param2"), new HashSet<String>(list));
+
+ //
+ return new EndTestResponse();
+ }
+ });
+ }
+}
\ No newline at end of file
Modified:
modules/portlet/trunk/test/src/test/resources/jsr286/tck/portletconfig-war/WEB-INF/portlet.xml
===================================================================
---
modules/portlet/trunk/test/src/test/resources/jsr286/tck/portletconfig-war/WEB-INF/portlet.xml 2008-01-13
01:34:39 UTC (rev 9488)
+++
modules/portlet/trunk/test/src/test/resources/jsr286/tck/portletconfig-war/WEB-INF/portlet.xml 2008-01-13
12:04:18 UTC (rev 9489)
@@ -139,6 +139,24 @@
</supports>
</portlet>
+ <portlet>
+ <portlet-name>UniversalTestPortletF</portlet-name>
+
<portlet-class>org.jboss.portal.test.portlet.framework.UTP6</portlet-class>
+ <supports>
+ <mime-type>text/html</mime-type>
+ </supports>
+ </portlet>
+
+ <portlet>
+ <portlet-name>UniversalTestPortletG</portlet-name>
+
<portlet-class>org.jboss.portal.test.portlet.framework.UTP7</portlet-class>
+ <supports>
+ <mime-type>text/html</mime-type>
+ </supports>
+
<supported-public-render-parameter>render_param1</supported-public-render-parameter>
+
<supported-public-render-parameter>render_param2</supported-public-render-parameter>
+ </portlet>
+
<default-namespace>urn:default-namespace</default-namespace>
<event-definition>
Modified: modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml
===================================================================
--- modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml 2008-01-13
01:34:39 UTC (rev 9488)
+++ modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml 2008-01-13
12:04:18 UTC (rev 9489)
@@ -5,7 +5,6 @@
xsi:schemaLocation="urn:jboss:jboss-unit:1.0 jboss-unit_1_0.xsd">
<!--Spec TCK Assertions tests-->
-<!--
<generic>
<class
name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId"
value="test-jsr168-tck-dispatcher.war"/>
@@ -50,10 +49,8 @@
<class
name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId"
value="test-jsr168-tck-windowstates.war"/>
</generic>
--->
<!--API Tests-->
-<!--
<generic>
<class
name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId"
value="test-jsr168-api-actionrequest.war"/>
@@ -106,10 +103,8 @@
<class
name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId"
value="test-jsr168-api-windowstate.war"/>
</generic>
--->
<!--Ext Tests-->
-<!--
<generic>
<class
name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId"
value="test-jsr168-ext-dispatcher.war"/>
@@ -150,7 +145,6 @@
<class
name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId"
value="test-jsr168-ext-nocache.war"/>
</generic>
--->
<!--Spec TCK Assertions tests-->
<generic>