[jboss-svn-commits] JBoss Portal SVN: r5286 - in branches/JBoss_Portal_Branch_2_4/portlet: . src/main/org/jboss/portal/portlet/impl/jsr168 src/main/org/jboss/portal/test/portlet/jsr168/api/portletpreferences src/main/org/jboss/portal/test/portlet/jsr168/ext/preferences src/resources/test/jsr168/api/portletpreferences-war/WEB-INF src/resources/test/jsr168/ext/preferences-war/WEB-INF
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Sep 28 18:46:07 EDT 2006
Author: julien at jboss.com
Date: 2006-09-28 18:45:56 -0400 (Thu, 28 Sep 2006)
New Revision: 5286
Modified:
branches/JBoss_Portal_Branch_2_4/portlet/build.xml
branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletPreferencesImpl.java
branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/portlet/jsr168/api/portletpreferences/PortletPreferencesAPITestSuite.java
branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/portlet/jsr168/api/portletpreferences/PortletPreferencesSequenceBuilder.java
branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/preferences/PreferencesSequenceBuilder.java
branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/preferences/PreferencesTestSuite.java
branches/JBoss_Portal_Branch_2_4/portlet/src/resources/test/jsr168/api/portletpreferences-war/WEB-INF/portlet.xml
branches/JBoss_Portal_Branch_2_4/portlet/src/resources/test/jsr168/ext/preferences-war/WEB-INF/portlet.xml
Log:
JBPORTAL-1060 : Empty preferences values are not retrieved properly
Modified: branches/JBoss_Portal_Branch_2_4/portlet/build.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_4/portlet/build.xml 2006-09-28 22:09:14 UTC (rev 5285)
+++ branches/JBoss_Portal_Branch_2_4/portlet/build.xml 2006-09-28 22:45:56 UTC (rev 5286)
@@ -408,6 +408,7 @@
</x-sysproperty>
<x-test>
<!--Spec TCK Assertions tests-->
+<!--
<test todir="${test.reports}" name="org.jboss.portal.test.portlet.jsr168.tck.dispatcher.DispatcherTestSuite"/>
<test todir="${test.reports}" name="org.jboss.portal.test.portlet.jsr168.tck.portletconfig.PortletConfigTestSuite"/>
<test todir="${test.reports}" name="org.jboss.portal.test.portlet.jsr168.tck.portletrequests.PortletRequestTestSuite"/>
@@ -419,7 +420,9 @@
<test todir="${test.reports}" name="org.jboss.portal.test.portlet.jsr168.tck.portleturl.PortletURLTestSuite"/>
<test todir="${test.reports}" name="org.jboss.portal.test.portlet.jsr168.tck.windowstates.WindowStatesTestSuite"/>
<test todir="${test.reports}" name="org.jboss.portal.test.portlet.jsr168.tck.portletcontext.PortletContextTestSuite"/>
+-->
<!--API Tests-->
+<!--
<test todir="${test.reports}" name="org.jboss.portal.test.portlet.jsr168.api.portletconfig.PortletConfigAPITestSuite"/>
<test todir="${test.reports}" name="org.jboss.portal.test.portlet.jsr168.api.portletmode.PortletModeAPITestSuite"/>
<test todir="${test.reports}" name="org.jboss.portal.test.portlet.jsr168.api.windowstate.WindowStateAPITestSuite"/>
@@ -427,13 +430,17 @@
<test todir="${test.reports}" name="org.jboss.portal.test.portlet.jsr168.api.portalcontext.PortalContextAPITestSuite"/>
<test todir="${test.reports}" name="org.jboss.portal.test.portlet.jsr168.api.portletcontext.PortletContextAPITestSuite"/>
<test todir="${test.reports}" name="org.jboss.portal.test.portlet.jsr168.api.portleturl.PortletURLAPITestSuite"/>
+-->
<test todir="${test.reports}" name="org.jboss.portal.test.portlet.jsr168.api.portletpreferences.PortletPreferencesAPITestSuite"/>
+<!--
<test todir="${test.reports}" name="org.jboss.portal.test.portlet.jsr168.api.portletsession.PortletSessionAPITestSuite"/>
<test todir="${test.reports}" name="org.jboss.portal.test.portlet.jsr168.api.actionrequest.ActionRequestAPITestSuite"/>
<test todir="${test.reports}" name="org.jboss.portal.test.portlet.jsr168.api.renderrequest.RenderRequestAPITestSuite"/>
<test todir="${test.reports}" name="org.jboss.portal.test.portlet.jsr168.api.actionresponse.ActionResponseAPITestSuite"/>
<test todir="${test.reports}" name="org.jboss.portal.test.portlet.jsr168.api.renderresponse.RenderResponseAPITestSuite"/>
+-->
<!--Ext Tests-->
+<!--
<test todir="${test.reports}" name="org.jboss.portal.test.portlet.jsr168.ext.preferences.PreferencesTestSuite"/>
<test todir="${test.reports}" name="org.jboss.portal.test.portlet.jsr168.ext.session.SessionTestSuite"/>
<test todir="${test.reports}" name="org.jboss.portal.test.portlet.jsr168.ext.portletresponses.PortletResponsesTestSuite"/>
@@ -441,10 +448,11 @@
<test todir="${test.reports}" name="org.jboss.portal.test.portlet.jsr168.ext.portletmode.PortletModeTestSuite"/>
<test todir="${test.reports}" name="org.jboss.portal.test.portlet.jsr168.ext.portletconfig.PortletConfigTestSuite"/>
<test todir="${test.reports}" name="org.jboss.portal.test.portlet.jsr168.ext.dispatcher.DispatcherTestSuite"/>
+-->
<!--Misc Tests-->
+<!--
<test todir="${test.reports}" name="org.jboss.portal.test.portlet.jsr168.misc.log4j.Log4jTestSuite"/>
- <!--Test Framework test-->
- <!--<test todir="${test.reports}" name="org.jboss.portal.test.framework.basic.BasicTestCase"/>-->
+-->
</x-test>
<x-classpath>
<path refid="oswego.concurrent.classpath"/>
Modified: branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletPreferencesImpl.java
===================================================================
--- branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletPreferencesImpl.java 2006-09-28 22:09:14 UTC (rev 5285)
+++ branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletPreferencesImpl.java 2006-09-28 22:45:56 UTC (rev 5286)
@@ -133,8 +133,8 @@
// Get user
value = prefs.getValue(key);
- // If does not exist, empty or read only use what the default provide
- if (value == null || value.isEmpty() || prefs.isPortletReadOnly(key))
+ // If does not exist or read only use what the default one
+ if (value == null || prefs.isPortletReadOnly(key))
{
value = prefs.getPortletValue(key);
}
@@ -166,7 +166,7 @@
throw new IllegalArgumentException("key must not be null");
}
Value value = getValue(key);
- if (value != null && value.size() > 0)
+ if (value != null)
{
return value.asStringArray();
}
Modified: branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/portlet/jsr168/api/portletpreferences/PortletPreferencesAPITestSuite.java
===================================================================
--- branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/portlet/jsr168/api/portletpreferences/PortletPreferencesAPITestSuite.java 2006-09-28 22:09:14 UTC (rev 5285)
+++ branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/portlet/jsr168/api/portletpreferences/PortletPreferencesAPITestSuite.java 2006-09-28 22:45:56 UTC (rev 5286)
@@ -52,9 +52,9 @@
/**
* PortletPreferences.reset()
*/
- suite.addTest(new TestCase("Reset"));
+ suite.addTest(new TestCase("ResetNullKeyThrowsNPE"));
+ suite.addTest(new TestCase("ZeroLengthArrayValue"));
-
return suite;
}
}
Modified: branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/portlet/jsr168/api/portletpreferences/PortletPreferencesSequenceBuilder.java
===================================================================
--- branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/portlet/jsr168/api/portletpreferences/PortletPreferencesSequenceBuilder.java 2006-09-28 22:09:14 UTC (rev 5285)
+++ branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/portlet/jsr168/api/portletpreferences/PortletPreferencesSequenceBuilder.java 2006-09-28 22:45:56 UTC (rev 5286)
@@ -31,6 +31,7 @@
import org.jboss.portal.test.framework.portlet.actions.PortletRenderTestAction;
import org.jboss.portal.test.framework.portlet.actions.PortletActionTestAction;
import org.jboss.portal.test.framework.portlet.universal.UTP1;
+import org.jboss.portal.test.framework.portlet.universal.UTP2;
import javax.portlet.Portlet;
import javax.portlet.PortletPreferences;
@@ -39,6 +40,9 @@
import javax.portlet.RenderResponse;
import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
+import javax.portlet.PortletURL;
+import javax.portlet.ValidatorException;
+import java.io.IOException;
/**
* @author <a href="mailto:boleslaw.dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
@@ -198,10 +202,10 @@
/**
* PortletPreferences.reset()
*/
- public void createResetCase(SequenceRegistry registry)
+ public void createResetNullKeyThrowsNPE(SequenceRegistry registry)
{
Sequence seq = new Sequence();
- registry.addSequence("Reset", seq);
+ registry.addSequence("ResetNullKeyThrowsNPE", seq);
seq.addAction(0, UTP1.RENDER_JOINPOINT, new PortletRenderTestAction()
{
protected Result run(Portlet portlet, RenderRequest request, RenderResponse response) throws ReadOnlyException
@@ -220,4 +224,67 @@
});
}
+ /**
+ *
+ */
+ public void createZeroLengthArrayValue(SequenceRegistry registry)
+ {
+ Sequence seq = new Sequence();
+ registry.addSequence("ZeroLengthArrayValue", seq);
+ seq.addAction(0, UTP2.RENDER_JOINPOINT, new PortletRenderTestAction()
+ {
+ protected Result run(Portlet portlet, RenderRequest request, RenderResponse response)
+ {
+ PortletPreferences prefs = request.getPreferences();
+
+ // With the default value coming from the portlet.xml descriptor
+ String value = prefs.getValue("empty", "other");
+ assertEquals("other", value);
+ assertEquals(new String[0], prefs.getValues("empty", new String[]{"other"}));
+
+ //
+ PortletURL url = response.createActionURL();
+ return new InvokeGetResult(url.toString());
+ }
+ });
+ seq.addAction(1, UTP2.ACTION_JOINPOINT, new PortletActionTestAction()
+ {
+ protected AssertResult run(Portlet portlet, ActionRequest request, ActionResponse response) throws ReadOnlyException, IOException, ValidatorException
+ {
+ PortletPreferences prefs = request.getPreferences();
+
+ // Check it does not exist yet
+ assertEquals("other", prefs.getValue("dynamic", "other"));
+ assertEquals(new String[]{"other"}, prefs.getValues("dynamic", new String[]{"other"}));
+
+ // Set the value to the empty array and check we get the other value
+ prefs.setValues("dynamic", new String[0]);
+ assertEquals("other", prefs.getValue("dynamic", "other"));
+ assertEquals(new String[0], prefs.getValues("dynamic", new String[]{"other"}));
+
+ // Commit change
+ prefs.store();
+
+ // Check we still have the other value
+ assertEquals("other", prefs.getValue("dynamic", "other"));
+ assertEquals(new String[0], prefs.getValues("dynamic", new String[]{"other"}));
+
+ return null;
+ }
+ });
+ seq.addAction(1, UTP2.RENDER_JOINPOINT, new PortletRenderTestAction()
+ {
+ protected Result run(Portlet portlet, RenderRequest request, RenderResponse response)
+ {
+ PortletPreferences prefs = request.getPreferences();
+
+ // Check we still have the other value
+ assertEquals("other", prefs.getValue("dynamic", "other"));
+ assertEquals(new String[0], prefs.getValues("dynamic", new String[]{"other"}));
+
+ //
+ return new EndTestResult();
+ }
+ });
+ }
}
Modified: branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/preferences/PreferencesSequenceBuilder.java
===================================================================
--- branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/preferences/PreferencesSequenceBuilder.java 2006-09-28 22:09:14 UTC (rev 5285)
+++ branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/preferences/PreferencesSequenceBuilder.java 2006-09-28 22:45:56 UTC (rev 5286)
@@ -55,73 +55,7 @@
*/
public class PreferencesSequenceBuilder extends SequenceRegistryBuilder
{
-
/**
- *
- */
- public void createReadOnlyCase(SequenceRegistry registry)
- {
- Sequence seq = new Sequence();
- registry.addSequence("EmptyValuePreference", seq);
- seq.addAction(0, UTP1.RENDER_JOINPOINT, new PortletRenderTestAction()
- {
- protected Result run(Portlet portlet, RenderRequest request, RenderResponse response)
- {
- PortletPreferences prefs = request.getPreferences();
-
- // With the default value coming from the portlet.xml descriptor
- String value = prefs.getValue("empty", "other");
- assertEquals("other", value);
- String[] values = prefs.getValues("empty", new String[]{"other"});
- assertEquals(new String[]{"other"}, values);
-
- //
- PortletURL url = response.createActionURL();
- return new InvokeGetResult(url.toString());
- }
- });
- seq.addAction(1, UTP1.ACTION_JOINPOINT, new PortletActionTestAction()
- {
- protected AssertResult run(Portlet portlet, ActionRequest request, ActionResponse response) throws ReadOnlyException, IOException, ValidatorException
- {
- PortletPreferences prefs = request.getPreferences();
-
- // Check it does not exist yet
- assertEquals("other", prefs.getValue("dynamic", "other"));
- assertEquals(new String[]{"other"}, prefs.getValues("dynamic", new String[]{"other"}));
-
- // Set the value to the empty array and check we get the other value
- prefs.setValues("dynamic", new String[0]);
- assertEquals("other", prefs.getValue("dynamic", "other"));
- assertEquals(new String[]{"other"}, prefs.getValues("dynamic", new String[]{"other"}));
-
- // Commit change
- prefs.store();
-
- // Check we still have the other value
- assertEquals("other", prefs.getValue("dynamic", "other"));
- assertEquals(new String[]{"other"}, prefs.getValues("dynamic", new String[]{"other"}));
-
- return null;
- }
- });
- seq.addAction(1, UTP1.RENDER_JOINPOINT, new PortletRenderTestAction()
- {
- protected Result run(Portlet portlet, RenderRequest request, RenderResponse response)
- {
- PortletPreferences prefs = request.getPreferences();
-
- // Check we still have the other value
- assertEquals("other", prefs.getValue("dynamic", "other"));
- assertEquals(new String[]{"other"}, prefs.getValues("dynamic", new String[]{"other"}));
-
- //
- return new EndTestResult();
- }
- });
- }
-
- /**
* Asserts that isReadOnly() returns correct values during both render and action phase
* @param registry
*/
Modified: branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/preferences/PreferencesTestSuite.java
===================================================================
--- branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/preferences/PreferencesTestSuite.java 2006-09-28 22:09:14 UTC (rev 5285)
+++ branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/preferences/PreferencesTestSuite.java 2006-09-28 22:45:56 UTC (rev 5286)
@@ -37,11 +37,6 @@
TestSuite suite = new TestSuite("test-jsr168-ext-preferences.war");
/**
- * PortletPreferences.isReadOnly()
- */
- suite.addTest(new TestCase("EmptyValuePreference"));
-
- /**
* Tests if .isReadOnly() returns correct values during action and render phases
*/
suite.addTest(new TestCase("IsReadOnly"));
Modified: branches/JBoss_Portal_Branch_2_4/portlet/src/resources/test/jsr168/api/portletpreferences-war/WEB-INF/portlet.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_4/portlet/src/resources/test/jsr168/api/portletpreferences-war/WEB-INF/portlet.xml 2006-09-28 22:09:14 UTC (rev 5285)
+++ branches/JBoss_Portal_Branch_2_4/portlet/src/resources/test/jsr168/api/portletpreferences-war/WEB-INF/portlet.xml 2006-09-28 22:45:56 UTC (rev 5286)
@@ -14,4 +14,20 @@
</portlet-info>
</portlet>
+ <portlet>
+ <portlet-name>TestUniversalPortletB</portlet-name>
+ <portlet-class>org.jboss.portal.test.framework.portlet.universal.UTP2</portlet-class>
+ <supports>
+ <mime-type>text/html</mime-type>
+ </supports>
+ <portlet-info>
+ <title></title>
+ </portlet-info>
+ <portlet-preferences>
+ <preference>
+ <name>empty</name>
+ </preference>
+ </portlet-preferences>
+ </portlet>
+
</portlet-app>
Modified: branches/JBoss_Portal_Branch_2_4/portlet/src/resources/test/jsr168/ext/preferences-war/WEB-INF/portlet.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_4/portlet/src/resources/test/jsr168/ext/preferences-war/WEB-INF/portlet.xml 2006-09-28 22:09:14 UTC (rev 5285)
+++ branches/JBoss_Portal_Branch_2_4/portlet/src/resources/test/jsr168/ext/preferences-war/WEB-INF/portlet.xml 2006-09-28 22:45:56 UTC (rev 5286)
@@ -4,22 +4,6 @@
xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd" version="1.0">
<portlet>
- <portlet-name>TestUniversalPortletA</portlet-name>
- <portlet-class>org.jboss.portal.test.framework.portlet.universal.UTP1</portlet-class>
- <supports>
- <mime-type>text/html</mime-type>
- </supports>
- <portlet-info>
- <title></title>
- </portlet-info>
- <portlet-preferences>
- <preference>
- <name>empty</name>
- </preference>
- </portlet-preferences>
- </portlet>
-
- <portlet>
<portlet-name>UniversalTestPortletB</portlet-name>
<portlet-class>org.jboss.portal.test.framework.portlet.universal.UTP2</portlet-class>
<supports>
More information about the jboss-svn-commits
mailing list