Search in sources :

Example 76 with BridgeTest

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

the class Tests method getAuthTypeTest.

// Test #6.69
@BridgeTest(test = "getAuthTypeTest")
public String getAuthTypeTest(TestBean testBean) {
    testBean.setTestComplete(true);
    FacesContext facesContext = FacesContext.getCurrentInstance();
    ExternalContext externalContext = facesContext.getExternalContext();
    RenderRequest request = (RenderRequest) externalContext.getRequest();
    String authType = externalContext.getAuthType();
    String requestAuthType = request.getAuthType();
    if (((authType == null) && (requestAuthType == null)) || authType.equals(requestAuthType)) {
        testBean.setTestResult(true, "externalContext.getAuthType() correctly returned the same value as request.getAuthType()");
    } else {
        testBean.setTestResult(false, "externalContext.getAuthType() failed:  it returned a different value than request.getAuthType(): it returned: " + authType + " but we expected: " + requestAuthType);
    }
    if (testBean.getTestStatus()) {
        return Constants.TEST_SUCCESS;
    } else {
        return Constants.TEST_FAILED;
    }
}
Also used : FacesContext(javax.faces.context.FacesContext) ExternalContext(javax.faces.context.ExternalContext) RenderRequest(javax.portlet.RenderRequest) BridgeTest(com.liferay.faces.bridge.tck.annotation.BridgeTest)

Example 77 with BridgeTest

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

the class Tests method getRequestContextPathTest.

// Test #6.74
@BridgeTest(test = "getRequestContextPathTest")
public String getRequestContextPathTest(TestBean testBean) {
    testBean.setTestComplete(true);
    FacesContext facesContext = FacesContext.getCurrentInstance();
    ExternalContext externalContext = facesContext.getExternalContext();
    RenderRequest request = (RenderRequest) externalContext.getRequest();
    String contextPath = externalContext.getRequestContextPath();
    String requestContextPath = request.getContextPath();
    if (contextPath.equals(requestContextPath)) {
        testBean.setTestResult(true, "externalContext.getRequestContextPath() correctly returned the same value as request.getRequestContextPath()");
    } else {
        testBean.setTestResult(false, "externalContext.getRequestContextPath() failed:  it returned a different value than request.getRequestContextPath(): it returned: " + contextPath + " but we expected: " + requestContextPath);
    }
    if (testBean.getTestStatus()) {
        return Constants.TEST_SUCCESS;
    } else {
        return Constants.TEST_FAILED;
    }
}
Also used : FacesContext(javax.faces.context.FacesContext) ExternalContext(javax.faces.context.ExternalContext) RenderRequest(javax.portlet.RenderRequest) BridgeTest(com.liferay.faces.bridge.tck.annotation.BridgeTest)

Example 78 with BridgeTest

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

the class Tests method getRemoteUserTest.

// Test #6.73
@BridgeTest(test = "getRemoteUserTest")
public String getRemoteUserTest(TestBean testBean) {
    testBean.setTestComplete(true);
    FacesContext facesContext = FacesContext.getCurrentInstance();
    ExternalContext externalContext = facesContext.getExternalContext();
    RenderRequest request = (RenderRequest) externalContext.getRequest();
    String remoteUser = externalContext.getRemoteUser();
    String requestRemoteUser = request.getRemoteUser();
    if (((remoteUser == null) && (requestRemoteUser == null)) || remoteUser.equals(requestRemoteUser)) {
        testBean.setTestResult(true, "externalContext.getRemoteUser() correctly returned the same value as request.getRemoteUser()");
    } else {
        testBean.setTestResult(false, "externalContext.getRemoteUser() failed:  it returned a different value than request.getRemoteUser(): it returned: " + remoteUser + " but we expected: " + requestRemoteUser);
    }
    if (testBean.getTestStatus()) {
        return Constants.TEST_SUCCESS;
    } else {
        return Constants.TEST_FAILED;
    }
}
Also used : FacesContext(javax.faces.context.FacesContext) ExternalContext(javax.faces.context.ExternalContext) RenderRequest(javax.portlet.RenderRequest) BridgeTest(com.liferay.faces.bridge.tck.annotation.BridgeTest)

Example 79 with BridgeTest

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

the class Tests method encodeNamespaceTest.

// Test is SingleRequest -- Render only
// Test #6.67
@BridgeTest(test = "encodeNamespaceTest")
public String encodeNamespaceTest(TestBean testBean) {
    testBean.setTestComplete(true);
    FacesContext facesContext = FacesContext.getCurrentInstance();
    ExternalContext externalContext = facesContext.getExternalContext();
    MimeResponse response = (MimeResponse) externalContext.getResponse();
    String encodedNamespace = externalContext.encodeNamespace("");
    if (encodedNamespace == null) {
        testBean.setTestResult(false, "externalContext.encodeNamespace() failed:  it returned a null value");
    } else if (encodedNamespace.equals(response.getNamespace())) {
        testBean.setTestResult(true, "externalContext.encodeNamespace() correctly returned the same value as response.encodeNamespace when encoding the empty string.");
    } else {
        testBean.setTestResult(false, "externalContext.encodeNamespace() failed:  it returned a different value than response.encodeNamespace when encoding the empty string: it returned: " + encodedNamespace + " but we expected: " + response.getNamespace());
    }
    if (testBean.getTestStatus()) {
        return Constants.TEST_SUCCESS;
    } else {
        return Constants.TEST_FAILED;
    }
}
Also used : FacesContext(javax.faces.context.FacesContext) ExternalContext(javax.faces.context.ExternalContext) MimeResponse(javax.portlet.MimeResponse) BridgeTest(com.liferay.faces.bridge.tck.annotation.BridgeTest)

Example 80 with BridgeTest

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

the class Tests method setResponseHeaderTest.

// Test 6.148
@BridgeTest(test = "setResponseHeaderTest")
public String setResponseHeaderTest(TestBean testBean) {
    FacesContext facesContext = FacesContext.getCurrentInstance();
    if (BridgeUtil.getPortletRequestPhase(facesContext) == Bridge.PortletPhase.RESOURCE_PHASE) {
        ExternalContext externalContext = facesContext.getExternalContext();
        externalContext.setResponseHeader("foo", "1234");
        testBean.setTestResult(true, "externalContext.setResponseHeader(String,String) functioned properly");
        testBean.setTestComplete(true);
        return Constants.TEST_SUCCESS;
    }
    return "";
}
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