Return-Path: Delivered-To: apmail-portals-pluto-scm-archive@www.apache.org Received: (qmail 19341 invoked from network); 1 Sep 2007 12:51:57 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 1 Sep 2007 12:51:57 -0000 Received: (qmail 7995 invoked by uid 500); 1 Sep 2007 12:51:52 -0000 Delivered-To: apmail-portals-pluto-scm-archive@portals.apache.org Received: (qmail 7967 invoked by uid 500); 1 Sep 2007 12:51:52 -0000 Mailing-List: contact pluto-scm-help@portals.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list pluto-scm@portals.apache.org Received: (qmail 7955 invoked by uid 99); 1 Sep 2007 12:51:52 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 01 Sep 2007 05:51:52 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED 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; Sat, 01 Sep 2007 12:51:54 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 109051A983A; Sat, 1 Sep 2007 05:51:34 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r571792 [2/2] - in /portals/pluto/branches/1.1-286-trunk-merge/pluto-testsuite: ./ src/assemble/ src/main/java/org/apache/pluto/testsuite/ src/main/java/org/apache/pluto/testsuite/test/ src/main/java/org/apache/pluto/testsuite/validator/ sr... Date: Sat, 01 Sep 2007 12:51:28 -0000 To: pluto-scm@portals.apache.org From: cdoremus@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20070901125134.109051A983A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Modified: portals/pluto/branches/1.1-286-trunk-merge/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/PreferenceCommonTest.java URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-trunk-merge/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/PreferenceCommonTest.java?rev=571792&r1=571791&r2=571792&view=diff ============================================================================== --- portals/pluto/branches/1.1-286-trunk-merge/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/PreferenceCommonTest.java (original) +++ portals/pluto/branches/1.1-286-trunk-merge/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/PreferenceCommonTest.java Sat Sep 1 05:51:24 2007 @@ -1,9 +1,10 @@ /* - * Copyright 2003,2004 The Apache Software Foundation. - * - * Licensed 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 + * 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 * @@ -30,36 +31,35 @@ /** * Common portlet preferences test. - * @author ZHENG Zhong */ public class PreferenceCommonTest extends AbstractReflectivePortletTest { - + /** Logger. */ private static final Log LOG = LogFactory.getLog(PreferenceCommonTest.class); - + protected static final String BOGUS_KEY = "org.apache.pluto.testsuite.BOGUS_KEY"; - + protected static final String READ_ONLY_PREF_NAME = "readonly"; - + protected static final String NO_VALUE_PREF_NAME = "nameWithNoValue"; - + protected static final String PREF_NAME = "dummyName"; protected static final String PREF_VALUE = "dummyValue"; - + protected static final String DEF_VALUE = "Default"; protected static final String NEW_VALUE = "notTheOriginal"; - - + + // Test Methods ------------------------------------------------------------ - + protected TestResult checkGetEmptyPreference(PortletRequest request) { return doCheckDefaultPreference(request, "nonexistence!"); } - + protected TestResult checkGetNoValuePreference(PortletRequest request) { return doCheckDefaultPreference(request, NO_VALUE_PREF_NAME); } - + /** * Private method that checks if a preference is not defined or has no * value in portlet.xml, the default values are returned. @@ -74,7 +74,7 @@ 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, @@ -100,7 +100,7 @@ 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)) { @@ -110,12 +110,12 @@ } return result; } - + 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"); @@ -123,7 +123,7 @@ 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); @@ -137,7 +137,7 @@ 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"}); @@ -168,12 +168,12 @@ } return result; } - + 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); @@ -181,7 +181,7 @@ 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); @@ -190,13 +190,13 @@ } return result; } - + protected TestResult checkSetPreferencesReturnsFirst(PortletRequest request) { 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" }); @@ -213,16 +213,16 @@ } return result; } - + 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); @@ -240,7 +240,7 @@ TestUtils.failOnException("Unable to set preference value.", ex, result); return result; } - + // Everything is OK. if (setOccured && resetOccured) { result.setReturnCode(TestResult.PASSED); @@ -259,17 +259,17 @@ } return result; } - + protected TestResult checkResetPreferenceWithoutDefault(PortletRequest request) { 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); @@ -287,7 +287,7 @@ TestUtils.failOnException("Unable to set preference value.", ex, result); return result; } - + // Everything is OK. if (setOccured && resetOccured) { result.setReturnCode(TestResult.PASSED); @@ -307,14 +307,14 @@ } return result; } - + protected TestResult checkModifyReadOnlyPreferences(PortletRequest request) { TestResult result = new TestResult(); 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); @@ -323,32 +323,32 @@ + "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) { result.setReturnCode(TestResult.PASSED); } else { @@ -369,12 +369,12 @@ } return result; } - + 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; @@ -384,7 +384,7 @@ break; } } - + if (hasAll) { result.setReturnCode(TestResult.PASSED); } else { @@ -394,7 +394,7 @@ } return result; } - + /** * FIXME: */ @@ -414,13 +414,13 @@ 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); @@ -430,7 +430,7 @@ originalValue = values[0]; values[0] = modifiedValue; } - + // Check if the value held by portlet preferences is modified. if (LOG.isDebugEnabled()) { LOG.debug("Modified Preferences:"); @@ -446,11 +446,11 @@ } return result; } - - + + // Debug Methods ----------------------------------------------------------- - - + + /** * Logs out the portlet preferences. * @param preferences PortletPreferences to log. @@ -475,9 +475,9 @@ // Spec allows null values. buffer.append("NULL"); } - buffer.append(";"); + buffer.append(";"); } LOG.debug("PortletPreferences: " + buffer.toString()); } - + } Modified: portals/pluto/branches/1.1-286-trunk-merge/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/PreferenceInActionTest.java URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-trunk-merge/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/PreferenceInActionTest.java?rev=571792&r1=571791&r2=571792&view=diff ============================================================================== --- portals/pluto/branches/1.1-286-trunk-merge/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/PreferenceInActionTest.java (original) +++ portals/pluto/branches/1.1-286-trunk-merge/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/PreferenceInActionTest.java Sat Sep 1 05:51:24 2007 @@ -1,9 +1,10 @@ /* - * Copyright 2003,2004 The Apache Software Foundation. - * - * Licensed 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 + * 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 * @@ -30,23 +31,21 @@ import javax.portlet.ValidatorException; /** - * @author David H. DeWolf - * @author ZHENG Zhong */ public class PreferenceInActionTest extends PreferenceCommonTest implements ActionTest { - + /** Logger. */ private static final Log LOG = LogFactory.getLog(PreferenceInActionTest.class); - - + + // Test Methods ------------------------------------------------------------ - + protected TestResult checkPreferenceValidator(PortletRequest request) { TestResult result = new TestResult(); result.setDescription("Ensure the validator catches invalid preferences."); result.setSpecPLT("14.4"); - + PortletPreferences preferences = request.getPreferences(); if (LOG.isDebugEnabled()) { LOG.debug("Original preferences:"); @@ -61,15 +60,15 @@ } // Call store() method to invoke the validator. preferences.store(); - + } catch (ReadOnlyException ex) { TestUtils.failOnException("Unable to set preference value.", ex, result); return result; - + } catch (IOException ex) { TestUtils.failOnException("Unable to store preference value.", ex, result); return result; - + } catch (ValidatorException ex) { // We are expecting this exception! exceptionThrown = true; @@ -79,10 +78,10 @@ preferences.setValue("TEST", "OK"); preferences.reset("TEST"); } catch (Throwable th) { - LOG.error(th); + LOG.error(th); } } - + if (exceptionThrown) { result.setReturnCode(TestResult.PASSED); } else { @@ -91,14 +90,14 @@ } return result; } - + protected TestResult checkOnePreferenceValidatorPerPortletDefinition( PortletRequest request) { TestResult result = new TestResult(); result.setDescription("Ensure only one validator instance is created " + "per portlet definition."); result.setSpecPLT("14.4"); - + PortletPreferences preferences = request.getPreferences(); try { preferences.setValue( @@ -130,15 +129,15 @@ TestResult result = new TestResult(); result.setDescription("Ensure storage works for portlet preferences."); result.setSpecPLT("14.1"); - + PortletPreferences preferences = request.getPreferences(); if (LOG.isDebugEnabled()) { LOG.debug("Preferences to store: " + preferences); } - + boolean setOccured = false; boolean storeOccured = false; - + try { // Set new value for preference "dummyName". preferences.setValue(PREF_NAME, NEW_VALUE); @@ -171,7 +170,7 @@ return result; } } - + // Everything is OK. if (setOccured && storeOccured) { result.setReturnCode(TestResult.PASSED); @@ -190,5 +189,5 @@ } return result; } - + } Modified: portals/pluto/branches/1.1-286-trunk-merge/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/PreferenceInRenderTest.java URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-trunk-merge/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/PreferenceInRenderTest.java?rev=571792&r1=571791&r2=571792&view=diff ============================================================================== --- portals/pluto/branches/1.1-286-trunk-merge/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/PreferenceInRenderTest.java (original) +++ portals/pluto/branches/1.1-286-trunk-merge/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/PreferenceInRenderTest.java Sat Sep 1 05:51:24 2007 @@ -1,9 +1,10 @@ /* - * Copyright 2003,2004 The Apache Software Foundation. - * - * Licensed 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 + * 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 * Modified: portals/pluto/branches/1.1-286-trunk-merge/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/RenderParameterTest.java URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-trunk-merge/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/RenderParameterTest.java?rev=571792&r1=571791&r2=571792&view=diff ============================================================================== --- portals/pluto/branches/1.1-286-trunk-merge/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/RenderParameterTest.java (original) +++ portals/pluto/branches/1.1-286-trunk-merge/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/RenderParameterTest.java Sat Sep 1 05:51:24 2007 @@ -1,9 +1,10 @@ /* - * Copyright 2003,2004 The Apache Software Foundation. - * - * Licensed 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 + * 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 * @@ -25,8 +26,6 @@ import javax.portlet.PortletRequest; /** - * @author David H. DeWolf - * @author ZHENG Zhong */ public class RenderParameterTest extends AbstractReflectivePortletTest { @@ -34,22 +33,22 @@ private static final String RENDER_KEY = "org.apache.pluto.testsuite.PARAM_RENDER_KEY"; private static final String RENDER_VALUE = "org.apache.pluto.testsuite.RENDER_VALUE"; - - + + public Map getRenderParameters(PortletRequest request) { Map parameterMap = new HashMap(); parameterMap.put(RENDER_KEY, new String[] { RENDER_VALUE }); return parameterMap; } - - + + // Test Methods ------------------------------------------------------------ - + protected TestResult checkActionParametersNotHere(PortletRequest request) { TestResult result = new TestResult(); result.setDescription("Ensure that action parameters are not available " + "in the following render request."); - + String value = request.getParameter(ACTION_KEY); if (value == null) { result.setReturnCode(TestResult.PASSED); @@ -64,7 +63,7 @@ TestResult result = new TestResult(); result.setDescription("Ensure that render parameters set in action " + "response are available in the following render request."); - + String value = request.getParameter(RENDER_KEY); if (RENDER_VALUE.equals(value)) { result.setReturnCode(TestResult.PASSED); @@ -94,7 +93,7 @@ TestResult result = new TestResult(); result.setDescription("Ensure that render request returns the correct " + "parameter map."); - + Map parameterMap = request.getParameterMap(); String[] values = (String[]) parameterMap.get(RENDER_KEY); if (values != null && values.length == 1 @@ -132,7 +131,7 @@ hasRenderParameter = true; } } - + if (!hasActionParameter && hasRenderParameter) { result.setReturnCode(TestResult.PASSED); } else { Modified: portals/pluto/branches/1.1-286-trunk-merge/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/RenderResponseNoContentTypeTest.java URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-trunk-merge/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/RenderResponseNoContentTypeTest.java?rev=571792&r1=571791&r2=571792&view=diff ============================================================================== --- portals/pluto/branches/1.1-286-trunk-merge/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/RenderResponseNoContentTypeTest.java (original) +++ portals/pluto/branches/1.1-286-trunk-merge/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/RenderResponseNoContentTypeTest.java Sat Sep 1 05:51:24 2007 @@ -1,9 +1,10 @@ /* - * Copyright 2003,2004 The Apache Software Foundation. - * - * Licensed 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 + * 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 * @@ -27,14 +28,13 @@ /** * FIXME: separate the two check methods to two classes. - * - * @author ZHENG Zhong + * */ public class RenderResponseNoContentTypeTest extends AbstractReflectivePortletTest { - + private static final Log LOG = LogFactory.getLog(RenderResponseNoContentTypeTest.class); - + /** * Overwrite super implementation to return null. This test requires that * content type of the render response is not set. @@ -43,22 +43,22 @@ public String getRenderResponseContentType() { return null; } - + // Test Methods ------------------------------------------------------------ - + protected TestResult checkGetPortletOutputStream(PortletResponse response) { TestResult result = new TestResult(); result.setDescription("Ensure If the getPortletOutputStream() method " + "is called before the setContentType() method, it will throw " + "an IllegalStateException."); result.setSpecPLT("12.3.1"); - + RenderResponse renderResponse = (RenderResponse) response; ensureContentTypeNotSet(renderResponse, result); if (result.getReturnCode() == TestResult.WARNING) { return result; } - + try { renderResponse.getPortletOutputStream(); result.setReturnCode(TestResult.FAILED); @@ -81,13 +81,13 @@ + "is called before the setContentType() method, it will throw " + "an IllegalStateException."); result.setSpecPLT("12.3.1"); - + RenderResponse renderResponse = (RenderResponse) response; ensureContentTypeNotSet(renderResponse, result); if (result.getReturnCode() == TestResult.WARNING) { return result; } - + try { renderResponse.getWriter(); result.setReturnCode(TestResult.FAILED); @@ -103,10 +103,10 @@ } return result; } - - + + // Private Methods --------------------------------------------------------- - + /** * Ensures that the content type of the current render response is not set. * If the content type is already set, this method sets the test result to Modified: portals/pluto/branches/1.1-286-trunk-merge/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/ResourceBundleTest.java URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-trunk-merge/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/ResourceBundleTest.java?rev=571792&r1=571791&r2=571792&view=diff ============================================================================== --- portals/pluto/branches/1.1-286-trunk-merge/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/ResourceBundleTest.java (original) +++ portals/pluto/branches/1.1-286-trunk-merge/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/ResourceBundleTest.java Sat Sep 1 05:51:24 2007 @@ -1,9 +1,10 @@ /* - * Copyright 2003,2004 The Apache Software Foundation. - * - * Licensed 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 + * 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 * @@ -15,63 +16,69 @@ */ package org.apache.pluto.testsuite.test; -import org.apache.pluto.testsuite.TestResult; +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.*; -import java.util.*; +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. * - * @author David H. DeWolf - * @author ZHENG Zhong */ 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); @@ -82,7 +89,7 @@ } return result; } - + protected TestResult checkGetNames(PortletConfig config, PortletRequest request) { TestResult result = new TestResult(); @@ -93,7 +100,7 @@ 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); @@ -102,12 +109,12 @@ + "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 { @@ -142,17 +149,17 @@ 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 local " + locale); - + + "under locale " + locale); + // Retrieve title, short title and keywords from portlet resource bundle. ResourceBundle bundle = config.getResourceBundle(locale); if (bundle == null) { @@ -165,7 +172,7 @@ 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(); @@ -175,7 +182,7 @@ 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(); @@ -201,7 +208,7 @@ .append(keywords).append("' != '") .append(expectedKeywords).append("'; "); } - + if (!inconsistent) { result.setReturnCode(TestResult.PASSED); } else { @@ -210,7 +217,7 @@ } return result; } - + private boolean isBundleDeclared() { String bundleDeclared = (String) getInitParameters().get( BUNDLE_DECLARED_PARAM); Modified: portals/pluto/branches/1.1-286-trunk-merge/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/SecurityMappingTest.java URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-trunk-merge/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/SecurityMappingTest.java?rev=571792&r1=571791&r2=571792&view=diff ============================================================================== --- portals/pluto/branches/1.1-286-trunk-merge/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/SecurityMappingTest.java (original) +++ portals/pluto/branches/1.1-286-trunk-merge/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/SecurityMappingTest.java Sat Sep 1 05:51:24 2007 @@ -1,9 +1,10 @@ /* - * Copyright 2003,2004 The Apache Software Foundation. - * - * Licensed 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 + * 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 * @@ -20,20 +21,18 @@ import org.apache.pluto.testsuite.TestResult; /** - * @author David H. DeWolf - * @author ZHENG Zhong */ 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)) { @@ -45,14 +44,14 @@ } 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)) { @@ -64,14 +63,14 @@ } 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); @@ -81,10 +80,10 @@ } return result; } - - + + // Private Methods --------------------------------------------------------- - + private TestResult isUserLoggedIn(PortletRequest request) { TestResult result = new TestResult(); if (request.getRemoteUser() == null) { Modified: portals/pluto/branches/1.1-286-trunk-merge/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/SessionTimeoutTest.java URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-trunk-merge/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/SessionTimeoutTest.java?rev=571792&r1=571791&r2=571792&view=diff ============================================================================== --- portals/pluto/branches/1.1-286-trunk-merge/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/SessionTimeoutTest.java (original) +++ portals/pluto/branches/1.1-286-trunk-merge/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/SessionTimeoutTest.java Sat Sep 1 05:51:24 2007 @@ -1,9 +1,10 @@ /* - * Copyright 2003,2004 The Apache Software Foundation. - * - * Licensed 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 + * 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 * Modified: portals/pluto/branches/1.1-286-trunk-merge/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/SimpleAttributeTest.java URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-trunk-merge/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/SimpleAttributeTest.java?rev=571792&r1=571791&r2=571792&view=diff ============================================================================== --- portals/pluto/branches/1.1-286-trunk-merge/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/SimpleAttributeTest.java (original) +++ portals/pluto/branches/1.1-286-trunk-merge/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/SimpleAttributeTest.java Sat Sep 1 05:51:24 2007 @@ -1,9 +1,10 @@ /* - * Copyright 2003,2004 The Apache Software Foundation. - * - * Licensed 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 + * 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 * @@ -28,17 +29,15 @@ * Tests basic attribute retrieval and storage functions within the portlet * request, session, and context objects. * - * @author David H. DeWolf - * @author ZHENG Zhong */ 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 " @@ -75,7 +74,7 @@ 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); @@ -91,12 +90,12 @@ 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(); ) { @@ -113,10 +112,10 @@ } return result; } - - + + // Test Methods for Session Attributes ------------------------------------- - + protected TestResult checkGetNullAttribute(PortletSession session) { TestResult res = new TestResult(); res.setName("Retrieve Missing Session Attribute Test"); @@ -172,10 +171,10 @@ } 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); @@ -189,7 +188,7 @@ found++; } } - + if (count != found) { result.setReturnCode(TestResult.FAILED); result.setResultMessage("Expected " + count + " attributes. " @@ -263,12 +262,12 @@ 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(); ) { @@ -276,7 +275,7 @@ found++; } } - + if (count == found) { result.setReturnCode(TestResult.PASSED); } else { Modified: portals/pluto/branches/1.1-286-trunk-merge/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/validator/PreferencesValidatorImpl.java URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-trunk-merge/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/validator/PreferencesValidatorImpl.java?rev=571792&r1=571791&r2=571792&view=diff ============================================================================== --- portals/pluto/branches/1.1-286-trunk-merge/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/validator/PreferencesValidatorImpl.java (original) +++ portals/pluto/branches/1.1-286-trunk-merge/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/validator/PreferencesValidatorImpl.java Sat Sep 1 05:51:24 2007 @@ -1,12 +1,13 @@ /* - * Copyright 2003,2004 The Apache Software Foundation. - * - * Licensed 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 - * + * 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. @@ -30,23 +31,22 @@ /** * Implementation of the portlet preferences validator. - * @author ZHENG Zhong */ 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. */ @@ -62,10 +62,10 @@ } INSTANCE_COUNTER.put(getClass().getName(), count); } - - + + // PreferencesValidator Impl ----------------------------------------------- - + public void validate(PortletPreferences preferences) throws ValidatorException { validateInvoked++; @@ -73,7 +73,7 @@ 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 @@ -102,14 +102,14 @@ } } } - + 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..."); @@ -127,5 +127,5 @@ null); } } - + } Modified: portals/pluto/branches/1.1-286-trunk-merge/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/validator/PreferencesValidatorImpl2.java URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-trunk-merge/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/validator/PreferencesValidatorImpl2.java?rev=571792&r1=571791&r2=571792&view=diff ============================================================================== --- portals/pluto/branches/1.1-286-trunk-merge/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/validator/PreferencesValidatorImpl2.java (original) +++ portals/pluto/branches/1.1-286-trunk-merge/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/validator/PreferencesValidatorImpl2.java Sat Sep 1 05:51:24 2007 @@ -1,9 +1,10 @@ /* - * Copyright 2003,2004 The Apache Software Foundation. - * - * Licensed 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 + * 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 * Modified: portals/pluto/branches/1.1-286-trunk-merge/pluto-testsuite/src/main/resources/testsuite.xml URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-trunk-merge/pluto-testsuite/src/main/resources/testsuite.xml?rev=571792&r1=571791&r2=571792&view=diff ============================================================================== --- portals/pluto/branches/1.1-286-trunk-merge/pluto-testsuite/src/main/resources/testsuite.xml (original) +++ portals/pluto/branches/1.1-286-trunk-merge/pluto-testsuite/src/main/resources/testsuite.xml Sat Sep 1 05:51:24 2007 @@ -1,8 +1,10 @@