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 es...@apache.org on 2007/12/29 18:20:42 UTC
svn commit: r607448 [30/36] - in /portals/pluto/branches/pluto-1.1.x: ./
assembly/src/main/assembly/ assembly/src/main/resources/ maven-pluto-plugin/
maven-pluto-plugin/src/main/java/org/apache/pluto/maven/ pluto-ant-tasks/
pluto-ant-tasks/src/assemble...
Modified: portals/pluto/branches/pluto-1.1.x/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/ActionParameterTest.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/pluto-1.1.x/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/ActionParameterTest.java?rev=607448&r1=607447&r2=607448&view=diff
==============================================================================
--- portals/pluto/branches/pluto-1.1.x/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/ActionParameterTest.java (original)
+++ portals/pluto/branches/pluto-1.1.x/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/ActionParameterTest.java Sat Dec 29 09:20:23 2007
@@ -1,96 +1,96 @@
-/*
+/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.pluto.testsuite.test;
-
-import org.apache.pluto.testsuite.ActionTest;
-import org.apache.pluto.testsuite.TestResult;
-import org.apache.pluto.testsuite.TestUtils;
-
-import java.util.Enumeration;
-import java.util.Map;
-
-import javax.portlet.PortletRequest;
-
-/**
- */
-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 "
- + "available in the action request.");
-
- String value = request.getParameter(KEY);
- if (value != null && value.equals(VALUE)) {
- result.setReturnCode(TestResult.PASSED);
- } else {
- TestUtils.failOnAssertion("parameter", value, VALUE, result);
- }
- return result;
- }
-
- protected TestResult checkGetActionParamerMap(PortletRequest request) {
- 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])) {
- result.setReturnCode(TestResult.PASSED);
- } else {
- TestUtils.failOnAssertion("parameter values",
- values, new String[] { VALUE }, result);
- }
- 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(); ) {
- String name = (String) en.nextElement();
- if (KEY.equals(name)) {
- hasParameterName = true;
- }
- }
-
- if (hasParameterName) {
- result.setReturnCode(TestResult.PASSED);
- } else {
- result.setReturnCode(TestResult.FAILED);
- result.setResultMessage("Parameter name " + KEY
- + " not found in parameter name enumeration.");
- }
- return result;
- }
-
-}
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pluto.testsuite.test;
+
+import org.apache.pluto.testsuite.ActionTest;
+import org.apache.pluto.testsuite.TestResult;
+import org.apache.pluto.testsuite.TestUtils;
+
+import java.util.Enumeration;
+import java.util.Map;
+
+import javax.portlet.PortletRequest;
+
+/**
+ */
+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 "
+ + "available in the action request.");
+
+ String value = request.getParameter(KEY);
+ if (value != null && value.equals(VALUE)) {
+ result.setReturnCode(TestResult.PASSED);
+ } else {
+ TestUtils.failOnAssertion("parameter", value, VALUE, result);
+ }
+ return result;
+ }
+
+ protected TestResult checkGetActionParamerMap(PortletRequest request) {
+ 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])) {
+ result.setReturnCode(TestResult.PASSED);
+ } else {
+ TestUtils.failOnAssertion("parameter values",
+ values, new String[] { VALUE }, result);
+ }
+ 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(); ) {
+ String name = (String) en.nextElement();
+ if (KEY.equals(name)) {
+ hasParameterName = true;
+ }
+ }
+
+ if (hasParameterName) {
+ result.setReturnCode(TestResult.PASSED);
+ } else {
+ result.setReturnCode(TestResult.FAILED);
+ result.setResultMessage("Parameter name " + KEY
+ + " not found in parameter name enumeration.");
+ }
+ return result;
+ }
+
+}
Propchange: portals/pluto/branches/pluto-1.1.x/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/ActionParameterTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: portals/pluto/branches/pluto-1.1.x/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/AppScopedSessionAttributeTest.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/pluto-1.1.x/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/AppScopedSessionAttributeTest.java?rev=607448&r1=607447&r2=607448&view=diff
==============================================================================
--- portals/pluto/branches/pluto-1.1.x/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/AppScopedSessionAttributeTest.java (original)
+++ portals/pluto/branches/pluto-1.1.x/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/AppScopedSessionAttributeTest.java Sat Dec 29 09:20:23 2007
@@ -1,86 +1,86 @@
-/*
+/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.pluto.testsuite.test;
-
-import org.apache.pluto.testsuite.TestResult;
-import org.apache.pluto.testsuite.TestUtils;
-
-import javax.portlet.PortletSession;
-
-/**
- */
-public class AppScopedSessionAttributeTest
-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 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);
- } else {
- TestUtils.failOnAssertion("session attribute", value, null, result);
- }
- 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)) {
- result.setReturnCode(TestResult.PASSED);
- } else {
- TestUtils.failOnAssertion("session attribute", value, VALUE, result);
- }
- return result;
- }
-
- protected TestResult checkRemoveAppScopedAttribute(PortletSession session) {
- TestResult result = new TestResult();
- 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);
- if (value == null) {
- result.setReturnCode(TestResult.PASSED);
- } else {
- TestUtils.failOnAssertion("session attribute", value, null, result);
- }
- return result;
- }
-
-}
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.pluto.testsuite.test;
+
+import org.apache.pluto.testsuite.TestResult;
+import org.apache.pluto.testsuite.TestUtils;
+
+import javax.portlet.PortletSession;
+
+/**
+ */
+public class AppScopedSessionAttributeTest
+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 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);
+ } else {
+ TestUtils.failOnAssertion("session attribute", value, null, result);
+ }
+ 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)) {
+ result.setReturnCode(TestResult.PASSED);
+ } else {
+ TestUtils.failOnAssertion("session attribute", value, VALUE, result);
+ }
+ return result;
+ }
+
+ protected TestResult checkRemoveAppScopedAttribute(PortletSession session) {
+ TestResult result = new TestResult();
+ 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);
+ if (value == null) {
+ result.setReturnCode(TestResult.PASSED);
+ } else {
+ TestUtils.failOnAssertion("session attribute", value, null, result);
+ }
+ return result;
+ }
+
+}
Propchange: portals/pluto/branches/pluto-1.1.x/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/AppScopedSessionAttributeTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: portals/pluto/branches/pluto-1.1.x/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/ContextInitParameterTest.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/pluto-1.1.x/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/ContextInitParameterTest.java?rev=607448&r1=607447&r2=607448&view=diff
==============================================================================
--- portals/pluto/branches/pluto-1.1.x/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/ContextInitParameterTest.java (original)
+++ portals/pluto/branches/pluto-1.1.x/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/ContextInitParameterTest.java Sat Dec 29 09:20:23 2007
@@ -1,97 +1,97 @@
-/*
+/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.pluto.testsuite.test;
-
-import org.apache.pluto.testsuite.TestResult;
-import org.apache.pluto.testsuite.TestUtils;
-
-import javax.portlet.PortletContext;
-import javax.portlet.PortletSession;
-import java.util.Enumeration;
-
-/**
- * @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(); ) {
- String name = (String) en.nextElement();
- if (TEST_PARAM_NAME.equals(name)) {
- found = true;
- }
- }
-
- if (found) {
- result.setReturnCode(TestResult.PASSED);
- } else {
- result.setReturnCode(TestResult.FAILED);
- result.setResultMessage("Expected init parameter '"
- + TEST_PARAM_NAME + "' not found in portlet context.");
- }
- 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);
- } else {
- TestUtils.failOnAssertion("init parameter", value, TEST_PARAM_VALUE, result);
- }
- return result;
- }
-
- /**
- * FIXME: should this test reside in this class? -- ZHENG Zhong
- */
- protected TestResult checkGetContextFromSession(PortletSession session) {
- 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);
- } else {
- result.setReturnCode(TestResult.FAILED);
- result.setResultMessage("Fail to retrieve PortletContext from "
- + "PortletSession: null returned.");
- }
- return result;
- }
-}
-
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pluto.testsuite.test;
+
+import org.apache.pluto.testsuite.TestResult;
+import org.apache.pluto.testsuite.TestUtils;
+
+import javax.portlet.PortletContext;
+import javax.portlet.PortletSession;
+import java.util.Enumeration;
+
+/**
+ * @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(); ) {
+ String name = (String) en.nextElement();
+ if (TEST_PARAM_NAME.equals(name)) {
+ found = true;
+ }
+ }
+
+ if (found) {
+ result.setReturnCode(TestResult.PASSED);
+ } else {
+ result.setReturnCode(TestResult.FAILED);
+ result.setResultMessage("Expected init parameter '"
+ + TEST_PARAM_NAME + "' not found in portlet context.");
+ }
+ 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);
+ } else {
+ TestUtils.failOnAssertion("init parameter", value, TEST_PARAM_VALUE, result);
+ }
+ return result;
+ }
+
+ /**
+ * FIXME: should this test reside in this class? -- ZHENG Zhong
+ */
+ protected TestResult checkGetContextFromSession(PortletSession session) {
+ 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);
+ } else {
+ result.setReturnCode(TestResult.FAILED);
+ result.setResultMessage("Fail to retrieve PortletContext from "
+ + "PortletSession: null returned.");
+ }
+ return result;
+ }
+}
+
Propchange: portals/pluto/branches/pluto-1.1.x/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/ContextInitParameterTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: portals/pluto/branches/pluto-1.1.x/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/DispatcherRenderParameterTest.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/pluto-1.1.x/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/DispatcherRenderParameterTest.java?rev=607448&r1=607447&r2=607448&view=diff
==============================================================================
--- portals/pluto/branches/pluto-1.1.x/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/DispatcherRenderParameterTest.java (original)
+++ portals/pluto/branches/pluto-1.1.x/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/DispatcherRenderParameterTest.java Sat Dec 29 09:20:23 2007
@@ -1,341 +1,341 @@
-/*
+/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.pluto.testsuite.test;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.pluto.testsuite.TestResult;
-import org.apache.pluto.testsuite.TestUtils;
-
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.Map;
-
-import javax.portlet.PortletContext;
-import javax.portlet.PortletException;
-import javax.portlet.PortletRequest;
-import javax.portlet.PortletRequestDispatcher;
-import javax.portlet.PortletResponse;
-import javax.portlet.RenderRequest;
-import javax.portlet.RenderResponse;
-import javax.servlet.GenericServlet;
-import javax.servlet.ServletException;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-
-/**
- *
- * @version 1.0
- * @since Mar 9, 2005
- */
-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.
- */
- public Map getRenderParameters(PortletRequest request) {
- Map parameterMap = super.getRenderParameters(request);
- 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("?")
- .append(KEY_TARGET).append("=").append(TARGET_SAME_NAME_PARAM)
- .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)
- throws IOException, PortletException {
- // Dispatch to the companion servlet: call checkAddedSameNameParameter().
- StringBuffer buffer = new StringBuffer();
- buffer.append(SERVLET_PATH).append("?")
- .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("?")
- .append(KEY_TARGET).append("=").append(TARGET_INVALID_PARAMS)
- .append("&").append(KEY_A)
- .append("&").append(KEY_B).append("=").append(VALUE_B)
- .append("&").append(KEY_C).append("=");
- 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;
- }
-
-
- // Nested Companion Servlet Class ------------------------------------------
-
- /**
- * Nested static companion servlet class.
- */
- 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
- * to run, and saves the test result in the request scope, which will
- * be retrieved by the test portlet.
- * @param request the incoming servlet request.
- * @param response the incoming servlet response.
- */
- public void service(ServletRequest request, ServletResponse response)
- throws ServletException, IOException {
- TestResult result = null;
- String target = request.getParameter(KEY_TARGET);
- if (TARGET_PARAMS.equals(target)) {
- result = checkParameters(request);
- } else if (TARGET_SAME_NAME_PARAM.equals(target)) {
- result = checkSameNameParameter(request);
- } else if (TARGET_ADDED_SAME_NAME_PARAM.equals(target)) {
- result = checkAddedSameNameParameter(request);
- } else if (TARGET_INVALID_PARAMS.equals(target)) {
- result = checkInvalidParameters(request);
- } else {
- result = failOnUnknownTarget(request);
- }
- request.setAttribute(RESULT_KEY, result);
- }
-
-
- // Private Methods -----------------------------------------------------
-
- /**
- * Check that parameters A and B are available in the dispatching
- * request.
- * @param request the servlet request.
- */
- private TestResult checkParameters(ServletRequest request) {
- TestResult result = new TestResult();
- result.setDescription("Ensure query parameters added during "
- + "dispatching are attached to the request.");
- String valueA = request.getParameter(KEY_A);
- String valueB = request.getParameter(KEY_B);
- if (VALUE_A.equals(valueA) && VALUE_B.equals(valueB)) {
- result.setReturnCode(TestResult.PASSED);
- } else if (!VALUE_A.equals(valueA)){
- TestUtils.failOnAssertion("parameter", valueA, VALUE_A, result);
- } else {
- TestUtils.failOnAssertion("parameter", valueB, VALUE_B, result);
- }
- return result;
- }
-
- /**
- * Check that parameter C has three values.
- * @param request the servlet reqeust.
- */
- private TestResult checkSameNameParameter(ServletRequest request) {
- TestResult result = new TestResult();
- result.setDescription("Ensure query parameters with the same name "
- + "added during dispatching are attached to the request.");
- String[] values = request.getParameterValues(KEY_C);
- String[] expected = new String[] {
- VALUE_C1, VALUE_C2, VALUE_C3, };
- if (Arrays.equals(values, expected)) {
- result.setReturnCode(TestResult.PASSED);
- } else {
- TestUtils.failOnAssertion("parameter", values, expected, result);
- }
- return result;
- }
-
- /**
- * Check that parameter RENDER has three values: one is the render
- * parameter, while the other two are appended in the dispatch URI.
- * @param request the servlet reqeust.
- */
- private TestResult checkAddedSameNameParameter(ServletRequest request) {
- TestResult result = new TestResult();
- result.setDescription("Ensure query parameters with the same name "
- + "added during dispatching are attached to the request "
- + "as well as render parameters.");
- String[] values = request.getParameterValues(KEY_RENDER);
- String[] expected = new String[] {
- VALUE_ADDED1, VALUE_ADDED2, VALUE_RENDER, };
- if (Arrays.equals(values, expected)) {
- result.setReturnCode(TestResult.PASSED);
- } else {
- TestUtils.failOnAssertion("parameter", values, expected, result);
- }
- return result;
- }
-
- /**
- * Check that invalid parameter A is ignored, parameter B is attached
- * to the dispatching request with the correct value, and parameter C
- * is attached to the dispatching request with an empty string.
- * @param request the servlet request.
- */
- private TestResult checkInvalidParameters(ServletRequest request) {
- TestResult result = new TestResult();
- result.setDescription("Ensure invalid query parameters added "
- + "during dispatching are ignored.");
- String valueA = request.getParameter(KEY_A);
- String valueB = request.getParameter(KEY_B);
- String valueC = request.getParameter(KEY_C);
- if (valueA == null && VALUE_B.equals(valueB) && "".equals(valueC)) {
- result.setReturnCode(TestResult.PASSED);
- } else if (valueA != null) {
- TestUtils.failOnAssertion("parameter", valueA, null, result);
- } else if (!VALUE_B.equals(valueB)) {
- TestUtils.failOnAssertion("parameter", valueB, VALUE_B, result);
- } else {
- TestUtils.failOnAssertion("parameter", valueC, "", result);
- }
- return result;
- }
-
- private TestResult failOnUnknownTarget(ServletRequest request) {
- TestResult result = new TestResult();
- result.setReturnCode(TestResult.FAILED);
- result.setResultMessage("Unable to perform test for parameter "
- + KEY_TARGET + ": " + request.getParameter(KEY_TARGET));
- return result;
- }
-
- }
-
-}
-
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pluto.testsuite.test;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.pluto.testsuite.TestResult;
+import org.apache.pluto.testsuite.TestUtils;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Map;
+
+import javax.portlet.PortletContext;
+import javax.portlet.PortletException;
+import javax.portlet.PortletRequest;
+import javax.portlet.PortletRequestDispatcher;
+import javax.portlet.PortletResponse;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.servlet.GenericServlet;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+
+/**
+ *
+ * @version 1.0
+ * @since Mar 9, 2005
+ */
+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.
+ */
+ public Map getRenderParameters(PortletRequest request) {
+ Map parameterMap = super.getRenderParameters(request);
+ 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("?")
+ .append(KEY_TARGET).append("=").append(TARGET_SAME_NAME_PARAM)
+ .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)
+ throws IOException, PortletException {
+ // Dispatch to the companion servlet: call checkAddedSameNameParameter().
+ StringBuffer buffer = new StringBuffer();
+ buffer.append(SERVLET_PATH).append("?")
+ .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("?")
+ .append(KEY_TARGET).append("=").append(TARGET_INVALID_PARAMS)
+ .append("&").append(KEY_A)
+ .append("&").append(KEY_B).append("=").append(VALUE_B)
+ .append("&").append(KEY_C).append("=");
+ 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;
+ }
+
+
+ // Nested Companion Servlet Class ------------------------------------------
+
+ /**
+ * Nested static companion servlet class.
+ */
+ 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
+ * to run, and saves the test result in the request scope, which will
+ * be retrieved by the test portlet.
+ * @param request the incoming servlet request.
+ * @param response the incoming servlet response.
+ */
+ public void service(ServletRequest request, ServletResponse response)
+ throws ServletException, IOException {
+ TestResult result = null;
+ String target = request.getParameter(KEY_TARGET);
+ if (TARGET_PARAMS.equals(target)) {
+ result = checkParameters(request);
+ } else if (TARGET_SAME_NAME_PARAM.equals(target)) {
+ result = checkSameNameParameter(request);
+ } else if (TARGET_ADDED_SAME_NAME_PARAM.equals(target)) {
+ result = checkAddedSameNameParameter(request);
+ } else if (TARGET_INVALID_PARAMS.equals(target)) {
+ result = checkInvalidParameters(request);
+ } else {
+ result = failOnUnknownTarget(request);
+ }
+ request.setAttribute(RESULT_KEY, result);
+ }
+
+
+ // Private Methods -----------------------------------------------------
+
+ /**
+ * Check that parameters A and B are available in the dispatching
+ * request.
+ * @param request the servlet request.
+ */
+ private TestResult checkParameters(ServletRequest request) {
+ TestResult result = new TestResult();
+ result.setDescription("Ensure query parameters added during "
+ + "dispatching are attached to the request.");
+ String valueA = request.getParameter(KEY_A);
+ String valueB = request.getParameter(KEY_B);
+ if (VALUE_A.equals(valueA) && VALUE_B.equals(valueB)) {
+ result.setReturnCode(TestResult.PASSED);
+ } else if (!VALUE_A.equals(valueA)){
+ TestUtils.failOnAssertion("parameter", valueA, VALUE_A, result);
+ } else {
+ TestUtils.failOnAssertion("parameter", valueB, VALUE_B, result);
+ }
+ return result;
+ }
+
+ /**
+ * Check that parameter C has three values.
+ * @param request the servlet reqeust.
+ */
+ private TestResult checkSameNameParameter(ServletRequest request) {
+ TestResult result = new TestResult();
+ result.setDescription("Ensure query parameters with the same name "
+ + "added during dispatching are attached to the request.");
+ String[] values = request.getParameterValues(KEY_C);
+ String[] expected = new String[] {
+ VALUE_C1, VALUE_C2, VALUE_C3, };
+ if (Arrays.equals(values, expected)) {
+ result.setReturnCode(TestResult.PASSED);
+ } else {
+ TestUtils.failOnAssertion("parameter", values, expected, result);
+ }
+ return result;
+ }
+
+ /**
+ * Check that parameter RENDER has three values: one is the render
+ * parameter, while the other two are appended in the dispatch URI.
+ * @param request the servlet reqeust.
+ */
+ private TestResult checkAddedSameNameParameter(ServletRequest request) {
+ TestResult result = new TestResult();
+ result.setDescription("Ensure query parameters with the same name "
+ + "added during dispatching are attached to the request "
+ + "as well as render parameters.");
+ String[] values = request.getParameterValues(KEY_RENDER);
+ String[] expected = new String[] {
+ VALUE_ADDED1, VALUE_ADDED2, VALUE_RENDER, };
+ if (Arrays.equals(values, expected)) {
+ result.setReturnCode(TestResult.PASSED);
+ } else {
+ TestUtils.failOnAssertion("parameter", values, expected, result);
+ }
+ return result;
+ }
+
+ /**
+ * Check that invalid parameter A is ignored, parameter B is attached
+ * to the dispatching request with the correct value, and parameter C
+ * is attached to the dispatching request with an empty string.
+ * @param request the servlet request.
+ */
+ private TestResult checkInvalidParameters(ServletRequest request) {
+ TestResult result = new TestResult();
+ result.setDescription("Ensure invalid query parameters added "
+ + "during dispatching are ignored.");
+ String valueA = request.getParameter(KEY_A);
+ String valueB = request.getParameter(KEY_B);
+ String valueC = request.getParameter(KEY_C);
+ if (valueA == null && VALUE_B.equals(valueB) && "".equals(valueC)) {
+ result.setReturnCode(TestResult.PASSED);
+ } else if (valueA != null) {
+ TestUtils.failOnAssertion("parameter", valueA, null, result);
+ } else if (!VALUE_B.equals(valueB)) {
+ TestUtils.failOnAssertion("parameter", valueB, VALUE_B, result);
+ } else {
+ TestUtils.failOnAssertion("parameter", valueC, "", result);
+ }
+ return result;
+ }
+
+ private TestResult failOnUnknownTarget(ServletRequest request) {
+ TestResult result = new TestResult();
+ result.setReturnCode(TestResult.FAILED);
+ result.setResultMessage("Unable to perform test for parameter "
+ + KEY_TARGET + ": " + request.getParameter(KEY_TARGET));
+ return result;
+ }
+
+ }
+
+}
+
Propchange: portals/pluto/branches/pluto-1.1.x/pluto-testsuite/src/main/java/org/apache/pluto/testsuite/test/DispatcherRenderParameterTest.java
------------------------------------------------------------------------------
svn:eol-style = native