Return-Path: Delivered-To: apmail-geronimo-scm-archive@www.apache.org Received: (qmail 32990 invoked from network); 26 Jul 2007 21:23:06 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 26 Jul 2007 21:23:06 -0000 Received: (qmail 20914 invoked by uid 500); 26 Jul 2007 21:23:06 -0000 Delivered-To: apmail-geronimo-scm-archive@geronimo.apache.org Received: (qmail 20876 invoked by uid 500); 26 Jul 2007 21:23:06 -0000 Mailing-List: contact scm-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@geronimo.apache.org List-Id: Delivered-To: mailing list scm@geronimo.apache.org Received: (qmail 20864 invoked by uid 99); 26 Jul 2007 21:23:06 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 26 Jul 2007 14:23:06 -0700 X-ASF-Spam-Status: No, hits=-99.5 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 26 Jul 2007 14:23:02 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 1DFBE1A9827; Thu, 26 Jul 2007 14:22:17 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r559986 [6/7] - in /geronimo/sandbox/portals: pluto-portal/src/assemble/ pluto-portal/src/assemble/config/ pluto-portal/src/main/resources/ pluto-portal/src/main/webapp/ pluto-portal/src/main/webapp/WEB-INF/ pluto-portal/src/main/webapp/WEB... Date: Thu, 26 Jul 2007 21:22:14 -0000 To: scm@geronimo.apache.org From: jbohn@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070726212217.1DFBE1A9827@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Modified: geronimo/sandbox/portals/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/ResourceBundleTest.java URL: http://svn.apache.org/viewvc/geronimo/sandbox/portals/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/ResourceBundleTest.java?view=diff&rev=559986&r1=559985&r2=559986 ============================================================================== --- geronimo/sandbox/portals/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/ResourceBundleTest.java (original) +++ geronimo/sandbox/portals/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/ResourceBundleTest.java Thu Jul 26 14:22:10 2007 @@ -1,235 +1,235 @@ -/* +/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.pluto.testsuite.test; - -import java.util.ArrayList; -import java.util.Enumeration; -import java.util.Iterator; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.ResourceBundle; - -import javax.portlet.PortletConfig; -import javax.portlet.PortletRequest; - -import org.apache.pluto.testsuite.TestResult; - -/** - * Tests basic attribute retrieval and storage functions within - * the portlet request, session, and context objects. - * - */ -public class ResourceBundleTest extends AbstractReflectivePortletTest { - - // Static Constant Definitions --------------------------------------------- - - /** Key for portlet title defined in portlet.xml/init-param. */ - private static final String TITLE_KEY = "javax.portlet.title"; - - /** Key for portlet short title defined in portlet.xml/init-param. */ - private static final String SHORT_TITLE_KEY = "javax.portlet.short-title"; - - /** Key for portlet keywords defined in portlet.xml/init-param. */ - private static final String KEYWORDS_KEY = "javax.portlet.keywords"; - - /** - * Parameter name for if resource bundle is declared in - * testsuite-config/init-param. - */ - private static final String BUNDLE_DECLARED_PARAM = "resource-bundle"; - - /** - * Parameter name for portlet title in - * testsuite-config/init-param. - */ - private static final String TITLE_PARAM = "title"; - - /** - * Parameter name for portlet short title in - * testsuite-config/init-param. - */ - private static final String SHORT_TITLE_PARAM = "short-title"; - - /** - * Parameter name for portlet keywords in - * testsuite-config/init-param. - */ - private static final String KEYWORDS_PARAM = "keywords"; - - - // Test Methods ------------------------------------------------------------ - - protected TestResult checkResourceBundleExists(PortletConfig config, - PortletRequest request) { - TestResult result = new TestResult(); - result.setDescription("Ensure the resource bundle is not null."); - - ResourceBundle bundle = config.getResourceBundle(request.getLocale()); - if (bundle != null) { - result.setReturnCode(TestResult.PASSED); - } else { - result.setReturnCode(TestResult.FAILED); - result.setResultMessage("Unable to retrieve resource bundle " - + "for locale: " + request.getLocale()); - } - return result; - } - - protected TestResult checkGetNames(PortletConfig config, - PortletRequest request) { - TestResult result = new TestResult(); - result.setDescription("Retrieve the property names and ensure that " - + "the required keys are present."); - - List requiredKeys = new ArrayList(); - requiredKeys.add(TITLE_KEY); - requiredKeys.add(SHORT_TITLE_KEY); - requiredKeys.add(KEYWORDS_KEY); - - ResourceBundle bundle = config.getResourceBundle(request.getLocale()); - if (bundle == null) { - result.setReturnCode(TestResult.WARNING); - result.setResultMessage("A function upon which this test depends " - + "failed to execute as expected. " - + "Check the other test results in this test suite."); - return result; - } - - for (Enumeration en = bundle.getKeys(); en.hasMoreElements(); ) { - String key = (String) en.nextElement(); - requiredKeys.remove(key); - } - - if (requiredKeys.isEmpty()) { - result.setReturnCode(TestResult.PASSED); - } else { - result.setReturnCode(TestResult.FAILED); - StringBuffer buffer = new StringBuffer(); - for (Iterator it = requiredKeys.iterator(); it.hasNext(); ) { - buffer.append(it.next()).append(", "); - } - result.setResultMessage("Required keys [" + buffer.toString() - + "] are missing in the resource bundle."); - } - return result; - } - - protected TestResult checkGetGermanBundle(PortletConfig config, - PortletRequest request) { - return doGenericLocaleRequiredFields(config, - request, - Locale.GERMAN); - } - - protected TestResult checkGetEnglishBundle(PortletConfig config, - PortletRequest request) { - return doGenericLocaleRequiredFields(config, - request, - Locale.ENGLISH); - } - - /* - protected TestResult checkGetDfltBundle(PortletConfig config, - PortletRequest req) { - return doGenericLocaleRequiredFields(config, req, new Locale("dflt")); - } - */ - - - // Private Methods --------------------------------------------------------- - - private TestResult doGenericLocaleRequiredFields(PortletConfig config, - PortletRequest request, - Locale locale) { - TestResult result = new TestResult(); - result.setDescription("Retrieve the title and ensure it's set properly " - + "under locale " + locale); - - // Retrieve title, short title and keywords from portlet resource bundle. - ResourceBundle bundle = config.getResourceBundle(locale); - if (bundle == null) { - result.setReturnCode(TestResult.WARNING); - result.setResultMessage("A function upon which this test depends " - + "failed to execute as expected. " - + "Check the other test results in this test suite."); - return result; - } - String title = bundle.getString(TITLE_KEY); - String shortTitle = bundle.getString(SHORT_TITLE_KEY); - String keywords = bundle.getString(KEYWORDS_KEY); - - // Retrieve expected title, short title and keywords from test config. - String suffix = isBundleDeclared() ? ("_" + locale.getLanguage()) : ""; - Map initParams = getInitParameters(); - String expectedTitle = (String) initParams.get( - TITLE_PARAM + suffix); - String expectedShortTitle = (String) initParams.get( - SHORT_TITLE_PARAM + suffix); - String expectedKeywords = (String) initParams.get( - KEYWORDS_PARAM + suffix); - - // Assert that values retrieved from resource bundler are expected. - boolean inconsistent = false; - StringBuffer buffer = new StringBuffer(); - buffer.append("The following information is not correct: "); - if (title == null || expectedTitle == null - || !title.trim().equals(expectedTitle.trim())) { - inconsistent = true; - buffer.append("Inconsistent title: '") - .append(title).append("' != '") - .append(expectedTitle).append("'; "); - } - if (shortTitle == null || expectedShortTitle == null - || !shortTitle.trim().equals(expectedShortTitle.trim())) { - inconsistent = true; - buffer.append("Inconsistent short title: '") - .append(shortTitle).append("' != '") - .append(expectedShortTitle).append("'; "); - } - if (keywords == null || expectedKeywords == null - || !keywords.trim().equals(expectedKeywords.trim())) { - inconsistent = true; - buffer.append("Inconsistent keywords: '") - .append(keywords).append("' != '") - .append(expectedKeywords).append("'; "); - } - - if (!inconsistent) { - result.setReturnCode(TestResult.PASSED); - } else { - result.setReturnCode(TestResult.FAILED); - result.setResultMessage(buffer.toString()); - } - return result; - } - - private boolean isBundleDeclared() { - String bundleDeclared = (String) getInitParameters().get( - BUNDLE_DECLARED_PARAM); - if (Boolean.TRUE.toString().equalsIgnoreCase(bundleDeclared)) { - return true; - } else { - return false; - } - } - - - - - -} + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.pluto.testsuite.test; + +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.Iterator; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.ResourceBundle; + +import javax.portlet.PortletConfig; +import javax.portlet.PortletRequest; + +import org.apache.pluto.testsuite.TestResult; + +/** + * Tests basic attribute retrieval and storage functions within + * the portlet request, session, and context objects. + * + */ +public class ResourceBundleTest extends AbstractReflectivePortletTest { + + // Static Constant Definitions --------------------------------------------- + + /** Key for portlet title defined in portlet.xml/init-param. */ + private static final String TITLE_KEY = "javax.portlet.title"; + + /** Key for portlet short title defined in portlet.xml/init-param. */ + private static final String SHORT_TITLE_KEY = "javax.portlet.short-title"; + + /** Key for portlet keywords defined in portlet.xml/init-param. */ + private static final String KEYWORDS_KEY = "javax.portlet.keywords"; + + /** + * Parameter name for if resource bundle is declared in + * testsuite-config/init-param. + */ + private static final String BUNDLE_DECLARED_PARAM = "resource-bundle"; + + /** + * Parameter name for portlet title in + * testsuite-config/init-param. + */ + private static final String TITLE_PARAM = "title"; + + /** + * Parameter name for portlet short title in + * testsuite-config/init-param. + */ + private static final String SHORT_TITLE_PARAM = "short-title"; + + /** + * Parameter name for portlet keywords in + * testsuite-config/init-param. + */ + private static final String KEYWORDS_PARAM = "keywords"; + + + // Test Methods ------------------------------------------------------------ + + protected TestResult checkResourceBundleExists(PortletConfig config, + PortletRequest request) { + TestResult result = new TestResult(); + result.setDescription("Ensure the resource bundle is not null."); + + ResourceBundle bundle = config.getResourceBundle(request.getLocale()); + if (bundle != null) { + result.setReturnCode(TestResult.PASSED); + } else { + result.setReturnCode(TestResult.FAILED); + result.setResultMessage("Unable to retrieve resource bundle " + + "for locale: " + request.getLocale()); + } + return result; + } + + protected TestResult checkGetNames(PortletConfig config, + PortletRequest request) { + TestResult result = new TestResult(); + result.setDescription("Retrieve the property names and ensure that " + + "the required keys are present."); + + List requiredKeys = new ArrayList(); + requiredKeys.add(TITLE_KEY); + requiredKeys.add(SHORT_TITLE_KEY); + requiredKeys.add(KEYWORDS_KEY); + + ResourceBundle bundle = config.getResourceBundle(request.getLocale()); + if (bundle == null) { + result.setReturnCode(TestResult.WARNING); + result.setResultMessage("A function upon which this test depends " + + "failed to execute as expected. " + + "Check the other test results in this test suite."); + return result; + } + + for (Enumeration en = bundle.getKeys(); en.hasMoreElements(); ) { + String key = (String) en.nextElement(); + requiredKeys.remove(key); + } + + if (requiredKeys.isEmpty()) { + result.setReturnCode(TestResult.PASSED); + } else { + result.setReturnCode(TestResult.FAILED); + StringBuffer buffer = new StringBuffer(); + for (Iterator it = requiredKeys.iterator(); it.hasNext(); ) { + buffer.append(it.next()).append(", "); + } + result.setResultMessage("Required keys [" + buffer.toString() + + "] are missing in the resource bundle."); + } + return result; + } + + protected TestResult checkGetGermanBundle(PortletConfig config, + PortletRequest request) { + return doGenericLocaleRequiredFields(config, + request, + Locale.GERMAN); + } + + protected TestResult checkGetEnglishBundle(PortletConfig config, + PortletRequest request) { + return doGenericLocaleRequiredFields(config, + request, + Locale.ENGLISH); + } + + /* + protected TestResult checkGetDfltBundle(PortletConfig config, + PortletRequest req) { + return doGenericLocaleRequiredFields(config, req, new Locale("dflt")); + } + */ + + + // Private Methods --------------------------------------------------------- + + private TestResult doGenericLocaleRequiredFields(PortletConfig config, + PortletRequest request, + Locale locale) { + TestResult result = new TestResult(); + result.setDescription("Retrieve the title and ensure it's set properly " + + "under locale " + locale); + + // Retrieve title, short title and keywords from portlet resource bundle. + ResourceBundle bundle = config.getResourceBundle(locale); + if (bundle == null) { + result.setReturnCode(TestResult.WARNING); + result.setResultMessage("A function upon which this test depends " + + "failed to execute as expected. " + + "Check the other test results in this test suite."); + return result; + } + String title = bundle.getString(TITLE_KEY); + String shortTitle = bundle.getString(SHORT_TITLE_KEY); + String keywords = bundle.getString(KEYWORDS_KEY); + + // Retrieve expected title, short title and keywords from test config. + String suffix = isBundleDeclared() ? ("_" + locale.getLanguage()) : ""; + Map initParams = getInitParameters(); + String expectedTitle = (String) initParams.get( + TITLE_PARAM + suffix); + String expectedShortTitle = (String) initParams.get( + SHORT_TITLE_PARAM + suffix); + String expectedKeywords = (String) initParams.get( + KEYWORDS_PARAM + suffix); + + // Assert that values retrieved from resource bundler are expected. + boolean inconsistent = false; + StringBuffer buffer = new StringBuffer(); + buffer.append("The following information is not correct: "); + if (title == null || expectedTitle == null + || !title.trim().equals(expectedTitle.trim())) { + inconsistent = true; + buffer.append("Inconsistent title: '") + .append(title).append("' != '") + .append(expectedTitle).append("'; "); + } + if (shortTitle == null || expectedShortTitle == null + || !shortTitle.trim().equals(expectedShortTitle.trim())) { + inconsistent = true; + buffer.append("Inconsistent short title: '") + .append(shortTitle).append("' != '") + .append(expectedShortTitle).append("'; "); + } + if (keywords == null || expectedKeywords == null + || !keywords.trim().equals(expectedKeywords.trim())) { + inconsistent = true; + buffer.append("Inconsistent keywords: '") + .append(keywords).append("' != '") + .append(expectedKeywords).append("'; "); + } + + if (!inconsistent) { + result.setReturnCode(TestResult.PASSED); + } else { + result.setReturnCode(TestResult.FAILED); + result.setResultMessage(buffer.toString()); + } + return result; + } + + private boolean isBundleDeclared() { + String bundleDeclared = (String) getInitParameters().get( + BUNDLE_DECLARED_PARAM); + if (Boolean.TRUE.toString().equalsIgnoreCase(bundleDeclared)) { + return true; + } else { + return false; + } + } + + + + + +} Propchange: geronimo/sandbox/portals/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/ResourceBundleTest.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: geronimo/sandbox/portals/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/SecurityMappingTest.java URL: http://svn.apache.org/viewvc/geronimo/sandbox/portals/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/SecurityMappingTest.java?view=diff&rev=559986&r1=559985&r2=559986 ============================================================================== --- geronimo/sandbox/portals/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/SecurityMappingTest.java (original) +++ geronimo/sandbox/portals/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/SecurityMappingTest.java Thu Jul 26 14:22:10 2007 @@ -1,95 +1,95 @@ -/* +/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.pluto.testsuite.test; - -import javax.portlet.PortletRequest; - -import org.apache.pluto.testsuite.TestResult; - -/** - */ -public class SecurityMappingTest extends AbstractReflectivePortletTest { - - // Test Methods ------------------------------------------------------------ - - protected TestResult checkIsUserInMappedRole(PortletRequest request) { - TestResult result = isUserLoggedIn(request); - result.setDescription("Test if user is in mapped role."); - if (result.getReturnCode() == TestResult.WARNING) { - return result; - } - - ExpectedResults expectedResults = ExpectedResults.getInstance(); - String role = expectedResults.getMappedSecurityRole(); - if (request.isUserInRole(role)) { - result.setReturnCode(TestResult.PASSED); - } else { - result.setReturnCode(TestResult.WARNING); - result.setResultMessage("User is not in the expected role: " + role - + ". This may be due to misconfiuration."); - } - return result; - } - - protected TestResult checkIsUserInUnmappedRole(PortletRequest request) { - TestResult result = isUserLoggedIn(request); - result.setDescription("Test if user is in unmapped role"); - if (result.getReturnCode() == TestResult.WARNING) { - return result; - } - - ExpectedResults expectedResults = ExpectedResults.getInstance(); - String role = expectedResults.getUnmappedSecurityRole(); - if (request.isUserInRole(role)) { - result.setReturnCode(TestResult.PASSED); - } else { - result.setReturnCode(TestResult.WARNING); - result.setResultMessage("User is not in the expected role: " + role - + ". This may be due to misconfiuration."); - } - return result; - } - - protected TestResult checkIsUserIndUndeclaredRole(PortletRequest request) { - TestResult result = isUserLoggedIn(request); - result.setDescription("Test if user is in undeclared role"); - if (result.getReturnCode() == TestResult.WARNING) { - return result; - } - - String fakeRole = "fakeTestRoleFooBar"; - if (!request.isUserInRole(fakeRole)) { - result.setReturnCode(TestResult.PASSED); - } else { - result.setReturnCode(TestResult.FAILED); - result.setResultMessage("User is in the fake role named " + fakeRole); - } - return result; - } - - - // Private Methods --------------------------------------------------------- - - private TestResult isUserLoggedIn(PortletRequest request) { - TestResult result = new TestResult(); - if (request.getRemoteUser() == null) { - result.setReturnCode(TestResult.WARNING); - result.setResultMessage("User is not logged in."); - } - return result; - } -} + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.pluto.testsuite.test; + +import javax.portlet.PortletRequest; + +import org.apache.pluto.testsuite.TestResult; + +/** + */ +public class SecurityMappingTest extends AbstractReflectivePortletTest { + + // Test Methods ------------------------------------------------------------ + + protected TestResult checkIsUserInMappedRole(PortletRequest request) { + TestResult result = isUserLoggedIn(request); + result.setDescription("Test if user is in mapped role."); + if (result.getReturnCode() == TestResult.WARNING) { + return result; + } + + ExpectedResults expectedResults = ExpectedResults.getInstance(); + String role = expectedResults.getMappedSecurityRole(); + if (request.isUserInRole(role)) { + result.setReturnCode(TestResult.PASSED); + } else { + result.setReturnCode(TestResult.WARNING); + result.setResultMessage("User is not in the expected role: " + role + + ". This may be due to misconfiuration."); + } + return result; + } + + protected TestResult checkIsUserInUnmappedRole(PortletRequest request) { + TestResult result = isUserLoggedIn(request); + result.setDescription("Test if user is in unmapped role"); + if (result.getReturnCode() == TestResult.WARNING) { + return result; + } + + ExpectedResults expectedResults = ExpectedResults.getInstance(); + String role = expectedResults.getUnmappedSecurityRole(); + if (request.isUserInRole(role)) { + result.setReturnCode(TestResult.PASSED); + } else { + result.setReturnCode(TestResult.WARNING); + result.setResultMessage("User is not in the expected role: " + role + + ". This may be due to misconfiuration."); + } + return result; + } + + protected TestResult checkIsUserIndUndeclaredRole(PortletRequest request) { + TestResult result = isUserLoggedIn(request); + result.setDescription("Test if user is in undeclared role"); + if (result.getReturnCode() == TestResult.WARNING) { + return result; + } + + String fakeRole = "fakeTestRoleFooBar"; + if (!request.isUserInRole(fakeRole)) { + result.setReturnCode(TestResult.PASSED); + } else { + result.setReturnCode(TestResult.FAILED); + result.setResultMessage("User is in the fake role named " + fakeRole); + } + return result; + } + + + // Private Methods --------------------------------------------------------- + + private TestResult isUserLoggedIn(PortletRequest request) { + TestResult result = new TestResult(); + if (request.getRemoteUser() == null) { + result.setReturnCode(TestResult.WARNING); + result.setResultMessage("User is not logged in."); + } + return result; + } +} Propchange: geronimo/sandbox/portals/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/SecurityMappingTest.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: geronimo/sandbox/portals/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/SessionTimeoutTest.java URL: http://svn.apache.org/viewvc/geronimo/sandbox/portals/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/SessionTimeoutTest.java?view=diff&rev=559986&r1=559985&r2=559986 ============================================================================== --- geronimo/sandbox/portals/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/SessionTimeoutTest.java (original) +++ geronimo/sandbox/portals/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/SessionTimeoutTest.java Thu Jul 26 14:22:10 2007 @@ -1,99 +1,99 @@ -/* +/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.pluto.testsuite.test; - -import javax.portlet.PortletRequest; -import javax.portlet.PortletSession; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.pluto.testsuite.TestResult; - -public class SessionTimeoutTest extends AbstractReflectivePortletTest { - - /** Logger. */ - private static final Log LOG = LogFactory.getLog(SessionTimeoutTest.class); - - /** - * Render parameter name indicating if the max inactive interval is set to - * the portlet session or not. - */ - private static final String MAX_INACTIVE_INTERVAL_SET = "maxInactiveIntervalSet"; - - - // Test Methods ------------------------------------------------------------ - - protected TestResult checkSessionInvalidated(PortletRequest request) { - TestResult result = new TestResult(); - result.setDescription("Ensure portlet session is invalidated after " - + "the max inactive interval."); - result.setSpecPLT("15.6"); - - // Check if max inactive interval is set to the portlet session. - String maxInactiveIntervalSet = request.getParameter( - MAX_INACTIVE_INTERVAL_SET); - if (LOG.isDebugEnabled()) { - LOG.debug("Retrieved render parameter: " + MAX_INACTIVE_INTERVAL_SET - + " = " + maxInactiveIntervalSet); - } - - // If the max inactive interval is set to portlet session, the portlet - // session should have been invalidated by the container. - if (Boolean.TRUE.toString().equals(maxInactiveIntervalSet)) { - if (LOG.isDebugEnabled()) { - LOG.debug("Max inactive interval is set to portlet session: " - + "portlet session should have expired " - + "(current time millis: " - + System.currentTimeMillis() + ")..."); - } - PortletSession session = request.getPortletSession(false); - if (session == null) { - result.setReturnCode(TestResult.PASSED); - } else { - result.setReturnCode(TestResult.FAILED); - result.setResultMessage("PortletSession should have expired " - + "and have been invalidated, but is still available. " - + "Make sure that other portlets did not create a new " - + "portlet session."); - } - } - - // If the max inactive interval is not set to portlet session, set its - // value to 5 (seconds). In this way, next time the test portlet is - // rendered, the portlet session should have been invalidated. - else { - if (LOG.isDebugEnabled()) { - LOG.debug("Max inactive interval is not set to portlet session: " - + "setting to 5 seconds (current time millis: " - + System.currentTimeMillis() + ")..."); - } - PortletSession session = request.getPortletSession(true); - session.setMaxInactiveInterval(5); - result.setReturnCode(TestResult.WARNING); - result.setResultMessage("Click the provided link to validate test."); - } - - // Return the test result: - // PASSED - the test is passed. - // FAILED - the test is failed. - // WARNING - the test requires manual intervention. - return result; - } - -} - - + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.pluto.testsuite.test; + +import javax.portlet.PortletRequest; +import javax.portlet.PortletSession; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.pluto.testsuite.TestResult; + +public class SessionTimeoutTest extends AbstractReflectivePortletTest { + + /** Logger. */ + private static final Log LOG = LogFactory.getLog(SessionTimeoutTest.class); + + /** + * Render parameter name indicating if the max inactive interval is set to + * the portlet session or not. + */ + private static final String MAX_INACTIVE_INTERVAL_SET = "maxInactiveIntervalSet"; + + + // Test Methods ------------------------------------------------------------ + + protected TestResult checkSessionInvalidated(PortletRequest request) { + TestResult result = new TestResult(); + result.setDescription("Ensure portlet session is invalidated after " + + "the max inactive interval."); + result.setSpecPLT("15.6"); + + // Check if max inactive interval is set to the portlet session. + String maxInactiveIntervalSet = request.getParameter( + MAX_INACTIVE_INTERVAL_SET); + if (LOG.isDebugEnabled()) { + LOG.debug("Retrieved render parameter: " + MAX_INACTIVE_INTERVAL_SET + + " = " + maxInactiveIntervalSet); + } + + // If the max inactive interval is set to portlet session, the portlet + // session should have been invalidated by the container. + if (Boolean.TRUE.toString().equals(maxInactiveIntervalSet)) { + if (LOG.isDebugEnabled()) { + LOG.debug("Max inactive interval is set to portlet session: " + + "portlet session should have expired " + + "(current time millis: " + + System.currentTimeMillis() + ")..."); + } + PortletSession session = request.getPortletSession(false); + if (session == null) { + result.setReturnCode(TestResult.PASSED); + } else { + result.setReturnCode(TestResult.FAILED); + result.setResultMessage("PortletSession should have expired " + + "and have been invalidated, but is still available. " + + "Make sure that other portlets did not create a new " + + "portlet session."); + } + } + + // If the max inactive interval is not set to portlet session, set its + // value to 5 (seconds). In this way, next time the test portlet is + // rendered, the portlet session should have been invalidated. + else { + if (LOG.isDebugEnabled()) { + LOG.debug("Max inactive interval is not set to portlet session: " + + "setting to 5 seconds (current time millis: " + + System.currentTimeMillis() + ")..."); + } + PortletSession session = request.getPortletSession(true); + session.setMaxInactiveInterval(5); + result.setReturnCode(TestResult.WARNING); + result.setResultMessage("Click the provided link to validate test."); + } + + // Return the test result: + // PASSED - the test is passed. + // FAILED - the test is failed. + // WARNING - the test requires manual intervention. + return result; + } + +} + + Propchange: geronimo/sandbox/portals/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/SessionTimeoutTest.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: geronimo/sandbox/portals/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/SimpleAttributeTest.java URL: http://svn.apache.org/viewvc/geronimo/sandbox/portals/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/SimpleAttributeTest.java?view=diff&rev=559986&r1=559985&r2=559986 ============================================================================== --- geronimo/sandbox/portals/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/SimpleAttributeTest.java (original) +++ geronimo/sandbox/portals/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/SimpleAttributeTest.java Thu Jul 26 14:22:10 2007 @@ -1,289 +1,289 @@ -/* +/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.pluto.testsuite.test; - -import org.apache.pluto.testsuite.TestResult; -import org.apache.pluto.testsuite.TestUtils; - -import java.util.Enumeration; - -import javax.portlet.PortletContext; -import javax.portlet.PortletRequest; -import javax.portlet.PortletSession; - -/** - * Tests basic attribute retrieval and storage functions within the portlet - * request, session, and context objects. - * - */ -public class SimpleAttributeTest extends AbstractReflectivePortletTest { - - private static final String KEY = "org.apache.pluto.testsuite.BOGUS_KEY"; - private static final String VAL = "! TEST VAL !"; - - - // Test Methods ------------------------------------------------------------ - - protected TestResult checkGetNullAttribute(PortletRequest req) { - TestResult result = new TestResult(); - result.setDescription("Ensure that if an attribute bound to an invalid " - + "key is retrieved, null is returned."); - - Object val = req.getAttribute(KEY); - if (val == null) { - result.setReturnCode(TestResult.PASSED); - } else { - TestUtils.failOnAssertion("unbound attribute", val, null, result); - } - return result; - } - - - protected TestResult checkSetAttribute(PortletRequest req) { - TestResult result = new TestResult(); - result.setDescription("Ensure that attributes can be set to " - + "portlet request."); - - req.setAttribute(KEY, VAL); - Object val = req.getAttribute(KEY); - if (VAL.equals(val)) { - result.setReturnCode(TestResult.PASSED); - } else { - TestUtils.failOnAssertion("attribute", val, VAL, result); - } - - req.removeAttribute(KEY); - return result; - } - - protected TestResult checkRemoveAttribute(PortletRequest req) { - TestResult result = new TestResult(); - result.setDescription("Ensure that attributes can be removed from " - + "portlet request."); - - req.setAttribute(KEY, VAL); - req.removeAttribute(KEY); - Object val = req.getAttribute(KEY); - if (val == null) { - result.setReturnCode(TestResult.PASSED); - } else { - TestUtils.failOnAssertion("removed attribute", val, null, result); - } - return result; - } - - protected TestResult checkEnumerateAttributes(PortletRequest req) { - TestResult result = new TestResult(); - result.setDescription("Ensure that all attribute names appear in the " - + "attribute name enumeration returned by portlet request."); - - int count = 5; - for (int i = 0; i < count; i++) { - req.setAttribute(KEY + "." + i, VAL); - } - - int found = 0; - for (Enumeration en = req.getAttributeNames(); - en.hasMoreElements(); ) { - if (en.nextElement().toString().startsWith(KEY)) { - found++; - } - } - - if (count == found) { - result.setReturnCode(TestResult.PASSED); - } else { - TestUtils.failOnAssertion("count of attribute names", - String.valueOf(found), String.valueOf(count), result); - } - return result; - } - - - // Test Methods for Session Attributes ------------------------------------- - - protected TestResult checkGetNullAttribute(PortletSession session) { - TestResult res = new TestResult(); - res.setName("Retrieve Missing Session Attribute Test"); - res.setDescription("Retrieves an attribute bound to an invalid key set are retrieved as null"); - - Object val = session.getAttribute(KEY); - if(val != null) { - res.setReturnCode(TestResult.FAILED); - res.setResultMessage("Retrieved value: '"+val+"' for attribute '"+KEY+"'"); - } - else { - res.setReturnCode(TestResult.PASSED); - } - return res; - } - - protected TestResult checkSetAttribute(PortletSession session) { - TestResult res = new TestResult(); - res.setName("Set Attribute Test"); - res.setDescription("Sets and retrieves portlet sessionuest attribute."); - - session.setAttribute(KEY, VAL); - Object val = session.getAttribute(KEY); - if(!VAL.equals(val)) { - res.setReturnCode(TestResult.FAILED); - res.setResultMessage("Retrieved value: '"+val+"' - Expected '"+VAL+"'"); - } - else { - res.setReturnCode(TestResult.PASSED); - } - - session.removeAttribute(KEY); - return res; - } - - protected TestResult checkRemoveAttribute(PortletSession session) { - TestResult res = new TestResult(); - res.setName("Remove Session Attribute Test"); - res.setDescription("Sets, removes and retrieves portlet request attribute."); - - session.setAttribute(KEY, VAL); - session.removeAttribute(KEY); - Object val = session.getAttribute(KEY); - if(val!=null) { - res.setReturnCode(TestResult.FAILED); - res.setResultMessage("Retrieved value: '"+val+"' - Expected '"+VAL+"'"); - } - else { - res.setReturnCode(TestResult.PASSED); - } - - return res; - } - - protected TestResult checkEnumerateAttributes(PortletSession session) { - - TestResult result = new TestResult(); - result.setDescription("Sets session attributes and enumerates over them."); - - int count = 5; - for (int i = 0; i < count; i++) { - session.setAttribute(KEY + "." + i, VAL); - } - - int found = 0; - for (Enumeration en = session.getAttributeNames(); - en.hasMoreElements(); ) { - String name = (String) en.nextElement(); - if (name.startsWith(KEY)) { - found++; - } - } - - if (count != found) { - result.setReturnCode(TestResult.FAILED); - result.setResultMessage("Expected " + count + " attributes. " - + "Found " + found); - } else { - result.setReturnCode(TestResult.PASSED); - } - return result; - } - -// -// Context Tests -// - - protected TestResult checkGetNullAttribute(PortletContext context) { - TestResult res = new TestResult(); - res.setName("Retrieve Missing Context Attribute Test"); - res.setDescription("Retrieves an attribute bound to an invalid key set are retrieved as null"); - - Object val = context.getAttribute(KEY); - if(val != null) { - res.setReturnCode(TestResult.FAILED); - res.setResultMessage("Retrieved value: '"+val+"' for attribute '"+KEY+"'"); - } - else { - res.setReturnCode(TestResult.PASSED); - } - return res; - } - - protected TestResult checkSetAttribute(PortletContext context) { - TestResult res = new TestResult(); - res.setName("Set Attribute Test"); - res.setDescription("Sets and retrieves portlet contextuest attribute."); - - context.setAttribute(KEY, VAL); - Object val = context.getAttribute(KEY); - if(!VAL.equals(val)) { - res.setReturnCode(TestResult.FAILED); - res.setResultMessage("Retrieved value: '"+val+"' - Expected '"+VAL+"'"); - } - else { - res.setReturnCode(TestResult.PASSED); - } - - context.removeAttribute(KEY); - return res; - } - - protected TestResult checkRemoveAttribute(PortletContext context) { - TestResult res = new TestResult(); - res.setName("Remove Context Attribute Test"); - res.setDescription("Sets, removes and retrieves portlet request attribute."); - - context.setAttribute(KEY, VAL); - context.removeAttribute(KEY); - Object val = context.getAttribute(KEY); - if(val!=null) { - res.setReturnCode(TestResult.FAILED); - res.setResultMessage("Retrieved value: '"+val+"' - Expected '"+VAL+"'"); - } - else { - res.setReturnCode(TestResult.PASSED); - } - - return res; - } - - protected TestResult checkEnumerateAttributesInContext( - PortletContext context) { - TestResult result = new TestResult(); - result.setDescription("Sets attributes in portlet context " - + "and enumerates over them."); - - int count = 5; - for (int i = 0; i < count; i++) { - context.setAttribute(KEY + "." + i, VAL); - } - - int found = 0; - for (Enumeration en = context.getAttributeNames(); - en.hasMoreElements(); ) { - if (en.nextElement().toString().startsWith(KEY)) { - found++; - } - } - - if (count == found) { - result.setReturnCode(TestResult.PASSED); - } else { - result.setReturnCode(TestResult.FAILED); - result.setResultMessage("Expected " + count + " attributes. " - + "Found " + found); - } - return result; - } - -} + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.pluto.testsuite.test; + +import org.apache.pluto.testsuite.TestResult; +import org.apache.pluto.testsuite.TestUtils; + +import java.util.Enumeration; + +import javax.portlet.PortletContext; +import javax.portlet.PortletRequest; +import javax.portlet.PortletSession; + +/** + * Tests basic attribute retrieval and storage functions within the portlet + * request, session, and context objects. + * + */ +public class SimpleAttributeTest extends AbstractReflectivePortletTest { + + private static final String KEY = "org.apache.pluto.testsuite.BOGUS_KEY"; + private static final String VAL = "! TEST VAL !"; + + + // Test Methods ------------------------------------------------------------ + + protected TestResult checkGetNullAttribute(PortletRequest req) { + TestResult result = new TestResult(); + result.setDescription("Ensure that if an attribute bound to an invalid " + + "key is retrieved, null is returned."); + + Object val = req.getAttribute(KEY); + if (val == null) { + result.setReturnCode(TestResult.PASSED); + } else { + TestUtils.failOnAssertion("unbound attribute", val, null, result); + } + return result; + } + + + protected TestResult checkSetAttribute(PortletRequest req) { + TestResult result = new TestResult(); + result.setDescription("Ensure that attributes can be set to " + + "portlet request."); + + req.setAttribute(KEY, VAL); + Object val = req.getAttribute(KEY); + if (VAL.equals(val)) { + result.setReturnCode(TestResult.PASSED); + } else { + TestUtils.failOnAssertion("attribute", val, VAL, result); + } + + req.removeAttribute(KEY); + return result; + } + + protected TestResult checkRemoveAttribute(PortletRequest req) { + TestResult result = new TestResult(); + result.setDescription("Ensure that attributes can be removed from " + + "portlet request."); + + req.setAttribute(KEY, VAL); + req.removeAttribute(KEY); + Object val = req.getAttribute(KEY); + if (val == null) { + result.setReturnCode(TestResult.PASSED); + } else { + TestUtils.failOnAssertion("removed attribute", val, null, result); + } + return result; + } + + protected TestResult checkEnumerateAttributes(PortletRequest req) { + TestResult result = new TestResult(); + result.setDescription("Ensure that all attribute names appear in the " + + "attribute name enumeration returned by portlet request."); + + int count = 5; + for (int i = 0; i < count; i++) { + req.setAttribute(KEY + "." + i, VAL); + } + + int found = 0; + for (Enumeration en = req.getAttributeNames(); + en.hasMoreElements(); ) { + if (en.nextElement().toString().startsWith(KEY)) { + found++; + } + } + + if (count == found) { + result.setReturnCode(TestResult.PASSED); + } else { + TestUtils.failOnAssertion("count of attribute names", + String.valueOf(found), String.valueOf(count), result); + } + return result; + } + + + // Test Methods for Session Attributes ------------------------------------- + + protected TestResult checkGetNullAttribute(PortletSession session) { + TestResult res = new TestResult(); + res.setName("Retrieve Missing Session Attribute Test"); + res.setDescription("Retrieves an attribute bound to an invalid key set are retrieved as null"); + + Object val = session.getAttribute(KEY); + if(val != null) { + res.setReturnCode(TestResult.FAILED); + res.setResultMessage("Retrieved value: '"+val+"' for attribute '"+KEY+"'"); + } + else { + res.setReturnCode(TestResult.PASSED); + } + return res; + } + + protected TestResult checkSetAttribute(PortletSession session) { + TestResult res = new TestResult(); + res.setName("Set Attribute Test"); + res.setDescription("Sets and retrieves portlet sessionuest attribute."); + + session.setAttribute(KEY, VAL); + Object val = session.getAttribute(KEY); + if(!VAL.equals(val)) { + res.setReturnCode(TestResult.FAILED); + res.setResultMessage("Retrieved value: '"+val+"' - Expected '"+VAL+"'"); + } + else { + res.setReturnCode(TestResult.PASSED); + } + + session.removeAttribute(KEY); + return res; + } + + protected TestResult checkRemoveAttribute(PortletSession session) { + TestResult res = new TestResult(); + res.setName("Remove Session Attribute Test"); + res.setDescription("Sets, removes and retrieves portlet request attribute."); + + session.setAttribute(KEY, VAL); + session.removeAttribute(KEY); + Object val = session.getAttribute(KEY); + if(val!=null) { + res.setReturnCode(TestResult.FAILED); + res.setResultMessage("Retrieved value: '"+val+"' - Expected '"+VAL+"'"); + } + else { + res.setReturnCode(TestResult.PASSED); + } + + return res; + } + + protected TestResult checkEnumerateAttributes(PortletSession session) { + + TestResult result = new TestResult(); + result.setDescription("Sets session attributes and enumerates over them."); + + int count = 5; + for (int i = 0; i < count; i++) { + session.setAttribute(KEY + "." + i, VAL); + } + + int found = 0; + for (Enumeration en = session.getAttributeNames(); + en.hasMoreElements(); ) { + String name = (String) en.nextElement(); + if (name.startsWith(KEY)) { + found++; + } + } + + if (count != found) { + result.setReturnCode(TestResult.FAILED); + result.setResultMessage("Expected " + count + " attributes. " + + "Found " + found); + } else { + result.setReturnCode(TestResult.PASSED); + } + return result; + } + +// +// Context Tests +// + + protected TestResult checkGetNullAttribute(PortletContext context) { + TestResult res = new TestResult(); + res.setName("Retrieve Missing Context Attribute Test"); + res.setDescription("Retrieves an attribute bound to an invalid key set are retrieved as null"); + + Object val = context.getAttribute(KEY); + if(val != null) { + res.setReturnCode(TestResult.FAILED); + res.setResultMessage("Retrieved value: '"+val+"' for attribute '"+KEY+"'"); + } + else { + res.setReturnCode(TestResult.PASSED); + } + return res; + } + + protected TestResult checkSetAttribute(PortletContext context) { + TestResult res = new TestResult(); + res.setName("Set Attribute Test"); + res.setDescription("Sets and retrieves portlet contextuest attribute."); + + context.setAttribute(KEY, VAL); + Object val = context.getAttribute(KEY); + if(!VAL.equals(val)) { + res.setReturnCode(TestResult.FAILED); + res.setResultMessage("Retrieved value: '"+val+"' - Expected '"+VAL+"'"); + } + else { + res.setReturnCode(TestResult.PASSED); + } + + context.removeAttribute(KEY); + return res; + } + + protected TestResult checkRemoveAttribute(PortletContext context) { + TestResult res = new TestResult(); + res.setName("Remove Context Attribute Test"); + res.setDescription("Sets, removes and retrieves portlet request attribute."); + + context.setAttribute(KEY, VAL); + context.removeAttribute(KEY); + Object val = context.getAttribute(KEY); + if(val!=null) { + res.setReturnCode(TestResult.FAILED); + res.setResultMessage("Retrieved value: '"+val+"' - Expected '"+VAL+"'"); + } + else { + res.setReturnCode(TestResult.PASSED); + } + + return res; + } + + protected TestResult checkEnumerateAttributesInContext( + PortletContext context) { + TestResult result = new TestResult(); + result.setDescription("Sets attributes in portlet context " + + "and enumerates over them."); + + int count = 5; + for (int i = 0; i < count; i++) { + context.setAttribute(KEY + "." + i, VAL); + } + + int found = 0; + for (Enumeration en = context.getAttributeNames(); + en.hasMoreElements(); ) { + if (en.nextElement().toString().startsWith(KEY)) { + found++; + } + } + + if (count == found) { + result.setReturnCode(TestResult.PASSED); + } else { + result.setReturnCode(TestResult.FAILED); + result.setResultMessage("Expected " + count + " attributes. " + + "Found " + found); + } + return result; + } + +} Propchange: geronimo/sandbox/portals/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/SimpleAttributeTest.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: geronimo/sandbox/portals/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/validator/PreferencesValidatorImpl.java URL: http://svn.apache.org/viewvc/geronimo/sandbox/portals/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/validator/PreferencesValidatorImpl.java?view=diff&rev=559986&r1=559985&r2=559986 ============================================================================== --- geronimo/sandbox/portals/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/validator/PreferencesValidatorImpl.java (original) +++ geronimo/sandbox/portals/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/validator/PreferencesValidatorImpl.java Thu Jul 26 14:22:10 2007 @@ -1,131 +1,131 @@ -/* +/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.pluto.testsuite.validator; - -import javax.portlet.PortletPreferences; -import javax.portlet.PreferencesValidator; -import javax.portlet.ValidatorException; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.Map; - -/** - * Implementation of the portlet preferences validator. - */ -public class PreferencesValidatorImpl implements PreferencesValidator { - - /** Logger. */ - private static final Log LOG = LogFactory.getLog(PreferencesValidatorImpl.class); - - public static final String CHECK_VALIDATOR_COUNT = "checkValidatorCount"; - - /** Count of instances created. */ - private static final Map INSTANCE_COUNTER = new HashMap(); - - /** Count of invocation number of method validate(). */ - private int validateInvoked = 0; - - // Constructor ------------------------------------------------------------- - - /** - * Default no-arg constructor. - */ - public PreferencesValidatorImpl() { - if (LOG.isDebugEnabled()) { - LOG.debug("Creating validator instance: " + getClass().getName()); - } - Integer count = (Integer) INSTANCE_COUNTER.get(getClass().getName()); - if (count == null) { - count = new Integer(1); - } else { - count = new Integer(count.intValue() + 1); - } - INSTANCE_COUNTER.put(getClass().getName(), count); - } - - - // PreferencesValidator Impl ----------------------------------------------- - - public void validate(PortletPreferences preferences) - throws ValidatorException { - validateInvoked++; - String value = preferences.getValue(CHECK_VALIDATOR_COUNT, null); - if (value != null && value.equalsIgnoreCase("true")) { - checkValidatorCount(); - } - - // - // TODO: Determine why we use this - I seem to remember it's a - // spec requirement, and fix it so that we don't have issues - // anymore. When enabled, all preferences fail in testsuite. - // - final String[] DEFAULT_VALUES = new String[] { "no values" }; - Collection failedNames = new ArrayList(); - for (Enumeration en = preferences.getNames(); en.hasMoreElements(); ) { - String name = (String) en.nextElement(); - String[] values = preferences.getValues(name, DEFAULT_VALUES); - if (values != null) { // null values are allowed - for (int i = 0; i < values.length; i++) { - if (values[i] != null) { // null values are allowed - // Validate that the preferences do not - // start or end with white spaces. - if (!values[i].equals(values[i].trim())) { - if (LOG.isDebugEnabled()) { - LOG.debug("Validation failed: " - + "value has white spaces: " - + "name=" + name - + "; value=|" + values[i] + "|"); - } - failedNames.add(name); - } - } - } - } - } - - if (!failedNames.isEmpty()) { - throw new ValidatorException( - "One or more preferences do not pass the validation.", - failedNames); - } - } - - private void checkValidatorCount() throws ValidatorException { - if (LOG.isDebugEnabled()) { - LOG.debug("Checking validator count..."); - } - Integer instanceCreated = (Integer) INSTANCE_COUNTER.get( - getClass().getName()); - if (LOG.isDebugEnabled()) { - LOG.debug("Method validate() invoked " + validateInvoked + " times."); - LOG.debug("Validator created " + instanceCreated.intValue() + " times."); - } - if (instanceCreated.intValue() != 1) { - throw new ValidatorException(instanceCreated.toString() - + " validator instances were created, " - + "expected 1 validator instance per portlet definition.", - null); - } - } - -} + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.pluto.testsuite.validator; + +import javax.portlet.PortletPreferences; +import javax.portlet.PreferencesValidator; +import javax.portlet.ValidatorException; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Map; + +/** + * Implementation of the portlet preferences validator. + */ +public class PreferencesValidatorImpl implements PreferencesValidator { + + /** Logger. */ + private static final Log LOG = LogFactory.getLog(PreferencesValidatorImpl.class); + + public static final String CHECK_VALIDATOR_COUNT = "checkValidatorCount"; + + /** Count of instances created. */ + private static final Map INSTANCE_COUNTER = new HashMap(); + + /** Count of invocation number of method validate(). */ + private int validateInvoked = 0; + + // Constructor ------------------------------------------------------------- + + /** + * Default no-arg constructor. + */ + public PreferencesValidatorImpl() { + if (LOG.isDebugEnabled()) { + LOG.debug("Creating validator instance: " + getClass().getName()); + } + Integer count = (Integer) INSTANCE_COUNTER.get(getClass().getName()); + if (count == null) { + count = new Integer(1); + } else { + count = new Integer(count.intValue() + 1); + } + INSTANCE_COUNTER.put(getClass().getName(), count); + } + + + // PreferencesValidator Impl ----------------------------------------------- + + public void validate(PortletPreferences preferences) + throws ValidatorException { + validateInvoked++; + String value = preferences.getValue(CHECK_VALIDATOR_COUNT, null); + if (value != null && value.equalsIgnoreCase("true")) { + checkValidatorCount(); + } + + // + // TODO: Determine why we use this - I seem to remember it's a + // spec requirement, and fix it so that we don't have issues + // anymore. When enabled, all preferences fail in testsuite. + // + final String[] DEFAULT_VALUES = new String[] { "no values" }; + Collection failedNames = new ArrayList(); + for (Enumeration en = preferences.getNames(); en.hasMoreElements(); ) { + String name = (String) en.nextElement(); + String[] values = preferences.getValues(name, DEFAULT_VALUES); + if (values != null) { // null values are allowed + for (int i = 0; i < values.length; i++) { + if (values[i] != null) { // null values are allowed + // Validate that the preferences do not + // start or end with white spaces. + if (!values[i].equals(values[i].trim())) { + if (LOG.isDebugEnabled()) { + LOG.debug("Validation failed: " + + "value has white spaces: " + + "name=" + name + + "; value=|" + values[i] + "|"); + } + failedNames.add(name); + } + } + } + } + } + + if (!failedNames.isEmpty()) { + throw new ValidatorException( + "One or more preferences do not pass the validation.", + failedNames); + } + } + + private void checkValidatorCount() throws ValidatorException { + if (LOG.isDebugEnabled()) { + LOG.debug("Checking validator count..."); + } + Integer instanceCreated = (Integer) INSTANCE_COUNTER.get( + getClass().getName()); + if (LOG.isDebugEnabled()) { + LOG.debug("Method validate() invoked " + validateInvoked + " times."); + LOG.debug("Validator created " + instanceCreated.intValue() + " times."); + } + if (instanceCreated.intValue() != 1) { + throw new ValidatorException(instanceCreated.toString() + + " validator instances were created, " + + "expected 1 validator instance per portlet definition.", + null); + } + } + +} Propchange: geronimo/sandbox/portals/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/validator/PreferencesValidatorImpl.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: geronimo/sandbox/portals/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/validator/PreferencesValidatorImpl2.java URL: http://svn.apache.org/viewvc/geronimo/sandbox/portals/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/validator/PreferencesValidatorImpl2.java?view=diff&rev=559986&r1=559985&r2=559986 ============================================================================== --- geronimo/sandbox/portals/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/validator/PreferencesValidatorImpl2.java (original) +++ geronimo/sandbox/portals/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/validator/PreferencesValidatorImpl2.java Thu Jul 26 14:22:10 2007 @@ -1,21 +1,21 @@ -/* +/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.pluto.testsuite.validator; - -public class PreferencesValidatorImpl2 extends PreferencesValidatorImpl { - -} + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.pluto.testsuite.validator; + +public class PreferencesValidatorImpl2 extends PreferencesValidatorImpl { + +} Propchange: geronimo/sandbox/portals/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/validator/PreferencesValidatorImpl2.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: geronimo/sandbox/portals/pluto-testsuite/src/main/resources/testsuite.xml URL: http://svn.apache.org/viewvc/geronimo/sandbox/portals/pluto-testsuite/src/main/resources/testsuite.xml?view=diff&rev=559986&r1=559985&r2=559986 ============================================================================== --- geronimo/sandbox/portals/pluto-testsuite/src/main/resources/testsuite.xml (original) +++ geronimo/sandbox/portals/pluto-testsuite/src/main/resources/testsuite.xml Thu Jul 26 14:22:10 2007 @@ -1,20 +1,20 @@ - - - +the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +implied. + +See the License for the specific language governing permissions and +limitations under the License. +--> + + Propchange: geronimo/sandbox/portals/pluto-testsuite/src/main/resources/testsuite.xml ------------------------------------------------------------------------------ svn:eol-style = native Modified: geronimo/sandbox/portals/pluto-testsuite/src/main/webapp/WEB-INF/classes/TestPortlet.properties URL: http://svn.apache.org/viewvc/geronimo/sandbox/portals/pluto-testsuite/src/main/webapp/WEB-INF/classes/TestPortlet.properties?view=diff&rev=559986&r1=559985&r2=559986 ============================================================================== --- geronimo/sandbox/portals/pluto-testsuite/src/main/webapp/WEB-INF/classes/TestPortlet.properties (original) +++ geronimo/sandbox/portals/pluto-testsuite/src/main/webapp/WEB-INF/classes/TestPortlet.properties Thu Jul 26 14:22:10 2007 @@ -1,27 +1,27 @@ -# +# # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -# implied. -# -# See the License for the specific language governing permissions and -# limitations under the License. -# -# - -javax.portlet.title=Test Portlet 2 (dflt) -javax.portlet.short-title=Test 2 (dflt) -javax.portlet.keywords=Test,Testing - -org.apache.pluto.testsuite.resource_bundle_test=true; - - +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# +# See the License for the specific language governing permissions and +# limitations under the License. +# +# + +javax.portlet.title=Test Portlet 2 (dflt) +javax.portlet.short-title=Test 2 (dflt) +javax.portlet.keywords=Test,Testing + +org.apache.pluto.testsuite.resource_bundle_test=true; + + Propchange: geronimo/sandbox/portals/pluto-testsuite/src/main/webapp/WEB-INF/classes/TestPortlet.properties ------------------------------------------------------------------------------ svn:eol-style = native Modified: geronimo/sandbox/portals/pluto-testsuite/src/main/webapp/WEB-INF/classes/TestPortlet_de.properties URL: http://svn.apache.org/viewvc/geronimo/sandbox/portals/pluto-testsuite/src/main/webapp/WEB-INF/classes/TestPortlet_de.properties?view=diff&rev=559986&r1=559985&r2=559986 ============================================================================== --- geronimo/sandbox/portals/pluto-testsuite/src/main/webapp/WEB-INF/classes/TestPortlet_de.properties (original) +++ geronimo/sandbox/portals/pluto-testsuite/src/main/webapp/WEB-INF/classes/TestPortlet_de.properties Thu Jul 26 14:22:10 2007 @@ -1,22 +1,22 @@ -# +# # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -# implied. -# -# See the License for the specific language governing permissions and -# limitations under the License. -# -# -javax.portlet.title = Test Portlet 2 (de) -javax.portlet.short-title = Test 2 (de) -javax.portlet.keywords = Test,Testen +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# +# See the License for the specific language governing permissions and +# limitations under the License. +# +# +javax.portlet.title = Test Portlet 2 (de) +javax.portlet.short-title = Test 2 (de) +javax.portlet.keywords = Test,Testen Propchange: geronimo/sandbox/portals/pluto-testsuite/src/main/webapp/WEB-INF/classes/TestPortlet_de.properties ------------------------------------------------------------------------------ svn:eol-style = native Modified: geronimo/sandbox/portals/pluto-testsuite/src/main/webapp/WEB-INF/classes/TestPortlet_en.properties URL: http://svn.apache.org/viewvc/geronimo/sandbox/portals/pluto-testsuite/src/main/webapp/WEB-INF/classes/TestPortlet_en.properties?view=diff&rev=559986&r1=559985&r2=559986 ============================================================================== --- geronimo/sandbox/portals/pluto-testsuite/src/main/webapp/WEB-INF/classes/TestPortlet_en.properties (original) +++ geronimo/sandbox/portals/pluto-testsuite/src/main/webapp/WEB-INF/classes/TestPortlet_en.properties Thu Jul 26 14:22:10 2007 @@ -1,26 +1,26 @@ -# +# # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -# implied. -# -# See the License for the specific language governing permissions and -# limitations under the License. -# -# -javax.portlet.title = Test Portlet 2 (en) -javax.portlet.short-title = Test 2 (en) -javax.portlet.keywords = Test,Testing - -org.apache.pluto.testsuite.expected-title=Test Portlet 2 (en) -org.apache.pluto.testsuite.expected-short-title=Test 2 (en) -org.apache.pluto.testsuite.keywords=Test, Testing +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# +# See the License for the specific language governing permissions and +# limitations under the License. +# +# +javax.portlet.title = Test Portlet 2 (en) +javax.portlet.short-title = Test 2 (en) +javax.portlet.keywords = Test,Testing + +org.apache.pluto.testsuite.expected-title=Test Portlet 2 (en) +org.apache.pluto.testsuite.expected-short-title=Test 2 (en) +org.apache.pluto.testsuite.keywords=Test, Testing Propchange: geronimo/sandbox/portals/pluto-testsuite/src/main/webapp/WEB-INF/classes/TestPortlet_en.properties ------------------------------------------------------------------------------ svn:eol-style = native Modified: geronimo/sandbox/portals/pluto-testsuite/src/main/webapp/WEB-INF/classes/logging.properties URL: http://svn.apache.org/viewvc/geronimo/sandbox/portals/pluto-testsuite/src/main/webapp/WEB-INF/classes/logging.properties?view=diff&rev=559986&r1=559985&r2=559986 ============================================================================== --- geronimo/sandbox/portals/pluto-testsuite/src/main/webapp/WEB-INF/classes/logging.properties (original) +++ geronimo/sandbox/portals/pluto-testsuite/src/main/webapp/WEB-INF/classes/logging.properties Thu Jul 26 14:22:10 2007 @@ -1,36 +1,36 @@ -# +# # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -# implied. -# -# See the License for the specific language governing permissions and -# limitations under the License. - -handlers = org.apache.juli.FileHandler - -############################################################ -# -# JDK 1.4+ logging handler specific properties for Pluto portal -# using Tomcat's custom implementation of LogManager. -# Logging level can be set to any one of: -# SEVERE, WARN, INFO, CONFIG, FINE, FINEST or ALL. -# See the Tomcat documentation for more details. -# -############################################################ - -org.apache.juli.FileHandler.level = FINE -org.apache.juli.FileHandler.directory = ${catalina.base}/logs -#Log file will be named testsuite..log -org.apache.juli.FileHandler.prefix = testsuite. - +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# +# See the License for the specific language governing permissions and +# limitations under the License. + +handlers = org.apache.juli.FileHandler + +############################################################ +# +# JDK 1.4+ logging handler specific properties for Pluto portal +# using Tomcat's custom implementation of LogManager. +# Logging level can be set to any one of: +# SEVERE, WARN, INFO, CONFIG, FINE, FINEST or ALL. +# See the Tomcat documentation for more details. +# +############################################################ + +org.apache.juli.FileHandler.level = FINE +org.apache.juli.FileHandler.directory = ${catalina.base}/logs +#Log file will be named testsuite..log +org.apache.juli.FileHandler.prefix = testsuite. + org.apache.pluto.level=FINE Propchange: geronimo/sandbox/portals/pluto-testsuite/src/main/webapp/WEB-INF/classes/logging.properties ------------------------------------------------------------------------------ svn:eol-style = native