Author: julien(a)jboss.com
Date: 2008-02-26 13:15:26 -0500 (Tue, 26 Feb 2008)
New Revision: 10120
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletPreferencesImpl.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr168/api/portletpreferences/ZeroLengthArrayValueTestCase.java
Log:
change wrong interpretation of the spec when a prefs has no values
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletPreferencesImpl.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletPreferencesImpl.java 2008-02-26
13:54:30 UTC (rev 10119)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletPreferencesImpl.java 2008-02-26
18:15:26 UTC (rev 10120)
@@ -198,13 +198,21 @@
throw new IllegalArgumentException("key must not be null");
}
Value value = getValue(key);
- if (value != null)
+// if (value != null)
+// {
+// return value.asStringArray();
+// }
+// else
+// {
+// return def;
+// }
+ if (value == null || value.isEmpty())
{
- return value.asStringArray();
+ return def;
}
else
{
- return def;
+ return value.asStringArray();
}
}
Modified:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr168/api/portletpreferences/ZeroLengthArrayValueTestCase.java
===================================================================
---
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr168/api/portletpreferences/ZeroLengthArrayValueTestCase.java 2008-02-26
13:54:30 UTC (rev 10119)
+++
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr168/api/portletpreferences/ZeroLengthArrayValueTestCase.java 2008-02-26
18:15:26 UTC (rev 10120)
@@ -62,7 +62,7 @@
// 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"}));
+ assertEquals(new String[]{"other"},
prefs.getValues("empty", new String[]{"other"}));
//
PortletURL url = response.createActionURL();
@@ -82,14 +82,14 @@
// 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"}));
+ 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[0], prefs.getValues("dynamic", new
String[]{"other"}));
+ assertEquals(new String[]{"other"},
prefs.getValues("dynamic", new String[]{"other"}));
}
});
seq.bindAction(1, UTP2.RENDER_JOIN_POINT, new PortletRenderTestAction()
@@ -100,7 +100,7 @@
// Check we still have the other value
assertEquals("other", prefs.getValue("dynamic",
"other"));
- assertEquals(new String[0], prefs.getValues("dynamic", new
String[]{"other"}));
+ assertEquals(new String[]{"other"},
prefs.getValues("dynamic", new String[]{"other"}));
//
return new EndTestResponse();
Show replies by date