Java Code Examples for javax.portlet.RenderResponse#getWriter()
The following examples show how to use
javax.portlet.RenderResponse#getWriter() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DispatcherTests3S_SPEC2_19_ForwardServletEvent.java From portals-pluto with Apache License 2.0 | 6 votes |
@Override public void render(RenderRequest portletReq, RenderResponse portletResp) throws PortletException, IOException { long tid = Thread.currentThread().getId(); portletReq.setAttribute(THREADID_ATTR, tid); PrintWriter writer = portletResp.getWriter(); /* TestCase: V2DispatcherTests3S_SPEC2_19_ForwardServletEvent_dispatch4 */ /* Details: "The parameters associated with a request dispatcher are */ /* scoped only for the duration of the include or forward call" */ { PortletURL aurl = portletResp.createActionURL(); aurl.setParameters(portletReq.getPrivateParameterMap()); TestButton tb = new TestButton(V2DISPATCHERTESTS3S_SPEC2_19_FORWARDSERVLETEVENT_DISPATCH4, aurl); tb.writeTo(writer); } }
Example 2
Source File: DispatcherTests5_SPEC2_19_IncThenForwardServletResource.java From portals-pluto with Apache License 2.0 | 6 votes |
@Override public void render(RenderRequest portletReq, RenderResponse portletResp) throws PortletException, IOException { long tid = Thread.currentThread().getId(); portletReq.setAttribute(THREADID_ATTR, tid); PrintWriter writer = portletResp.getWriter(); writer.write("<div id=\"DispatcherTests5_SPEC2_19_IncThenForwardServletResource\">no resource output.</div>\n"); ResourceURL resurl = portletResp.createResourceURL(); resurl.setCacheability(PAGE); writer.write("<script>\n"); writer.write("(function () {\n"); writer.write(" var xhr = new XMLHttpRequest();\n"); writer.write(" xhr.onreadystatechange=function() {\n"); writer.write(" if (xhr.readyState==4 && xhr.status==200) {\n"); writer.write(" document.getElementById(\"DispatcherTests5_SPEC2_19_IncThenForwardServletResource\").innerHTML=xhr.responseText;\n"); writer.write(" }\n"); writer.write(" };\n"); writer.write(" xhr.open(\"GET\",\"" + resurl.toString() + "\",true);\n"); writer.write(" xhr.send();\n"); writer.write("})();\n"); writer.write("</script>\n"); }
Example 3
Source File: DispatcherTests2_SPEC2_19_IncludeJSPEvent_event.java From portals-pluto with Apache License 2.0 | 6 votes |
@Override public void render(RenderRequest portletReq, RenderResponse portletResp) throws PortletException, IOException { portletResp.setContentType("text/html"); PrintWriter writer = portletResp.getWriter(); writer.write("<h3>Event Companion Portlet </h3>\n"); writer.write("<p>DispatcherTests2_SPEC2_19_IncludeJSPEvent_event</p>\n"); String msg = (String) portletReq.getPortletSession().getAttribute( RESULT_ATTR_PREFIX + "DispatcherTests2_SPEC2_19_IncludeJSPEvent", APPLICATION_SCOPE); msg = (msg == null) ? "Not ready. click test case link." : msg; writer.write("<p>" + msg + "</p>\n"); /* TestCase: V2DispatcherTests2_SPEC2_19_IncludeJSPEvent_dispatch2 */ /* Details: "Parameters specified in the query strings must be */ /* aggregated with the portlet render parameters" */ PortletURL urlEvent = ((MimeResponse) portletResp).createRenderURL(); urlEvent.setParameter("qparm2", "renderVal2"); TestSetupLink tlEvent = new TestSetupLink(V2DISPATCHERTESTS2_SPEC2_19_INCLUDEJSPEVENT_DISPATCH2, urlEvent); tlEvent.writeTo(writer); }
Example 4
Source File: PortletTests_GenericPortlet_ApiRender.java From portals-pluto with Apache License 2.0 | 6 votes |
@Override protected void doView(RenderRequest req, RenderResponse resp) throws PortletException, IOException { PrintWriter writer = resp.getWriter(); JSR286ApiTestCaseDetails tcd = new JSR286ApiTestCaseDetails(); /* TestCase: V2PortletTests_GenericPortlet_ApiRender_doView1 */ /* Details: "Method doView(RenderRequest, RenderResponse): If */ /* overridden, is called when a render request in view mode occurs" */ TestResult tr7 = tcd.getTestResultFailed( V2PORTLETTESTS_GENERICPORTLET_APIRENDER_DOVIEW1); tr7.setTcSuccess(true); tr7.writeTo(writer); }
Example 5
Source File: TestModule2_CompanionPortlet.java From portals-pluto with Apache License 2.0 | 6 votes |
@Override public void render(RenderRequest request, RenderResponse response) throws PortletException, IOException { LOGGER.trace("render: Entry"); PrintWriter writer = response.getWriter(); TestResult tr = null; // Test: TestModule2_PublicRenderParameterCanBeSetThroughUrl // The link with the public render parameter is generated // by the main portlet. String parm = request.getParameter("publicRenderParameter1"); if (parm != null) { // test was executed so generate results tr = tcd.getTestResultSucceeded(TEST4); tr.writeTo(writer); } else { // test not executed yet, or was not correctly executed TestMessage tm = new TestMessage(TEST4, "Waiting for publicRenderParameter1 to be set."); tm.writeTo(writer); } }
Example 6
Source File: AnnotationPortletAppConfigOverrideTests_SPEC1_28_EventConfiguration1.java From portals-pluto with Apache License 2.0 | 6 votes |
@Override public void render(RenderRequest portletReq, RenderResponse portletResp) throws PortletException, IOException { PrintWriter writer = portletResp.getWriter(); ModuleTestCaseDetails tcd = new ModuleTestCaseDetails(); RenderParameters renderParams = portletReq.getRenderParameters(); /* TestCase: V3AnnotationPortletAppConfigOverrideTests_SPEC1_28_EventConfiguration1_declaringEvents3 */ /* Details: "Same event declared in @PortletApplication and deployment * descriptor portlet.xml is overridden by deployment descriptor" */ if(renderParams.getValue("tr0")!=null && renderParams.getValue("tr0").equals("true")){ TestResult result = tcd.getTestResultFailed(V3ANNOTATIONPORTLETAPPCONFIGOVERRIDETESTS_SPEC1_28_EVENTCONFIGURATION1_DECLARINGEVENTS3); result.setTcSuccess(true); result.writeTo(writer); } else { ActionURL aurl = portletResp.createActionURL(); TestButton tb = new TestButton( V3ANNOTATIONPORTLETAPPCONFIGOVERRIDETESTS_SPEC1_28_EVENTCONFIGURATION1_DECLARINGEVENTS3, aurl); tb.writeTo(writer); } }
Example 7
Source File: DispatcherTests2_SPEC2_19_IncludeJSPResource.java From portals-pluto with Apache License 2.0 | 6 votes |
@Override public void render(RenderRequest portletReq, RenderResponse portletResp) throws PortletException, IOException { long tid = Thread.currentThread().getId(); portletReq.setAttribute(THREADID_ATTR, tid); PrintWriter writer = portletResp.getWriter(); writer.write("<div id=\"DispatcherTests2_SPEC2_19_IncludeJSPResource\">no resource output.</div>\n"); ResourceURL resurl = portletResp.createResourceURL(); resurl.setCacheability(PAGE); writer.write("<script>\n"); writer.write("(function () {\n"); writer.write(" var xhr = new XMLHttpRequest();\n"); writer.write(" xhr.onreadystatechange=function() {\n"); writer.write(" if (xhr.readyState==4 && xhr.status==200) {\n"); writer.write(" document.getElementById(\"DispatcherTests2_SPEC2_19_IncludeJSPResource\").innerHTML=xhr.responseText;\n"); writer.write(" }\n"); writer.write(" };\n"); writer.write(" xhr.open(\"GET\",\"" + resurl.toString() + "\",true);\n"); writer.write(" xhr.send();\n"); writer.write("})();\n"); writer.write("</script>\n"); }
Example 8
Source File: AnnotationPortletAppConfigOverrideTests_SPEC1_28_DefaultNamespaceURI.java From portals-pluto with Apache License 2.0 | 6 votes |
@Override public void render(RenderRequest portletReq, RenderResponse portletResp) throws PortletException, IOException { PrintWriter writer = portletResp.getWriter(); ModuleTestCaseDetails tcd = new ModuleTestCaseDetails(); /* TestCase: V3AnnotationPortletAppConfigOverrideTests_SPEC1_28_DefaultNamespaceURI_declaringDefaultNamespaceURI2 */ /* Details: "DefaultNamespaceURI defined in the @PortletApplication */ /* annotation could be overridden by deployment descriptor portlet.xml" */ { TestResult result = tcd.getTestResultFailed(V3ANNOTATIONPORTLETAPPCONFIGOVERRIDETESTS_SPEC1_28_DEFAULTNAMESPACEURI_DECLARINGDEFAULTNAMESPACEURI2); if(portletConfig.getDefaultNamespace().equals("http://www.apache.org/portals/pluto/portlet-tck_3.0/overridden")){ result.setTcSuccess(true); } else { result.appendTcDetail("Failed because default namespace URI is not http://www.apache.org/portals/pluto/portlet-tck_3.0/overridden but "+portletConfig.getDefaultNamespace()); } result.writeTo(writer); } }
Example 9
Source File: DispatcherTests5_SPEC2_19_IncThenIncludeServletRender.java From portals-pluto with Apache License 2.0 | 6 votes |
@Override public void render(RenderRequest portletReq, RenderResponse portletResp) throws PortletException, IOException { long tid = Thread.currentThread().getId(); portletReq.setAttribute(THREADID_ATTR, tid); portletResp.getWriter(); // Multilevel forward / include portletReq.setAttribute(ATTR_DISPATCH_ACTION, "include"); String targ = SERVLET_PREFIX + "DispatcherTests5_SPEC2_19_IncThenIncludeServletRender_servlet" + EXTRA_PATH + "?" + QUERY_STRING; portletReq.setAttribute(ATTR_DISPATCH_TARGET, targ); // Now do the actual dispatch String target = SERVLET_INCFWD + "?" + QUERY_STRING; PortletRequestDispatcher rd = portletConfig.getPortletContext().getRequestDispatcher(target); rd.include(portletReq, portletResp); }
Example 10
Source File: AnnotationPortletApplicationConfigTests_SPEC1_28_PortletContainerRuntimeOptionsBase.java From portals-pluto with Apache License 2.0 | 6 votes |
public void render(RenderRequest portletReq, RenderResponse portletResp) throws PortletException, IOException { PrintWriter writer = portletResp.getWriter(); ModuleTestCaseDetails tcd = new ModuleTestCaseDetails(); /* TestCase: V3AnnotationPortletApplicationConfigTests_SPEC1_28_PortletContainerRuntimeOptions_declaringPCRO1 */ /* Details: "Portlet container runtime options may be declared in the */ /* @PortletApplication annotation using @RuntimeOption annotation." */ { TestResult result = tcd.getTestResultFailed(V3ANNOTATIONPORTLETAPPLICATIONCONFIGTESTS_SPEC1_28_PORTLETCONTAINERRUNTIMEOPTIONS_DECLARINGPCRO1); Map<String, String[]> runtimeOptions = portletConfig.getContainerRuntimeOptions(); if (isRuntimeOptionsCorrect(runtimeOptions)) { result.setTcSuccess(true); } result.writeTo(writer); } }
Example 11
Source File: AnnotationPortletApplicationConfigTests_SPEC1_28_PublicRenderParameters.java From portals-pluto with Apache License 2.0 | 6 votes |
@Override public void render(RenderRequest portletReq, RenderResponse portletResp) throws PortletException, IOException { PrintWriter writer = portletResp.getWriter(); ModuleTestCaseDetails tcd = new ModuleTestCaseDetails(); /* TestCase: V3AnnotationPortletApplicationConfigTests_SPEC1_28_PublicRenderParameters_declaringPRP1 */ /* Details: "A public render parameters may be declared in the */ /* @PortletApplication annotation using @PublicRenderParameterDefinition */ /* annotation." */ { TestResult result = tcd.getTestResultFailed(V3ANNOTATIONPORTLETAPPLICATIONCONFIGTESTS_SPEC1_28_PUBLICRENDERPARAMETERS_DECLARINGPRP1); if(portletReq.getRenderParameters().isPublic("tr0_public")){ result.setTcSuccess(true); } else { result.appendTcDetail("Failed because tr0_public public render parameter is not found."); } result.writeTo(writer); } }
Example 12
Source File: DispatcherTests6_SPEC2_19_FwdThenForwardServletResource.java From portals-pluto with Apache License 2.0 | 6 votes |
@Override public void render(RenderRequest portletReq, RenderResponse portletResp) throws PortletException, IOException { long tid = Thread.currentThread().getId(); portletReq.setAttribute(THREADID_ATTR, tid); PrintWriter writer = portletResp.getWriter(); writer.write("<div id=\"DispatcherTests6_SPEC2_19_FwdThenForwardServletResource\">no resource output.</div>\n"); ResourceURL resurl = portletResp.createResourceURL(); resurl.setCacheability(PAGE); writer.write("<script>\n"); writer.write("(function () {\n"); writer.write(" var xhr = new XMLHttpRequest();\n"); writer.write(" xhr.onreadystatechange=function() {\n"); writer.write(" if (xhr.readyState==4 && xhr.status==200) {\n"); writer.write(" document.getElementById(\"DispatcherTests6_SPEC2_19_FwdThenForwardServletResource\").innerHTML=xhr.responseText;\n"); writer.write(" }\n"); writer.write(" };\n"); writer.write(" xhr.open(\"GET\",\"" + resurl.toString() + "\",true);\n"); writer.write(" xhr.send();\n"); writer.write("})();\n"); writer.write("</script>\n"); }
Example 13
Source File: HeaderPortletTests_SPEC15_MimeResponse_ApiHeader1.java From portals-pluto with Apache License 2.0 | 5 votes |
@Override public void render(RenderRequest renderRequest, RenderResponse renderResponse) throws PortletException, IOException { PrintWriter writer = renderResponse.getWriter(); String msg = (String) renderRequest.getAttribute( RESULT_ATTR_PREFIX + "HeaderPortletTests_SPEC15_MimeResponse_ApiHeader1"); writer.write("<p>" + msg + "</p>\n"); renderRequest.removeAttribute( RESULT_ATTR_PREFIX + "HeaderPortletTests_SPEC15_MimeResponse_ApiHeader1"); }
Example 14
Source File: SigTestsResource_ClientDataRequest_SIGResource.java From portals-pluto with Apache License 2.0 | 5 votes |
@Override public void render(RenderRequest portletReq, RenderResponse portletResp) throws PortletException, IOException { long tid = Thread.currentThread().getId(); portletReq.setAttribute(THREADID_ATTR, tid); PrintWriter writer = portletResp.getWriter(); writer.write( "<div id=\"SigTestsResource_ClientDataRequest_SIGResource\">no resource output.</div>\n"); ResourceURL resurl = portletResp.createResourceURL(); resurl.setCacheability(PAGE); writer.write("<script>\n"); writer.write("(function () {\n"); writer.write(" var xhr = new XMLHttpRequest();\n"); writer.write(" xhr.onreadystatechange=function() {\n"); writer.write(" if (xhr.readyState==4 && xhr.status==200) {\n"); writer.write( " document.getElementById(\"SigTestsResource_ClientDataRequest_SIGResource\").innerHTML=xhr.responseText;\n"); writer.write(" }\n"); writer.write(" };\n"); writer.write(" xhr.open(\"GET\",\"" + resurl.toString() + "\",true);\n"); writer.write(" xhr.send();\n"); writer.write("})();\n"); writer.write("</script>\n"); }
Example 15
Source File: PortletTests_Portlet_ApiAction.java From portals-pluto with Apache License 2.0 | 5 votes |
@Override public void render(RenderRequest portletReq, RenderResponse portletResp) throws PortletException, IOException { 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 + "PortletTests_Portlet_ApiAction", APPLICATION_SCOPE); if (msg != null) { writer.write("<p>" + msg + "</p><br/>\n"); ps.removeAttribute(RESULT_ATTR_PREFIX + "PortletTests_Portlet_ApiAction", APPLICATION_SCOPE); } /* TestCase: V2PortletTests_Portlet_ApiAction_processAction */ /* Details: "Method processAction(ActionRequest, ActionResponse): is */ /* called when an action URL for the portlet is triggered" */ { PortletURL aurl = portletResp.createActionURL(); aurl.setParameters(portletReq.getPrivateParameterMap()); TestButton tb = new TestButton(V2PORTLETTESTS_PORTLET_APIACTION_PROCESSACTION, aurl); tb.writeTo(writer); } }
Example 16
Source File: AddlPortletTests_SPEC2_2_Compatibility.java From portals-pluto with Apache License 2.0 | 5 votes |
@Override public void render(RenderRequest portletReq, RenderResponse portletResp) throws PortletException, IOException { long tid = Thread.currentThread().getId(); portletReq.setAttribute(THREADID_ATTR, tid); PrintWriter writer = portletResp.getWriter(); JSR286SpecTestCaseDetails tcd = new JSR286SpecTestCaseDetails(); // Create result objects for the tests /* TestCase: V2AddlPortletTests_SPEC2_2_Compatibility_deployJSR168_1 */ /* Details: "A portlet with the JSR 168 deployment descriptor can be */ /* deployed" */ TestResult tr0 = tcd.getTestResultFailed(V2ADDLPORTLETTESTS_SPEC2_2_COMPATIBILITY_DEPLOYJSR168_1); // The deployment descriptor of this portlet is of JSR168 format. If the execution reaches here // then test is successful. tr0.setTcSuccess(true); tr0.writeTo(writer); /* TestCase: V2AddlPortletTests_SPEC2_2_Compatibility_deployJSR168_2 */ /* Details: "A portlet implementing only the JSR 168 API can be */ /* deployed" */ TestResult tr1 = tcd.getTestResultFailed(V2ADDLPORTLETTESTS_SPEC2_2_COMPATIBILITY_DEPLOYJSR168_2); // The code of this class is compatible with JSR 168 API. If this executes then test is // successful. tr1.setTcSuccess(true); tr1.writeTo(writer); }
Example 17
Source File: DispatcherTests3S_SPEC2_19_ForwardServletResource.java From portals-pluto with Apache License 2.0 | 5 votes |
@Override public void render(RenderRequest portletReq, RenderResponse portletResp) throws PortletException, IOException { PrintWriter writer = portletResp.getWriter(); String msg = (String) portletReq.getPortletSession().getAttribute( RESULT_ATTR_PREFIX + V2DISPATCHERTESTS3S_SPEC2_19_FORWARDSERVLETRESOURCE_DISPATCH4, APPLICATION_SCOPE); if (msg == null) { writer.write("<p>Not ready. click test case link.</p>\n"); writer.write("<div id=\"DispatcherTests3S_SPEC2_19_ForwardServletResource\">no resource output.</div>\n"); ResourceURL resurl = portletResp.createResourceURL(); resurl.setCacheability(PAGE); writer.write("<script>\n"); writer.write("(function () {\n"); writer.write(" var xhr = new XMLHttpRequest();\n"); writer.write(" xhr.onreadystatechange=function() {\n"); writer.write(" if (xhr.readyState==4 && xhr.status==200) {\n"); writer.write(" document.getElementById(\"DispatcherTests3S_SPEC2_19_ForwardServletResource\").innerHTML=xhr.responseText;\n"); writer.write(" }\n"); writer.write(" };\n"); writer.write(" xhr.open(\"GET\",\"" + resurl.toString() + "\",true);\n"); writer.write(" xhr.send();\n"); writer.write("})();\n"); writer.write("</script>\n"); } else { portletReq.getPortletSession().removeAttribute( RESULT_ATTR_PREFIX + V2DISPATCHERTESTS3S_SPEC2_19_FORWARDSERVLETRESOURCE_DISPATCH4, APPLICATION_SCOPE); writer.write("<p>" + msg + "</p>\n"); } }
Example 18
Source File: FilterTests_FilterChain_ApiRenderFilter_filter2.java From portals-pluto with Apache License 2.0 | 5 votes |
@Override public void doFilter(RenderRequest portletReq, RenderResponse portletResp, FilterChain chain) throws IOException, PortletException { PrintWriter writer = portletResp.getWriter(); // first execute the chain // now do the tests and write output JSR286ApiTestCaseDetails tcd = new JSR286ApiTestCaseDetails(); // Create result objects for the tests /* TestCase: V2FilterTests_FilterChain_ApiRenderFilter_invokeRenderFilter */ /* Details: "Invoking doFilter(RenderRequest, RenderResponse): causes */ /* next filter to be invoked" */ TestResult tr0 = tcd.getTestResultFailed(V2FILTERTESTS_FILTERCHAIN_APIRENDERFILTER_INVOKERENDERFILTER); if (FilterTests_FilterChain_ApiRenderFilter_filter.tr0_success) { tr0.setTcSuccess(true); } tr0.writeTo(writer); /* TestCase: V2FilterTests_FilterChain_ApiRenderFilter_invokeRenderFilter2 */ /* Details: "Invoking doFilter(RenderRequest, RenderResponse): causes */ /* portlet Render method to be invoked" */ FilterTests_FilterChain_ApiRenderFilter_filter2.tr1_success = true; chain.doFilter(portletReq, portletResp); }
Example 19
Source File: HeaderPortletTests_SPEC15_HeaderResponse1.java From portals-pluto with Apache License 2.0 | 4 votes |
@Override public void render(RenderRequest renderRequest, RenderResponse renderResponse) throws PortletException, IOException { PrintWriter writer = renderResponse.getWriter(); String msg = (String) renderRequest.getAttribute( RESULT_ATTR_PREFIX + "HeaderPortletTests_SPEC15_HeaderResponse1"); writer.write("<p>" + msg + "</p>\n"); renderRequest.removeAttribute( RESULT_ATTR_PREFIX + "HeaderPortletTests_SPEC15_HeaderResponse1"); /* TestCase: V3HeaderPortletTests_SPEC15_HeaderResponse_getWriter */ /* Details: "Data written to the HeaderResponse writer is added to the */ /* aggregated portal document HEAD section." */ writer.write("<script type='text/javascript'>"); writer.write("document.addEventListener('DOMContentLoaded', function(event) {"); writer.write(" var jQueryTag = document.getElementsByClassName('jquery-tag');"); writer.write(" if(jQueryTag.length){"); writer.write(" document.getElementById('V3HeaderPortletTests_SPEC15_HeaderResponse_getWriter-result').innerHTML = 'Test Succeeded';"); writer.write(" }"); writer.write("});"); writer.write("</script>"); /* TestCase: V3HeaderPortletTests_SPEC15_HeaderResponse_addDependency7 */ /* Details: "Method addDependency(String name, String scope, String version, */ /* String markup) - Adds a dependency on a page-level resource that is */ /* managed by the portal and adds a resource for addition to the page for the */ /* dependency." */ writer.write("<script type='text/javascript'>"); writer.write("document.addEventListener('DOMContentLoaded', function(event) {"); writer.write(" var dependencyTag = document.getElementsByClassName('dependency-test');"); writer.write(" if(dependencyTag.length){"); writer.write(" document.getElementById('V3HeaderPortletTests_SPEC15_HeaderResponse_addDependency7-result').innerHTML= 'Test Succeeded';"); writer.write(" }"); writer.write("});"); writer.write("</script>"); /* TestCase: V3HeaderPortletTests_SPEC15_HeaderResponse_addDependency8 */ /* Details: "Method addDependency(String name, String scope, String version, */ /* String markup) - The portal may choose to include the later version of the */ /* resource on the page if 2 same dependencies with different version are */ /* declared." */ writer.write("<script type='text/javascript'>"); writer.write("document.addEventListener('DOMContentLoaded', function(event) {"); writer.write(" var dependencyTag2_1 = document.getElementsByClassName('dependency-test2-1');"); writer.write(" var dependencyTag2_2 = document.getElementsByClassName('dependency-test2-2');"); writer.write(" if(dependencyTag2_1.length==0 && dependencyTag2_2.length>0){"); writer.write(" document.getElementById('V3HeaderPortletTests_SPEC15_HeaderResponse_addDependency8-result').innerHTML= 'Test Succeeded';"); writer.write(" }"); writer.write("});"); writer.write("</script>"); /* TestCase: V3HeaderPortletTests_SPEC15_HeaderResponse_addDependency2 */ /* Details: "Method addDependency(String name, String scope, String version) */ /* - The dependency added by this method can be shared with other portlets." */ writer.write("<script type='text/javascript'>"); writer.write("document.addEventListener('DOMContentLoaded', function(event) {"); writer.write(" if (typeof window.portlet != 'undefined') { "); writer.write(" document.getElementById('V3HeaderPortletTests_SPEC15_HeaderResponse_addDependency2-result').innerHTML= 'Test Succeeded';"); writer.write(" }"); writer.write("});"); writer.write("</script>"); }
Example 20
Source File: FilterTests_FilterConfig_ApiRenderFilter_filter.java From portals-pluto with Apache License 2.0 | 4 votes |
@Override public void doFilter(RenderRequest portletReq, RenderResponse portletResp, FilterChain chain) throws IOException, PortletException { PrintWriter writer = portletResp.getWriter(); // first execute the chain chain.doFilter(portletReq, portletResp); // now do the tests and write output JSR286ApiTestCaseDetails tcd = new JSR286ApiTestCaseDetails(); // Create result objects for the tests /* TestCase: V2FilterTests_FilterConfig_ApiRenderFilter_getFilterName */ /* Details: "Method getFilterName(): getFilterName method returns */ /* filter name as defined in deployment descriptor" */ TestResult tr0 = tcd.getTestResultFailed(V2FILTERTESTS_FILTERCONFIG_APIRENDERFILTER_GETFILTERNAME); String getFiltName = filterConfig.getFilterName(); if (getFiltName.equals(this.getClass().getSimpleName())) { tr0.setTcSuccess(true); } tr0.writeTo(writer); /* TestCase: V2FilterTests_FilterConfig_ApiRenderFilter_getPortletContext */ /* Details: "Method getPortletContext(): Returns reference to */ /* PortletContext object" */ TestResult tr1 = tcd.getTestResultFailed(V2FILTERTESTS_FILTERCONFIG_APIRENDERFILTER_GETPORTLETCONTEXT); PortletContext pc = filterConfig.getPortletContext(); if (pc != null) { tr1.setTcSuccess(true); } tr1.writeTo(writer); /* TestCase: V2FilterTests_FilterConfig_ApiRenderFilter_getInitParameter1 */ /* Details: "Method getInitParameter(String): Returns null if */ /* initialization parameter does not exist" */ TestResult tr2 = tcd.getTestResultFailed(V2FILTERTESTS_FILTERCONFIG_APIRENDERFILTER_GETINITPARAMETER1); String getInit1 = filterConfig.getInitParameter("TestParm3"); if (getInit1 == null) { tr2.setTcSuccess(true); } tr2.writeTo(writer); /* TestCase: V2FilterTests_FilterConfig_ApiRenderFilter_getInitParameter2 */ /* Details: "Method getInitParameter(String): Returns value of */ /* specified initialization parameter" */ TestResult tr3 = tcd.getTestResultSucceeded(V2FILTERTESTS_FILTERCONFIG_APIRENDERFILTER_GETINITPARAMETER2); String getInit2 = filterConfig.getInitParameter("TestParm1"); if ((getInit2 == null) || !getInit2.equals("TestValue1")) { tr3.setTcSuccess(false); StringBuilder txt3 = new StringBuilder(128); txt3.append("Value for TestParm1 was not 'TestValue1' but ").append(getInit2); tr3.appendTcDetail(txt3.toString()); } tr3.writeTo(writer); /* TestCase: V2FilterTests_FilterConfig_ApiRenderFilter_getInitParameterNames2 */ /* Details: "Method getInitParameterNames(): Returns an Enumeration */ /* of initialization parameters defined in deployment descriptor" */ TestResult tr5 = tcd.getTestResultFailed(V2FILTERTESTS_FILTERCONFIG_APIRENDERFILTER_GETINITPARAMETERNAMES2); Enumeration<String> getNames2 = filterConfig.getInitParameterNames(); List<String> li5 = Collections.list(getNames2); if (li5.size() == 2) { if (li5.contains("TestParm1") && li5.contains("TestParm2")) { tr5.setTcSuccess(true); } else { tr5.appendTcDetail("Parameter names don't match: " + li5.toString()); } } else { tr5.appendTcDetail("Parameter name enumeration had invalid length: " + li5.size()); } tr5.writeTo(writer); }