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;
}
}
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;
}
}
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;
}
}
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;
}
}
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 "";
}
Aggregations