Package javax.portlet

Examples of javax.portlet.PortletPreferences


      TestResult result = new TestResult();
      result.setDescription("Ensure proper default is returned when "
          + "a non-existing/value-undefined preference is requested.");
      result.setSpecPLT("14.1");
     
      PortletPreferences preferences = request.getPreferences();
      String value =  preferences.getValue(preferenceName, DEF_VALUE);
      String[] values = preferences.getValues(preferenceName,
                                              new String[] { DEF_VALUE });
      if (DEF_VALUE.equals(value)
          && values != null && values.length == 1
          && DEF_VALUE.equals(values[0])) {
        result.setReturnCode(TestResult.PASSED);
View Full Code Here


        TestResult result = new TestResult();
        result.setDescription("Ensure that preferences defined "
            + "in the deployment descriptor may be retrieved.");
        result.setSpecPLT("14.1");
       
        PortletPreferences preferences = request.getPreferences();
        String value = preferences.getValue(PREF_NAME, DEF_VALUE);
        if (value != null && value.equals(PREF_VALUE)) {
          result.setReturnCode(TestResult.PASSED);
        } else {
          TestUtils.failOnAssertion("preference value", value, PREF_VALUE, result);
        }
View Full Code Here

    protected TestResult checkSetPreferenceSingleValue(PortletRequest request) {
        TestResult result = new TestResult();
        result.setDescription("Ensure a single preference value can be set.");
        result.setSpecPLT("14.1");
       
        PortletPreferences preferences = request.getPreferences();
        try {
            preferences.setValue("TEST", "TEST_VALUE");
        } catch (ReadOnlyException ex) {
          TestUtils.failOnException("Unable to set preference value.", ex, result);
            return result;
        }
       
        String value = preferences.getValue("TEST", DEF_VALUE);
        if (value != null && value.equals("TEST_VALUE")) {
          result.setReturnCode(TestResult.PASSED);
        } else {
          TestUtils.failOnAssertion("preference value", value, "TEST_VALUE", result);
        }
View Full Code Here

    protected TestResult checkSetPreferenceMultiValues(PortletRequest request) {
        TestResult result = new TestResult();
        result.setDescription("Ensure multiple preference values can be set.");
        result.setSpecPLT("14.1");
       
        PortletPreferences preferences = request.getPreferences();
        try {
            preferences.setValues("TEST", new String[] {"ONE", "ANOTHER"});
        } catch (ReadOnlyException ex) {
          TestUtils.failOnException("Unable to set preference values.", ex, result);
          return result;
        }

        String[] values = preferences.getValues("TEST", new String[] { DEF_VALUE });
        if (values != null && values.length == 2
            && values[0].equals("ONE") && values[1].equals("ANOTHER")) {
          result.setReturnCode(TestResult.PASSED);
        } else if (values == null) {
          TestUtils.failOnAssertion("preference values",
View Full Code Here

    protected TestResult checkSetPreferenceNull(PortletRequest request) {
        TestResult result = new TestResult();
        result.setDescription("Ensure a preference value can be set to null.");
        result.setSpecPLT("14.1");
       
        PortletPreferences preferences = request.getPreferences();
        try {
            preferences.setValue("TEST", null);
        } catch (ReadOnlyException ex) {
          TestUtils.failOnException("Unable to set preference value.", ex, result);
            return result;
        }
       
        String value = preferences.getValue("TEST", DEF_VALUE);
        if (DEF_VALUE.equals(value)) {
          result.setReturnCode(TestResult.PASSED);
        } else {
          TestUtils.failOnAssertion("preference value", value, DEF_VALUE, result);
        }
View Full Code Here

        TestResult result = new TestResult();
        result.setDescription("Ensure the first value set to a given "
            + "preference is returned first by PortletPreferences.getValue().");
        result.setSpecPLT("14.1");
       
        PortletPreferences preferences = request.getPreferences();
        try {
            preferences.setValues("TEST", new String[] { "FIRST", "SECOND" });
        } catch (ReadOnlyException ex) {
          TestUtils.failOnException("Unable to set preference values.", ex, result);
          return result;
        }

        String value = preferences.getValue("TEST", DEF_VALUE);
        if (value != null && value.equals("FIRST")) {
          result.setReturnCode(TestResult.PASSED);
        } else {
          TestUtils.failOnAssertion("preference value", value, "FIRST", result);
        }
View Full Code Here

    protected TestResult checkResetPreferenceToDefault(PortletRequest request) {
      TestResult result = new TestResult();
      result.setDescription("Ensure preferences are properly reset.");
      result.setSpecPLT("14.1");
       
        PortletPreferences preferences = request.getPreferences();
        boolean setOccured = false;
        boolean resetOccured = false;
       
        try {
          // Set new value to overwrite the default value.
            preferences.setValue(PREF_NAME, NEW_VALUE);
            String value = preferences.getValue(PREF_NAME, DEF_VALUE);
            if (NEW_VALUE.equals(value)) {
                setOccured = true;
            }
            // Reset the preference so that default value is restored.
            preferences.reset(PREF_NAME);
            value =  preferences.getValue(PREF_NAME, DEF_VALUE);
            if (PREF_VALUE.equals(value)) {
                resetOccured = true;
            }
        } catch (ReadOnlyException ex) {
          TestUtils.failOnException("Unable to set preference value.", ex, result);
View Full Code Here

      TestResult result = new TestResult();
        result.setDescription("Ensure preferences are properly reset (removed) "
            + "when the default value is not defined.");
        result.setSpecPLT("14.1");
       
        PortletPreferences preferences = request.getPreferences();
        boolean setOccured = false;
        boolean resetOccured = false;
       
        try {
          // Set preference value to overwrite the original (null).
            preferences.setValue(BOGUS_KEY, NEW_VALUE);
            String value = preferences.getValue(BOGUS_KEY, DEF_VALUE);
            if (NEW_VALUE.equals(value)) {
                setOccured = true;
            }
            // Reset preference value to null.
            preferences.reset(BOGUS_KEY);
            value =  preferences.getValue(BOGUS_KEY, DEF_VALUE);
            if (DEF_VALUE.equals(value)) {
                resetOccured = true;
            }
        } catch (ReadOnlyException ex) {
          TestUtils.failOnException("Unable to set preference value.", ex, result);
View Full Code Here

        result.setDescription("Ensure that setValue() / setValues() / reset() "
            + "methods throw ReadOnlyException when invoked "
            + "on read-only preferences.");
        result.setSpecPLT("14.1");
       
        PortletPreferences preferences = request.getPreferences();
        if (!preferences.isReadOnly(READ_ONLY_PREF_NAME)) {
          result.setReturnCode(TestResult.WARNING);
          result.setResultMessage("Preference " + READ_ONLY_PREF_NAME
              + " is not a read-only preference. "
              + "This may be due to misconfiuration.");
          return result;
        }
       
        boolean setValueOK = false;
        boolean setValuesOK = false;
        boolean resetOK = false;
       
        // Check setValue() method.
        try {
            preferences.setValue(READ_ONLY_PREF_NAME, "written");
        } catch (ReadOnlyException ex) {
            setValueOK = true;
        }
       
        // Check setValues() method.
        try {
          preferences.setValues(READ_ONLY_PREF_NAME, new String[] { "written" });
        } catch (ReadOnlyException ex) {
          setValuesOK = true;
        }
       
        // Check reset() method.
        try {
          preferences.reset(READ_ONLY_PREF_NAME);
        } catch (ReadOnlyException ex) {
          resetOK = true;
        }
       
        if (setValueOK && setValuesOK && resetOK) {
View Full Code Here

    protected TestResult checkGetPreferenceNames(PortletRequest request) {
        TestResult result = new TestResult();
        result.setDescription("Ensure returned enumeration is valid.");
        result.setSpecPLT("14.1");
       
        PortletPreferences preferences = request.getPreferences();
        Map prefMap = preferences.getMap();
        boolean hasAll = true;
        for (Enumeration en = preferences.getNames(); en.hasMoreElements(); ) {
            if (!prefMap.containsKey(en.nextElement())) {
                hasAll = false;
                break;
            }
        }
View Full Code Here

TOP

Related Classes of javax.portlet.PortletPreferences

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.