Search in sources :

Example 1 with BridgeTest

use of com.liferay.faces.bridge.tck.annotation.BridgeTest in project liferay-faces-bridge-impl by liferay.

the class TestsCDI1 method mutableRenderParamsAlternativeTest.

@BridgeTest(test = "mutableRenderParamsAlternativeTest")
public String mutableRenderParamsAlternativeTest(TestBean testBean) {
    FacesContext facesContext = FacesContext.getCurrentInstance();
    Bridge.PortletPhase portletPhase = BridgeUtil.getPortletRequestPhase(facesContext);
    if (portletPhase == Bridge.PortletPhase.ACTION_PHASE) {
        bridgeRequestScopedBean.setFoo(mutableRenderParams.getClass().getSimpleName());
        return "multiRequestTestResultRenderCheck";
    } else if (portletPhase == Bridge.PortletPhase.HEADER_PHASE) {
        if ("MutableRenderParametersTCKImpl".equals(bridgeRequestScopedBean.getFoo())) {
            testBean.setTestResult(true, "The bridge's alternative producer for MutableRenderParameters was properly invoked");
            return Constants.TEST_SUCCESS;
        } else {
            testBean.setTestResult(false, "The bridge's alternative producer for MutableRenderParameters was not invoked");
            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 BridgeTest

use of com.liferay.faces.bridge.tck.annotation.BridgeTest in project liferay-faces-bridge-impl by liferay.

the class TestsCDI1 method eventResponseAlternativeTest.

@BridgeTest(test = "eventResponseAlternativeTest")
public String eventResponseAlternativeTest(TestBean testBean) {
    FacesContext facesContext = FacesContext.getCurrentInstance();
    Bridge.PortletPhase portletPhase = BridgeUtil.getPortletRequestPhase(facesContext);
    if (portletPhase == Bridge.PortletPhase.ACTION_PHASE) {
        // Publish an event that gets handled by Ch7TestEventHandler.handleEvent(FacesContext,Event)
        StateAwareResponse stateAwareResponse = (StateAwareResponse) facesContext.getExternalContext().getResponse();
        stateAwareResponse.setEvent(new QName(Constants.EVENT_QNAME, Constants.EVENT_NAME), testBean.getTestName());
        return "multiRequestTestResultRenderCheck";
    } else if (portletPhase == Bridge.PortletPhase.EVENT_PHASE) {
        ELContext elContext = facesContext.getELContext();
        ELResolver elResolver = elContext.getELResolver();
        EventBean eventBean = (EventBean) elResolver.getValue(elContext, null, "eventBean");
        bridgeRequestScopedBean.setFoo(eventBean.getInjectedEventResponseFQCN());
        return null;
    } else if (portletPhase == Bridge.PortletPhase.HEADER_PHASE) {
        String foo = bridgeRequestScopedBean.getFoo();
        if ((foo != null) && foo.endsWith("EventResponseTCKImpl")) {
            testBean.setTestResult(true, "The bridge's alternative producer for EventResponse was properly invoked");
            return Constants.TEST_SUCCESS;
        } else {
            testBean.setTestResult(false, "The bridge's alternative producer for EventResponse was not invoked");
            return Constants.TEST_FAILED;
        }
    }
    testBean.setTestResult(false, "Unexpected portletPhase=" + portletPhase);
    return Constants.TEST_FAILED;
}
Also used : FacesContext(javax.faces.context.FacesContext) StateAwareResponse(javax.portlet.StateAwareResponse) ELContext(javax.el.ELContext) ELResolver(javax.el.ELResolver) QName(javax.xml.namespace.QName) Bridge(javax.portlet.faces.Bridge) BridgeTest(com.liferay.faces.bridge.tck.annotation.BridgeTest)

Example 3 with BridgeTest

use of com.liferay.faces.bridge.tck.annotation.BridgeTest in project liferay-faces-bridge-impl by liferay.

the class TestsCDI1 method clientDataRequestAlternativeTest.

@BridgeTest(test = "clientDataRequestAlternativeTest")
public String clientDataRequestAlternativeTest(TestBean testBean) {
    FacesContext facesContext = FacesContext.getCurrentInstance();
    Bridge.PortletPhase portletPhase = BridgeUtil.getPortletRequestPhase(facesContext);
    if (portletPhase == Bridge.PortletPhase.ACTION_PHASE) {
        bridgeRequestScopedBean.setFoo(clientDataRequest.getClass().getSimpleName());
        return "multiRequestTestResultRenderCheck";
    } else if (portletPhase == Bridge.PortletPhase.HEADER_PHASE) {
        if ("ActionRequestTCKImpl".equals(bridgeRequestScopedBean.getFoo())) {
            testBean.setTestResult(true, "The bridge's alternative producer for ClientDataRequest was properly invoked");
            return Constants.TEST_SUCCESS;
        } else {
            testBean.setTestResult(false, "The bridge's alternative producer for ClientDataRequest was not invoked");
            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 4 with BridgeTest

use of com.liferay.faces.bridge.tck.annotation.BridgeTest in project liferay-faces-bridge-impl by liferay.

the class TestsCDI1 method actionResponseAlternativeTest.

@BridgeTest(test = "actionResponseAlternativeTest")
public String actionResponseAlternativeTest(TestBean testBean) {
    FacesContext facesContext = FacesContext.getCurrentInstance();
    Bridge.PortletPhase portletPhase = BridgeUtil.getPortletRequestPhase(facesContext);
    if (portletPhase == Bridge.PortletPhase.ACTION_PHASE) {
        bridgeRequestScopedBean.setFoo(actionResponse.getClass().getSimpleName());
        return "multiRequestTestResultRenderCheck";
    } else if (portletPhase == Bridge.PortletPhase.HEADER_PHASE) {
        if ("ActionResponseTCKImpl".equals(bridgeRequestScopedBean.getFoo())) {
            testBean.setTestResult(true, "The bridge's alternative producer for ActionResponse was properly invoked");
            return Constants.TEST_SUCCESS;
        } else {
            testBean.setTestResult(false, "The bridge's alternative producer for ActionResponse was not invoked");
            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 5 with BridgeTest

use of com.liferay.faces.bridge.tck.annotation.BridgeTest in project liferay-faces-bridge-impl by liferay.

the class TestsCDI1 method eventRequestAlternativeTest.

@BridgeTest(test = "eventRequestAlternativeTest")
public String eventRequestAlternativeTest(TestBean testBean) {
    FacesContext facesContext = FacesContext.getCurrentInstance();
    Bridge.PortletPhase portletPhase = BridgeUtil.getPortletRequestPhase(facesContext);
    if (portletPhase == Bridge.PortletPhase.ACTION_PHASE) {
        // Publish an event that gets handled by Ch7TestEventHandler.handleEvent(FacesContext,Event)
        StateAwareResponse stateAwareResponse = (StateAwareResponse) facesContext.getExternalContext().getResponse();
        stateAwareResponse.setEvent(new QName(Constants.EVENT_QNAME, Constants.EVENT_NAME), testBean.getTestName());
        return "multiRequestTestResultRenderCheck";
    } else if (portletPhase == Bridge.PortletPhase.EVENT_PHASE) {
        ELContext elContext = facesContext.getELContext();
        ELResolver elResolver = elContext.getELResolver();
        EventBean eventBean = (EventBean) elResolver.getValue(elContext, null, "eventBean");
        bridgeRequestScopedBean.setFoo(eventBean.getInjectedEventRequestFQCN());
        return null;
    } else if (portletPhase == Bridge.PortletPhase.HEADER_PHASE) {
        String foo = bridgeRequestScopedBean.getFoo();
        if ((foo != null) && foo.endsWith("EventRequestTCKImpl")) {
            testBean.setTestResult(true, "The bridge's alternative producer for EventRequest was properly invoked");
            return Constants.TEST_SUCCESS;
        } else {
            testBean.setTestResult(false, "The bridge's alternative producer for EventRequest was not invoked");
            return Constants.TEST_FAILED;
        }
    }
    testBean.setTestResult(false, "Unexpected portletPhase=" + portletPhase);
    return Constants.TEST_FAILED;
}
Also used : FacesContext(javax.faces.context.FacesContext) StateAwareResponse(javax.portlet.StateAwareResponse) ELContext(javax.el.ELContext) ELResolver(javax.el.ELResolver) QName(javax.xml.namespace.QName) Bridge(javax.portlet.faces.Bridge) BridgeTest(com.liferay.faces.bridge.tck.annotation.BridgeTest)

Aggregations

BridgeTest (com.liferay.faces.bridge.tck.annotation.BridgeTest)204 FacesContext (javax.faces.context.FacesContext)201 ExternalContext (javax.faces.context.ExternalContext)166 PortletRequest (javax.portlet.PortletRequest)40 StateAwareResponse (javax.portlet.StateAwareResponse)26 QName (javax.xml.namespace.QName)26 Bridge (javax.portlet.faces.Bridge)19 Map (java.util.Map)17 PortletContext (javax.portlet.PortletContext)10 MimeResponse (javax.portlet.MimeResponse)9 RenderRequest (javax.portlet.RenderRequest)9 Enumeration (java.util.Enumeration)8 Locale (java.util.Locale)8 PortletMode (javax.portlet.PortletMode)7 WindowState (javax.portlet.WindowState)7 ELResolver (javax.el.ELResolver)6 IOException (java.io.IOException)5 ELContext (javax.el.ELContext)5 ViewHandler (javax.faces.application.ViewHandler)5 UIViewRoot (javax.faces.component.UIViewRoot)5