You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pluto-scm@portals.apache.org by cz...@apache.org on 2007/03/09 10:47:16 UTC
svn commit: r516346 [3/4] - in /portals/pluto/trunk: ./
pluto-descriptor-api/src/main/java/org/apache/pluto/descriptors/common/
pluto-descriptor-api/src/main/java/org/apache/pluto/descriptors/portlet/
pluto-descriptor-api/src/main/java/org/apache/pluto...
Modified: portals/pluto/trunk/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/TestConfig.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/TestConfig.java?view=diff&rev=516346&r1=516345&r2=516346
==============================================================================
--- portals/pluto/trunk/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/TestConfig.java (original)
+++ portals/pluto/trunk/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/TestConfig.java Fri Mar 9 01:47:12 2007
@@ -25,57 +25,55 @@
/**
* Configuration for <code>PortletTest</code>.
- *
+ *
* @see TestConfigFactory
* @see PortletTest
- *
- * @author <a href="mailto:ddewolf@apache.org">David H. DeWolf</a>
- * @author <a href="mailto:zheng@apache.org">ZHENG Zhong</a>
+ *
* @version 1.0
* @since Sep 15, 2004
*/
public class TestConfig implements Serializable {
-
+
// Private Member Variables ------------------------------------------------
-
+
/** PortletTest class name. */
- private String testClassName = null;
-
+ private String testClassName;
+
/** Test name. */
- private String name = null;
-
- private String displayURI = null;
-
+ private String name;
+
+ private String displayURI;
+
private Map initParameters = new HashMap();
-
+
/**
* The action parameters list holding TestConfig.Parameter objects.
* We are not using Map to hold action parameters because parameters with
* the same name are allowed.
*/
private List actionParameters = new ArrayList();
-
+
/**
* The render parameters list holding TestConfig.Parameter objects.
* We are not using Map to hold render parameters because parameters with
* the same name are allowed.
- *
+ *
* FIXME: when is this field used?
*/
private List renderParameters = new ArrayList();
-
-
+
+
// Constructor -------------------------------------------------------------
-
+
/**
* Default constructor required by Digester.
*/
public TestConfig() {
// Do nothing.
}
-
+
// Public Methods ----------------------------------------------------------
-
+
public String getTestClassName() {
return testClassName;
}
@@ -111,18 +109,18 @@
public void addActionParameter(String name, String value) {
actionParameters.add(new Parameter(name, value));
}
-
+
public List getActionParameters() {
return actionParameters;
}
-
+
/**
* FIXME: why is this method required?
*/
public void addRenderParameter(String name, String value) {
renderParameters.add(new Parameter(name, value));
}
-
+
/**
* FIXME: when is this method used?
*/
@@ -136,7 +134,7 @@
buffer.append("[").append(getName()).append("]");
return buffer.toString();
}
-
+
public static class Parameter {
private String name = null;
private String value = null;
@@ -144,7 +142,7 @@
this.name = name;
this.value = value;
}
-
+
public String getName() {
return name;
}
@@ -152,6 +150,6 @@
return value;
}
}
-
+
}
Modified: portals/pluto/trunk/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/TestConfigFactory.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/TestConfigFactory.java?view=diff&rev=516346&r1=516345&r2=516346
==============================================================================
--- portals/pluto/trunk/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/TestConfigFactory.java (original)
+++ portals/pluto/trunk/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/TestConfigFactory.java Fri Mar 9 01:47:12 2007
@@ -22,26 +22,23 @@
import java.util.List;
import org.apache.commons.digester.Digester;
-import org.apache.pluto.testsuite.TestConfig;
import org.xml.sax.SAXException;
/**
* Test configuration factory that reads and parses testsuite config file using
* Digester and constructs <code>TestConfig</code> objects.
- *
+ *
* @see TestConfig
- *
- * @author <a href="mailto:ddewolf@apache.org">David H. DeWolf</a>
- * @author <a href="mailto:zheng@apache.org">ZHENG Zhong</a>
+ *
*/
public class TestConfigFactory {
-
+
/** Digester instance used to parse testsuite config file. */
private Digester digester = new Digester();
-
-
+
+
// Constructor -------------------------------------------------------------
-
+
/**
* Creates a factory instance.
*/
@@ -75,14 +72,14 @@
digester.addSetRoot("testportlet-config/testsuite-config", "add");
}
-
-
+
+
// Public Methods ----------------------------------------------------------
-
+
/**
* Reads and parses testsuite config file, creates a list of
* <code>TestConfig</code> objects.
- *
+ *
* @param in the input stream of the testsuite config file.
* @return a list of <code>TestConfig</code> objects.
* @throws SAXException if a parsing error occurs.
@@ -93,5 +90,5 @@
throws SAXException, IOException {
return (List) digester.parse(in);
}
-
+
}
Modified: portals/pluto/trunk/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/TestPortlet.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/TestPortlet.java?view=diff&rev=516346&r1=516345&r2=516346
==============================================================================
--- portals/pluto/trunk/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/TestPortlet.java (original)
+++ portals/pluto/trunk/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/TestPortlet.java Fri Mar 9 01:47:12 2007
@@ -5,9 +5,9 @@
* 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.
@@ -38,46 +38,44 @@
/**
* Pluto testsuite's test portlet.
- *
+ *
* @see TestConfig
* @see PortletTest
- * @author <a href="mailto:ddewolf@apache.org">David H. DeWolf</a>
- * @author <a href="mailto:zheng@apache.org">ZHENG Zhong</a>
* @version 1.0
*/
public class TestPortlet extends GenericPortlet {
/** Internal logger. */
private static final Log LOG = LogFactory.getLog(TestPortlet.class);
-
-
+
+
// Private Member Variables ------------------------------------------------
-
+
/** List of test configurations. */
- private List testConfigs = null;
-
+ private List testConfigs;
+
/**
* Map of test instances: key is an integer ID (as a string), and value is
* the <code>PortletTest</code> instances.
*/
- private Map tests = null;
-
-
+ private Map tests;
+
+
// GenericPortlet Impl -----------------------------------------------------
-
+
/**
* Initialize the test portlet. This method reads the testsuite's config
* files, constructs and initializes all <code>PortletTest</code> instances.
* @throws PortletException if fail to read the configuration file.
*/
public void init() throws PortletException {
-
+
// Get configuration file name.
String configFile = getInitParameter("config");
if (configFile == null) {
configFile = "/WEB-INF/testsuite-config.xml";
}
-
+
// Get configuration file as an input stream.
InputStream is = getPortletContext().getResourceAsStream(configFile);
if (is == null) {
@@ -85,7 +83,7 @@
LOG.error(message);
throw new PortletException(message);
}
-
+
// Load PortletTest instances: constructing and initializing.
TestConfigFactory factory = new TestConfigFactory();
try {
@@ -117,14 +115,14 @@
throw new PortletException(message, th);
}
}
-
-
+
+
public void processAction(ActionRequest request, ActionResponse response)
throws PortletException, IOException {
-
+
String testId = getTestId(request);
PortletTest test = (PortletTest) tests.get(testId);
-
+
// For ActionTest, run test and save results in session.
if (test != null && test instanceof ActionTest) {
TestResults results = test.doTest(getPortletConfig(),
@@ -134,7 +132,7 @@
PortletSession session = request.getPortletSession();
session.setAttribute(test.getClass().getName(), results);
}
-
+
Map renderParameters = null;
if (test != null) {
renderParameters = test.getRenderParameters(request);
@@ -145,17 +143,17 @@
renderParameters.put("testId", new String[] { testId });
response.setRenderParameters(renderParameters);
}
-
+
/**
* Serves up the <code>view</code> mode.
* TODO: more javadoc.
- *
+ *
* @param request the protlet request.
* @param response the portlet response.
*/
public void doView(RenderRequest request, RenderResponse response)
throws PortletException, IOException {
-
+
// Get the current test ID, the test instance and its config.
String testId = getTestId(request);
TestConfig testConfig = null;
@@ -164,7 +162,7 @@
testConfig = (TestConfig) testConfigs.get(Integer.parseInt(testId));
test = (PortletTest) tests.get(testId);
}
-
+
// For non-ActionTest, run test and save results in request.
if (test != null && !(test instanceof ActionTest)) {
TestResults results = test.doTest(getPortletConfig(),
@@ -180,8 +178,8 @@
test.getClass().getName());
request.setAttribute("results", results);
}
-
-
+
+
if (testId == null) {
// FIXME: update attribute name from tests to testConfigs.
request.setAttribute("tests", testConfigs);
@@ -202,7 +200,7 @@
request.setAttribute("prevTest", prevTestConfig);
request.setAttribute("nextTest", nextTestConfig);
}
-
+
// Set content type for render response, and dispatch to JSP.
response.setContentType("text/html");
String displayUri = null;
@@ -228,7 +226,7 @@
.getRequestDispatcher("/jsp/edit.jsp");
dispatcher.include(request, response);
}
-
+
/**
* Serves up the <code>help</code> mode. This method dispatches the request
* and response to the help JSP page (<code>/jsp/help.jsp</code>).
@@ -241,28 +239,28 @@
.getRequestDispatcher("/jsp/help.jsp");
dispatcher.include(request, response);
}
-
-
+
+
// Private Methods ---------------------------------------------------------
-
+
/**
* Returns the current test ID.
* @param request the portlet request.
* @return the current test ID.
*/
private String getTestId(PortletRequest request) {
-
+
String testId = request.getParameter("testId");
String prevTestId = request.getParameter("previousTestId");
String nextTestId = request.getParameter("nextTestId");
-
+
// If none of the parameters are available, return null.
if ((testId == null || testId.trim().length() == 0)
&& nextTestId == null && prevTestId == null
&& tests.size() > 0) {
return null;
}
-
+
// Retrieve the test which is next to the previous test.
else if (testId == null && prevTestId != null) {
int previousTestIdInt = Integer.parseInt(prevTestId);
@@ -272,7 +270,7 @@
testId = String.valueOf(previousTestIdInt + 1);
}
}
-
+
// Retrieve the test which is previous to the next test.
else if (testId == null && nextTestId != null) {
int nextTestIdInt = Integer.parseInt(nextTestId);
@@ -282,7 +280,7 @@
testId = String.valueOf(nextTestIdInt - 1);
}
}
-
+
// Return the current test ID.
return testId;
}
Modified: portals/pluto/trunk/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/TestResult.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/TestResult.java?view=diff&rev=516346&r1=516345&r2=516346
==============================================================================
--- portals/pluto/trunk/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/TestResult.java (original)
+++ portals/pluto/trunk/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/TestResult.java Fri Mar 9 01:47:12 2007
@@ -20,45 +20,43 @@
/**
* The test result represents the result of one test method.
- *
- * @author <a href="mailto:ddewolf@apache.org">David H. DeWolf</a>
- * @author <a href="mailto:zheng@apache.org">ZHENG Zhong</a>
+ *
*/
public class TestResult implements Serializable {
-
+
/** The undefined return code. */
public static final int UNDEFINED = -1;
-
+
/** The warning return code. */
public static final int WARNING = 0;
-
+
/** The failed return code. */
public static final int FAILED = 1;
-
+
/** The passed return code. */
public static final int PASSED = 2;
-
-
+
+
// Private Member Variables ------------------------------------------------
-
+
/** The name of the test. */
- private String name = null;
-
+ private String name;
+
/** The description of the test. */
private String description = "[unknown]";
-
+
/** The PLT number in the spec that is tested. */
private String specPLT = "[unknown]";
-
+
/** The return code of the test result: PASSED, WARNING, FAILED. */
private int returnCode = UNDEFINED;
-
+
/** The message of the test result. */
private String resultMessage ="[unknown]";
-
-
+
+
// Public Methods ----------------------------------------------------------
-
+
public String getName() {
return name;
}
@@ -66,27 +64,27 @@
public void setName(String name) {
this.name = name;
}
-
+
public String getDescription() {
return description;
}
-
+
public void setDescription(String description) {
this.description = description;
}
-
+
public String getSpecPLT() {
return specPLT;
}
-
+
public void setSpecPLT(String specPLT) {
this.specPLT = specPLT;
}
-
+
public int getReturnCode() {
return returnCode;
}
-
+
public String getReturnCodeAsString() {
if (returnCode == WARNING) {
return "WARNING";
@@ -102,18 +100,18 @@
public void setReturnCode(int returnCode) {
this.returnCode = returnCode;
}
-
+
public String getResultMessage() {
return resultMessage;
}
-
+
public void setResultMessage(String resultMessage) {
this.resultMessage = resultMessage;
}
-
-
+
+
// Object Methods ----------------------------------------------------------
-
+
/**
* Override of toString() that prints out name and results values.
* @see java.lang.Object#toString()
@@ -123,8 +121,8 @@
buffer.append(getClass().getName());
buffer.append("[name=").append(name);
buffer.append(";returnCode=").append(returnCode);
- buffer.append(";resultMessage=").append(resultMessage).append("]");
+ buffer.append(";resultMessage=").append(resultMessage).append("]");
return buffer.toString();
}
-
+
}
Modified: portals/pluto/trunk/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/TestResults.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/TestResults.java?view=diff&rev=516346&r1=516345&r2=516346
==============================================================================
--- portals/pluto/trunk/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/TestResults.java (original)
+++ portals/pluto/trunk/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/TestResults.java Fri Mar 9 01:47:12 2007
@@ -16,25 +16,21 @@
*/
package org.apache.pluto.testsuite;
-import org.apache.pluto.testsuite.TestResult;
-
+import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
-import java.io.Serializable;
/**
* This class contains one or more test results.
- * @author <a href="mailto:ddewolf@apache.org">David H. DeWolf</a>
- * @author <a href="mailto:zheng@apache.org">ZHENG Zhong</a>
*/
public class TestResults implements Serializable {
-
-
- private String name = null;
-
+
+
+ private String name;
+
private ArrayList list = new ArrayList();
-
+
private boolean failed = false;
private boolean inQuestion = false;
@@ -74,7 +70,7 @@
/**
* Override of toString() that prints out variable
* names and values.
- *
+ *
* @see java.lang.Object#toString()
*/
public String toString(){
@@ -83,7 +79,7 @@
buffer.append("[name=").append(name);
buffer.append(";failed=").append(failed);
buffer.append(";inQuestion=").append(inQuestion);
- buffer.append(";results={").append(list).append("}]");
+ buffer.append(";results={").append(list).append("}]");
return buffer.toString();
}
}
Modified: portals/pluto/trunk/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/TestUtils.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/TestUtils.java?view=diff&rev=516346&r1=516345&r2=516346
==============================================================================
--- portals/pluto/trunk/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/TestUtils.java (original)
+++ portals/pluto/trunk/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/TestUtils.java Fri Mar 9 01:47:12 2007
@@ -21,27 +21,26 @@
/**
* Static class that provides utility methods for Pluto testsuite.
- * @author <a href="mailto:zheng@apache.org">ZHENG Zhong</a>
* @since 2006-02-13
*/
public class TestUtils {
-
+
/** Logger. */
private static final Log LOG = LogFactory.getLog(TestUtils.class);
-
-
+
+
// Private Constructor -----------------------------------------------------
-
+
/**
* Private method that prevents external instantiation.
*/
private TestUtils() {
// Do nothing.
}
-
-
+
+
// Public Static Methods ---------------------------------------------------
-
+
/**
* Sets the test result return code to <code>FAILED</code>, and reports
* assertion details by specifying values got and values expected.
@@ -59,7 +58,7 @@
arrayToString(valuesExpected),
result);
}
-
+
/**
* Sets the test result return code to <code>FAILED</code>, and reports
* assertion details by specifying value got and value expected.
@@ -79,7 +78,7 @@
result.setReturnCode(TestResult.FAILED);
result.setResultMessage(buffer.toString());
}
-
+
/**
* Sets the test result return code to <code>FAILED</code>, and reports
* exception details.
@@ -99,20 +98,20 @@
}
buffer.append(" Cause (").append(cause.getClass().getName()).append("): ");
buffer.append(cause.getMessage());
-
+
// Log error message.
if (LOG.isErrorEnabled()) {
LOG.error(buffer.toString(), cause);
}
-
+
// Set error message to test result.
result.setReturnCode(TestResult.FAILED);
result.setResultMessage(buffer.toString());
}
-
-
+
+
// Private Static Methods --------------------------------------------------
-
+
/**
* Converts a string array to a string.
* @param values the string array to convert.
@@ -134,6 +133,6 @@
}
return buffer.toString();
}
-
-
+
+
}
Modified: portals/pluto/trunk/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/AbstractReflectivePortletTest.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/AbstractReflectivePortletTest.java?view=diff&rev=516346&r1=516345&r2=516346
==============================================================================
--- portals/pluto/trunk/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/AbstractReflectivePortletTest.java (original)
+++ portals/pluto/trunk/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/AbstractReflectivePortletTest.java Fri Mar 9 01:47:12 2007
@@ -38,26 +38,24 @@
import java.util.HashMap;
/**
- * @author <a href="mailto:ddewolf@apache.org">David H. DeWolf</a>
- * @author <a href="mailto:zheng@apache.org">ZHENG Zhong</a>
*/
public abstract class AbstractReflectivePortletTest implements PortletTest {
-
+
/** Logger. */
private static final Log LOG = LogFactory.getLog(
AbstractReflectivePortletTest.class);
-
- private Map initParameters = null;
- private TestConfig config = null;
-
-
+
+ private Map initParameters;
+ private TestConfig config;
+
+
// PortletTest Impl --------------------------------------------------------
-
+
public void init(TestConfig config) {
this.config = config;
this.initParameters = config.getInitParameters();
}
-
+
/**
* Returns the render parameters that will be set into the render request.
* The default implementation just returns an empty Map object. This method
@@ -69,11 +67,11 @@
public Map getRenderParameters(PortletRequest request) {
return new HashMap();
}
-
+
public TestConfig getConfig() {
return config;
}
-
+
/**
* Returns the test suite name. The test suite name is the portlet test
* class name without package name prefix.
@@ -88,7 +86,7 @@
return className;
}
}
-
+
/**
* Invoke test methods using java reflection. All 'check*' methods are
* invoked and test results are saved into <code>TestResults</code> object.
@@ -96,14 +94,14 @@
* @param context the portlet context.
* @param request the portlet request.
* @param response the portlet response.
- * @return the test results including several TestResult instances.
+ * @return the test results including several TestResult instances.
*/
public TestResults doTest(PortletConfig config,
PortletContext context,
PortletRequest request,
PortletResponse response) {
TestResults results = new TestResults(getTestSuiteName());
-
+
for (Iterator it = getCheckMethods().iterator(); it.hasNext(); ) {
Method method = (Method) it.next();
debugWithName("Invoking test method: " + method.getName());
@@ -126,39 +124,39 @@
results.add(result);
}
}
-
+
return results;
}
-
-
+
+
// Protected Methods -------------------------------------------------------
-
+
protected Map getInitParameters() {
return initParameters;
}
-
-
+
+
// Private Methods ---------------------------------------------------------
-
+
private void debugWithName(String message) {
if (LOG.isDebugEnabled()) {
LOG.debug("Test [" + getTestSuiteName() + "]: " + message);
}
}
-
+
private void errorWithName(String message, Throwable cause) {
if (LOG.isErrorEnabled()) {
LOG.error("Test [" + getTestSuiteName() + "]: " + message, cause);
}
}
-
+
/**
* Returns check methods to run as tests using java reflection.
* The following rules are applied to select check methods:
* <ul>
* <li>methods declared in this class or inherited from super class</li>
* <li>methods with modifier 'public' or 'protected', but not 'abstract'</li>
- * <li>methods that starts with <code>check</code></li>
+ * <li>methods that starts with <code>check</code></li>
* </ul>
* @return a list of check methods.
*/
@@ -181,7 +179,7 @@
}
return checkMethods;
}
-
+
/**
* Invokes the test method ('<code>check*</code>') by preparing method
* parameters. A test method may accept the following types of parameters:
@@ -219,10 +217,10 @@
TestResult result = (TestResult) method.invoke(this, paramValues);
return result;
}
-
-
+
+
// Object Methods ----------------------------------------------------------
-
+
/**
* Override of toString() that prints out names and values of variables.
* @see java.lang.Object#toString()
@@ -231,7 +229,7 @@
StringBuffer buffer = new StringBuffer();
buffer.append(getClass().getName());
buffer.append("[initParameters=").append(initParameters);
- buffer.append(";config=").append(config).append("]");
+ buffer.append(";config=").append(config).append("]");
return buffer.toString();
}
}
Modified: portals/pluto/trunk/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/ActionParameterTest.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/ActionParameterTest.java?view=diff&rev=516346&r1=516345&r2=516346
==============================================================================
--- portals/pluto/trunk/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/ActionParameterTest.java (original)
+++ portals/pluto/trunk/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/ActionParameterTest.java Fri Mar 9 01:47:12 2007
@@ -26,21 +26,19 @@
import javax.portlet.PortletRequest;
/**
- * @author <a href="mailto:ddewolf@apache.org">David H. DeWolf</a>
- * @author <a href="mailto:zheng@apache.org">ZHENG Zhong</a>
*/
public class ActionParameterTest extends AbstractReflectivePortletTest
implements ActionTest {
-
+
/** Parameter key encoded in the action URL. */
public static final String KEY = "org.apache.pluto.testsuite.PARAM_ACTION_KEY";
-
+
/** Parameter value encoded in the action URL. */
public static final String VALUE = "org.apache.pluto.testsuite.ACTION_VALUE";
-
-
+
+
// Test Methods ------------------------------------------------------------
-
+
protected TestResult checkGetActionParameter(PortletRequest request) {
TestResult result = new TestResult();
result.setDescription("Ensure parameters encoded in action URL are "
@@ -59,7 +57,7 @@
TestResult result = new TestResult();
result.setDescription("Ensure parameters encoded in action URL are "
+ "available in the action request parameter map.");
-
+
Map parameterMap = request.getParameterMap();
String[] values = (String[]) parameterMap.get(KEY);
if (values != null && values.length == 1 && VALUE.equals(values[0])) {
@@ -70,12 +68,12 @@
}
return result;
}
-
+
protected TestResult checkParameterNames(PortletRequest request) {
TestResult result = new TestResult();
result.setDescription("Ensure parameters encoded in action URL "
+ "exists in the parameter name enumeration.");
-
+
boolean hasParameterName = false;
for (Enumeration en = request.getParameterNames();
!hasParameterName && en.hasMoreElements(); ) {
@@ -84,7 +82,7 @@
hasParameterName = true;
}
}
-
+
if (hasParameterName) {
result.setReturnCode(TestResult.PASSED);
} else {
@@ -94,5 +92,5 @@
}
return result;
}
-
+
}
Modified: portals/pluto/trunk/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/AppScopedSessionAttributeTest.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/AppScopedSessionAttributeTest.java?view=diff&rev=516346&r1=516345&r2=516346
==============================================================================
--- portals/pluto/trunk/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/AppScopedSessionAttributeTest.java (original)
+++ portals/pluto/trunk/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/AppScopedSessionAttributeTest.java Fri Mar 9 01:47:12 2007
@@ -23,8 +23,6 @@
import javax.portlet.PortletSession;
/**
- * @author <a href="mailto:ddewolf@apache.org">David H. DeWolf</a>
- * @author <a href="mailto:zheng@apache.org">ZHENG Zhong</a>
*/
public class AppScopedSessionAttributeTest
extends AbstractReflectivePortletTest {
@@ -32,17 +30,17 @@
private static final String BOGUS_KEY = "org.apache.pluto.testsuite.BOGUS_KEY";
private static final String KEY = "org.apache.pluto.testsuite.KEY";
private static final String VALUE = "VALUE";
-
-
+
+
// Test Methods ------------------------------------------------------------
-
+
protected TestResult checkGetEmptyAppScopedAttribute(PortletSession session) {
TestResult result = new TestResult();
result.setDescription("Retrieve an attribute that has not been set "
+ "in the session's application scope "
+ "and ensure it's value is null.");
result.setSpecPLT("15.3");
-
+
Object value = session.getAttribute(BOGUS_KEY, PortletSession.APPLICATION_SCOPE);
if (value == null) {
result.setReturnCode(TestResult.PASSED);
@@ -51,13 +49,13 @@
}
return result;
}
-
+
protected TestResult checkSetAppScopedAttribute(PortletSession session) {
TestResult result = new TestResult();
result.setDescription("Set an application scoped session attribute "
+ "and ensure it's retrievable.");
result.setSpecPLT("15.3");
-
+
session.setAttribute(KEY, VALUE, PortletSession.APPLICATION_SCOPE);
Object value = session.getAttribute(KEY, PortletSession.APPLICATION_SCOPE);
if (VALUE.equals(value)) {
@@ -73,7 +71,7 @@
result.setDescription("Remove an application scoped session attribute "
+ "and ensure it's null.");
result.setSpecPLT("15.3");
-
+
session.setAttribute(KEY, VALUE, PortletSession.APPLICATION_SCOPE);
session.removeAttribute(KEY, PortletSession.APPLICATION_SCOPE);
Object value = session.getAttribute(KEY, PortletSession.APPLICATION_SCOPE);
@@ -84,5 +82,5 @@
}
return result;
}
-
+
}
Modified: portals/pluto/trunk/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/ContextInitParameterTest.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/ContextInitParameterTest.java?view=diff&rev=516346&r1=516345&r2=516346
==============================================================================
--- portals/pluto/trunk/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/ContextInitParameterTest.java (original)
+++ portals/pluto/trunk/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/ContextInitParameterTest.java Fri Mar 9 01:47:12 2007
@@ -24,26 +24,24 @@
import java.util.Enumeration;
/**
- * @author <a href="mailto:ddewolf@apache.org">David H. DeWolf</a>
- * @author <a href="mailto:zheng@apache.org">ZHENG Zhong</a>
* @version 1.0
* @since Sep 15, 2004
*/
public class ContextInitParameterTest extends AbstractReflectivePortletTest {
-
+
private static final String TEST_PARAM_NAME = "test-parameter-name";
private static final String TEST_PARAM_VALUE = "test-parameter-val";
-
-
+
+
// Test Methods ------------------------------------------------------------
-
+
protected TestResult checkEnumerationContainsNames(
PortletContext context) {
TestResult result = new TestResult();
result.setDescription("Ensure that the expected init parameter name "
+ "exists in the portlet context's init parameters.");
result.setSpecPLT("10.3.1");
-
+
boolean found = false;
for (Enumeration en = context.getInitParameterNames();
!found && en.hasMoreElements(); ) {
@@ -62,12 +60,12 @@
}
return result;
}
-
+
protected TestResult checkGetInitParameter(PortletContext context) {
TestResult result = new TestResult();
result.setDescription("Ensure that init parameters are retrieveable.");
result.setSpecPLT("10.3.1");
-
+
String value = context.getInitParameter(TEST_PARAM_NAME);
if (TEST_PARAM_VALUE.equals(value)) {
result.setReturnCode(TestResult.PASSED);
@@ -76,7 +74,7 @@
}
return result;
}
-
+
/**
* FIXME: should this test reside in this class? -- ZHENG Zhong
*/
@@ -84,7 +82,7 @@
TestResult result = new TestResult();
result.setDescription("Ensure that the PortletContext can be retrieved "
+ "from the portlet session.");
-
+
PortletContext context = session.getPortletContext();
if (context != null) {
result.setReturnCode(TestResult.PASSED);
Modified: portals/pluto/trunk/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/DispatcherRenderParameterTest.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/DispatcherRenderParameterTest.java?view=diff&rev=516346&r1=516345&r2=516346
==============================================================================
--- portals/pluto/trunk/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/DispatcherRenderParameterTest.java (original)
+++ portals/pluto/trunk/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/DispatcherRenderParameterTest.java Fri Mar 9 01:47:12 2007
@@ -38,53 +38,51 @@
import javax.servlet.ServletResponse;
/**
- *
- * @author <a href="mailto:ddewolf@apache.org">David H. DeWolf</a>
- * @author <a href="mailto:zheng@apache.org">ZHENG Zhong</a>
+ *
* @version 1.0
* @since Mar 9, 2005
*/
-public class DispatcherRenderParameterTest
+public class DispatcherRenderParameterTest
extends AbstractReflectivePortletTest {
-
+
/** Internal logger. */
private static final Log LOG = LogFactory.getLog(
DispatcherRenderParameterTest.class);
-
+
// Static Final Constants --------------------------------------------------
-
+
/** The path to the companion servlet. */
private static final String SERVLET_PATH = "/test/DispatcherRenderParameterTest_Servlet";
-
+
private static final String KEY_TARGET = "target";
-
+
private static final String TARGET_PARAMS = "testParams";
private static final String TARGET_SAME_NAME_PARAM = "testSameNameParam";
private static final String TARGET_ADDED_SAME_NAME_PARAM = "testAddedSameNameParam";
private static final String TARGET_INVALID_PARAMS = "testInvalidParams";
-
+
private static final String KEY_RENDER = "renderParamKey";
private static final String VALUE_RENDER = "renderParamValue";
private static final String VALUE_ADDED1 = "addedParamValue1";
private static final String VALUE_ADDED2 = "addedParamValue2";
-
+
private static final String KEY_A = "includedTestKeyA";
private static final String VALUE_A = "includedTestValueA";
-
+
private static final String KEY_B = "includedTestKeyB";
private static final String VALUE_B = "includedTestValueB";
-
+
private static final String KEY_C = "includedTestKeyC";
private static final String VALUE_C1 = "valueOneOfKeyC";
private static final String VALUE_C2 = "valueTwoOfKeyC";
private static final String VALUE_C3 = "valueThreeOfKeyC";
-
+
public static final String RESULT_KEY =
DispatcherRenderParameterTest.class.getName() + ".RESULT_KEY";
-
-
+
+
// AbstractReflectivePortletTest Impl --------------------------------------
-
+
/**
* Overwrites <code>super.getRenderParameters(..)</code> to set the
* test-specific render parameter in the render URL.
@@ -94,42 +92,42 @@
parameterMap.put(KEY_RENDER, new String[] { VALUE_RENDER });
return parameterMap;
}
-
-
+
+
// Test Methods ------------------------------------------------------------
-
+
protected TestResult checkParameters(PortletContext context,
PortletRequest request,
PortletResponse response)
throws IOException, PortletException {
-
+
// Dispatch to the companion servlet: call checkParameters().
StringBuffer buffer = new StringBuffer();
buffer.append(SERVLET_PATH).append("?")
.append(KEY_TARGET).append("=").append(TARGET_PARAMS)
.append("&").append(KEY_A).append("=").append(VALUE_A)
.append("&").append(KEY_B).append("=").append(VALUE_B);
-
+
if (LOG.isDebugEnabled()) {
LOG.debug("Dispatching to: " + buffer.toString());
}
PortletRequestDispatcher dispatcher = context.getRequestDispatcher(
buffer.toString());
dispatcher.include((RenderRequest) request, (RenderResponse) response);
-
+
// Retrieve test result returned by the companion servlet.
TestResult result = (TestResult) request.getAttribute(RESULT_KEY);
request.removeAttribute(RESULT_KEY);
return result;
}
-
-
+
+
protected TestResult checkSameNameParameter(PortletContext context,
PortletRequest request,
PortletResponse response)
throws IOException, PortletException {
-
+
// Dispatch to the companion servlet: call checkSameNameParameter().
StringBuffer buffer = new StringBuffer();
buffer.append(SERVLET_PATH).append("?")
@@ -137,20 +135,20 @@
.append("&").append(KEY_C).append("=").append(VALUE_C1)
.append("&").append(KEY_C).append("=").append(VALUE_C2)
.append("&").append(KEY_C).append("=").append(VALUE_C3);
-
+
if (LOG.isDebugEnabled()) {
LOG.debug("Dispatching to: " + buffer.toString());
}
PortletRequestDispatcher dispatcher = context.getRequestDispatcher(
buffer.toString());
dispatcher.include((RenderRequest) request, (RenderResponse) response);
-
+
// Retrieve test result returned by the companion servlet.
TestResult result = (TestResult) request.getAttribute(RESULT_KEY);
request.removeAttribute(RESULT_KEY);
return result;
}
-
+
protected TestResult checkAddedSameNameParameter(PortletContext context,
PortletRequest request,
PortletResponse response)
@@ -161,25 +159,25 @@
.append(KEY_TARGET).append("=").append(TARGET_ADDED_SAME_NAME_PARAM)
.append("&").append(KEY_RENDER).append("=").append(VALUE_ADDED1)
.append("&").append(KEY_RENDER).append("=").append(VALUE_ADDED2);
-
+
if (LOG.isDebugEnabled()) {
LOG.debug("Dispatching to: " + buffer.toString());
}
PortletRequestDispatcher dispatcher = context.getRequestDispatcher(
buffer.toString());
dispatcher.include((RenderRequest) request, (RenderResponse) response);
-
+
// Retrieve test result returned by the companion servlet.
TestResult result = (TestResult) request.getAttribute(RESULT_KEY);
request.removeAttribute(RESULT_KEY);
return result;
}
-
+
protected TestResult checkInvalidParameters(PortletContext context,
PortletRequest request,
PortletResponse response)
throws IOException, PortletException {
-
+
// Dispatch to the companion servlet: call checkInvalidParameters().
StringBuffer buffer = new StringBuffer();
buffer.append(SERVLET_PATH).append("?")
@@ -193,29 +191,27 @@
PortletRequestDispatcher dispatcher = context.getRequestDispatcher(
buffer.toString());
dispatcher.include((RenderRequest) request, (RenderResponse) response);
-
+
// Retrieve test result returned by the companion servlet.
TestResult result = (TestResult) request.getAttribute(RESULT_KEY);
request.removeAttribute(RESULT_KEY);
return result;
}
-
-
+
+
// Nested Companion Servlet Class ------------------------------------------
-
+
/**
* Nested static companion servlet class.
- * @author <a href="mailto:ddewolf@apache.org">David H. DeWolf</a>
- * @author <a href="mailto:zheng@apache.org">ZHENG Zhong</a>
*/
public static class CompanionServlet extends GenericServlet {
// GenericServlet Impl -------------------------------------------------
-
+
public String getServletInfo() {
return getClass().getName();
}
-
+
/**
* Services the servlet request dispatched from the test portlet.
* This method checks the 'target' parameter to determine which test
@@ -241,10 +237,10 @@
}
request.setAttribute(RESULT_KEY, result);
}
-
-
+
+
// Private Methods -----------------------------------------------------
-
+
/**
* Check that parameters A and B are available in the dispatching
* request.
@@ -265,7 +261,7 @@
}
return result;
}
-
+
/**
* Check that parameter C has three values.
* @param request the servlet reqeust.
@@ -284,7 +280,7 @@
}
return result;
}
-
+
/**
* Check that parameter RENDER has three values: one is the render
* parameter, while the other two are appended in the dispatch URI.
@@ -305,7 +301,7 @@
}
return result;
}
-
+
/**
* Check that invalid parameter A is ignored, parameter B is attached
* to the dispatching request with the correct value, and parameter C
@@ -330,7 +326,7 @@
}
return result;
}
-
+
private TestResult failOnUnknownTarget(ServletRequest request) {
TestResult result = new TestResult();
result.setReturnCode(TestResult.FAILED);
@@ -338,8 +334,8 @@
+ KEY_TARGET + ": " + request.getParameter(KEY_TARGET));
return result;
}
-
+
}
-
+
}
Modified: portals/pluto/trunk/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/ExpectedResults.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/ExpectedResults.java?view=diff&rev=516346&r1=516345&r2=516346
==============================================================================
--- portals/pluto/trunk/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/ExpectedResults.java (original)
+++ portals/pluto/trunk/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/ExpectedResults.java Fri Mar 9 01:47:12 2007
@@ -5,15 +5,15 @@
* 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;
@@ -27,26 +27,24 @@
/**
* A Singleton which loads a properties file containing data expected by the
* tests in the testsuite.
- * @author <a href="mailto:ddewolf@apache.org">David H. DeWolf</a>
- * @author <a href="mailto:zheng@apache.org">ZHENG Zhong</a>
*/
public class ExpectedResults {
-
+
/** The file name of properties holding expected results. */
public static final String PROPERTY_FILENAME = "expectedResults.properties";
-
+
/** The static singleton instance. */
- private static ExpectedResults instance = null;
-
-
+ private static ExpectedResults instance;
+
+
// Private Member Variables ------------------------------------------------
-
+
/** The nested properties. */
- private Properties properties = null;
-
-
+ private Properties properties;
+
+
// Constructor -------------------------------------------------------------
-
+
/**
* Private constructor that prevents external instantiation.
* @throws IOException if fail to load properties from file.
@@ -61,7 +59,7 @@
throw new IOException("Could not find " + PROPERTY_FILENAME);
}
}
-
+
/**
* Returns the singleton expected results instance.
* @return the singleton expected results instance.
@@ -71,7 +69,7 @@
throws InvalidConfigurationException {
if (instance == null) {
try {
- instance = new ExpectedResults();
+ instance = new ExpectedResults();
} catch (IOException ex) {
throw new InvalidConfigurationException("Error reading file "
+ PROPERTY_FILENAME + ": " + ex.getMessage());
@@ -79,34 +77,34 @@
}
return instance;
}
-
-
+
+
// Public Methods ----------------------------------------------------------
-
+
public String getMajorVersion() {
return properties.getProperty("expected.version.major");
}
-
+
public String getMinorVersion() {
return properties.getProperty("expected.version.minor");
}
-
+
public String getServerInfo() {
- return properties.getProperty("expected.serverInfo");
+ return properties.getProperty("expected.serverInfo");
}
-
+
public String getPortalInfo() {
return properties.getProperty("expected.portalInfo");
}
-
+
public String getMappedSecurityRole() {
return properties.getProperty("expected.security.role.mapped");
}
-
+
public String getUnmappedSecurityRole() {
return properties.getProperty("expected.security.role");
}
-
+
}
Modified: portals/pluto/trunk/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/ExternalAppScopedAttributeTest.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/ExternalAppScopedAttributeTest.java?view=diff&rev=516346&r1=516345&r2=516346
==============================================================================
--- portals/pluto/trunk/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/ExternalAppScopedAttributeTest.java (original)
+++ portals/pluto/trunk/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/ExternalAppScopedAttributeTest.java Fri Mar 9 01:47:12 2007
@@ -30,24 +30,22 @@
import javax.servlet.http.HttpSession;
/**
- * @author <a href="mailto:ddewolf@apache.org">David H. DeWolf</a>
- * @author <a href="mailto:zheng@apache.org">ZHENG Zhong</a>
*/
public class ExternalAppScopedAttributeTest extends AbstractReflectivePortletTest {
public static final String INT_KEY = "org.apache.pluto.testsuite.INTERNALLY_SET_APP_SCOPED_SESSION_TEST_KEY";
public static final String EXT_KEY = "org.apache.pluto.testsuite.EXTERNALLY_SET_APP_SCOPED_SESSION_TEST_KEY";
public static final String VALUE = "Should be visible to all Portlets and Web Resources.";
-
-
+
+
// Test Methods ------------------------------------------------------------
-
+
protected TestResult checkSetAppScopedAttributeHereSeenElsewhere(
PortletSession session) {
TestResult result = new TestResult();
result.setDescription("Ensure application scoped attributes set here "
+ "in portlet session can be seen elsewhere.");
-
+
session.setAttribute(INT_KEY, VALUE, PortletSession.APPLICATION_SCOPE);
result.setReturnCode(TestResult.WARNING);
result.setResultMessage("Click the provided link to validate test.");
@@ -59,7 +57,7 @@
TestResult result = new TestResult();
result.setDescription("Ensure application scoped attributes set "
+ "elsewhere in portlet session can be seen here.");
-
+
Object value = session.getAttribute(EXT_KEY,
PortletSession.APPLICATION_SCOPE);
if (VALUE.equals(value)) {
@@ -71,10 +69,10 @@
}
return result;
}
-
-
+
+
// Nested Servlet Class ----------------------------------------------------
-
+
/**
* The companion servlet that cooperates with this portlet test.
*/
@@ -89,12 +87,12 @@
request.setAttribute("passed", new Boolean(true));
session.setAttribute(EXT_KEY, VALUE);
}
-
+
RequestDispatcher dispatcher = request.getRequestDispatcher(
"/jsp/ExternalAppScopedAttributeTest_companion.jsp");
dispatcher.forward(request, response);
}
-
+
}
-
+
}
Modified: portals/pluto/trunk/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/MiscTest.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/MiscTest.java?view=diff&rev=516346&r1=516345&r2=516346
==============================================================================
--- portals/pluto/trunk/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/MiscTest.java (original)
+++ portals/pluto/trunk/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/MiscTest.java Fri Mar 9 01:47:12 2007
@@ -30,17 +30,15 @@
import org.apache.pluto.testsuite.TestUtils;
/**
- * @author <a href="mailto:ddewolf@apache.org">David H. DeWolf</a>
- * @author <a href="mailto:zheng@apache.org">ZHENG Zhong</a>
*/
public class MiscTest extends AbstractReflectivePortletTest {
// Test Methods ------------------------------------------------------------
-
+
protected TestResult checkContextMajorVersion(PortletContext context) {
TestResult result = new TestResult();
result.setDescription("Ensure the expected major version number is returned.");
-
+
String majorVersion = String.valueOf(context.getMajorVersion());
ExpectedResults expectedResults = ExpectedResults.getInstance();
String expected = expectedResults.getMajorVersion();
@@ -55,7 +53,7 @@
protected TestResult checkContextMinorVersion(PortletContext context) {
TestResult result = new TestResult();
result.setDescription("Ensure the expected minor version number is returned.");
-
+
String minorVersion = String.valueOf(context.getMinorVersion());
ExpectedResults expectedResults = ExpectedResults.getInstance();
String expected = expectedResults.getMinorVersion();
@@ -66,11 +64,11 @@
}
return result;
}
-
+
protected TestResult checkContextServerInfo(PortletContext context) {
TestResult result = new TestResult();
result.setDescription("Ensure the expected server info is returned.");
-
+
String serverInfo = context.getServerInfo();
ExpectedResults expectedResults = ExpectedResults.getInstance();
String expected = expectedResults.getServerInfo();
@@ -85,7 +83,7 @@
protected TestResult checkPortalInfo(PortletRequest request) {
TestResult result = new TestResult();
result.setDescription("Ensure the expected portal info is returned.");
-
+
String portalInfo = request.getPortalContext().getPortalInfo();
ExpectedResults expectedResults = ExpectedResults.getInstance();
String expected = expectedResults.getPortalInfo();
@@ -106,7 +104,7 @@
protected TestResult checkSupportedModes(PortletRequest request) {
TestResult result = new TestResult();
result.setDescription("Ensure the expected portlet modes are returned.");
-
+
List requiredPortletModes = new ArrayList();
requiredPortletModes.add(PortletMode.VIEW);
requiredPortletModes.add(PortletMode.EDIT);
@@ -117,7 +115,7 @@
PortletMode portletMode = (PortletMode) en.nextElement();
requiredPortletModes.remove(portletMode);
}
-
+
if (requiredPortletModes.isEmpty()) {
result.setReturnCode(TestResult.PASSED);
} else {
@@ -136,18 +134,18 @@
protected TestResult checkSupportedWindowSates(PortletRequest request) {
TestResult result = new TestResult();
result.setDescription("Ensure the expected window states are returned.");
-
+
List requiredWindowStates = new ArrayList();
requiredWindowStates.add(WindowState.MINIMIZED);
requiredWindowStates.add(WindowState.MAXIMIZED);
requiredWindowStates.add(WindowState.NORMAL);
-
+
for (Enumeration en = request.getPortalContext().getSupportedWindowStates();
en.hasMoreElements(); ) {
WindowState windowState = (WindowState) en.nextElement();
requiredWindowStates.remove(windowState);
}
-
+
if (requiredWindowStates.isEmpty()) {
result.setReturnCode(TestResult.PASSED);
} else {
Modified: portals/pluto/trunk/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/PreferenceCommonTest.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/PreferenceCommonTest.java?view=diff&rev=516346&r1=516345&r2=516346
==============================================================================
--- portals/pluto/trunk/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/PreferenceCommonTest.java (original)
+++ portals/pluto/trunk/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/PreferenceCommonTest.java Fri Mar 9 01:47:12 2007
@@ -31,36 +31,35 @@
/**
* Common portlet preferences test.
- * @author <a href="mailto:zheng@apache.org">ZHENG Zhong</a>
*/
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 <code>portlet.xml</code>, the default values are returned.
@@ -75,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,
@@ -101,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)) {
@@ -111,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");
@@ -124,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);
@@ -138,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"});
@@ -169,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);
@@ -182,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);
@@ -191,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" });
@@ -214,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);
@@ -241,7 +240,7 @@
TestUtils.failOnException("Unable to set preference value.", ex, result);
return result;
}
-
+
// Everything is OK.
if (setOccured && resetOccured) {
result.setReturnCode(TestResult.PASSED);
@@ -260,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);
@@ -288,7 +287,7 @@
TestUtils.failOnException("Unable to set preference value.", ex, result);
return result;
}
-
+
// Everything is OK.
if (setOccured && resetOccured) {
result.setReturnCode(TestResult.PASSED);
@@ -308,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);
@@ -324,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 {
@@ -370,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;
@@ -385,7 +384,7 @@
break;
}
}
-
+
if (hasAll) {
result.setReturnCode(TestResult.PASSED);
} else {
@@ -395,7 +394,7 @@
}
return result;
}
-
+
/**
* FIXME:
*/
@@ -415,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);
@@ -431,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:");
@@ -447,11 +446,11 @@
}
return result;
}
-
-
+
+
// Debug Methods -----------------------------------------------------------
-
-
+
+
/**
* Logs out the portlet preferences.
* @param preferences PortletPreferences to log.
@@ -476,9 +475,9 @@
// Spec allows null values.
buffer.append("NULL");
}
- buffer.append(";");
+ buffer.append(";");
}
LOG.debug("PortletPreferences: " + buffer.toString());
}
-
+
}
Modified: portals/pluto/trunk/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/PreferenceInActionTest.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/PreferenceInActionTest.java?view=diff&rev=516346&r1=516345&r2=516346
==============================================================================
--- portals/pluto/trunk/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/PreferenceInActionTest.java (original)
+++ portals/pluto/trunk/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/PreferenceInActionTest.java Fri Mar 9 01:47:12 2007
@@ -31,23 +31,21 @@
import javax.portlet.ValidatorException;
/**
- * @author <a href="mailto:ddewolf@apache.org">David H. DeWolf</a>
- * @author <a href="mailto:zheng@apache.org">ZHENG Zhong</a>
*/
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:");
@@ -62,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;
@@ -80,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 {
@@ -92,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(
@@ -131,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);
@@ -172,7 +170,7 @@
return result;
}
}
-
+
// Everything is OK.
if (setOccured && storeOccured) {
result.setReturnCode(TestResult.PASSED);
@@ -191,5 +189,5 @@
}
return result;
}
-
+
}
Modified: portals/pluto/trunk/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/RenderParameterTest.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/RenderParameterTest.java?view=diff&rev=516346&r1=516345&r2=516346
==============================================================================
--- portals/pluto/trunk/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/RenderParameterTest.java (original)
+++ portals/pluto/trunk/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/RenderParameterTest.java Fri Mar 9 01:47:12 2007
@@ -26,8 +26,6 @@
import javax.portlet.PortletRequest;
/**
- * @author <a href="mailto:ddewolf@apache.org">David H. DeWolf</a>
- * @author <a href="mailto:zheng@apache.org">ZHENG Zhong</a>
*/
public class RenderParameterTest extends AbstractReflectivePortletTest {
@@ -35,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);
@@ -65,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);
@@ -95,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
@@ -133,7 +131,7 @@
hasRenderParameter = true;
}
}
-
+
if (!hasActionParameter && hasRenderParameter) {
result.setReturnCode(TestResult.PASSED);
} else {
Modified: portals/pluto/trunk/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/RenderResponseNoContentTypeTest.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/RenderResponseNoContentTypeTest.java?view=diff&rev=516346&r1=516345&r2=516346
==============================================================================
--- portals/pluto/trunk/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/RenderResponseNoContentTypeTest.java (original)
+++ portals/pluto/trunk/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/RenderResponseNoContentTypeTest.java Fri Mar 9 01:47:12 2007
@@ -28,14 +28,13 @@
/**
* FIXME: separate the two check methods to two classes.
- *
- * @author <a href="mailto:zheng@apache.org">ZHENG Zhong</a>
+ *
*/
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.
@@ -44,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);
@@ -82,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);
@@ -104,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/trunk/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/ResourceBundleTest.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/ResourceBundleTest.java?view=diff&rev=516346&r1=516345&r2=516346
==============================================================================
--- portals/pluto/trunk/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/ResourceBundleTest.java (original)
+++ portals/pluto/trunk/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/ResourceBundleTest.java Fri Mar 9 01:47:12 2007
@@ -16,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.PortletConfig;
+import javax.portlet.PortletRequest;
-import javax.portlet.*;
-import java.util.*;
+import org.apache.pluto.testsuite.TestResult;
/**
* Tests basic attribute retrieval and storage functions within
* the portlet request, session, and context objects.
*
- * @author <a href="mailto:ddewolf@apache.org">David H. DeWolf</a>
- * @author <a href="mailto:zheng@apache.org">ZHENG Zhong</a>
*/
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
* <code>testsuite-config/init-param</code>.
*/
private static final String BUNDLE_DECLARED_PARAM = "resource-bundle";
-
+
/**
* Parameter name for portlet title in
* <code>testsuite-config/init-param</code>.
*/
private static final String TITLE_PARAM = "title";
-
+
/**
* Parameter name for portlet short title in
* <code>testsuite-config/init-param</code>.
*/
private static final String SHORT_TITLE_PARAM = "short-title";
-
+
/**
* Parameter name for portlet keywords in
* <code>testsuite-config/init-param</code>.
*/
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);
@@ -83,7 +89,7 @@
}
return result;
}
-
+
protected TestResult checkGetNames(PortletConfig config,
PortletRequest request) {
TestResult result = new TestResult();
@@ -94,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);
@@ -103,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 {
@@ -143,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 locale " + locale);
-
+
// Retrieve title, short title and keywords from portlet resource bundle.
ResourceBundle bundle = config.getResourceBundle(locale);
if (bundle == null) {
@@ -166,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();
@@ -176,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();
@@ -202,7 +208,7 @@
.append(keywords).append("' != '")
.append(expectedKeywords).append("'; ");
}
-
+
if (!inconsistent) {
result.setReturnCode(TestResult.PASSED);
} else {
@@ -211,7 +217,7 @@
}
return result;
}
-
+
private boolean isBundleDeclared() {
String bundleDeclared = (String) getInitParameters().get(
BUNDLE_DECLARED_PARAM);
Modified: portals/pluto/trunk/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/SecurityMappingTest.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/SecurityMappingTest.java?view=diff&rev=516346&r1=516345&r2=516346
==============================================================================
--- portals/pluto/trunk/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/SecurityMappingTest.java (original)
+++ portals/pluto/trunk/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/SecurityMappingTest.java Fri Mar 9 01:47:12 2007
@@ -21,20 +21,18 @@
import org.apache.pluto.testsuite.TestResult;
/**
- * @author <a href="mailto:ddewolf@apache.org">David H. DeWolf</a>
- * @author <a href="mailto:zheng@apache.org">ZHENG Zhong</a>
*/
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)) {
@@ -46,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)) {
@@ -65,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);
@@ -82,10 +80,10 @@
}
return result;
}
-
-
+
+
// Private Methods ---------------------------------------------------------
-
+
private TestResult isUserLoggedIn(PortletRequest request) {
TestResult result = new TestResult();
if (request.getRemoteUser() == null) {