[jboss-svn-commits] JBoss Portal SVN: r5285 - in trunk/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:09:25 EDT 2006


Author: julien at jboss.com
Date: 2006-09-28 18:09:14 -0400 (Thu, 28 Sep 2006)
New Revision: 5285

Modified:
   trunk/portlet/build.xml
   trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletPreferencesImpl.java
   trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/api/portletpreferences/PortletPreferencesAPITestSuite.java
   trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/api/portletpreferences/PortletPreferencesSequenceBuilder.java
   trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/preferences/PreferencesSequenceBuilder.java
   trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/preferences/PreferencesTestSuite.java
   trunk/portlet/src/resources/test/jsr168/api/portletpreferences-war/WEB-INF/portlet.xml
   trunk/portlet/src/resources/test/jsr168/ext/preferences-war/WEB-INF/portlet.xml
Log:
JBPORTAL-1060 : Empty preferences values are not retrieved properly

Modified: trunk/portlet/build.xml
===================================================================
--- trunk/portlet/build.xml	2006-09-28 18:41:14 UTC (rev 5284)
+++ trunk/portlet/build.xml	2006-09-28 22:09:14 UTC (rev 5285)
@@ -465,8 +465,6 @@
             <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: trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletPreferencesImpl.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletPreferencesImpl.java	2006-09-28 18:41:14 UTC (rev 5284)
+++ trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletPreferencesImpl.java	2006-09-28 22:09:14 UTC (rev 5285)
@@ -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: trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/api/portletpreferences/PortletPreferencesAPITestSuite.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/api/portletpreferences/PortletPreferencesAPITestSuite.java	2006-09-28 18:41:14 UTC (rev 5284)
+++ trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/api/portletpreferences/PortletPreferencesAPITestSuite.java	2006-09-28 22:09:14 UTC (rev 5285)
@@ -52,7 +52,8 @@
       /**
        * PortletPreferences.reset()
        */
-      suite.addTest(new TestCase("Reset"));
+      suite.addTest(new TestCase("ResetNullKeyThrowsNPE"));
+      suite.addTest(new TestCase("ZeroLengthArrayValue"));
 
 
       return suite;

Modified: trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/api/portletpreferences/PortletPreferencesSequenceBuilder.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/api/portletpreferences/PortletPreferencesSequenceBuilder.java	2006-09-28 18:41:14 UTC (rev 5284)
+++ trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/api/portletpreferences/PortletPreferencesSequenceBuilder.java	2006-09-28 22:09:14 UTC (rev 5285)
@@ -30,6 +30,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;
@@ -38,6 +39,9 @@
 import javax.portlet.RenderResponse;
 import javax.portlet.ActionRequest;
 import javax.portlet.ActionResponse;
+import javax.portlet.ValidatorException;
+import javax.portlet.PortletURL;
+import java.io.IOException;
 
 /**
  * @author <a href="mailto:boleslaw.dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
@@ -198,7 +202,7 @@
    public void createResetCase(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
@@ -217,4 +221,65 @@
       });
    }
 
+   /**
+    *
+    */
+   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 void 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"}));
+         }
+      });
+      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: trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/preferences/PreferencesSequenceBuilder.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/preferences/PreferencesSequenceBuilder.java	2006-09-28 18:41:14 UTC (rev 5284)
+++ trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/preferences/PreferencesSequenceBuilder.java	2006-09-28 22:09:14 UTC (rev 5285)
@@ -54,69 +54,6 @@
 {
 
    /**
-    *
-    */
-   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 void 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"}));
-         }
-      });
-      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
     */
@@ -141,7 +78,7 @@
 
       seq.addAction(1, UTP2.ACTION_JOINPOINT, new PortletActionTestAction()
       {
-         protected void run(Portlet portlet, ActionRequest request, ActionResponse response) throws ReadOnlyException, IOException
+         protected void run(Portlet portlet, ActionRequest request, ActionResponse response)
          {
             // Get prefs
             PortletPreferences prefs = request.getPreferences();

Modified: trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/preferences/PreferencesTestSuite.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/preferences/PreferencesTestSuite.java	2006-09-28 18:41:14 UTC (rev 5284)
+++ trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/preferences/PreferencesTestSuite.java	2006-09-28 22:09:14 UTC (rev 5285)
@@ -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: trunk/portlet/src/resources/test/jsr168/api/portletpreferences-war/WEB-INF/portlet.xml
===================================================================
--- trunk/portlet/src/resources/test/jsr168/api/portletpreferences-war/WEB-INF/portlet.xml	2006-09-28 18:41:14 UTC (rev 5284)
+++ trunk/portlet/src/resources/test/jsr168/api/portletpreferences-war/WEB-INF/portlet.xml	2006-09-28 22:09:14 UTC (rev 5285)
@@ -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: trunk/portlet/src/resources/test/jsr168/ext/preferences-war/WEB-INF/portlet.xml
===================================================================
--- trunk/portlet/src/resources/test/jsr168/ext/preferences-war/WEB-INF/portlet.xml	2006-09-28 18:41:14 UTC (rev 5284)
+++ trunk/portlet/src/resources/test/jsr168/ext/preferences-war/WEB-INF/portlet.xml	2006-09-28 22:09:14 UTC (rev 5285)
@@ -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