Search in sources :

Example 1 with Bridge

use of javax.portlet.faces.Bridge in project liferay-faces-bridge-impl by liferay.

the class TestsCDI1 method bridgeRequestScopedBeanTest.

@BridgeTest(test = "bridgeRequestScopedBeanTest")
public String bridgeRequestScopedBeanTest(TestBean testBean) {
    FacesContext facesContext = FacesContext.getCurrentInstance();
    Bridge.PortletPhase portletPhase = BridgeUtil.getPortletRequestPhase(facesContext);
    if (portletPhase == Bridge.PortletPhase.ACTION_PHASE) {
        bridgeRequestScopedBean.setFoo("setInActionPhase");
        return "multiRequestTestResultRenderCheck";
    } else if (portletPhase == Bridge.PortletPhase.HEADER_PHASE) {
        testBean.setTestComplete(true);
        if ("setInActionPhase".equals(bridgeRequestScopedBean.getFoo())) {
            testBean.setTestResult(true, "@BridgeRequestScoped is behaving like faces-config <managed-bean> <scope>request&lt/scope> (bridge request scope)");
            return Constants.TEST_SUCCESS;
        } else {
            testBean.setTestResult(false, "@BridgeRequestScoped is behaving like @PortletRequestScoped");
            return Constants.TEST_FAILED;
        }
    }
    testBean.setTestResult(false, "Unexpected portletPhase=" + portletPhase);
    return Constants.TEST_FAILED;
}
Also used : FacesContext(javax.faces.context.FacesContext) Bridge(javax.portlet.faces.Bridge) BridgeTest(com.liferay.faces.bridge.tck.annotation.BridgeTest)

Example 2 with Bridge

use of javax.portlet.faces.Bridge in project liferay-faces-bridge-impl by liferay.

the class Tests method portletRequestScopedBeanExtensionTest.

@BridgeTest(test = "portletRequestScopedBeanExtensionTest")
public String portletRequestScopedBeanExtensionTest(TestBean testBean) {
    FacesContext facesContext = FacesContext.getCurrentInstance();
    Bridge.PortletPhase portletPhase = BridgeUtil.getPortletRequestPhase(facesContext);
    if (portletPhase == Bridge.PortletPhase.ACTION_PHASE) {
        portletRequestScopedBeanExtension.setFoo("setInActionPhase");
        return "multiRequestTestResultRenderCheck";
    } else if (portletPhase == Bridge.PortletPhase.HEADER_PHASE) {
        testBean.setTestComplete(true);
        if ("setInActionPhase".equals(portletRequestScopedBeanExtension.getFoo())) {
            testBean.setTestResult(true, "@PortletRequestScoped is behaving like faces-config <managed-bean> <scope>request&lt/scope> (bridge request scope)");
            return Constants.TEST_SUCCESS;
        } else {
            testBean.setTestResult(false, "@PortletRequestScoped is behaving like Portlet 3.0 @PortletRequestScoped rather than @BridgeRequestScoped");
            return Constants.TEST_FAILED;
        }
    }
    testBean.setTestResult(false, "Unexpected portletPhase=" + portletPhase);
    return Constants.TEST_FAILED;
}
Also used : FacesContext(javax.faces.context.FacesContext) Bridge(javax.portlet.faces.Bridge) BridgeTest(com.liferay.faces.bridge.tck.annotation.BridgeTest)

Example 3 with Bridge

use of javax.portlet.faces.Bridge in project liferay-faces-bridge-impl by liferay.

the class BridgeDestroyTestPortlet method runActionDestroyTest.

private void runActionDestroyTest(ActionRequest request, ActionResponse response) throws PortletException, IOException {
    BridgeTCKResultWriter resultWriter = new BridgeTCKResultWriter(DESTROY_ACTION_TEST);
    // Run test
    Bridge bridge = getFacesBridge(request, response);
    bridge.destroy();
    try {
        bridge.doFacesRequest(request, response);
        resultWriter.setStatus(BridgeTCKResultWriter.FAIL);
        resultWriter.setDetail("Didn't throw the BridgeUninitializedException from doFacesRequest(action) when passed a destroyed bridge. Instead the request completed without an exception.");
    } catch (BridgeUninitializedException bue) {
        resultWriter.setStatus(BridgeTCKResultWriter.PASS);
        resultWriter.setDetail("Correctly threw BridgeUninitializedException from doFacesRequest(action) when passed a destroyed bridge.");
    } catch (Exception e) {
        resultWriter.setStatus(BridgeTCKResultWriter.FAIL);
        resultWriter.setDetail("Didn't throw the BridgeUninitializedException from doFacesRequest(action) when passed a destroyed bridge. Instead it threw: " + e.toString());
    }
    mActionResult = resultWriter.toString();
}
Also used : BridgeTCKResultWriter(com.liferay.faces.bridge.tck.common.util.BridgeTCKResultWriter) BridgeUninitializedException(javax.portlet.faces.BridgeUninitializedException) Bridge(javax.portlet.faces.Bridge) IOException(java.io.IOException) BridgeUninitializedException(javax.portlet.faces.BridgeUninitializedException) PortletException(javax.portlet.PortletException)

Example 4 with Bridge

use of javax.portlet.faces.Bridge in project liferay-faces-bridge-impl by liferay.

the class BridgeDestroyTestPortlet method runNullRequestActionTest.

private void runNullRequestActionTest(ActionRequest request, ActionResponse response) throws PortletException, IOException {
    BridgeTCKResultWriter resultWriter = new BridgeTCKResultWriter(NULLREQUEST_ACTION_TEST);
    // Run test
    try {
        Bridge bridge = getFacesBridge(request, response);
        bridge.doFacesRequest((ActionRequest) null, (ActionResponse) null);
        resultWriter.setStatus(BridgeTCKResultWriter.FAIL);
        resultWriter.setDetail("Didn't throw the NullPointerException from doFacesRequest(action) when passed a null request/response. Instead the request completed without an exception.");
    } catch (NullPointerException bue) {
        resultWriter.setStatus(BridgeTCKResultWriter.PASS);
        resultWriter.setDetail("Correctly threw NullPointerException from doFacesRequest(action) when passed a null request/response.");
    } catch (Exception e) {
        resultWriter.setStatus(BridgeTCKResultWriter.FAIL);
        resultWriter.setDetail("Didn't throw the NullPointerException from doFacesRequest(action) when passed a null request/response. Instead it threw: " + e.toString());
    }
    mActionResult = resultWriter.toString();
}
Also used : BridgeTCKResultWriter(com.liferay.faces.bridge.tck.common.util.BridgeTCKResultWriter) Bridge(javax.portlet.faces.Bridge) IOException(java.io.IOException) BridgeUninitializedException(javax.portlet.faces.BridgeUninitializedException) PortletException(javax.portlet.PortletException)

Example 5 with Bridge

use of javax.portlet.faces.Bridge in project liferay-faces-bridge-impl by liferay.

the class BridgeDestroyTestPortlet method runDoubleDestroyTest.

private void runDoubleDestroyTest(RenderRequest request, RenderResponse response) throws PortletException, IOException {
    response.setContentType("text/html");
    PrintWriter responsePrintWriter = response.getWriter();
    BridgeTCKResultWriter resultWriter = new BridgeTCKResultWriter(DESTROY_DOUBLE_TEST);
    // Run test
    Bridge bridge = getFacesBridge(request, response);
    bridge.destroy();
    try {
        bridge.destroy();
        resultWriter.setStatus(BridgeTCKResultWriter.PASS);
        resultWriter.setDetail("Calling destroy on a destroyed bridge correctly completed without exception.");
    } catch (Exception e) {
        resultWriter.setStatus(BridgeTCKResultWriter.FAIL);
        resultWriter.setDetail("Calling destroy on a destroyed bridge incorrectly threw an exception: " + e.toString());
    }
    responsePrintWriter.println(resultWriter.toString());
}
Also used : BridgeTCKResultWriter(com.liferay.faces.bridge.tck.common.util.BridgeTCKResultWriter) Bridge(javax.portlet.faces.Bridge) IOException(java.io.IOException) BridgeUninitializedException(javax.portlet.faces.BridgeUninitializedException) PortletException(javax.portlet.PortletException) PrintWriter(java.io.PrintWriter)

Aggregations

Bridge (javax.portlet.faces.Bridge)18 IOException (java.io.IOException)9 PortletException (javax.portlet.PortletException)9 BridgeTCKResultWriter (com.liferay.faces.bridge.tck.common.util.BridgeTCKResultWriter)7 BridgeUninitializedException (javax.portlet.faces.BridgeUninitializedException)7 BridgeTest (com.liferay.faces.bridge.tck.annotation.BridgeTest)6 FacesContext (javax.faces.context.FacesContext)6 ExternalContext (javax.faces.context.ExternalContext)5 PrintWriter (java.io.PrintWriter)3 FacesMessage (javax.faces.application.FacesMessage)2 ActionResponse (javax.portlet.ActionResponse)2 PortletRequest (javax.portlet.PortletRequest)2 PortletResponse (javax.portlet.PortletResponse)2 IncongruityContext (com.liferay.faces.bridge.context.internal.IncongruityContext)1 ViewBean (com.liferay.faces.bridge.tck.beans.ViewBean)1 FacesMessageWrapper (com.liferay.faces.bridge.util.internal.FacesMessageWrapper)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 BaseURL (javax.portlet.BaseURL)1