Search in sources :

Example 41 with BridgeTest

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

the class ScopeCommonTests method scopeAfterRedisplayResourcePPRTestListener.

// ActionListener
@BridgeTest(test = "scopeAfterRedisplayResourcePPRTestActionListener")
public void scopeAfterRedisplayResourcePPRTestListener(TestBean testBean, ActionEvent action) {
    FacesContext facesContext = FacesContext.getCurrentInstance();
    ExternalContext externalContext = facesContext.getExternalContext();
    Map<String, Object> requestMap = externalContext.getRequestMap();
    requestMap.put("com.liferay.faces.bridge.tck.pprSubmitted", Boolean.TRUE);
}
Also used : FacesContext(javax.faces.context.FacesContext) ExternalContext(javax.faces.context.ExternalContext) BridgeTest(com.liferay.faces.bridge.tck.annotation.BridgeTest)

Example 42 with BridgeTest

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

the class Tests method isPortletNamingContainerTest.

// Test is SingleRequest -- Render
// Test #6.86
@BridgeTest(test = "isPortletNamingContainerTest")
public String isPortletNamingContainerTest(TestBean testBean) {
    UIViewRoot uiViewRoot = FacesContext.getCurrentInstance().getViewRoot();
    testBean.setTestComplete(true);
    if (uiViewRoot.getClass().getAnnotation(PortletNamingContainer.class) != null) {
        testBean.setTestResult(true, "UIViewRoot is correctly annotated with javax.portlet.faces.annotation.PortletNamingContainer.");
        return Constants.TEST_SUCCESS;
    } else {
        testBean.setTestResult(false, "UIViewRoot is not annotated with javax.portlet.faces.annotation.PortletNamingContainer.");
        return Constants.TEST_FAILED;
    }
}
Also used : PortletNamingContainer(javax.portlet.faces.annotation.PortletNamingContainer) UIViewRoot(javax.faces.component.UIViewRoot) BridgeTest(com.liferay.faces.bridge.tck.annotation.BridgeTest)

Example 43 with BridgeTest

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

the class Tests method processPRPInRestoreViewPhaseTest.

// Test is MultiRequest -- Render/Action
// Test #5.69
@BridgeTest(test = "processPRPInRestoreViewPhaseTest")
public String processPRPInRestoreViewPhaseTest(TestBean testBean) {
    FacesContext facesContext = FacesContext.getCurrentInstance();
    ExternalContext externalContext = facesContext.getExternalContext();
    if (BridgeUtil.getPortletRequestPhase(facesContext) == Bridge.PortletPhase.ACTION_PHASE) {
        if (externalContext.getSessionMap().get("tck.processPRPInRestoreViewPhaseTest.modelPRPSet") == null) {
            externalContext.getRequestMap().put("modelPRP", testBean.getTestName());
            externalContext.getRequestMap().put("modelPRP2", testBean.getTestName());
            // Put it on the request Map -- to carry forward to the render -- which will set it on the session --
            // this avoids having the render that follows this action from thinking the test is done.
            externalContext.getRequestMap().put("tck.processPRPInRestoreViewPhaseTest.modelPRPSet", Boolean.TRUE);
            // returns from edit mode
            return "processPRPInRestoreViewPhaseTest";
        } else {
            return "processPRPInRestoreViewPhaseTestResult";
        }
    } else {
        if (Boolean.TRUE.equals((Boolean) externalContext.getSessionMap().get("tck.processPRPInRestoreViewPhaseTest.modelPRPSet"))) {
            testBean.setTestComplete(true);
            externalContext.getSessionMap().remove("tck.processPRPInRestoreViewPhaseTest.modelPRPSet");
            // Marked as true in the phaseListener so command link name would change.
            externalContext.getSessionMap().remove("com.liferay.faces.bridge.tck.testCompleted");
            if (externalContext.getRequestMap().get("tck.notSetBeforeRestoreView") == null) {
                testBean.setTestResult(false, "PRP set before RestoreView phase. It should be set after the RestoreView phase and before other phases.");
                return Constants.TEST_FAILED;
            } else if (externalContext.getRequestMap().get("tck.setAfterRestoreView") == null) {
                testBean.setTestResult(false, "PRP not set in the after RestoreView phase. It wasn't set in any of the other phases before phase.");
                return Constants.TEST_FAILED;
            } else {
                testBean.setTestResult(true, "PRP correctly updated the model after the RestoreView phase and before other phases.");
                return Constants.TEST_SUCCESS;
            }
        } else {
            if (externalContext.getRequestMap().get("tck.processPRPInRestoreViewPhaseTest.modelPRPSet") != null) {
                // Place on session so next action triggers running the test.
                externalContext.getSessionMap().put("tck.processPRPInRestoreViewPhaseTest.modelPRPSet", Boolean.TRUE);
            }
            return "Test is still being run.";
        }
    }
}
Also used : FacesContext(javax.faces.context.FacesContext) ExternalContext(javax.faces.context.ExternalContext) BridgeTest(com.liferay.faces.bridge.tck.annotation.BridgeTest)

Example 44 with BridgeTest

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

the class Tests method prpModelUpdateTest.

// Test is MultiRequest -- Render/Action
// Test #5.70 and 5.71
@BridgeTest(test = "prpModelUpdateTest")
public String prpModelUpdateTest(TestBean testBean) {
    FacesContext facesContext = FacesContext.getCurrentInstance();
    ExternalContext externalContext = facesContext.getExternalContext();
    if (BridgeUtil.getPortletRequestPhase(facesContext) == Bridge.PortletPhase.ACTION_PHASE) {
        if (externalContext.getSessionMap().get("tck.prpModelUpdateTest.modelPRPSet") == null) {
            externalContext.getRequestMap().put("modelPRP", testBean.getTestName());
            externalContext.getRequestMap().put("modelPRP2", testBean.getTestName());
            // Put it on the request Map -- to carry forward to the render -- which will set it on the session --
            // this avoids having the render that follows this action from thinking the test is done.
            externalContext.getRequestMap().put("tck.prpModelUpdateTest.modelPRPSet", Boolean.TRUE);
            // returns from edit mode
            return "prpModelUpdateTest";
        } else {
            return "prpModelUpdateTest";
        }
    } else {
        if (Boolean.TRUE.equals((Boolean) externalContext.getSessionMap().get("tck.prpModelUpdateTest.modelPRPSet"))) {
            testBean.setTestComplete(true);
            externalContext.getSessionMap().remove("tck.prpModelUpdateTest.modelPRPSet");
            String modelPRP = (String) externalContext.getRequestMap().get("modelPRP");
            String modelPRP2 = (String) externalContext.getRequestMap().get("modelPRP2");
            if (modelPRP == null) {
                testBean.setTestResult(false, "Expect 'modelPRP' PRP not set.");
                return Constants.TEST_FAILED;
            } else if (!modelPRP.equals(testBean.getTestName())) {
                testBean.setTestResult(false, "Expect 'modelPRP' doesn't have expected value.  Expected: " + testBean.getTestName() + " but PRP has a value of: " + modelPRP);
                return Constants.TEST_FAILED;
            } else if (modelPRP2 == null) {
                testBean.setTestResult(false, "Expect 'modelPRP2' PRP not set.");
                return Constants.TEST_FAILED;
            } else if (!modelPRP2.equals(testBean.getTestName())) {
                testBean.setTestResult(false, "Expect 'modelPRP2' doesn't have expected value.  Expected: " + testBean.getTestName() + " but PRP has a value of: " + modelPRP2);
                return Constants.TEST_FAILED;
            } else if (externalContext.getRequestMap().get("tck.prpProcessUpdatesCalled") == null) {
                testBean.setTestResult(false, "Though incoming PRPs updated their models, the registered processUpdates handler wasn't called.");
                return Constants.TEST_FAILED;
            } else {
                testBean.setTestResult(true, "Both PRPs correctly updated their models with expected values and the processUpdates handler was called.");
                return Constants.TEST_SUCCESS;
            }
        } else {
            if (externalContext.getRequestMap().get("tck.prpModelUpdateTest.modelPRPSet") != null) {
                // Place on session so next action triggers running the test.
                externalContext.getSessionMap().put("tck.prpModelUpdateTest.modelPRPSet", Boolean.TRUE);
            }
            return "Test is still being run.";
        }
    }
}
Also used : FacesContext(javax.faces.context.FacesContext) ExternalContext(javax.faces.context.ExternalContext) BridgeTest(com.liferay.faces.bridge.tck.annotation.BridgeTest)

Example 45 with BridgeTest

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

the class Tests method getResponseCharacterEncodingActionTest.

// Test #6.61
@BridgeTest(test = "getResponseCharacterEncodingActionTest")
public String getResponseCharacterEncodingActionTest(TestBean testBean) {
    FacesContext facesContext = FacesContext.getCurrentInstance();
    ExternalContext externalContext = facesContext.getExternalContext();
    if (BridgeUtil.getPortletRequestPhase(facesContext) == Bridge.PortletPhase.ACTION_PHASE) {
        try {
            String encoding = externalContext.getResponseCharacterEncoding();
            testBean.setTestResult(false, "externalContext.getResponseCharacterEncoding() didn't throw an IllegalStateException when called during an Action.");
        } catch (IllegalStateException e) {
            testBean.setTestResult(true, "externalContext.getResponseCharacterEncoding() correctly threw an IllegalStateException when called during an Action.");
        }
        return "getResponseCharacterEncodingActionTest";
    } else {
        testBean.setTestComplete(true);
        if (testBean.getTestStatus()) {
            return Constants.TEST_SUCCESS;
        } else {
            return Constants.TEST_FAILED;
        }
    }
}
Also used : FacesContext(javax.faces.context.FacesContext) ExternalContext(javax.faces.context.ExternalContext) 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