portals-pluto-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ddew...@apache.org
Subject svn commit: rev 36716 - portals/pluto/trunk/testsuite/src/java/org/apache/pluto/portalImpl/portlet/test
Date Mon, 23 Aug 2004 01:05:17 GMT
Author: ddewolf
Date: Sun Aug 22 18:05:16 2004
New Revision: 36716

Added:
   portals/pluto/trunk/testsuite/src/java/org/apache/pluto/portalImpl/portlet/test/
   portals/pluto/trunk/testsuite/src/java/org/apache/pluto/portalImpl/portlet/test/AbstractReflectivePortletTest.java
   portals/pluto/trunk/testsuite/src/java/org/apache/pluto/portalImpl/portlet/test/ActionAbstractReflectivePortletTest.java
   portals/pluto/trunk/testsuite/src/java/org/apache/pluto/portalImpl/portlet/test/ActionTest.java
   portals/pluto/trunk/testsuite/src/java/org/apache/pluto/portalImpl/portlet/test/ComplexAttributeTest.java
   portals/pluto/trunk/testsuite/src/java/org/apache/pluto/portalImpl/portlet/test/ExternalAppScopedAttributeTest.java
   portals/pluto/trunk/testsuite/src/java/org/apache/pluto/portalImpl/portlet/test/ExternalAppScopedAttributeTestCompanionServlet.java
   portals/pluto/trunk/testsuite/src/java/org/apache/pluto/portalImpl/portlet/test/MiscTest.java
   portals/pluto/trunk/testsuite/src/java/org/apache/pluto/portalImpl/portlet/test/PortletTest.java
   portals/pluto/trunk/testsuite/src/java/org/apache/pluto/portalImpl/portlet/test/SecurityMappingTest.java
   portals/pluto/trunk/testsuite/src/java/org/apache/pluto/portalImpl/portlet/test/SimpleAttributeTest.java
   portals/pluto/trunk/testsuite/src/java/org/apache/pluto/portalImpl/portlet/test/SimpleParameterTest.java
   portals/pluto/trunk/testsuite/src/java/org/apache/pluto/portalImpl/portlet/test/SimplePreferenceTest.java
   portals/pluto/trunk/testsuite/src/java/org/apache/pluto/portalImpl/portlet/test/TestResult.java
   portals/pluto/trunk/testsuite/src/java/org/apache/pluto/portalImpl/portlet/test/TestResults.java
Log:
The testsuite portlet has been enhanced.  Testing logic - where possible - has been moved into test classes for less scripting, easier maintenence, and to model best practices a little better.  Additional tests have been added.

Added: portals/pluto/trunk/testsuite/src/java/org/apache/pluto/portalImpl/portlet/test/AbstractReflectivePortletTest.java
==============================================================================
--- (empty file)
+++ portals/pluto/trunk/testsuite/src/java/org/apache/pluto/portalImpl/portlet/test/AbstractReflectivePortletTest.java	Sun Aug 22 18:05:16 2004
@@ -0,0 +1,74 @@
+package org.apache.pluto.portalImpl.portlet.test;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.InvocationTargetException;
+import java.util.Map;
+
+import javax.portlet.PortletContext;
+import javax.portlet.PortletRequest;
+import javax.portlet.PortletResponse;
+import javax.portlet.PortletSession;
+
+/**
+ * @author <a href="ddewolf@apache.org">David H. DeWolf</a>
+ */
+public abstract class AbstractReflectivePortletTest implements PortletTest {
+
+    public TestResults doTest(PortletContext context,
+                              PortletRequest req,
+                              PortletResponse res) {
+        TestResults results = new TestResults(getTestSuiteName());
+        
+        Class klass = getClass();
+        Method[] methods = klass.getDeclaredMethods();
+
+        for(int i = 0; i<methods.length;i++) {
+            if(methods[i].getName().startsWith("check")) {
+                try {
+                    results.add(invoke(methods[i], context, req, res));
+                }
+                catch(Exception e) {
+                    e.printStackTrace();
+                    TestResult result = new TestResult();
+                    result.setName(methods[i].getName());
+                    result.setDesc("Unknown");
+                    result.setReturnCode(TestResult.FAILED);
+                    result.setResults(e.getMessage());
+                    results.add(result);
+                }
+            }
+        }
+        return results;
+    }
+    
+    public TestResult invoke(Method method, PortletContext context,
+                             PortletRequest req, PortletResponse res)
+    throws IllegalAccessException, InvocationTargetException {
+
+        TestResult result = null;
+        Class[] paramTypes= method.getParameterTypes();
+        Object[] paramValues = new Object[paramTypes.length];
+
+        for(int i=0;i<paramTypes.length;i++) {
+            if(paramTypes[i].equals(PortletContext.class)) {
+                paramValues[i] = context;
+            }
+            if(paramTypes[i].equals(PortletRequest.class)) {
+                paramValues[i] = req;
+            }
+            if(paramTypes[i].equals(PortletResponse.class)) {
+                paramValues[i] = res;
+            }
+            if(paramTypes[i].equals(PortletSession.class)) {
+                paramValues[i] = req.getPortletSession();
+            }
+            result = (TestResult)method.invoke(this, paramValues);
+        }
+        return result;
+    }
+
+    public Map getRenderParameters(PortletRequest req) {
+        Map map = new java.util.HashMap();
+        return map;
+    }
+}

Added: portals/pluto/trunk/testsuite/src/java/org/apache/pluto/portalImpl/portlet/test/ActionAbstractReflectivePortletTest.java
==============================================================================
--- (empty file)
+++ portals/pluto/trunk/testsuite/src/java/org/apache/pluto/portalImpl/portlet/test/ActionAbstractReflectivePortletTest.java	Sun Aug 22 18:05:16 2004
@@ -0,0 +1,14 @@
+package org.apache.pluto.portalImpl.portlet.test;
+
+import java.util.Map;
+
+import javax.portlet.PortletRequest;
+
+/**
+ * @author <a href="david.dewolf@vivare.com">David H. DeWolf</a>
+ */
+public abstract class ActionAbstractReflectivePortletTest
+ extends AbstractReflectivePortletTest
+ implements ActionTest {
+
+}

Added: portals/pluto/trunk/testsuite/src/java/org/apache/pluto/portalImpl/portlet/test/ActionTest.java
==============================================================================
--- (empty file)
+++ portals/pluto/trunk/testsuite/src/java/org/apache/pluto/portalImpl/portlet/test/ActionTest.java	Sun Aug 22 18:05:16 2004
@@ -0,0 +1,14 @@
+package org.apache.pluto.portalImpl.portlet.test;
+
+import java.util.Map;
+
+import javax.portlet.PortletRequest;
+
+/**
+ * @author <a href="david.dewolf@vivare.com">David H. DeWolf</a>
+ */
+public interface ActionTest extends PortletTest {
+
+
+
+}

Added: portals/pluto/trunk/testsuite/src/java/org/apache/pluto/portalImpl/portlet/test/ComplexAttributeTest.java
==============================================================================
--- (empty file)
+++ portals/pluto/trunk/testsuite/src/java/org/apache/pluto/portalImpl/portlet/test/ComplexAttributeTest.java	Sun Aug 22 18:05:16 2004
@@ -0,0 +1,79 @@
+package org.apache.pluto.portalImpl.portlet.test;
+
+import java.util.Map;
+
+import javax.portlet.PortletContext;
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.PortletSession;
+
+/**
+ * @author <a href="david.dewolf@vivare.com">David H. DeWolf</a>
+ */
+public class ComplexAttributeTest extends AbstractReflectivePortletTest {
+
+    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 VAL = "VALUE";
+
+    public String getTestSuiteName() {
+        return "Complex Attribute Test";
+    }
+
+    public Map doPrerequisiteAction(PortletContext context, ActionRequest req,
+                                    ActionResponse res) {
+        return new java.util.HashMap();
+    }
+
+    protected TestResult checkGetEmptyApplicationScopedAttribute(PortletSession session) {
+        TestResult res = new TestResult();
+        res.setName("Get Empty Application Scoped Attribute Test");
+        res.setDesc("Retrieve an attribute that has not been set in the session's application scope and ensure it's value is null.");
+
+        Object val = session.getAttribute(BOGUS_KEY, PortletSession.APPLICATION_SCOPE);
+        if(val == null) {
+            res.setReturnCode(TestResult.PASSED);
+        }
+        else {
+            res.setReturnCode(TestResult.FAILED);
+            res.setResults("Retrieved attribute value '"+val+"'; expected null.");
+        }
+        return res;
+    }
+
+    protected TestResult checkSetApplicationScopedAttribute(PortletSession session) {
+        TestResult res = new TestResult();
+        res.setName("Set Application Scoped Attribute Test");
+        res.setDesc("Set an application scoped session attribute and ensure it's retrievable");
+
+        session.setAttribute(KEY, VAL, PortletSession.APPLICATION_SCOPE);
+
+        Object val = session.getAttribute(KEY, PortletSession.APPLICATION_SCOPE);
+        if(VAL.equals(val)) {
+            res.setReturnCode(TestResult.PASSED);
+        }
+        else {
+            res.setReturnCode(TestResult.FAILED);
+            res.setResults("Retrieved attribute value '"+val+"'; expected '"+VAL+"'");
+        }
+        return res;
+    }
+
+    protected TestResult checkRemoveApplicationScopedAttribute(PortletSession session) {
+        TestResult res = new TestResult();
+        res.setName("Remove Application Scoped Attribute Test");
+        res.setDesc("Remove an application scoped session attribute and ensure it's null.");
+
+        session.setAttribute(KEY, VAL, PortletSession.APPLICATION_SCOPE);
+        session.removeAttribute(KEY, PortletSession.APPLICATION_SCOPE);
+        Object val = session.getAttribute(KEY, PortletSession.APPLICATION_SCOPE);
+        if(null == val) {
+            res.setReturnCode(TestResult.PASSED);
+        }
+        else {
+            res.setReturnCode(TestResult.FAILED);
+            res.setResults("Retrieved attribute value '"+val+"'; expected null.");
+        }
+        return res;
+    }
+}

Added: portals/pluto/trunk/testsuite/src/java/org/apache/pluto/portalImpl/portlet/test/ExternalAppScopedAttributeTest.java
==============================================================================
--- (empty file)
+++ portals/pluto/trunk/testsuite/src/java/org/apache/pluto/portalImpl/portlet/test/ExternalAppScopedAttributeTest.java	Sun Aug 22 18:05:16 2004
@@ -0,0 +1,44 @@
+package org.apache.pluto.portalImpl.portlet.test;
+
+import javax.portlet.PortletSession;
+
+/**
+ * @author <a href="david.dewolf@vivare.com">David H. DeWolf</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.";
+
+    public String getTestSuiteName() {
+        return "External Application Scoped Attribute Test";
+    }
+
+    public TestResult checkSetHereSeenElsewhere(PortletSession session) {
+        TestResult res = new TestResult();
+        res.setName("Session Visibility Test");
+        res.setDesc("Ensure application scoped attributes set here can be seen elsewhere.");
+        res.setReturnCode(TestResult.WARNING);
+        res.setResults("Click the provided link to validate test.");
+
+        session.setAttribute(INT_KEY, VALUE, PortletSession.APPLICATION_SCOPE);
+        return res;
+    }
+
+    public TestResult checkSetElsewhereSeenHere(PortletSession session) {
+        TestResult res = new TestResult();
+        res.setName("Session Visibility Test");
+        res.setDesc("Ensure application scoped attributes set elsewhere can be seen here.");
+
+        Object val = session.getAttribute(EXT_KEY, PortletSession.APPLICATION_SCOPE);
+        if(VALUE.equals(val)) {
+            res.setReturnCode(TestResult.PASSED);
+        }
+        else {
+            res.setReturnCode(TestResult.WARNING);
+            res.setResults("This test will not pass until you have opened the external resource using the link provided below.");
+        }
+        return res;
+    }
+}

Added: portals/pluto/trunk/testsuite/src/java/org/apache/pluto/portalImpl/portlet/test/ExternalAppScopedAttributeTestCompanionServlet.java
==============================================================================
--- (empty file)
+++ portals/pluto/trunk/testsuite/src/java/org/apache/pluto/portalImpl/portlet/test/ExternalAppScopedAttributeTestCompanionServlet.java	Sun Aug 22 18:05:16 2004
@@ -0,0 +1,37 @@
+package org.apache.pluto.portalImpl.portlet.test;
+
+import java.io.IOException;
+
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletException;
+
+/**
+ * @author <a href="david.dewolf@vivare.com">David H. DeWolf</a>
+ */
+public class ExternalAppScopedAttributeTestCompanionServlet extends HttpServlet {
+
+    public void doGet(HttpServletRequest req, HttpServletResponse res)
+    throws ServletException, IOException {
+
+        HttpSession session = req.getSession();
+        String val = (String)
+            session.getAttribute(ExternalAppScopedAttributeTest.INT_KEY);
+
+        if(ExternalAppScopedAttributeTest.VALUE.equals(val)) {
+            req.setAttribute("passed", new Boolean(true));
+
+            session.setAttribute(
+                ExternalAppScopedAttributeTest.EXT_KEY,
+                ExternalAppScopedAttributeTest.VALUE
+            );
+        }
+
+        RequestDispatcher dis = req.getRequestDispatcher("/jsp/external_app_scoped_test_ext.jsp");
+        dis.forward(req, res);
+
+    }
+}

Added: portals/pluto/trunk/testsuite/src/java/org/apache/pluto/portalImpl/portlet/test/MiscTest.java
==============================================================================
--- (empty file)
+++ portals/pluto/trunk/testsuite/src/java/org/apache/pluto/portalImpl/portlet/test/MiscTest.java	Sun Aug 22 18:05:16 2004
@@ -0,0 +1,129 @@
+package org.apache.pluto.portalImpl.portlet.test;
+
+import java.util.Properties;
+import java.util.Set;
+import java.util.Enumeration;
+
+import javax.portlet.PortletRequest;
+import javax.portlet.PortletMode;
+import javax.portlet.WindowState;
+
+import org.apache.pluto.testsuite.ExpectedResults;
+
+/**
+ * @author <a href="david.dewolf@vivare.com">David H. DeWolf</a>
+ */
+public class MiscTest extends AbstractReflectivePortletTest {
+
+
+    public String getTestSuiteName() {
+        return "Misc Test";
+    }
+
+    protected TestResult checkContextServerInfo(PortletRequest req) {
+        TestResult res = new TestResult();
+        res.setName("Server Info Test");
+        res.setDesc("Make sure that the expected server info is returned.");
+        Properties props = ExpectedResults.getExpectedProperties();
+        System.out.println("PortalContext: "+req.getPortalContext());
+        if(req.getPortalContext().getPortalInfo().equals(props.getProperty("expected.portalInfo"))) {
+            res.setReturnCode(TestResult.PASSED);
+        }
+        else {
+            res.setReturnCode(TestResult.FAILED);
+            res.setResults("Server info: "+req.getPortalContext().getPortalInfo()+". Expected: "+props.getProperty("expected.portalInfo"));
+        }
+        return res;
+    }
+
+    /**
+     * Test to ensure that the basic modes are supported.
+     * @todo Enhance to check for custom modes.
+     * @param req
+     * @return
+     */
+    protected TestResult checkSupportedModes(PortletRequest req)  {
+        TestResult res = new TestResult();
+        res.setName("Supported Modes Test");
+        res.setDesc("Make sure that the expected modes are returned.");
+
+        boolean hasView = false;
+        boolean hasEdit = false;
+        boolean hasHelp = false;
+
+        Enumeration enum = req.getPortalContext().getSupportedPortletModes();
+        while(enum.hasMoreElements()) {
+            PortletMode mode = (PortletMode)enum.nextElement();
+            if(mode.equals(PortletMode.VIEW)) {
+                hasView  = true;
+            }
+            else if(mode.equals(PortletMode.EDIT)) {
+                hasEdit  = true;
+            }
+            else if(mode.equals(PortletMode.HELP)) {
+                hasHelp  = true;
+            }
+        }
+
+        if(hasView && hasEdit &&  hasHelp) {
+            res.setReturnCode(TestResult.PASSED);
+        }
+        else {
+            res.setReturnCode(TestResult.FAILED);
+            StringBuffer sb = new StringBuffer();
+            if(!hasView) {
+                sb.append("'View' mode not found. ");
+            }
+            if(!hasEdit) {
+                sb.append("'Edit' mode not found. ");
+            }
+            if(!hasHelp) {
+                sb.append("'Help' mode not found. ");
+            }
+        }
+        return res;
+    }
+
+    protected TestResult checkSupportedWindowSates(PortletRequest req) {
+        TestResult res = new TestResult();
+        res.setName("Supported Window States Test");
+        res.setDesc("Make sure that the expected states are returned.");
+
+        boolean hasMin = false;
+        boolean hasMax = false;
+        boolean hasNor = false;
+
+        Enumeration enum = req.getPortalContext().getSupportedWindowStates();
+        while(enum.hasMoreElements()) {
+            WindowState mode = (WindowState)enum.nextElement();
+            if(mode.equals(WindowState.MINIMIZED)) {
+                hasMin  = true;
+            }
+            else if(mode.equals(WindowState.MAXIMIZED)) {
+                hasMax  = true;
+            }
+            else if(mode.equals(WindowState.NORMAL)) {
+                hasNor  = true;
+            }
+        }
+
+        if(hasMin && hasMax &&  hasNor) {
+            res.setReturnCode(TestResult.PASSED);
+        }
+        else {
+            res.setReturnCode(TestResult.FAILED);
+            StringBuffer sb = new StringBuffer();
+            if(!hasMin) {
+                sb.append("'Minimized' state not found. ");
+            }
+            if(!hasMax) {
+                sb.append("'Maximized' state not found. ");
+            }
+            if(!hasNor) {
+                sb.append("'Normal' state not found. ");
+            }
+        }
+        return res;
+    }
+
+}

Added: portals/pluto/trunk/testsuite/src/java/org/apache/pluto/portalImpl/portlet/test/PortletTest.java
==============================================================================
--- (empty file)
+++ portals/pluto/trunk/testsuite/src/java/org/apache/pluto/portalImpl/portlet/test/PortletTest.java	Sun Aug 22 18:05:16 2004
@@ -0,0 +1,40 @@
+/*
+ * 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
+ *
+ *      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.portalImpl.portlet.test;
+
+import java.util.Map;
+
+import javax.portlet.PortletResponse;
+import javax.portlet.PortletRequest;
+import javax.portlet.PortletContext;
+import javax.portlet.ActionResponse;
+import javax.portlet.ActionRequest;
+
+/**
+ * @author <a href="ddewolf@apache.org">David H. DeWolf</a>
+ */
+public interface PortletTest {
+
+    String getTestSuiteName();
+    
+    Map getRenderParameters(PortletRequest req);
+
+    TestResults doTest(PortletContext context,
+                       PortletRequest req,
+                       PortletResponse res);
+
+}

Added: portals/pluto/trunk/testsuite/src/java/org/apache/pluto/portalImpl/portlet/test/SecurityMappingTest.java
==============================================================================
--- (empty file)
+++ portals/pluto/trunk/testsuite/src/java/org/apache/pluto/portalImpl/portlet/test/SecurityMappingTest.java	Sun Aug 22 18:05:16 2004
@@ -0,0 +1,91 @@
+package org.apache.pluto.portalImpl.portlet.test;
+
+import java.util.Map;
+
+import javax.portlet.PortletContext;
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.PortletRequest;
+
+/**
+ * @author <a href="david.dewolf@vivare.com">David H. DeWolf</a>
+ */
+public class SecurityMappingTest extends AbstractReflectivePortletTest {
+
+    public String getTestSuiteName() {
+        return "Security Mapping Tests";
+    }
+
+    public Map doPrerequisiteAction(PortletContext context, ActionRequest req,
+                                    ActionResponse res) {
+        return new java.util.HashMap();
+    }
+
+    protected TestResult checkIsUserInMappedRole(PortletRequest req) {
+        TestResult res = isUserLoggedIn(req);
+        res.setName("User In Mapped Role Test");
+        res.setDesc("Test if user is in mapped role");
+        if(TestResult.WARNING.equals(res.getReturnCode())) {
+            return res;
+        }
+
+        if(req.isUserInRole("plutoTestRole")) {
+            res.setReturnCode(TestResult.PASSED);
+        }
+        else {
+            res.setReturnCode(TestResult.WARNING);
+            res.setReturnCode("User is not in the expected 'tomcat' role.  This may be due to misconfiuration.");
+        }
+
+        return res;
+    }
+
+    protected TestResult checkIsUserInUnmappedRole(PortletRequest req) {
+        TestResult res = isUserLoggedIn(req);
+        res.setName("User In Unmapped Role Test");
+        res.setDesc("Test if user is in unmapped role");
+        if(TestResult.WARNING.equals(res.getReturnCode())) {
+            return res;
+        }
+
+        if(req.isUserInRole("tomcat")) {
+            res.setReturnCode(TestResult.PASSED);
+        }
+        else {
+            res.setReturnCode(TestResult.WARNING);
+            res.setReturnCode("User is not in the expected 'tomcat' role.  This may be due to misconfiuration.");
+        }
+
+        return res;
+    }
+
+    protected TestResult checkIsUserIndUndeclaredRole(PortletRequest req) {
+        TestResult res = isUserLoggedIn(req);
+        res.setName("User In Role Test");
+        res.setDesc("Test if user is in undeclared role");
+        if(TestResult.WARNING.equals(res.getReturnCode())) {
+            return res;
+        }
+
+        if(!req.isUserInRole("fakeTestRoleFooBar")) {
+            res.setReturnCode(TestResult.PASSED);
+        }
+        else {
+            res.setReturnCode(TestResult.FAILED);
+            res.setReturnCode("User is in the fake role named 'fakeTestRoleFooBar'");
+        }
+
+        return res;
+    }
+
+
+    private TestResult isUserLoggedIn(PortletRequest req) {
+        if(req.getRemoteUser()==null) {
+            TestResult res = new TestResult();
+            res.setReturnCode(TestResult.WARNING);
+            res.setResults("User is not logged in.");
+            return res;
+        }
+        else return new TestResult();
+    }
+}

Added: portals/pluto/trunk/testsuite/src/java/org/apache/pluto/portalImpl/portlet/test/SimpleAttributeTest.java
==============================================================================
--- (empty file)
+++ portals/pluto/trunk/testsuite/src/java/org/apache/pluto/portalImpl/portlet/test/SimpleAttributeTest.java	Sun Aug 22 18:05:16 2004
@@ -0,0 +1,291 @@
+package org.apache.pluto.portalImpl.portlet.test;
+
+import java.util.Enumeration;
+import java.util.Map;
+import java.util.HashMap;
+
+import javax.portlet.PortletResponse;
+import javax.portlet.PortletRequest;
+import javax.portlet.PortletSession;
+import javax.portlet.PortletContext;
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+
+/**
+ * Tests basic attribute retrieval and storage functions within
+ * the portlet request, session, and context objects.
+ *
+ * @author <a href="david.dewolf@vivare.com">David H. DeWolf</a>
+ */
+public class SimpleAttributeTest extends AbstractReflectivePortletTest {
+    private static final String KEY = "org.apache.pluto.testsuite.BOGUS_KEY";
+    private static final String VAL = "! TEST VAL !";
+
+    public String getTestSuiteName() {
+        return "Simple Attribute Test";
+    }
+
+    public Map doPrerequisiteAction(PortletContext context, ActionRequest req,
+                                    ActionResponse res) {
+        return new HashMap();
+
+    }
+//
+// Begin Request Tests
+//
+    protected TestResult checkGetNullAttribute(PortletRequest req) {
+        TestResult res = new TestResult();
+        res.setName("Retrieve Missing Request Attribute Test");
+        res.setDesc("Retrieves an attribute bound to an invalid key set are retrieved as null");
+
+        Object val = req.getAttribute(KEY);
+        if(val != null) {
+            res.setReturnCode(TestResult.FAILED);
+            res.setResults("Retrieved value: '"+val+"' for attribute '"+KEY+"'");
+        }
+        else {
+            res.setReturnCode(TestResult.PASSED);
+        }
+        return res;
+    }
+
+
+    protected TestResult checkSetAttribute(PortletRequest req) {
+        TestResult res = new TestResult();
+        res.setName("Set Request Attribute Test");
+        res.setDesc("Sets and retrieves portlet request attribute.");
+
+        req.setAttribute(KEY, VAL);
+        Object val = req.getAttribute(KEY);
+        if(!VAL.equals(val)) {
+            res.setReturnCode(TestResult.FAILED);
+            res.setResults("Retrieved value: '"+val+"' - Expected '"+VAL+"'");
+        }
+        else {
+            res.setReturnCode(TestResult.PASSED);
+        }
+
+        req.removeAttribute(KEY);
+        return res;
+    }
+
+    protected TestResult checkRemoveAttribute(PortletRequest req) {
+        TestResult res = new TestResult();
+        res.setName("Remove Request Attribute Test");
+        res.setDesc("Sets, removes and retrieves portlet request attribute.");
+
+        req.setAttribute(KEY, VAL);
+        req.removeAttribute(KEY);
+        Object val = req.getAttribute(KEY);
+        if(val!=null) {
+            res.setReturnCode(TestResult.FAILED);
+            res.setResults("Retrieved value: '"+val+"' - Expected '"+VAL+"'");
+        }
+        else {
+            res.setReturnCode(TestResult.PASSED);
+        }
+
+        return res;
+    }
+
+    protected TestResult checkEnumerateAttributes(PortletRequest req) {
+        TestResult res = new TestResult();
+        res.setName("Enumerate Request Attribute Names Test");
+        res.setDesc("Sets request attributes and enumerates over them.");
+
+        int count = 5;
+        for(int i=0;i<count;i++) {
+            req.setAttribute(KEY+"."+i,VAL);
+        }
+
+        int found = 0;
+        Enumeration enum = req.getAttributeNames();
+        while(enum.hasMoreElements()) {
+            if(enum.nextElement().toString().startsWith(KEY)) {
+                found++;
+            }
+        }
+
+        if(count != found) {
+            res.setReturnCode(TestResult.FAILED);
+            res.setResults("Expected "+count+" attributes.  Found "+found);
+        }
+        else {
+            res.setReturnCode(TestResult.PASSED);
+        }
+        return res;
+    }
+
+//
+// Begin Session Tests
+//
+
+    protected TestResult checkGetNullAttribute(PortletSession session) {
+        TestResult res = new TestResult();
+        res.setName("Retrieve Missing Session Attribute Test");
+        res.setDesc("Retrieves an attribute bound to an invalid key set are retrieved as null");
+
+        Object val = session.getAttribute(KEY);
+        if(val != null) {
+            res.setReturnCode(TestResult.FAILED);
+            res.setResults("Retrieved value: '"+val+"' for attribute '"+KEY+"'");
+        }
+        else {
+            res.setReturnCode(TestResult.PASSED);
+        }
+        return res;
+    }
+
+    protected TestResult checkSetAttribute(PortletSession session) {
+        TestResult res = new TestResult();
+        res.setName("Set Attribute Test");
+        res.setDesc("Sets and retrieves portlet sessionuest attribute.");
+
+        session.setAttribute(KEY, VAL);
+        Object val = session.getAttribute(KEY);
+        if(!VAL.equals(val)) {
+            res.setReturnCode(TestResult.FAILED);
+            res.setResults("Retrieved value: '"+val+"' - Expected '"+VAL+"'");
+        }
+        else {
+            res.setReturnCode(TestResult.PASSED);
+        }
+
+        session.removeAttribute(KEY);
+        return res;
+    }
+
+    protected TestResult checkRemoveAttribute(PortletSession session) {
+        TestResult res = new TestResult();
+        res.setName("Remove Session Attribute Test");
+        res.setDesc("Sets, removes and retrieves portlet request attribute.");
+
+        session.setAttribute(KEY, VAL);
+        session.removeAttribute(KEY);
+        Object val = session.getAttribute(KEY);
+        if(val!=null) {
+            res.setReturnCode(TestResult.FAILED);
+            res.setResults("Retrieved value: '"+val+"' - Expected '"+VAL+"'");
+        }
+        else {
+            res.setReturnCode(TestResult.PASSED);
+        }
+
+        return res;
+    }
+
+    protected TestResult checkEnumerateAttributes(PortletSession req) {
+        TestResult res = new TestResult();
+        res.setName("Enumerate Session Attribute Names Test");
+        res.setDesc("Sets request attributes and enumerates over them.");
+
+        int count = 5;
+        for(int i=0;i<count;i++) {
+            req.setAttribute(KEY+"."+i,VAL);
+        }
+
+        int found = 0;
+        Enumeration enum = req.getAttributeNames();
+        while(enum.hasMoreElements()) {
+            if(enum.nextElement().toString().startsWith(KEY)) {
+                found++;
+            }
+        }
+
+        if(count != found) {
+            res.setReturnCode(TestResult.FAILED);
+            res.setResults("Expected "+count+" attributes.  Found "+found);
+        }
+        else {
+            res.setReturnCode(TestResult.PASSED);
+        }
+        return res;
+    }
+
+//
+// Context Tests
+//
+
+    protected TestResult checkGetNullAttribute(PortletContext context) {
+        TestResult res = new TestResult();
+        res.setName("Retrieve Missing Context Attribute Test");
+        res.setDesc("Retrieves an attribute bound to an invalid key set are retrieved as null");
+
+        Object val = context.getAttribute(KEY);
+        if(val != null) {
+            res.setReturnCode(TestResult.FAILED);
+            res.setResults("Retrieved value: '"+val+"' for attribute '"+KEY+"'");
+        }
+        else {
+            res.setReturnCode(TestResult.PASSED);
+        }
+        return res;
+    }
+
+    protected TestResult checkSetAttribute(PortletContext context) {
+        TestResult res = new TestResult();
+        res.setName("Set Attribute Test");
+        res.setDesc("Sets and retrieves portlet contextuest attribute.");
+
+        context.setAttribute(KEY, VAL);
+        Object val = context.getAttribute(KEY);
+        if(!VAL.equals(val)) {
+            res.setReturnCode(TestResult.FAILED);
+            res.setResults("Retrieved value: '"+val+"' - Expected '"+VAL+"'");
+        }
+        else {
+            res.setReturnCode(TestResult.PASSED);
+        }
+
+        context.removeAttribute(KEY);
+        return res;
+    }
+
+    protected TestResult checkRemoveAttribute(PortletContext context) {
+        TestResult res = new TestResult();
+        res.setName("Remove Context Attribute Test");
+        res.setDesc("Sets, removes and retrieves portlet request attribute.");
+
+        context.setAttribute(KEY, VAL);
+        context.removeAttribute(KEY);
+        Object val = context.getAttribute(KEY);
+        if(val!=null) {
+            res.setReturnCode(TestResult.FAILED);
+            res.setResults("Retrieved value: '"+val+"' - Expected '"+VAL+"'");
+        }
+        else {
+            res.setReturnCode(TestResult.PASSED);
+        }
+
+        return res;
+    }
+
+    protected TestResult checkEnumerateAttributes(PortletContext req) {
+        TestResult res = new TestResult();
+        res.setName("Enumerate Context Attribute Names Test");
+        res.setDesc("Sets request attributes and enumerates over them.");
+
+        int count = 5;
+        for(int i=0;i<count;i++) {
+            req.setAttribute(KEY+"."+i,VAL);
+        }
+
+        int found = 0;
+        Enumeration enum = req.getAttributeNames();
+        while(enum.hasMoreElements()) {
+            if(enum.nextElement().toString().startsWith(KEY)) {
+                found++;
+            }
+        }
+
+        if(count != found) {
+            res.setReturnCode(TestResult.FAILED);
+            res.setResults("Expected "+count+" attributes.  Found "+found);
+        }
+        else {
+            res.setReturnCode(TestResult.PASSED);
+        }
+        return res;
+    }
+
+}

Added: portals/pluto/trunk/testsuite/src/java/org/apache/pluto/portalImpl/portlet/test/SimpleParameterTest.java
==============================================================================
--- (empty file)
+++ portals/pluto/trunk/testsuite/src/java/org/apache/pluto/portalImpl/portlet/test/SimpleParameterTest.java	Sun Aug 22 18:05:16 2004
@@ -0,0 +1,97 @@
+package org.apache.pluto.portalImpl.portlet.test;
+
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Enumeration;
+
+import javax.portlet.PortletContext;
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.PortletRequest;
+
+/**
+ * @author <a href="david.dewolf@vivare.com">David H. DeWolf</a>
+ */
+public class SimpleParameterTest extends AbstractReflectivePortletTest {
+    public static final String KEY = "org.apache.pluto.testsuite.PARAM_TEST_KEY";
+    public static final String VALUE = "org.apache.pluto.testsuite.PARAM_TEST_VALUE";
+
+    private static final String IKEY = "org.apache.pluto.testsuite.PARAM_TEST_KEY";
+
+    public String getTestSuiteName() {
+        return "Simple Parameter Test";
+    }
+
+    public Map getRenderParameters(PortletRequest req) {
+        Map map = new HashMap(req.getParameterMap());
+        map.put(IKEY, new String[] {VALUE});
+        return map;
+    }
+
+    protected TestResult checkSentParameters(PortletRequest req) {
+        TestResult res = new TestResult();
+        res.setName("Sent Parameter Test");
+        res.setDesc("Ensure that parameters sent through the action query stream have made it all the way through");
+
+        String val = req.getParameter(KEY);
+        if(val == null || !VALUE.equals(val)) {
+            res.setReturnCode(TestResult.FAILED);
+            res.setResults("Expected : "+VALUE+" retrieved "+val);
+        }
+        else {
+            res.setReturnCode(TestResult.PASSED);
+        }
+        return res;
+    }
+
+
+    protected TestResult checkInternalRenderParameters(PortletRequest req) {
+        TestResult res = new TestResult();
+        res.setName("Render Parameters Test");
+        res.setDesc("Enumerate through all render parameters sent in the action");
+
+        String val = req.getParameter(IKEY);
+        if(val == null || !VALUE.equals(val)) {
+            res.setReturnCode(TestResult.FAILED);
+            res.setResults("Expected : "+VALUE+" retrieved "+val);
+        }
+        else {
+            res.setReturnCode(TestResult.PASSED);
+        }
+        return res;
+    }
+
+    protected TestResult checkParameterNames(PortletRequest req) {
+        TestResult res = new TestResult();
+        res.setName("Test Parameter Names Enumeration.");
+        res.setDesc("Enumerate through all expected names.");
+
+        boolean hasExternal = false;
+        boolean hasInternal = false;
+        Enumeration enum = req.getParameterNames();
+        while(enum.hasMoreElements()) {
+            String val = enum.nextElement().toString();
+            if(KEY.equals(val)) {
+                hasExternal = true;
+            }
+            if(IKEY.equals(val)) {
+                hasInternal = true;
+            }
+        }
+        if(!hasInternal || !hasExternal) {
+            res.setReturnCode(TestResult.FAILED);
+            StringBuffer sb = new StringBuffer();
+            if(!hasInternal) {
+                sb.append("Internal Parameter Not Found. ");
+            }
+            if(!hasExternal) {
+                sb.append("External Parameter Not Found. ");
+            }
+            res.setResults(sb.toString());
+        }
+        else {
+            res.setReturnCode(TestResult.PASSED);
+        }
+        return res;
+    }
+}

Added: portals/pluto/trunk/testsuite/src/java/org/apache/pluto/portalImpl/portlet/test/SimplePreferenceTest.java
==============================================================================
--- (empty file)
+++ portals/pluto/trunk/testsuite/src/java/org/apache/pluto/portalImpl/portlet/test/SimplePreferenceTest.java	Sun Aug 22 18:05:16 2004
@@ -0,0 +1,395 @@
+package org.apache.pluto.portalImpl.portlet.test;
+
+import java.util.Map;
+import java.util.Enumeration;
+import java.io.IOException;
+
+import javax.portlet.PortletRequest;
+import javax.portlet.PortletPreferences;
+import javax.portlet.ReadOnlyException;
+import javax.portlet.ValidatorException;
+import javax.portlet.PortletContext;
+import javax.portlet.PortletResponse;
+
+/**
+ * @author <a href="ddewolf@apache.org">David H. DeWolf</a>
+ */
+public class SimplePreferenceTest
+ extends ActionAbstractReflectivePortletTest
+ implements ActionTest {
+
+    private static final String BOGUS_KEY = "org.apache.pluto.testsuite.BOGUS_KEY";
+
+    public String getTestSuiteName() {
+        return "Simple Preferences Test";
+    }
+
+    protected TestResult checkGetEmptyPreference(PortletRequest req) {
+        TestResult res = new TestResult();
+        res.setName("Get Empty Preference Test");
+        res.setDesc("Ensure proper default is returned when a non-existing preference is requested.");
+        PortletPreferences preferences = req.getPreferences();
+        String preference =  preferences.getValue("nonexistence!", "Default");
+        if(preference.equals("Default")) {
+            res.setReturnCode(TestResult.PASSED);
+        }
+        else {
+            res.setReturnCode(TestResult.FAILED);
+            res.setResults("Preferences value was '"+preference+"' expected 'permanent'.");
+        }
+        return res;
+    }
+
+    protected TestResult checkGetEmptyPreferences(PortletRequest req) {
+        TestResult res = new TestResult();
+        res.setName("Get Empty Preferences Test");
+        res.setDesc("Ensure proper defaults are returned when a non-existent preference set is requested.");
+        PortletPreferences preferences = req.getPreferences();
+        String[] preference = preferences.getValues("nonexistence!", new String[] {"Default"});
+        if(preference.length == 1 && preference[0].equals("Default")) {
+            res.setReturnCode(TestResult.PASSED);
+        }
+        else {
+            res.setReturnCode(TestResult.FAILED);
+            res.setResults("Preferences value was '"+preference[0]+"' expected 'permanent'.");
+        }
+        return res;
+    }
+
+
+    protected TestResult checkGetPreferences(PortletRequest req) {
+        TestResult res = new TestResult();
+        res.setName("Get Preference Test");
+        res.setDesc("Tests that preferences defined in the deployment descriptor may be retrieved.");
+        PortletPreferences preferences = req.getPreferences();
+        String preference =  preferences.getValue("dummyName", "defaultValue");
+        if(preference.equals("dummyValue")) {
+            res.setReturnCode(TestResult.PASSED);
+        }
+        else {
+            res.setReturnCode(TestResult.FAILED);
+            res.setResults("Preferences value was '"+preference+"' expected 'dummyValue'.");
+        }
+        return res;
+    }
+
+    protected TestResult checkSetPreference(PortletRequest req) {
+        TestResult res = new TestResult();
+        res.setName("Set Preference  Test");
+        res.setDesc("Ensure a single preference can be set");
+
+        PortletPreferences preferences = req.getPreferences();
+        try {
+            preferences.setValue("TEST", "TEST_VALUE");
+        }
+        catch(ReadOnlyException roe) {
+            res.setReturnCode(TestResult.FAILED);
+            res.setResults(roe.getMessage());
+            return res;
+        }
+
+        String preference = preferences.getValue("TEST", "Error!");
+        if(preference.equals("TEST_VALUE")) {
+            res.setReturnCode(TestResult.PASSED);
+        }
+        else {
+            res.setReturnCode(TestResult.FAILED);
+            res.setResults("Preferences value was '"+preference+"' expected 'permanent'.");
+        }
+        return res;
+    }
+
+    protected TestResult checkSetPreferences(PortletRequest req) {
+        TestResult res = new TestResult();
+        res.setName("Set Preferences Test");
+        res.setDesc("Ensure preferences can be set.");
+
+        PortletPreferences preferences = req.getPreferences();
+        try {
+            preferences.setValues("TEST", new String[] {"TEST_VALUE", "ANOTHER"});
+        }
+        catch(ReadOnlyException roe) {
+            res.setReturnCode(TestResult.FAILED);
+            res.setResults(roe.getMessage());
+            return res;
+        }
+
+        String[] preference = preferences.getValues("TEST", new String[] { "Error!" });
+        if(preference.length == 2 && preference[0].equals("TEST_VALUE") &&
+           preference[1].equals("ANOTHER")) {
+            res.setReturnCode(TestResult.PASSED);
+        }
+        else {
+            res.setReturnCode(TestResult.FAILED);
+            res.setResults("Preferences value was '"+preference+"' expected 'permanent'.");
+        }
+        return res;
+    }
+
+    protected TestResult checkSetPreferencesReturnsFirst(PortletRequest req) {
+        TestResult res = new TestResult();
+        res.setName("Set Preferences Test");
+        res.setDesc("Ensure preferences can be set.");
+
+        PortletPreferences preferences = req.getPreferences();
+        try {
+            preferences.setValues("TEST", new String[] {"TEST_VALUE", "ANOTHER"});
+        }
+        catch(ReadOnlyException roe) {
+            res.setReturnCode(TestResult.FAILED);
+            res.setResults(roe.getMessage());
+            return res;
+        }
+
+        String preference = preferences.getValue("TEST", "Error!");
+        if(preference.equals("TEST_VALUE")) {
+            res.setReturnCode(TestResult.PASSED);
+        }
+        else {
+            res.setReturnCode(TestResult.FAILED);
+            res.setResults("Preferences value was '"+preference+"' expected 'permanent'.");
+        }
+        return res;
+    }
+
+    protected TestResult checkPreferenceValidator(PortletRequest req) {
+        TestResult res = new TestResult();
+        res.setName("Preference Validator Test");
+        res.setDesc("Check to make sure that the validator catches invalid preferences.");
+
+        PortletPreferences preferences = req.getPreferences();
+        boolean exceptionThrown = false;
+        try {
+            preferences.setValue("VALIDATION_TEST_KEY", " Spaces removed by trim ");
+            preferences.store();
+        }
+        catch (ReadOnlyException roe) {
+
+        }
+        catch (ValidatorException e) {
+            exceptionThrown = true;
+            try { preferences.reset("VALIDATION_TEST_KEY"); }catch(Throwable t) {}
+        }
+        catch (IOException io) {
+
+        }
+
+        if(exceptionThrown) {
+            res.setReturnCode(TestResult.PASSED);
+        }
+        else {
+            res.setReturnCode(TestResult.FAILED);
+            res.setResults("Illegal value not caught by validator.");
+        }
+        return res;
+    }
+
+    protected TestResult checkStorePreferences(PortletRequest req) {
+        TestResult res = new TestResult();
+        res.setName("Preference Store Test");
+        res.setDesc("Ensure storage works.");
+
+        PortletPreferences preferences = req.getPreferences();
+        boolean setOccured = false;
+        boolean storeOccured = false;
+        try {
+            preferences.setValue("dummyName", "notTheOriginal");
+            String pref = preferences.getValue("dummyName", "Default");
+            if("notTheOriginal".equals(pref)) {
+                setOccured = true;
+            }
+
+            preferences.store();
+            if("notTheOriginal".equals(preferences.getValue("dummyName", "Default"))) {
+                storeOccured = true;
+            }
+
+            preferences.reset("dummyName");
+        }
+        catch(ReadOnlyException roe) {
+
+        }
+        catch(ValidatorException ve) {
+
+        }
+        catch(IOException io) {
+
+        }
+
+        if(setOccured && storeOccured) {
+            res.setReturnCode(TestResult.PASSED);
+        }
+        else if (!setOccured) {
+            res.setReturnCode(TestResult.WARNING);
+            res.setResults("A function upon which the reset test depends failed to execute as expected. Check the other test results in this test suite.");
+        }
+        else {
+            res.setReturnCode(TestResult.FAILED);
+            res.setResults("Preferences not successfully stored.");
+        }
+        return res;
+    }
+
+    protected TestResult checkResetPreferences(PortletRequest req) {
+        TestResult res = new TestResult();
+        res.setName("Reset Preference Test");
+        res.setDesc("Tests that preferences are properly reset.");
+        PortletPreferences preferences = req.getPreferences();
+        boolean setOccured = false;
+        boolean storeOccured = false;
+        boolean resetOccured = false;
+        try {
+            preferences.setValue("dummyName", "notTheOriginal");
+            String pref = preferences.getValue("dummyName", "Default");
+            if("notTheOriginal".equals(pref)) {
+                setOccured = true;
+            }
+
+            preferences.store();
+            if("notTheOriginal".equals(preferences.getValue("dummyName", "Default"))) {
+                storeOccured = true;
+            }
+
+            preferences.reset("dummyName");
+
+            String preference =  preferences.getValue("dummyName", "defaultValue");
+            if(preference.equals("dummyValue")) {
+                resetOccured = true;
+            }
+        }
+        catch(ReadOnlyException roe) {
+            roe.printStackTrace();
+        }
+        catch(ValidatorException ve) {
+            ve.printStackTrace();
+        }
+        catch(IOException io) {
+            io.printStackTrace();
+        }
+
+        if(setOccured && storeOccured && resetOccured) {
+            res.setReturnCode(TestResult.PASSED);
+        }
+        else if(!setOccured || !storeOccured) {
+            res.setReturnCode(TestResult.WARNING);
+            res.setResults("A function upon which the reset test depends failed to execute as expected. Check the other test results in this test suite.");
+        }
+        else {
+            res.setReturnCode(TestResult.FAILED);
+            res.setResults("Preferences value was not successfully reset after store");
+        }
+
+        return res;
+    }
+
+    protected TestResult checkResetToNullPreferences(PortletRequest req) {
+        TestResult res = new TestResult();
+        res.setName("Reset to Null Preference Test");
+        res.setDesc("Tests that preferences are properly reset when originally null.");
+        PortletPreferences preferences = req.getPreferences();
+        boolean setOccured = false;
+        boolean storeOccured = false;
+        boolean resetOccured = false;
+        try {
+            preferences.setValue(BOGUS_KEY, "notTheOriginal");
+            String pref = preferences.getValue(BOGUS_KEY, "Default");
+            if("notTheOriginal".equals(pref)) {
+                setOccured = true;
+            }
+
+            preferences.store();
+            if("notTheOriginal".equals(preferences.getValue(BOGUS_KEY, "Default"))) {
+                storeOccured = true;
+            }
+
+            preferences.reset(BOGUS_KEY);
+
+            String preference =  preferences.getValue(BOGUS_KEY, "defaultValue");
+            if("defaultValue".equals(preference)) {
+                resetOccured = true;
+            }
+        }
+        catch(ReadOnlyException roe) {
+            roe.printStackTrace();
+        }
+        catch(ValidatorException ve) {
+            ve.printStackTrace();
+        }
+        catch(IOException io) {
+            io.printStackTrace();
+        }
+
+        if(setOccured && storeOccured && resetOccured) {
+            res.setReturnCode(TestResult.PASSED);
+        }
+        else if(!setOccured || !storeOccured) {
+            res.setReturnCode(TestResult.WARNING);
+            res.setResults("A function upon which the reset test depends failed to execute as expected. Check the other test results in this test suite.");
+        }
+        else {
+            res.setReturnCode(TestResult.FAILED);
+            res.setResults("Preferences value was not successfully reset after store.");
+        }
+        return res;
+    }
+
+    protected TestResult checkReadOnlyPreferences(PortletRequest req) {
+        TestResult res = new TestResult();
+        res.setName("Preference Read Only Test");
+        res.setDesc("Check to make sure that read only preferences may not be set.");
+
+        PortletPreferences preferences = req.getPreferences();
+        boolean exceptionThrown = false;
+        try {
+            preferences.setValue("readonly", "written");
+        }
+        catch (ReadOnlyException roe) {
+            exceptionThrown = true;
+        }
+
+        if(exceptionThrown) {
+            res.setReturnCode(TestResult.PASSED);
+        }
+        else {
+            res.setReturnCode(TestResult.FAILED);
+            res.setResults("Read Only Preference was written.");
+        }
+
+        return res;
+    }
+
+    protected TestResult checkGetPreferenceMap(PortletRequest req) {
+        TestResult res = checkGetPreferenceNames(req);
+        res.setName("Preference Map Test.");
+        res.setDesc("Ensure returned map is valid");
+        return res;
+    }
+
+    protected TestResult checkGetPreferenceNames(PortletRequest req) {
+        TestResult res = new TestResult();
+        res.setName("Preference Names Enumeration Test.");
+        res.setDesc("Ensure returned enumeration is valid");
+
+        PortletPreferences prefs = req.getPreferences();
+        Map map = prefs.getMap();
+        Enumeration enum = prefs.getNames();
+        boolean hasAll = true;
+        while(enum.hasMoreElements()) {
+            if(!map.containsKey(enum.nextElement())) {
+                hasAll = false;
+                break;
+            }
+        }
+
+        if(hasAll) {
+            res.setReturnCode(TestResult.PASSED);
+        }
+        else {
+            res.setReturnCode(TestResult.FAILED);
+            res.setResults("All names not found as preferences.");
+        }
+        return res;
+    }
+
+
+}

Added: portals/pluto/trunk/testsuite/src/java/org/apache/pluto/portalImpl/portlet/test/TestResult.java
==============================================================================
--- (empty file)
+++ portals/pluto/trunk/testsuite/src/java/org/apache/pluto/portalImpl/portlet/test/TestResult.java	Sun Aug 22 18:05:16 2004
@@ -0,0 +1,50 @@
+package org.apache.pluto.portalImpl.portlet.test;
+
+/**
+ * @author <a href="david.dewolf@vivare.com">David H. DeWolf</a>
+ */
+public class TestResult {
+
+    public static final String PASSED = "Passed";
+    public static final String FAILED = "Failed";
+    public static final String WARNING = "Warning";
+
+    private String name;
+    private String desc;
+    private String returnCode;
+    private String results ="uknown";
+
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getDesc() {
+        return desc;
+    }
+
+    public void setDesc(String desc) {
+        this.desc = desc;
+    }
+
+    public String getReturnCode() {
+        return returnCode;
+    }
+
+    public void setReturnCode(String returnCode) {
+        this.returnCode = returnCode;
+    }
+
+    public String getResults() {
+        return results;
+    }
+
+    public void setResults(String results) {
+        this.results = results;
+    }
+
+}

Added: portals/pluto/trunk/testsuite/src/java/org/apache/pluto/portalImpl/portlet/test/TestResults.java
==============================================================================
--- (empty file)
+++ portals/pluto/trunk/testsuite/src/java/org/apache/pluto/portalImpl/portlet/test/TestResults.java	Sun Aug 22 18:05:16 2004
@@ -0,0 +1,51 @@
+package org.apache.pluto.portalImpl.portlet.test;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+
+/**
+ * @author <a href="david.dewolf@vivare.com">David H. DeWolf</a>
+ */
+public class TestResults {
+
+    private String name;
+    private ArrayList list = new ArrayList();
+    private boolean failed;
+    private boolean inQuestion;
+
+    public TestResults(String name) {
+        this.name = name;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public void add(TestResult res) {
+        if(TestResult.FAILED.equals(res.getReturnCode())) {
+            failed = true;
+        }
+        if(TestResult.WARNING.equals(res.getReturnCode())) {
+            inQuestion = true;
+        }
+        list.add(res);
+    }
+
+    public boolean isFailed() {
+        return failed;
+    }
+
+    public boolean isInQuestion() {
+        return inQuestion;
+    }
+
+    public Collection getCollection() {
+        return Collections.unmodifiableCollection(list);
+    }
+
+}

Mime
View raw message