/**
* Check (xci) SPEC 91, PLT 14.1: Preferences values are not modified
* if the values in the Map are altered.
*/
protected TestResult checkPreferenceValueNotModified(PortletRequest request) {
TestResult result = new TestResult();
result.setDescription("Preferences values are not modified if "
+ "the values in the returned preference Map are altered.");
result.setSpecPLT("14.1");
PortletPreferences preferences = request.getPreferences();
if (LOG.isDebugEnabled()) {
LOG.debug("Original Preferences:");
logPreferences(preferences);
}
// Modify the returned preference map.
Map prefMap = preferences.getMap();
String[] values = (String[]) prefMap.get(PREF_NAME);
String originalValue = null;
String modifiedValue = "Value modified in preferences map.";
if (values != null && values.length == 1) {
originalValue = values[0];
values[0] = modifiedValue;
}
// Check if the value held by portlet preferences is modified.
if (LOG.isDebugEnabled()) {
LOG.debug("Modified Preferences:");
logPreferences(preferences);
}
String newValue = preferences.getValue(PREF_NAME, DEF_VALUE);
if (newValue != null && newValue.equals(originalValue)) {
result.setReturnCode(TestResult.PASSED);
} else {
result.setReturnCode(TestResult.FAILED);
result.setResultMessage("Preference value modified according to "
+ "the preference map.");
}
return result;
}