Return-Path: X-Original-To: apmail-portals-pluto-scm-archive@www.apache.org Delivered-To: apmail-portals-pluto-scm-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 87CD311426 for ; Mon, 25 Aug 2014 09:55:07 +0000 (UTC) Received: (qmail 822 invoked by uid 500); 25 Aug 2014 09:55:07 -0000 Delivered-To: apmail-portals-pluto-scm-archive@portals.apache.org Received: (qmail 789 invoked by uid 500); 25 Aug 2014 09:55:07 -0000 Mailing-List: contact pluto-scm-help@portals.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list pluto-scm@portals.apache.org Received: (qmail 780 invoked by uid 99); 25 Aug 2014 09:55:07 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 25 Aug 2014 09:55:07 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 1F72A9CFCEC; Mon, 25 Aug 2014 09:55:06 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: msnicklous@apache.org To: pluto-scm@portals.apache.org Date: Mon, 25 Aug 2014 09:55:16 -0000 Message-Id: <8ea1b4bd32fe4527955f7b478256ef13@git.apache.org> In-Reply-To: <9b715b36979c45358826497d8c260f05@git.apache.org> References: <9b715b36979c45358826497d8c260f05@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [12/22] began work on generating the additional spec tests and the portlet tab library tests again in order to improve structure and correct problems in test case names. http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/23a1c547/portlet-tck_3.0/V2AddlRequestTests/src/main/java/javax/portlet/tck/portlets/AddlRequestTests_SPEC2_11_Action.java ---------------------------------------------------------------------- diff --git a/portlet-tck_3.0/V2AddlRequestTests/src/main/java/javax/portlet/tck/portlets/AddlRequestTests_SPEC2_11_Action.java b/portlet-tck_3.0/V2AddlRequestTests/src/main/java/javax/portlet/tck/portlets/AddlRequestTests_SPEC2_11_Action.java new file mode 100644 index 0000000..c000ffb --- /dev/null +++ b/portlet-tck_3.0/V2AddlRequestTests/src/main/java/javax/portlet/tck/portlets/AddlRequestTests_SPEC2_11_Action.java @@ -0,0 +1,295 @@ +/* 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 javax.portlet.tck.portlets; + +import java.io.*; +import java.util.*; +import java.util.logging.*; +import static java.util.logging.Logger.*; +import javax.xml.namespace.QName; +import javax.portlet.*; +import javax.portlet.filter.*; +import javax.servlet.*; +import javax.servlet.http.*; +import javax.portlet.tck.beans.*; +import javax.portlet.tck.constants.*; +import static javax.portlet.tck.beans.JSR286SpecTestCaseDetails.*; +import static javax.portlet.tck.constants.Constants.*; +import static javax.portlet.PortletSession.*; +import static javax.portlet.ResourceURL.*; + +/** + * This portlet implements several test cases for the JSR 362 TCK. The test case names + * are defined in the /src/main/resources/xml-resources/additionalTCs.xml + * file. The build process will integrate the test case names defined in the + * additionalTCs.xml file into the complete list of test case names for execution by the driver. + * + * This is the main portlet for the test cases. If the test cases call for events, this portlet + * will initiate the events, but not process them. The processing is done in the companion + * portlet AddlRequestTests_SPEC2_11_Action_event + * + */ +public class AddlRequestTests_SPEC2_11_Action implements Portlet, ResourceServingPortlet { + private static final String LOG_CLASS = + AddlRequestTests_SPEC2_11_Action.class.getName(); + private final Logger LOGGER = Logger.getLogger(LOG_CLASS); + + private PortletConfig portletConfig = null; + + @Override + public void init(PortletConfig config) throws PortletException { + this.portletConfig = config; + } + + @Override + public void destroy() { + } + + @Override + public void processAction(ActionRequest portletReq, ActionResponse portletResp) + throws PortletException, IOException { + LOGGER.entering(LOG_CLASS, "main portlet processAction entry"); + + portletResp.setRenderParameters(portletReq.getParameterMap()); + long tid = Thread.currentThread().getId(); + portletReq.setAttribute(THREADID_ATTR, tid); + + StringWriter writer = new StringWriter(); + + JSR286SpecTestCaseDetails tcd = new JSR286SpecTestCaseDetails(); + + // Create result objects for the tests + + /* TestCase: V2AddlRequestTests_SPEC2_11_Action_parameters1 */ + /* Details: "If a portlet receives a request from a client request */ + /* targeted to the portlet itself, the parameters must be the string */ + /* parameters encoded in the URL (added when creating the PortletURL) */ + /* and the string parameters sent by the client to the portlet as */ + /* part of the client request" */ + TestResult tr0 = tcd.getTestResultFailed(V2ADDLREQUESTTESTS_SPEC2_11_ACTION_PARAMETERS1); + /* TODO: implement test */ + tr0.appendTcDetail("Not implemented."); + tr0.writeTo(writer); + + /* TestCase: V2AddlRequestTests_SPEC2_11_Action_parameters2 */ + /* Details: "The parameters the request object returns must be */ + /* \"x-www-form-urlencoded\" decoded" */ + TestResult tr1 = tcd.getTestResultFailed(V2ADDLREQUESTTESTS_SPEC2_11_ACTION_PARAMETERS2); + /* TODO: implement test */ + tr1.appendTcDetail("Not implemented."); + tr1.writeTo(writer); + + /* TestCase: V2AddlRequestTests_SPEC2_11_Action_parameters6 */ + /* Details: "The getParameterMap method must return an unmodifiable */ + /* Map object" */ + TestResult tr2 = tcd.getTestResultFailed(V2ADDLREQUESTTESTS_SPEC2_11_ACTION_PARAMETERS6); + /* TODO: implement test */ + tr2.appendTcDetail("Not implemented."); + tr2.writeTo(writer); + + /* TestCase: V2AddlRequestTests_SPEC2_11_Action_parameters8 */ + /* Details: "If the portlet is performing an HTML Form submission via */ + /* HTTP method POST the post form data will be populated to the */ + /* portlet request parameter set if the content type is */ + /* application/x-www-form-urlencoded" */ + TestResult tr3 = tcd.getTestResultFailed(V2ADDLREQUESTTESTS_SPEC2_11_ACTION_PARAMETERS8); + /* TODO: implement test */ + tr3.appendTcDetail("Not implemented."); + tr3.writeTo(writer); + + /* TestCase: V2AddlRequestTests_SPEC2_11_Action_parameters9 */ + /* Details: "If the portlet is performing an HTML Form submission via */ + /* the HTTP method GET the form data set is appended to the portlet */ + /* URL used for the form submission and are therefore accessible as */ + /* request parameters for the portlet" */ + TestResult tr4 = tcd.getTestResultFailed(V2ADDLREQUESTTESTS_SPEC2_11_ACTION_PARAMETERS9); + /* TODO: implement test */ + tr4.appendTcDetail("Not implemented."); + tr4.writeTo(writer); + + /* TestCase: V2AddlRequestTests_SPEC2_11_Action_publicRenderParameters15 */ + /* Details: "A map of private parameters can be obtained through the */ + /* getPrivateParameterMap method" */ + TestResult tr5 = tcd.getTestResultFailed(V2ADDLREQUESTTESTS_SPEC2_11_ACTION_PUBLICRENDERPARAMETERS15); + /* TODO: implement test */ + tr5.appendTcDetail("Not implemented."); + tr5.writeTo(writer); + + /* TestCase: V2AddlRequestTests_SPEC2_11_Action_publicRenderParameters16 */ + /* Details: "A map of public parameters can be obtained through the */ + /* getPublicParameterMap method" */ + TestResult tr6 = tcd.getTestResultFailed(V2ADDLREQUESTTESTS_SPEC2_11_ACTION_PUBLICRENDERPARAMETERS16); + /* TODO: implement test */ + tr6.appendTcDetail("Not implemented."); + tr6.writeTo(writer); + + /* TestCase: V2AddlRequestTests_SPEC2_11_Action_publicRenderParameters4 */ + /* Details: "Public render parameters are available in the */ + /* processAction method" */ + TestResult tr7 = tcd.getTestResultFailed(V2ADDLREQUESTTESTS_SPEC2_11_ACTION_PUBLICRENDERPARAMETERS4); + /* TODO: implement test */ + tr7.appendTcDetail("Not implemented."); + tr7.writeTo(writer); + + /* TestCase: V2AddlRequestTests_SPEC2_11_Action_publicRenderParameters11 */ + /* Details: "If the portlet sets an action parameter with the same */ + /* name as a public render parameter, this results in a multi-valued */ + /* parameter. The public render parameter values must be the last */ + /* entries in the parameter value array" */ + TestResult tr8 = tcd.getTestResultFailed(V2ADDLREQUESTTESTS_SPEC2_11_ACTION_PUBLICRENDERPARAMETERS11); + /* TODO: implement test */ + tr8.appendTcDetail("Not implemented."); + tr8.writeTo(writer); + + portletReq.getPortletSession().setAttribute( + Constants.RESULT_ATTR_PREFIX + "AddlRequestTests_SPEC2_11_Action", + writer.toString(), APPLICATION_SCOPE); + } + + @Override + public void serveResource(ResourceRequest portletReq, ResourceResponse portletResp) + throws PortletException, IOException { + LOGGER.entering(LOG_CLASS, "main portlet serveResource entry"); + + long tid = Thread.currentThread().getId(); + portletReq.setAttribute(THREADID_ATTR, tid); + + PrintWriter writer = portletResp.getWriter(); + + } + + @Override + public void render(RenderRequest portletReq, RenderResponse portletResp) + throws PortletException, IOException { + LOGGER.entering(LOG_CLASS, "main portlet render entry"); + + long tid = Thread.currentThread().getId(); + portletReq.setAttribute(THREADID_ATTR, tid); + + PrintWriter writer = portletResp.getWriter(); + + PortletSession ps = portletReq.getPortletSession(); + String msg = (String) ps.getAttribute(RESULT_ATTR_PREFIX + "AddlRequestTests_SPEC2_11_Action", APPLICATION_SCOPE); + if (msg != null) { + writer.write("

" + msg + "


\n"); + ps.removeAttribute(RESULT_ATTR_PREFIX + "AddlRequestTests_SPEC2_11_Action", APPLICATION_SCOPE); + } + + /* TestCase: V2AddlRequestTests_SPEC2_11_Action_parameters1 */ + /* Details: "If a portlet receives a request from a client request */ + /* targeted to the portlet itself, the parameters must be the string */ + /* parameters encoded in the URL (added when creating the PortletURL) */ + /* and the string parameters sent by the client to the portlet as */ + /* part of the client request" */ + { + PortletURL aurl = portletResp.createActionURL(); + aurl.setParameters(portletReq.getPrivateParameterMap()); + TestButton tb = new TestButton("V2AddlRequestTests_SPEC2_11_Action_parameters1", aurl); + tb.writeTo(writer); + } + + /* TestCase: V2AddlRequestTests_SPEC2_11_Action_parameters2 */ + /* Details: "The parameters the request object returns must be */ + /* \"x-www-form-urlencoded\" decoded" */ + { + PortletURL aurl = portletResp.createActionURL(); + aurl.setParameters(portletReq.getPrivateParameterMap()); + TestButton tb = new TestButton("V2AddlRequestTests_SPEC2_11_Action_parameters2", aurl); + tb.writeTo(writer); + } + + /* TestCase: V2AddlRequestTests_SPEC2_11_Action_parameters6 */ + /* Details: "The getParameterMap method must return an unmodifiable */ + /* Map object" */ + { + PortletURL aurl = portletResp.createActionURL(); + aurl.setParameters(portletReq.getPrivateParameterMap()); + TestButton tb = new TestButton("V2AddlRequestTests_SPEC2_11_Action_parameters6", aurl); + tb.writeTo(writer); + } + + /* TestCase: V2AddlRequestTests_SPEC2_11_Action_parameters8 */ + /* Details: "If the portlet is performing an HTML Form submission via */ + /* HTTP method POST the post form data will be populated to the */ + /* portlet request parameter set if the content type is */ + /* application/x-www-form-urlencoded" */ + { + PortletURL aurl = portletResp.createActionURL(); + aurl.setParameters(portletReq.getPrivateParameterMap()); + TestButton tb = new TestButton("V2AddlRequestTests_SPEC2_11_Action_parameters8", aurl); + tb.writeTo(writer); + } + + /* TestCase: V2AddlRequestTests_SPEC2_11_Action_parameters9 */ + /* Details: "If the portlet is performing an HTML Form submission via */ + /* the HTTP method GET the form data set is appended to the portlet */ + /* URL used for the form submission and are therefore accessible as */ + /* request parameters for the portlet" */ + { + PortletURL aurl = portletResp.createActionURL(); + aurl.setParameters(portletReq.getPrivateParameterMap()); + TestButton tb = new TestButton("V2AddlRequestTests_SPEC2_11_Action_parameters9", aurl); + tb.writeTo(writer); + } + + /* TestCase: V2AddlRequestTests_SPEC2_11_Action_publicRenderParameters15 */ + /* Details: "A map of private parameters can be obtained through the */ + /* getPrivateParameterMap method" */ + { + PortletURL aurl = portletResp.createActionURL(); + aurl.setParameters(portletReq.getPrivateParameterMap()); + TestButton tb = new TestButton("V2AddlRequestTests_SPEC2_11_Action_publicRenderParameters15", aurl); + tb.writeTo(writer); + } + + /* TestCase: V2AddlRequestTests_SPEC2_11_Action_publicRenderParameters16 */ + /* Details: "A map of public parameters can be obtained through the */ + /* getPublicParameterMap method" */ + { + PortletURL aurl = portletResp.createActionURL(); + aurl.setParameters(portletReq.getPrivateParameterMap()); + TestButton tb = new TestButton("V2AddlRequestTests_SPEC2_11_Action_publicRenderParameters16", aurl); + tb.writeTo(writer); + } + + /* TestCase: V2AddlRequestTests_SPEC2_11_Action_publicRenderParameters4 */ + /* Details: "Public render parameters are available in the */ + /* processAction method" */ + { + PortletURL aurl = portletResp.createActionURL(); + aurl.setParameters(portletReq.getPrivateParameterMap()); + TestButton tb = new TestButton("V2AddlRequestTests_SPEC2_11_Action_publicRenderParameters4", aurl); + tb.writeTo(writer); + } + + /* TestCase: V2AddlRequestTests_SPEC2_11_Action_publicRenderParameters11 */ + /* Details: "If the portlet sets an action parameter with the same */ + /* name as a public render parameter, this results in a multi-valued */ + /* parameter. The public render parameter values must be the last */ + /* entries in the parameter value array" */ + { + PortletURL aurl = portletResp.createActionURL(); + aurl.setParameters(portletReq.getPrivateParameterMap()); + TestButton tb = new TestButton("V2AddlRequestTests_SPEC2_11_Action_publicRenderParameters11", aurl); + tb.writeTo(writer); + } + + } + +} http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/23a1c547/portlet-tck_3.0/V2AddlRequestTests/src/main/java/javax/portlet/tck/portlets/AddlRequestTests_SPEC2_11_ActionAttr.java ---------------------------------------------------------------------- diff --git a/portlet-tck_3.0/V2AddlRequestTests/src/main/java/javax/portlet/tck/portlets/AddlRequestTests_SPEC2_11_ActionAttr.java b/portlet-tck_3.0/V2AddlRequestTests/src/main/java/javax/portlet/tck/portlets/AddlRequestTests_SPEC2_11_ActionAttr.java new file mode 100644 index 0000000..4759e88 --- /dev/null +++ b/portlet-tck_3.0/V2AddlRequestTests/src/main/java/javax/portlet/tck/portlets/AddlRequestTests_SPEC2_11_ActionAttr.java @@ -0,0 +1,171 @@ +/* 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 javax.portlet.tck.portlets; + +import java.io.*; +import java.util.*; +import java.util.logging.*; +import static java.util.logging.Logger.*; +import javax.xml.namespace.QName; +import javax.portlet.*; +import javax.portlet.filter.*; +import javax.servlet.*; +import javax.servlet.http.*; +import javax.portlet.tck.beans.*; +import javax.portlet.tck.constants.*; +import static javax.portlet.tck.beans.JSR286SpecTestCaseDetails.*; +import static javax.portlet.tck.constants.Constants.*; +import static javax.portlet.PortletSession.*; +import static javax.portlet.ResourceURL.*; + +/** + * This portlet implements several test cases for the JSR 362 TCK. The test case names + * are defined in the /src/main/resources/xml-resources/additionalTCs.xml + * file. The build process will integrate the test case names defined in the + * additionalTCs.xml file into the complete list of test case names for execution by the driver. + * + * This is the main portlet for the test cases. If the test cases call for events, this portlet + * will initiate the events, but not process them. The processing is done in the companion + * portlet AddlRequestTests_SPEC2_11_ActionAttr_event + * + */ +public class AddlRequestTests_SPEC2_11_ActionAttr implements Portlet, ResourceServingPortlet { + private static final String LOG_CLASS = + AddlRequestTests_SPEC2_11_ActionAttr.class.getName(); + private final Logger LOGGER = Logger.getLogger(LOG_CLASS); + + private PortletConfig portletConfig = null; + + @Override + public void init(PortletConfig config) throws PortletException { + this.portletConfig = config; + } + + @Override + public void destroy() { + } + + @Override + public void processAction(ActionRequest portletReq, ActionResponse portletResp) + throws PortletException, IOException { + LOGGER.entering(LOG_CLASS, "main portlet processAction entry"); + + portletResp.setRenderParameters(portletReq.getParameterMap()); + long tid = Thread.currentThread().getId(); + portletReq.setAttribute(THREADID_ATTR, tid); + + StringWriter writer = new StringWriter(); + + JSR286SpecTestCaseDetails tcd = new JSR286SpecTestCaseDetails(); + + // Create result objects for the tests + + /* TestCase: V2AddlRequestTests_SPEC2_11_ActionAttr_attributes1 */ + /* Details: "The portlet can access a map with user information */ + /* attributes via the request attribute PortletRequest.USER_INFO" */ + TestResult tr0 = tcd.getTestResultFailed(V2ADDLREQUESTTESTS_SPEC2_11_ACTIONATTR_ATTRIBUTES1); + /* TODO: implement test */ + tr0.appendTcDetail("Not implemented."); + tr0.writeTo(writer); + + /* TestCase: V2AddlRequestTests_SPEC2_11_ActionAttr_attributes2 */ + /* Details: "The PortletRequest.CCPP_PROFILE request attribute must */ + /* return a javax.ccpp.Profile based on the current portlet request" */ + TestResult tr1 = tcd.getTestResultFailed(V2ADDLREQUESTTESTS_SPEC2_11_ACTIONATTR_ATTRIBUTES2); + /* TODO: implement test */ + tr1.appendTcDetail("Not implemented."); + tr1.writeTo(writer); + + /* TestCase: V2AddlRequestTests_SPEC2_11_ActionAttr_attributes6 */ + /* Details: "During action processing, the LIFECYCLE_PHASE */ + /* (\"javax.portlet.lifecycle_phase\") attribute will contain the */ + /* string \"ACTION_PHASE\"" */ + TestResult tr2 = tcd.getTestResultFailed(V2ADDLREQUESTTESTS_SPEC2_11_ACTIONATTR_ATTRIBUTES6); + /* TODO: implement test */ + tr2.appendTcDetail("Not implemented."); + tr2.writeTo(writer); + + portletReq.getPortletSession().setAttribute( + Constants.RESULT_ATTR_PREFIX + "AddlRequestTests_SPEC2_11_ActionAttr", + writer.toString(), APPLICATION_SCOPE); + } + + @Override + public void serveResource(ResourceRequest portletReq, ResourceResponse portletResp) + throws PortletException, IOException { + LOGGER.entering(LOG_CLASS, "main portlet serveResource entry"); + + long tid = Thread.currentThread().getId(); + portletReq.setAttribute(THREADID_ATTR, tid); + + PrintWriter writer = portletResp.getWriter(); + + } + + @Override + public void render(RenderRequest portletReq, RenderResponse portletResp) + throws PortletException, IOException { + LOGGER.entering(LOG_CLASS, "main portlet render entry"); + + long tid = Thread.currentThread().getId(); + portletReq.setAttribute(THREADID_ATTR, tid); + + PrintWriter writer = portletResp.getWriter(); + + PortletSession ps = portletReq.getPortletSession(); + String msg = (String) ps.getAttribute(RESULT_ATTR_PREFIX + "AddlRequestTests_SPEC2_11_ActionAttr", APPLICATION_SCOPE); + if (msg != null) { + writer.write("

" + msg + "


\n"); + ps.removeAttribute(RESULT_ATTR_PREFIX + "AddlRequestTests_SPEC2_11_ActionAttr", APPLICATION_SCOPE); + } + + /* TestCase: V2AddlRequestTests_SPEC2_11_ActionAttr_attributes1 */ + /* Details: "The portlet can access a map with user information */ + /* attributes via the request attribute PortletRequest.USER_INFO" */ + { + PortletURL aurl = portletResp.createActionURL(); + aurl.setParameters(portletReq.getPrivateParameterMap()); + TestButton tb = new TestButton("V2AddlRequestTests_SPEC2_11_ActionAttr_attributes1", aurl); + tb.writeTo(writer); + } + + /* TestCase: V2AddlRequestTests_SPEC2_11_ActionAttr_attributes2 */ + /* Details: "The PortletRequest.CCPP_PROFILE request attribute must */ + /* return a javax.ccpp.Profile based on the current portlet request" */ + { + PortletURL aurl = portletResp.createActionURL(); + aurl.setParameters(portletReq.getPrivateParameterMap()); + TestButton tb = new TestButton("V2AddlRequestTests_SPEC2_11_ActionAttr_attributes2", aurl); + tb.writeTo(writer); + } + + /* TestCase: V2AddlRequestTests_SPEC2_11_ActionAttr_attributes6 */ + /* Details: "During action processing, the LIFECYCLE_PHASE */ + /* (\"javax.portlet.lifecycle_phase\") attribute will contain the */ + /* string \"ACTION_PHASE\"" */ + { + PortletURL aurl = portletResp.createActionURL(); + aurl.setParameters(portletReq.getPrivateParameterMap()); + TestButton tb = new TestButton("V2AddlRequestTests_SPEC2_11_ActionAttr_attributes6", aurl); + tb.writeTo(writer); + } + + } + +} http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/23a1c547/portlet-tck_3.0/V2AddlRequestTests/src/main/java/javax/portlet/tck/portlets/AddlRequestTests_SPEC2_11_ActionReq.java ---------------------------------------------------------------------- diff --git a/portlet-tck_3.0/V2AddlRequestTests/src/main/java/javax/portlet/tck/portlets/AddlRequestTests_SPEC2_11_ActionReq.java b/portlet-tck_3.0/V2AddlRequestTests/src/main/java/javax/portlet/tck/portlets/AddlRequestTests_SPEC2_11_ActionReq.java new file mode 100644 index 0000000..55f55f1 --- /dev/null +++ b/portlet-tck_3.0/V2AddlRequestTests/src/main/java/javax/portlet/tck/portlets/AddlRequestTests_SPEC2_11_ActionReq.java @@ -0,0 +1,271 @@ +/* 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 javax.portlet.tck.portlets; + +import java.io.*; +import java.util.*; +import java.util.logging.*; +import static java.util.logging.Logger.*; +import javax.xml.namespace.QName; +import javax.portlet.*; +import javax.portlet.filter.*; +import javax.servlet.*; +import javax.servlet.http.*; +import javax.portlet.tck.beans.*; +import javax.portlet.tck.constants.*; +import static javax.portlet.tck.beans.JSR286SpecTestCaseDetails.*; +import static javax.portlet.tck.constants.Constants.*; +import static javax.portlet.PortletSession.*; +import static javax.portlet.ResourceURL.*; + +/** + * This portlet implements several test cases for the JSR 362 TCK. The test case names + * are defined in the /src/main/resources/xml-resources/additionalTCs.xml + * file. The build process will integrate the test case names defined in the + * additionalTCs.xml file into the complete list of test case names for execution by the driver. + * + * This is the main portlet for the test cases. If the test cases call for events, this portlet + * will initiate the events, but not process them. The processing is done in the companion + * portlet AddlRequestTests_SPEC2_11_ActionReq_event + * + */ +public class AddlRequestTests_SPEC2_11_ActionReq implements Portlet, ResourceServingPortlet { + private static final String LOG_CLASS = + AddlRequestTests_SPEC2_11_ActionReq.class.getName(); + private final Logger LOGGER = Logger.getLogger(LOG_CLASS); + + private PortletConfig portletConfig = null; + + @Override + public void init(PortletConfig config) throws PortletException { + this.portletConfig = config; + } + + @Override + public void destroy() { + } + + @Override + public void processAction(ActionRequest portletReq, ActionResponse portletResp) + throws PortletException, IOException { + LOGGER.entering(LOG_CLASS, "main portlet processAction entry"); + + portletResp.setRenderParameters(portletReq.getParameterMap()); + long tid = Thread.currentThread().getId(); + portletReq.setAttribute(THREADID_ATTR, tid); + + StringWriter writer = new StringWriter(); + + JSR286SpecTestCaseDetails tcd = new JSR286SpecTestCaseDetails(); + + // Create result objects for the tests + + /* TestCase: V2AddlRequestTests_SPEC2_11_ActionReq_contentType1 */ + /* Details: "The getResponseContentType method returns a String */ + /* representing the default content type the portlet container */ + /* assumes for the output" */ + TestResult tr0 = tcd.getTestResultFailed(V2ADDLREQUESTTESTS_SPEC2_11_ACTIONREQ_CONTENTTYPE1); + /* TODO: implement test */ + tr0.appendTcDetail("Not implemented."); + tr0.writeTo(writer); + + /* TestCase: V2AddlRequestTests_SPEC2_11_ActionReq_contentType2 */ + /* Details: "The getResponseContentTypes method returns an */ + /* Enumeration of String elements representing the acceptable content */ + /* types for the output in order of preference" */ + TestResult tr1 = tcd.getTestResultFailed(V2ADDLREQUESTTESTS_SPEC2_11_ACTIONREQ_CONTENTTYPE2); + /* TODO: implement test */ + tr1.appendTcDetail("Not implemented."); + tr1.writeTo(writer); + + /* TestCase: V2AddlRequestTests_SPEC2_11_ActionReq_contentType3 */ + /* Details: "The first element of the Enumeration returned by the */ + /* getResponseContentTypes method must equal the value returned by */ + /* the getResponseContentType method" */ + TestResult tr2 = tcd.getTestResultFailed(V2ADDLREQUESTTESTS_SPEC2_11_ACTIONREQ_CONTENTTYPE3); + /* TODO: implement test */ + tr2.appendTcDetail("Not implemented."); + tr2.writeTo(writer); + + /* TestCase: V2AddlRequestTests_SPEC2_11_ActionReq_contentType4 */ + /* Details: "If a portlet defines support for all content types using */ + /* a wildcard and the portlet container supports all content types, */ + /* the getResponseContentType may return the wildcard" */ + TestResult tr3 = tcd.getTestResultFailed(V2ADDLREQUESTTESTS_SPEC2_11_ACTIONREQ_CONTENTTYPE4); + /* TODO: implement test */ + tr3.appendTcDetail("Not implemented."); + tr3.writeTo(writer); + + /* TestCase: V2AddlRequestTests_SPEC2_11_ActionReq_contentType5 */ + /* Details: "If a portlet defines support for all content types using */ + /* a wildcard and the portlet container supports all content types, */ + /* the getResponseContentType may return the preferred content type" */ + TestResult tr4 = tcd.getTestResultFailed(V2ADDLREQUESTTESTS_SPEC2_11_ACTIONREQ_CONTENTTYPE5); + /* TODO: implement test */ + tr4.appendTcDetail("Not implemented."); + tr4.writeTo(writer); + + /* TestCase: V2AddlRequestTests_SPEC2_11_ActionReq_windowId4 */ + /* Details: "The string returned by getWindowID method must be the */ + /* same ID used for scoping portlet-scope session attributes" */ + TestResult tr5 = tcd.getTestResultFailed(V2ADDLREQUESTTESTS_SPEC2_11_ACTIONREQ_WINDOWID4); + /* TODO: implement test */ + tr5.appendTcDetail("Not implemented."); + tr5.writeTo(writer); + + /* TestCase: V2AddlRequestTests_SPEC2_11_ActionReq_contentType6 */ + /* Details: "Within the processAction method, the content type must */ + /* include only the MIME type, not the character set" */ + TestResult tr6 = tcd.getTestResultFailed(V2ADDLREQUESTTESTS_SPEC2_11_ACTIONREQ_CONTENTTYPE6); + /* TODO: implement test */ + tr6.appendTcDetail("Not implemented."); + tr6.writeTo(writer); + + /* TestCase: V2AddlRequestTests_SPEC2_11_ActionReq_contentType7 */ + /* Details: "Within the processAction method, the */ + /* getResponseContentTypes method must return only the content types */ + /* supported by the current portlet mode" */ + TestResult tr7 = tcd.getTestResultFailed(V2ADDLREQUESTTESTS_SPEC2_11_ACTIONREQ_CONTENTTYPE7); + /* TODO: implement test */ + tr7.appendTcDetail("Not implemented."); + tr7.writeTo(writer); + + portletReq.getPortletSession().setAttribute( + Constants.RESULT_ATTR_PREFIX + "AddlRequestTests_SPEC2_11_ActionReq", + writer.toString(), APPLICATION_SCOPE); + } + + @Override + public void serveResource(ResourceRequest portletReq, ResourceResponse portletResp) + throws PortletException, IOException { + LOGGER.entering(LOG_CLASS, "main portlet serveResource entry"); + + long tid = Thread.currentThread().getId(); + portletReq.setAttribute(THREADID_ATTR, tid); + + PrintWriter writer = portletResp.getWriter(); + + } + + @Override + public void render(RenderRequest portletReq, RenderResponse portletResp) + throws PortletException, IOException { + LOGGER.entering(LOG_CLASS, "main portlet render entry"); + + long tid = Thread.currentThread().getId(); + portletReq.setAttribute(THREADID_ATTR, tid); + + PrintWriter writer = portletResp.getWriter(); + + PortletSession ps = portletReq.getPortletSession(); + String msg = (String) ps.getAttribute(RESULT_ATTR_PREFIX + "AddlRequestTests_SPEC2_11_ActionReq", APPLICATION_SCOPE); + if (msg != null) { + writer.write("

" + msg + "


\n"); + ps.removeAttribute(RESULT_ATTR_PREFIX + "AddlRequestTests_SPEC2_11_ActionReq", APPLICATION_SCOPE); + } + + /* TestCase: V2AddlRequestTests_SPEC2_11_ActionReq_contentType1 */ + /* Details: "The getResponseContentType method returns a String */ + /* representing the default content type the portlet container */ + /* assumes for the output" */ + { + PortletURL aurl = portletResp.createActionURL(); + aurl.setParameters(portletReq.getPrivateParameterMap()); + TestButton tb = new TestButton("V2AddlRequestTests_SPEC2_11_ActionReq_contentType1", aurl); + tb.writeTo(writer); + } + + /* TestCase: V2AddlRequestTests_SPEC2_11_ActionReq_contentType2 */ + /* Details: "The getResponseContentTypes method returns an */ + /* Enumeration of String elements representing the acceptable content */ + /* types for the output in order of preference" */ + { + PortletURL aurl = portletResp.createActionURL(); + aurl.setParameters(portletReq.getPrivateParameterMap()); + TestButton tb = new TestButton("V2AddlRequestTests_SPEC2_11_ActionReq_contentType2", aurl); + tb.writeTo(writer); + } + + /* TestCase: V2AddlRequestTests_SPEC2_11_ActionReq_contentType3 */ + /* Details: "The first element of the Enumeration returned by the */ + /* getResponseContentTypes method must equal the value returned by */ + /* the getResponseContentType method" */ + { + PortletURL aurl = portletResp.createActionURL(); + aurl.setParameters(portletReq.getPrivateParameterMap()); + TestButton tb = new TestButton("V2AddlRequestTests_SPEC2_11_ActionReq_contentType3", aurl); + tb.writeTo(writer); + } + + /* TestCase: V2AddlRequestTests_SPEC2_11_ActionReq_contentType4 */ + /* Details: "If a portlet defines support for all content types using */ + /* a wildcard and the portlet container supports all content types, */ + /* the getResponseContentType may return the wildcard" */ + { + PortletURL aurl = portletResp.createActionURL(); + aurl.setParameters(portletReq.getPrivateParameterMap()); + TestButton tb = new TestButton("V2AddlRequestTests_SPEC2_11_ActionReq_contentType4", aurl); + tb.writeTo(writer); + } + + /* TestCase: V2AddlRequestTests_SPEC2_11_ActionReq_contentType5 */ + /* Details: "If a portlet defines support for all content types using */ + /* a wildcard and the portlet container supports all content types, */ + /* the getResponseContentType may return the preferred content type" */ + { + PortletURL aurl = portletResp.createActionURL(); + aurl.setParameters(portletReq.getPrivateParameterMap()); + TestButton tb = new TestButton("V2AddlRequestTests_SPEC2_11_ActionReq_contentType5", aurl); + tb.writeTo(writer); + } + + /* TestCase: V2AddlRequestTests_SPEC2_11_ActionReq_windowId4 */ + /* Details: "The string returned by getWindowID method must be the */ + /* same ID used for scoping portlet-scope session attributes" */ + { + PortletURL aurl = portletResp.createActionURL(); + aurl.setParameters(portletReq.getPrivateParameterMap()); + TestButton tb = new TestButton("V2AddlRequestTests_SPEC2_11_ActionReq_windowId4", aurl); + tb.writeTo(writer); + } + + /* TestCase: V2AddlRequestTests_SPEC2_11_ActionReq_contentType6 */ + /* Details: "Within the processAction method, the content type must */ + /* include only the MIME type, not the character set" */ + { + PortletURL aurl = portletResp.createActionURL(); + aurl.setParameters(portletReq.getPrivateParameterMap()); + TestButton tb = new TestButton("V2AddlRequestTests_SPEC2_11_ActionReq_contentType6", aurl); + tb.writeTo(writer); + } + + /* TestCase: V2AddlRequestTests_SPEC2_11_ActionReq_contentType7 */ + /* Details: "Within the processAction method, the */ + /* getResponseContentTypes method must return only the content types */ + /* supported by the current portlet mode" */ + { + PortletURL aurl = portletResp.createActionURL(); + aurl.setParameters(portletReq.getPrivateParameterMap()); + TestButton tb = new TestButton("V2AddlRequestTests_SPEC2_11_ActionReq_contentType7", aurl); + tb.writeTo(writer); + } + + } + +} http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/23a1c547/portlet-tck_3.0/V2AddlRequestTests/src/main/java/javax/portlet/tck/portlets/AddlRequestTests_SPEC2_11_Event.java ---------------------------------------------------------------------- diff --git a/portlet-tck_3.0/V2AddlRequestTests/src/main/java/javax/portlet/tck/portlets/AddlRequestTests_SPEC2_11_Event.java b/portlet-tck_3.0/V2AddlRequestTests/src/main/java/javax/portlet/tck/portlets/AddlRequestTests_SPEC2_11_Event.java new file mode 100644 index 0000000..6b684eb --- /dev/null +++ b/portlet-tck_3.0/V2AddlRequestTests/src/main/java/javax/portlet/tck/portlets/AddlRequestTests_SPEC2_11_Event.java @@ -0,0 +1,179 @@ +/* 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 javax.portlet.tck.portlets; + +import java.io.*; +import java.util.*; +import java.util.logging.*; +import static java.util.logging.Logger.*; +import javax.xml.namespace.QName; +import javax.portlet.*; +import javax.portlet.filter.*; +import javax.servlet.*; +import javax.servlet.http.*; +import javax.portlet.tck.beans.*; +import javax.portlet.tck.constants.*; +import static javax.portlet.tck.beans.JSR286SpecTestCaseDetails.*; +import static javax.portlet.tck.constants.Constants.*; +import static javax.portlet.PortletSession.*; +import static javax.portlet.ResourceURL.*; + +/** + * This portlet implements several test cases for the JSR 362 TCK. The test case names + * are defined in the /src/main/resources/xml-resources/additionalTCs.xml + * file. The build process will integrate the test case names defined in the + * additionalTCs.xml file into the complete list of test case names for execution by the driver. + * + * This is the main portlet for the test cases. If the test cases call for events, this portlet + * will initiate the events, but not process them. The processing is done in the companion + * portlet AddlRequestTests_SPEC2_11_Event_event + * + */ +public class AddlRequestTests_SPEC2_11_Event implements Portlet, ResourceServingPortlet { + private static final String LOG_CLASS = + AddlRequestTests_SPEC2_11_Event.class.getName(); + private final Logger LOGGER = Logger.getLogger(LOG_CLASS); + + private PortletConfig portletConfig = null; + + @Override + public void init(PortletConfig config) throws PortletException { + this.portletConfig = config; + } + + @Override + public void destroy() { + } + + @Override + public void processAction(ActionRequest portletReq, ActionResponse portletResp) + throws PortletException, IOException { + LOGGER.entering(LOG_CLASS, "main portlet processAction entry"); + + portletResp.setRenderParameters(portletReq.getParameterMap()); + long tid = Thread.currentThread().getId(); + portletReq.setAttribute(THREADID_ATTR, tid); + + StringWriter writer = new StringWriter(); + + QName eventQName = new QName(TCKNAMESPACE, + "AddlRequestTests_SPEC2_11_Event"); + portletResp.setEvent(eventQName, "Hi!"); + } + + @Override + public void serveResource(ResourceRequest portletReq, ResourceResponse portletResp) + throws PortletException, IOException { + LOGGER.entering(LOG_CLASS, "main portlet serveResource entry"); + + long tid = Thread.currentThread().getId(); + portletReq.setAttribute(THREADID_ATTR, tid); + + PrintWriter writer = portletResp.getWriter(); + + } + + @Override + public void render(RenderRequest portletReq, RenderResponse portletResp) + throws PortletException, IOException { + LOGGER.entering(LOG_CLASS, "main portlet render entry"); + + long tid = Thread.currentThread().getId(); + portletReq.setAttribute(THREADID_ATTR, tid); + + PrintWriter writer = portletResp.getWriter(); + + /* TestCase: V2AddlRequestTests_SPEC2_11_Event_parameters1 */ + /* Details: "If a portlet receives a request from a client request */ + /* targeted to the portlet itself, the parameters must be the string */ + /* parameters encoded in the URL (added when creating the PortletURL) */ + /* and the string parameters sent by the client to the portlet as */ + /* part of the client request" */ + { + PortletURL aurl = portletResp.createActionURL(); + aurl.setParameters(portletReq.getPrivateParameterMap()); + TestButton tb = new TestButton("V2AddlRequestTests_SPEC2_11_Event_parameters1", aurl); + tb.writeTo(writer); + } + + /* TestCase: V2AddlRequestTests_SPEC2_11_Event_parameters2 */ + /* Details: "The parameters the request object returns must be */ + /* \"x-www-form-urlencoded\" decoded" */ + { + PortletURL aurl = portletResp.createActionURL(); + aurl.setParameters(portletReq.getPrivateParameterMap()); + TestButton tb = new TestButton("V2AddlRequestTests_SPEC2_11_Event_parameters2", aurl); + tb.writeTo(writer); + } + + /* TestCase: V2AddlRequestTests_SPEC2_11_Event_parameters6 */ + /* Details: "The getParameterMap method must return an unmodifiable */ + /* Map object" */ + { + PortletURL aurl = portletResp.createActionURL(); + aurl.setParameters(portletReq.getPrivateParameterMap()); + TestButton tb = new TestButton("V2AddlRequestTests_SPEC2_11_Event_parameters6", aurl); + tb.writeTo(writer); + } + + /* TestCase: V2AddlRequestTests_SPEC2_11_Event_parameters12 */ + /* Details: "If a portlet receives an event that is the result of a */ + /* client request targeted to another portlet in the portal page, the */ + /* parameters should be the same parameters as of the previous render */ + /* request from this client" */ + { + PortletURL aurl = portletResp.createActionURL(); + aurl.setParameters(portletReq.getPrivateParameterMap()); + TestButton tb = new TestButton("V2AddlRequestTests_SPEC2_11_Event_parameters12", aurl); + tb.writeTo(writer); + } + + /* TestCase: V2AddlRequestTests_SPEC2_11_Event_publicRenderParameters15 */ + /* Details: "A map of private parameters can be obtained through the */ + /* getPrivateParameterMap method" */ + { + PortletURL aurl = portletResp.createActionURL(); + aurl.setParameters(portletReq.getPrivateParameterMap()); + TestButton tb = new TestButton("V2AddlRequestTests_SPEC2_11_Event_publicRenderParameters15", aurl); + tb.writeTo(writer); + } + + /* TestCase: V2AddlRequestTests_SPEC2_11_Event_publicRenderParameters16 */ + /* Details: "A map of public parameters can be obtained through the */ + /* getPublicParameterMap method" */ + { + PortletURL aurl = portletResp.createActionURL(); + aurl.setParameters(portletReq.getPrivateParameterMap()); + TestButton tb = new TestButton("V2AddlRequestTests_SPEC2_11_Event_publicRenderParameters16", aurl); + tb.writeTo(writer); + } + + /* TestCase: V2AddlRequestTests_SPEC2_11_Event_publicRenderParameters5 */ + /* Details: "Public render parameters are available in the */ + /* processEvent method" */ + { + PortletURL aurl = portletResp.createActionURL(); + aurl.setParameters(portletReq.getPrivateParameterMap()); + TestButton tb = new TestButton("V2AddlRequestTests_SPEC2_11_Event_publicRenderParameters5", aurl); + tb.writeTo(writer); + } + + } + +} http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/23a1c547/portlet-tck_3.0/V2AddlRequestTests/src/main/java/javax/portlet/tck/portlets/AddlRequestTests_SPEC2_11_EventAttr.java ---------------------------------------------------------------------- diff --git a/portlet-tck_3.0/V2AddlRequestTests/src/main/java/javax/portlet/tck/portlets/AddlRequestTests_SPEC2_11_EventAttr.java b/portlet-tck_3.0/V2AddlRequestTests/src/main/java/javax/portlet/tck/portlets/AddlRequestTests_SPEC2_11_EventAttr.java new file mode 100644 index 0000000..9f62c6d --- /dev/null +++ b/portlet-tck_3.0/V2AddlRequestTests/src/main/java/javax/portlet/tck/portlets/AddlRequestTests_SPEC2_11_EventAttr.java @@ -0,0 +1,135 @@ +/* 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 javax.portlet.tck.portlets; + +import java.io.*; +import java.util.*; +import java.util.logging.*; +import static java.util.logging.Logger.*; +import javax.xml.namespace.QName; +import javax.portlet.*; +import javax.portlet.filter.*; +import javax.servlet.*; +import javax.servlet.http.*; +import javax.portlet.tck.beans.*; +import javax.portlet.tck.constants.*; +import static javax.portlet.tck.beans.JSR286SpecTestCaseDetails.*; +import static javax.portlet.tck.constants.Constants.*; +import static javax.portlet.PortletSession.*; +import static javax.portlet.ResourceURL.*; + +/** + * This portlet implements several test cases for the JSR 362 TCK. The test case names + * are defined in the /src/main/resources/xml-resources/additionalTCs.xml + * file. The build process will integrate the test case names defined in the + * additionalTCs.xml file into the complete list of test case names for execution by the driver. + * + * This is the main portlet for the test cases. If the test cases call for events, this portlet + * will initiate the events, but not process them. The processing is done in the companion + * portlet AddlRequestTests_SPEC2_11_EventAttr_event + * + */ +public class AddlRequestTests_SPEC2_11_EventAttr implements Portlet, ResourceServingPortlet { + private static final String LOG_CLASS = + AddlRequestTests_SPEC2_11_EventAttr.class.getName(); + private final Logger LOGGER = Logger.getLogger(LOG_CLASS); + + private PortletConfig portletConfig = null; + + @Override + public void init(PortletConfig config) throws PortletException { + this.portletConfig = config; + } + + @Override + public void destroy() { + } + + @Override + public void processAction(ActionRequest portletReq, ActionResponse portletResp) + throws PortletException, IOException { + LOGGER.entering(LOG_CLASS, "main portlet processAction entry"); + + portletResp.setRenderParameters(portletReq.getParameterMap()); + long tid = Thread.currentThread().getId(); + portletReq.setAttribute(THREADID_ATTR, tid); + + StringWriter writer = new StringWriter(); + + QName eventQName = new QName(TCKNAMESPACE, + "AddlRequestTests_SPEC2_11_EventAttr"); + portletResp.setEvent(eventQName, "Hi!"); + } + + @Override + public void serveResource(ResourceRequest portletReq, ResourceResponse portletResp) + throws PortletException, IOException { + LOGGER.entering(LOG_CLASS, "main portlet serveResource entry"); + + long tid = Thread.currentThread().getId(); + portletReq.setAttribute(THREADID_ATTR, tid); + + PrintWriter writer = portletResp.getWriter(); + + } + + @Override + public void render(RenderRequest portletReq, RenderResponse portletResp) + throws PortletException, IOException { + LOGGER.entering(LOG_CLASS, "main portlet render entry"); + + long tid = Thread.currentThread().getId(); + portletReq.setAttribute(THREADID_ATTR, tid); + + PrintWriter writer = portletResp.getWriter(); + + /* TestCase: V2AddlRequestTests_SPEC2_11_EventAttr_attributes1 */ + /* Details: "The portlet can access a map with user information */ + /* attributes via the request attribute PortletRequest.USER_INFO" */ + { + PortletURL aurl = portletResp.createActionURL(); + aurl.setParameters(portletReq.getPrivateParameterMap()); + TestButton tb = new TestButton("V2AddlRequestTests_SPEC2_11_EventAttr_attributes1", aurl); + tb.writeTo(writer); + } + + /* TestCase: V2AddlRequestTests_SPEC2_11_EventAttr_attributes2 */ + /* Details: "The PortletRequest.CCPP_PROFILE request attribute must */ + /* return a javax.ccpp.Profile based on the current portlet request" */ + { + PortletURL aurl = portletResp.createActionURL(); + aurl.setParameters(portletReq.getPrivateParameterMap()); + TestButton tb = new TestButton("V2AddlRequestTests_SPEC2_11_EventAttr_attributes2", aurl); + tb.writeTo(writer); + } + + /* TestCase: V2AddlRequestTests_SPEC2_11_EventAttr_attributes7 */ + /* Details: "During event processing, the LIFECYCLE_PHASE */ + /* (\"javax.portlet.lifecycle_phase\") attribute will contain the */ + /* string \"EVENT_PHASE\"" */ + { + PortletURL aurl = portletResp.createActionURL(); + aurl.setParameters(portletReq.getPrivateParameterMap()); + TestButton tb = new TestButton("V2AddlRequestTests_SPEC2_11_EventAttr_attributes7", aurl); + tb.writeTo(writer); + } + + } + +} http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/23a1c547/portlet-tck_3.0/V2AddlRequestTests/src/main/java/javax/portlet/tck/portlets/AddlRequestTests_SPEC2_11_EventAttr_event.java ---------------------------------------------------------------------- diff --git a/portlet-tck_3.0/V2AddlRequestTests/src/main/java/javax/portlet/tck/portlets/AddlRequestTests_SPEC2_11_EventAttr_event.java b/portlet-tck_3.0/V2AddlRequestTests/src/main/java/javax/portlet/tck/portlets/AddlRequestTests_SPEC2_11_EventAttr_event.java new file mode 100644 index 0000000..8e2b57b --- /dev/null +++ b/portlet-tck_3.0/V2AddlRequestTests/src/main/java/javax/portlet/tck/portlets/AddlRequestTests_SPEC2_11_EventAttr_event.java @@ -0,0 +1,134 @@ +/* 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 javax.portlet.tck.portlets; + +import java.io.*; +import java.util.*; +import java.util.logging.*; +import static java.util.logging.Logger.*; +import javax.xml.namespace.QName; +import javax.portlet.*; +import javax.portlet.filter.*; +import javax.servlet.*; +import javax.servlet.http.*; +import javax.portlet.tck.beans.*; +import javax.portlet.tck.constants.*; +import static javax.portlet.tck.constants.Constants.*; +import static javax.portlet.tck.beans.JSR286SpecTestCaseDetails.*; +import static javax.portlet.PortletSession.*; + +/** + * This is the event processing portlet for the test cases. This portlet processes events, + * but does not publish them. Events are published in the main portlet for the test cases. + */ +public class AddlRequestTests_SPEC2_11_EventAttr_event implements Portlet, EventPortlet, ResourceServingPortlet { + private static final String LOG_CLASS = + AddlRequestTests_SPEC2_11_EventAttr_event.class.getName(); + private final Logger LOGGER = Logger.getLogger(LOG_CLASS); + + private PortletConfig portletConfig = null; + + @Override + public void init(PortletConfig config) throws PortletException { + this.portletConfig = config; + } + + @Override + public void destroy() { + } + + @Override + public void processAction(ActionRequest portletReq, ActionResponse portletResp) + throws PortletException, IOException { + LOGGER.entering(LOG_CLASS, "event companion processAction - ERROR!!"); + } + + @Override + public void serveResource(ResourceRequest portletReq, ResourceResponse portletResp) + throws PortletException, IOException { + LOGGER.entering(LOG_CLASS, "event companion serveResource - ERROR!!"); + } + + @Override + public void processEvent(EventRequest portletReq, EventResponse portletResp) + throws PortletException, IOException { + LOGGER.entering(LOG_CLASS, "event companion processEvent"); + + + portletResp.setRenderParameters(portletReq); + + long tid = Thread.currentThread().getId(); + portletReq.setAttribute(THREADID_ATTR, tid); + + StringWriter writer = new StringWriter(); + + JSR286SpecTestCaseDetails tcd = new JSR286SpecTestCaseDetails(); + + // Create result objects for the tests + + /* TestCase: V2AddlRequestTests_SPEC2_11_EventAttr_attributes1 */ + /* Details: "The portlet can access a map with user information */ + /* attributes via the request attribute PortletRequest.USER_INFO" */ + TestResult tr0 = tcd.getTestResultFailed(V2ADDLREQUESTTESTS_SPEC2_11_EVENTATTR_ATTRIBUTES1); + /* TODO: implement test */ + tr0.appendTcDetail("Not implemented."); + tr0.writeTo(writer); + + /* TestCase: V2AddlRequestTests_SPEC2_11_EventAttr_attributes2 */ + /* Details: "The PortletRequest.CCPP_PROFILE request attribute must */ + /* return a javax.ccpp.Profile based on the current portlet request" */ + TestResult tr1 = tcd.getTestResultFailed(V2ADDLREQUESTTESTS_SPEC2_11_EVENTATTR_ATTRIBUTES2); + /* TODO: implement test */ + tr1.appendTcDetail("Not implemented."); + tr1.writeTo(writer); + + /* TestCase: V2AddlRequestTests_SPEC2_11_EventAttr_attributes7 */ + /* Details: "During event processing, the LIFECYCLE_PHASE */ + /* (\"javax.portlet.lifecycle_phase\") attribute will contain the */ + /* string \"EVENT_PHASE\"" */ + TestResult tr2 = tcd.getTestResultFailed(V2ADDLREQUESTTESTS_SPEC2_11_EVENTATTR_ATTRIBUTES7); + /* TODO: implement test */ + tr2.appendTcDetail("Not implemented."); + tr2.writeTo(writer); + + portletReq.getPortletSession().setAttribute( + Constants.RESULT_ATTR_PREFIX + "AddlRequestTests_SPEC2_11_EventAttr", + writer.toString(), APPLICATION_SCOPE); + + } + + @Override + public void render(RenderRequest portletReq, RenderResponse portletResp) + throws PortletException, IOException { + + LOGGER.entering(LOG_CLASS, "event companion render"); + + portletResp.setContentType("text/html"); + PrintWriter writer = portletResp.getWriter(); + writer.write("

Event Companion Portlet

\n"); + writer.write("

AddlRequestTests_SPEC2_11_EventAttr_event

\n"); + + String msg = (String) portletReq.getPortletSession() + .getAttribute(RESULT_ATTR_PREFIX + "AddlRequestTests_SPEC2_11_EventAttr", APPLICATION_SCOPE); + msg = (msg==null) ? "Not ready. click test case link." : msg; + writer.write("

" + msg + "

\n"); + + } + +} http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/23a1c547/portlet-tck_3.0/V2AddlRequestTests/src/main/java/javax/portlet/tck/portlets/AddlRequestTests_SPEC2_11_EventReq.java ---------------------------------------------------------------------- diff --git a/portlet-tck_3.0/V2AddlRequestTests/src/main/java/javax/portlet/tck/portlets/AddlRequestTests_SPEC2_11_EventReq.java b/portlet-tck_3.0/V2AddlRequestTests/src/main/java/javax/portlet/tck/portlets/AddlRequestTests_SPEC2_11_EventReq.java new file mode 100644 index 0000000..43770d8 --- /dev/null +++ b/portlet-tck_3.0/V2AddlRequestTests/src/main/java/javax/portlet/tck/portlets/AddlRequestTests_SPEC2_11_EventReq.java @@ -0,0 +1,190 @@ +/* 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 javax.portlet.tck.portlets; + +import java.io.*; +import java.util.*; +import java.util.logging.*; +import static java.util.logging.Logger.*; +import javax.xml.namespace.QName; +import javax.portlet.*; +import javax.portlet.filter.*; +import javax.servlet.*; +import javax.servlet.http.*; +import javax.portlet.tck.beans.*; +import javax.portlet.tck.constants.*; +import static javax.portlet.tck.beans.JSR286SpecTestCaseDetails.*; +import static javax.portlet.tck.constants.Constants.*; +import static javax.portlet.PortletSession.*; +import static javax.portlet.ResourceURL.*; + +/** + * This portlet implements several test cases for the JSR 362 TCK. The test case names + * are defined in the /src/main/resources/xml-resources/additionalTCs.xml + * file. The build process will integrate the test case names defined in the + * additionalTCs.xml file into the complete list of test case names for execution by the driver. + * + * This is the main portlet for the test cases. If the test cases call for events, this portlet + * will initiate the events, but not process them. The processing is done in the companion + * portlet AddlRequestTests_SPEC2_11_EventReq_event + * + */ +public class AddlRequestTests_SPEC2_11_EventReq implements Portlet, ResourceServingPortlet { + private static final String LOG_CLASS = + AddlRequestTests_SPEC2_11_EventReq.class.getName(); + private final Logger LOGGER = Logger.getLogger(LOG_CLASS); + + private PortletConfig portletConfig = null; + + @Override + public void init(PortletConfig config) throws PortletException { + this.portletConfig = config; + } + + @Override + public void destroy() { + } + + @Override + public void processAction(ActionRequest portletReq, ActionResponse portletResp) + throws PortletException, IOException { + LOGGER.entering(LOG_CLASS, "main portlet processAction entry"); + + portletResp.setRenderParameters(portletReq.getParameterMap()); + long tid = Thread.currentThread().getId(); + portletReq.setAttribute(THREADID_ATTR, tid); + + StringWriter writer = new StringWriter(); + + QName eventQName = new QName(TCKNAMESPACE, + "AddlRequestTests_SPEC2_11_EventReq"); + portletResp.setEvent(eventQName, "Hi!"); + } + + @Override + public void serveResource(ResourceRequest portletReq, ResourceResponse portletResp) + throws PortletException, IOException { + LOGGER.entering(LOG_CLASS, "main portlet serveResource entry"); + + long tid = Thread.currentThread().getId(); + portletReq.setAttribute(THREADID_ATTR, tid); + + PrintWriter writer = portletResp.getWriter(); + + } + + @Override + public void render(RenderRequest portletReq, RenderResponse portletResp) + throws PortletException, IOException { + LOGGER.entering(LOG_CLASS, "main portlet render entry"); + + long tid = Thread.currentThread().getId(); + portletReq.setAttribute(THREADID_ATTR, tid); + + PrintWriter writer = portletResp.getWriter(); + + /* TestCase: V2AddlRequestTests_SPEC2_11_EventReq_contentType1 */ + /* Details: "The getResponseContentType method returns a String */ + /* representing the default content type the portlet container */ + /* assumes for the output" */ + { + PortletURL aurl = portletResp.createActionURL(); + aurl.setParameters(portletReq.getPrivateParameterMap()); + TestButton tb = new TestButton("V2AddlRequestTests_SPEC2_11_EventReq_contentType1", aurl); + tb.writeTo(writer); + } + + /* TestCase: V2AddlRequestTests_SPEC2_11_EventReq_contentType2 */ + /* Details: "The getResponseContentTypes method returns an */ + /* Enumeration of String elements representing the acceptable content */ + /* types for the output in order of preference" */ + { + PortletURL aurl = portletResp.createActionURL(); + aurl.setParameters(portletReq.getPrivateParameterMap()); + TestButton tb = new TestButton("V2AddlRequestTests_SPEC2_11_EventReq_contentType2", aurl); + tb.writeTo(writer); + } + + /* TestCase: V2AddlRequestTests_SPEC2_11_EventReq_contentType3 */ + /* Details: "The first element of the Enumeration returned by the */ + /* getResponseContentTypes method must equal the value returned by */ + /* the getResponseContentType method" */ + { + PortletURL aurl = portletResp.createActionURL(); + aurl.setParameters(portletReq.getPrivateParameterMap()); + TestButton tb = new TestButton("V2AddlRequestTests_SPEC2_11_EventReq_contentType3", aurl); + tb.writeTo(writer); + } + + /* TestCase: V2AddlRequestTests_SPEC2_11_EventReq_contentType4 */ + /* Details: "If a portlet defines support for all content types using */ + /* a wildcard and the portlet container supports all content types, */ + /* the getResponseContentType may return the wildcard" */ + { + PortletURL aurl = portletResp.createActionURL(); + aurl.setParameters(portletReq.getPrivateParameterMap()); + TestButton tb = new TestButton("V2AddlRequestTests_SPEC2_11_EventReq_contentType4", aurl); + tb.writeTo(writer); + } + + /* TestCase: V2AddlRequestTests_SPEC2_11_EventReq_contentType5 */ + /* Details: "If a portlet defines support for all content types using */ + /* a wildcard and the portlet container supports all content types, */ + /* the getResponseContentType may return the preferred content type" */ + { + PortletURL aurl = portletResp.createActionURL(); + aurl.setParameters(portletReq.getPrivateParameterMap()); + TestButton tb = new TestButton("V2AddlRequestTests_SPEC2_11_EventReq_contentType5", aurl); + tb.writeTo(writer); + } + + /* TestCase: V2AddlRequestTests_SPEC2_11_EventReq_windowId4 */ + /* Details: "The string returned by getWindowID method must be the */ + /* same ID used for scoping portlet-scope session attributes" */ + { + PortletURL aurl = portletResp.createActionURL(); + aurl.setParameters(portletReq.getPrivateParameterMap()); + TestButton tb = new TestButton("V2AddlRequestTests_SPEC2_11_EventReq_windowId4", aurl); + tb.writeTo(writer); + } + + /* TestCase: V2AddlRequestTests_SPEC2_11_EventReq_contentType8 */ + /* Details: "Within the processEvent method, the content type must */ + /* include only the MIME type, not the character set" */ + { + PortletURL aurl = portletResp.createActionURL(); + aurl.setParameters(portletReq.getPrivateParameterMap()); + TestButton tb = new TestButton("V2AddlRequestTests_SPEC2_11_EventReq_contentType8", aurl); + tb.writeTo(writer); + } + + /* TestCase: V2AddlRequestTests_SPEC2_11_EventReq_contentType9 */ + /* Details: "Within the processEvent method, the */ + /* getResponseContentTypes method must return only the content types */ + /* supported by the current portlet mode" */ + { + PortletURL aurl = portletResp.createActionURL(); + aurl.setParameters(portletReq.getPrivateParameterMap()); + TestButton tb = new TestButton("V2AddlRequestTests_SPEC2_11_EventReq_contentType9", aurl); + tb.writeTo(writer); + } + + } + +} http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/23a1c547/portlet-tck_3.0/V2AddlRequestTests/src/main/java/javax/portlet/tck/portlets/AddlRequestTests_SPEC2_11_EventReq_event.java ---------------------------------------------------------------------- diff --git a/portlet-tck_3.0/V2AddlRequestTests/src/main/java/javax/portlet/tck/portlets/AddlRequestTests_SPEC2_11_EventReq_event.java b/portlet-tck_3.0/V2AddlRequestTests/src/main/java/javax/portlet/tck/portlets/AddlRequestTests_SPEC2_11_EventReq_event.java new file mode 100644 index 0000000..5799f86 --- /dev/null +++ b/portlet-tck_3.0/V2AddlRequestTests/src/main/java/javax/portlet/tck/portlets/AddlRequestTests_SPEC2_11_EventReq_event.java @@ -0,0 +1,179 @@ +/* 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 javax.portlet.tck.portlets; + +import java.io.*; +import java.util.*; +import java.util.logging.*; +import static java.util.logging.Logger.*; +import javax.xml.namespace.QName; +import javax.portlet.*; +import javax.portlet.filter.*; +import javax.servlet.*; +import javax.servlet.http.*; +import javax.portlet.tck.beans.*; +import javax.portlet.tck.constants.*; +import static javax.portlet.tck.constants.Constants.*; +import static javax.portlet.tck.beans.JSR286SpecTestCaseDetails.*; +import static javax.portlet.PortletSession.*; + +/** + * This is the event processing portlet for the test cases. This portlet processes events, + * but does not publish them. Events are published in the main portlet for the test cases. + */ +public class AddlRequestTests_SPEC2_11_EventReq_event implements Portlet, EventPortlet, ResourceServingPortlet { + private static final String LOG_CLASS = + AddlRequestTests_SPEC2_11_EventReq_event.class.getName(); + private final Logger LOGGER = Logger.getLogger(LOG_CLASS); + + private PortletConfig portletConfig = null; + + @Override + public void init(PortletConfig config) throws PortletException { + this.portletConfig = config; + } + + @Override + public void destroy() { + } + + @Override + public void processAction(ActionRequest portletReq, ActionResponse portletResp) + throws PortletException, IOException { + LOGGER.entering(LOG_CLASS, "event companion processAction - ERROR!!"); + } + + @Override + public void serveResource(ResourceRequest portletReq, ResourceResponse portletResp) + throws PortletException, IOException { + LOGGER.entering(LOG_CLASS, "event companion serveResource - ERROR!!"); + } + + @Override + public void processEvent(EventRequest portletReq, EventResponse portletResp) + throws PortletException, IOException { + LOGGER.entering(LOG_CLASS, "event companion processEvent"); + + + portletResp.setRenderParameters(portletReq); + + long tid = Thread.currentThread().getId(); + portletReq.setAttribute(THREADID_ATTR, tid); + + StringWriter writer = new StringWriter(); + + JSR286SpecTestCaseDetails tcd = new JSR286SpecTestCaseDetails(); + + // Create result objects for the tests + + /* TestCase: V2AddlRequestTests_SPEC2_11_EventReq_contentType1 */ + /* Details: "The getResponseContentType method returns a String */ + /* representing the default content type the portlet container */ + /* assumes for the output" */ + TestResult tr0 = tcd.getTestResultFailed(V2ADDLREQUESTTESTS_SPEC2_11_EVENTREQ_CONTENTTYPE1); + /* TODO: implement test */ + tr0.appendTcDetail("Not implemented."); + tr0.writeTo(writer); + + /* TestCase: V2AddlRequestTests_SPEC2_11_EventReq_contentType2 */ + /* Details: "The getResponseContentTypes method returns an */ + /* Enumeration of String elements representing the acceptable content */ + /* types for the output in order of preference" */ + TestResult tr1 = tcd.getTestResultFailed(V2ADDLREQUESTTESTS_SPEC2_11_EVENTREQ_CONTENTTYPE2); + /* TODO: implement test */ + tr1.appendTcDetail("Not implemented."); + tr1.writeTo(writer); + + /* TestCase: V2AddlRequestTests_SPEC2_11_EventReq_contentType3 */ + /* Details: "The first element of the Enumeration returned by the */ + /* getResponseContentTypes method must equal the value returned by */ + /* the getResponseContentType method" */ + TestResult tr2 = tcd.getTestResultFailed(V2ADDLREQUESTTESTS_SPEC2_11_EVENTREQ_CONTENTTYPE3); + /* TODO: implement test */ + tr2.appendTcDetail("Not implemented."); + tr2.writeTo(writer); + + /* TestCase: V2AddlRequestTests_SPEC2_11_EventReq_contentType4 */ + /* Details: "If a portlet defines support for all content types using */ + /* a wildcard and the portlet container supports all content types, */ + /* the getResponseContentType may return the wildcard" */ + TestResult tr3 = tcd.getTestResultFailed(V2ADDLREQUESTTESTS_SPEC2_11_EVENTREQ_CONTENTTYPE4); + /* TODO: implement test */ + tr3.appendTcDetail("Not implemented."); + tr3.writeTo(writer); + + /* TestCase: V2AddlRequestTests_SPEC2_11_EventReq_contentType5 */ + /* Details: "If a portlet defines support for all content types using */ + /* a wildcard and the portlet container supports all content types, */ + /* the getResponseContentType may return the preferred content type" */ + TestResult tr4 = tcd.getTestResultFailed(V2ADDLREQUESTTESTS_SPEC2_11_EVENTREQ_CONTENTTYPE5); + /* TODO: implement test */ + tr4.appendTcDetail("Not implemented."); + tr4.writeTo(writer); + + /* TestCase: V2AddlRequestTests_SPEC2_11_EventReq_windowId4 */ + /* Details: "The string returned by getWindowID method must be the */ + /* same ID used for scoping portlet-scope session attributes" */ + TestResult tr5 = tcd.getTestResultFailed(V2ADDLREQUESTTESTS_SPEC2_11_EVENTREQ_WINDOWID4); + /* TODO: implement test */ + tr5.appendTcDetail("Not implemented."); + tr5.writeTo(writer); + + /* TestCase: V2AddlRequestTests_SPEC2_11_EventReq_contentType8 */ + /* Details: "Within the processEvent method, the content type must */ + /* include only the MIME type, not the character set" */ + TestResult tr6 = tcd.getTestResultFailed(V2ADDLREQUESTTESTS_SPEC2_11_EVENTREQ_CONTENTTYPE8); + /* TODO: implement test */ + tr6.appendTcDetail("Not implemented."); + tr6.writeTo(writer); + + /* TestCase: V2AddlRequestTests_SPEC2_11_EventReq_contentType9 */ + /* Details: "Within the processEvent method, the */ + /* getResponseContentTypes method must return only the content types */ + /* supported by the current portlet mode" */ + TestResult tr7 = tcd.getTestResultFailed(V2ADDLREQUESTTESTS_SPEC2_11_EVENTREQ_CONTENTTYPE9); + /* TODO: implement test */ + tr7.appendTcDetail("Not implemented."); + tr7.writeTo(writer); + + portletReq.getPortletSession().setAttribute( + Constants.RESULT_ATTR_PREFIX + "AddlRequestTests_SPEC2_11_EventReq", + writer.toString(), APPLICATION_SCOPE); + + } + + @Override + public void render(RenderRequest portletReq, RenderResponse portletResp) + throws PortletException, IOException { + + LOGGER.entering(LOG_CLASS, "event companion render"); + + portletResp.setContentType("text/html"); + PrintWriter writer = portletResp.getWriter(); + writer.write("

Event Companion Portlet

\n"); + writer.write("

AddlRequestTests_SPEC2_11_EventReq_event

\n"); + + String msg = (String) portletReq.getPortletSession() + .getAttribute(RESULT_ATTR_PREFIX + "AddlRequestTests_SPEC2_11_EventReq", APPLICATION_SCOPE); + msg = (msg==null) ? "Not ready. click test case link." : msg; + writer.write("

" + msg + "

\n"); + + } + +} http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/23a1c547/portlet-tck_3.0/V2AddlRequestTests/src/main/java/javax/portlet/tck/portlets/AddlRequestTests_SPEC2_11_Event_event.java ---------------------------------------------------------------------- diff --git a/portlet-tck_3.0/V2AddlRequestTests/src/main/java/javax/portlet/tck/portlets/AddlRequestTests_SPEC2_11_Event_event.java b/portlet-tck_3.0/V2AddlRequestTests/src/main/java/javax/portlet/tck/portlets/AddlRequestTests_SPEC2_11_Event_event.java new file mode 100644 index 0000000..11b165a --- /dev/null +++ b/portlet-tck_3.0/V2AddlRequestTests/src/main/java/javax/portlet/tck/portlets/AddlRequestTests_SPEC2_11_Event_event.java @@ -0,0 +1,170 @@ +/* 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 javax.portlet.tck.portlets; + +import java.io.*; +import java.util.*; +import java.util.logging.*; +import static java.util.logging.Logger.*; +import javax.xml.namespace.QName; +import javax.portlet.*; +import javax.portlet.filter.*; +import javax.servlet.*; +import javax.servlet.http.*; +import javax.portlet.tck.beans.*; +import javax.portlet.tck.constants.*; +import static javax.portlet.tck.constants.Constants.*; +import static javax.portlet.tck.beans.JSR286SpecTestCaseDetails.*; +import static javax.portlet.PortletSession.*; + +/** + * This is the event processing portlet for the test cases. This portlet processes events, + * but does not publish them. Events are published in the main portlet for the test cases. + */ +public class AddlRequestTests_SPEC2_11_Event_event implements Portlet, EventPortlet, ResourceServingPortlet { + private static final String LOG_CLASS = + AddlRequestTests_SPEC2_11_Event_event.class.getName(); + private final Logger LOGGER = Logger.getLogger(LOG_CLASS); + + private PortletConfig portletConfig = null; + + @Override + public void init(PortletConfig config) throws PortletException { + this.portletConfig = config; + } + + @Override + public void destroy() { + } + + @Override + public void processAction(ActionRequest portletReq, ActionResponse portletResp) + throws PortletException, IOException { + LOGGER.entering(LOG_CLASS, "event companion processAction - ERROR!!"); + } + + @Override + public void serveResource(ResourceRequest portletReq, ResourceResponse portletResp) + throws PortletException, IOException { + LOGGER.entering(LOG_CLASS, "event companion serveResource - ERROR!!"); + } + + @Override + public void processEvent(EventRequest portletReq, EventResponse portletResp) + throws PortletException, IOException { + LOGGER.entering(LOG_CLASS, "event companion processEvent"); + + + portletResp.setRenderParameters(portletReq); + + long tid = Thread.currentThread().getId(); + portletReq.setAttribute(THREADID_ATTR, tid); + + StringWriter writer = new StringWriter(); + + JSR286SpecTestCaseDetails tcd = new JSR286SpecTestCaseDetails(); + + // Create result objects for the tests + + /* TestCase: V2AddlRequestTests_SPEC2_11_Event_parameters1 */ + /* Details: "If a portlet receives a request from a client request */ + /* targeted to the portlet itself, the parameters must be the string */ + /* parameters encoded in the URL (added when creating the PortletURL) */ + /* and the string parameters sent by the client to the portlet as */ + /* part of the client request" */ + TestResult tr0 = tcd.getTestResultFailed(V2ADDLREQUESTTESTS_SPEC2_11_EVENT_PARAMETERS1); + /* TODO: implement test */ + tr0.appendTcDetail("Not implemented."); + tr0.writeTo(writer); + + /* TestCase: V2AddlRequestTests_SPEC2_11_Event_parameters2 */ + /* Details: "The parameters the request object returns must be */ + /* \"x-www-form-urlencoded\" decoded" */ + TestResult tr1 = tcd.getTestResultFailed(V2ADDLREQUESTTESTS_SPEC2_11_EVENT_PARAMETERS2); + /* TODO: implement test */ + tr1.appendTcDetail("Not implemented."); + tr1.writeTo(writer); + + /* TestCase: V2AddlRequestTests_SPEC2_11_Event_parameters6 */ + /* Details: "The getParameterMap method must return an unmodifiable */ + /* Map object" */ + TestResult tr2 = tcd.getTestResultFailed(V2ADDLREQUESTTESTS_SPEC2_11_EVENT_PARAMETERS6); + /* TODO: implement test */ + tr2.appendTcDetail("Not implemented."); + tr2.writeTo(writer); + + /* TestCase: V2AddlRequestTests_SPEC2_11_Event_parameters12 */ + /* Details: "If a portlet receives an event that is the result of a */ + /* client request targeted to another portlet in the portal page, the */ + /* parameters should be the same parameters as of the previous render */ + /* request from this client" */ + TestResult tr3 = tcd.getTestResultFailed(V2ADDLREQUESTTESTS_SPEC2_11_EVENT_PARAMETERS12); + /* TODO: implement test */ + tr3.appendTcDetail("Not implemented."); + tr3.writeTo(writer); + + /* TestCase: V2AddlRequestTests_SPEC2_11_Event_publicRenderParameters15 */ + /* Details: "A map of private parameters can be obtained through the */ + /* getPrivateParameterMap method" */ + TestResult tr4 = tcd.getTestResultFailed(V2ADDLREQUESTTESTS_SPEC2_11_EVENT_PUBLICRENDERPARAMETERS15); + /* TODO: implement test */ + tr4.appendTcDetail("Not implemented."); + tr4.writeTo(writer); + + /* TestCase: V2AddlRequestTests_SPEC2_11_Event_publicRenderParameters16 */ + /* Details: "A map of public parameters can be obtained through the */ + /* getPublicParameterMap method" */ + TestResult tr5 = tcd.getTestResultFailed(V2ADDLREQUESTTESTS_SPEC2_11_EVENT_PUBLICRENDERPARAMETERS16); + /* TODO: implement test */ + tr5.appendTcDetail("Not implemented."); + tr5.writeTo(writer); + + /* TestCase: V2AddlRequestTests_SPEC2_11_Event_publicRenderParameters5 */ + /* Details: "Public render parameters are available in the */ + /* processEvent method" */ + TestResult tr6 = tcd.getTestResultFailed(V2ADDLREQUESTTESTS_SPEC2_11_EVENT_PUBLICRENDERPARAMETERS5); + /* TODO: implement test */ + tr6.appendTcDetail("Not implemented."); + tr6.writeTo(writer); + + portletReq.getPortletSession().setAttribute( + Constants.RESULT_ATTR_PREFIX + "AddlRequestTests_SPEC2_11_Event", + writer.toString(), APPLICATION_SCOPE); + + } + + @Override + public void render(RenderRequest portletReq, RenderResponse portletResp) + throws PortletException, IOException { + + LOGGER.entering(LOG_CLASS, "event companion render"); + + portletResp.setContentType("text/html"); + PrintWriter writer = portletResp.getWriter(); + writer.write("

Event Companion Portlet

\n"); + writer.write("

AddlRequestTests_SPEC2_11_Event_event

\n"); + + String msg = (String) portletReq.getPortletSession() + .getAttribute(RESULT_ATTR_PREFIX + "AddlRequestTests_SPEC2_11_Event", APPLICATION_SCOPE); + msg = (msg==null) ? "Not ready. click test case link." : msg; + writer.write("

" + msg + "

\n"); + + } + +}