use of com.liferay.faces.bridge.tck.annotation.BridgeTest in project liferay-faces-bridge-impl by liferay.
the class EncodeActionURLTests method encodeActionURLWithInvalidWindowStateRenderTest.
// Test is MultiRequest -- Render/Action
// Test #6.22
@BridgeTest(test = "encodeActionURLWithInvalidWindowStateRenderTest")
public String encodeActionURLWithInvalidWindowStateRenderTest(TestBean testBean) {
// This tests that we can encode an invalid window state in an actionURL done by navigation rule.
FacesContext facesContext = FacesContext.getCurrentInstance();
if (BridgeUtil.getPortletRequestPhase(facesContext) == Bridge.PortletPhase.ACTION_PHASE) {
PortletRequest portletRequest = (PortletRequest) facesContext.getExternalContext().getRequest();
// Parameter/Mode encoded in the faces-config.xml target
WindowState windowState = portletRequest.getWindowState();
// Check that the parameter came along too
String paramValue = facesContext.getExternalContext().getRequestParameterMap().get("param1");
if ((windowState == null) || !windowState.toString().equalsIgnoreCase("normal")) {
testBean.setTestResult(false, "encodeActionURL incorrectly encoded the invalid window state. The resulting request should have ignored the invalid window state and remained in 'normal' mode.");
} else if (paramValue == null) {
testBean.setTestResult(false, "encodeActionURL incorrectly encoded a portlet action URL containing an invalid window state and parameter. The resulting request didn't contain the expected 'param1' parameter.");
} else if (!paramValue.equals("testValue")) {
testBean.setTestResult(false, "encodeActionURL incorrectly encoded a portlet action URL containing an invalid window state and parameter. The resulting request contained the wrong parameter value. Expected: testValue Received: " + paramValue);
} else {
testBean.setTestResult(true, "encodeActionURL correctly encoded a portlet action URL by ignoring the invalid window state and properly encoding the parameter.");
}
// action Navigation result
return "encodeActionURLWithInvalidWindowStateRenderTest";
} else {
testBean.setTestComplete(true);
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 EncodeActionURLTests method encodeActionURLWithParamActionTest.
// Test is MultiRequest -- Render/Action
// Test #6.17
@BridgeTest(test = "encodeActionURLWithParamActionTest")
public String encodeActionURLWithParamActionTest(TestBean testBean) {
// This tests that we can encode a new name=value parameter in an actionURL done by navigation rule.
FacesContext facesContext = FacesContext.getCurrentInstance();
if (BridgeUtil.getPortletRequestPhase(facesContext) == Bridge.PortletPhase.ACTION_PHASE) {
// action Navigation result
return "encodeActionURLWithParamActionTest";
} else {
testBean.setTestComplete(true);
// Parameter encoded in the faces-config.xml target
String paramValue = facesContext.getExternalContext().getRequestParameterMap().get("param1");
if ((paramValue != null) && paramValue.equals("testValue")) {
testBean.setTestResult(true, "encodeActionURL correctly encoded a portlet action URL containing a parameter.");
return Constants.TEST_SUCCESS;
} else {
if (paramValue == null) {
testBean.setTestResult(false, "encodeActionURL incorrectly encoded a portlet action URL containing a parameter. The resulting request didn't contain the expected 'param1' parameter.");
} else {
testBean.setTestResult(false, "encodeActionURL incorrectly encoded a portlet action URL containing a parameter. The resulting request contained the wrong parameter value. Expected: testValue Received: " + paramValue);
}
}
return Constants.TEST_FAILED;
}
}
use of com.liferay.faces.bridge.tck.annotation.BridgeTest in project liferay-faces-bridge-impl by liferay.
the class EncodeActionURLTests method encodeActionURLWithInvalidSecurityRenderTest.
// Test is MultiRequest -- Render/Action
// Test #6.24
@BridgeTest(test = "encodeActionURLWithInvalidSecurityRenderTest")
public String encodeActionURLWithInvalidSecurityRenderTest(TestBean testBean) {
// This tests that we can encode an invalid security state in an actionURL done by navigation rule.
FacesContext facesContext = FacesContext.getCurrentInstance();
if (BridgeUtil.getPortletRequestPhase(facesContext) == Bridge.PortletPhase.ACTION_PHASE) {
PortletRequest portletRequest = (PortletRequest) facesContext.getExternalContext().getRequest();
// Check that the parameter came along too
String paramValue = facesContext.getExternalContext().getRequestParameterMap().get("param1");
if (portletRequest.isSecure()) {
testBean.setTestResult(false, "encodeActionURL incorrectly encoded an invalid portlet security state. The resulting request wasn't in the expected 'non-secure' mode.");
return Constants.TEST_FAILED;
} else if (paramValue == null) {
testBean.setTestResult(false, "encodeActionURL incorrectly encoded a portlet action URL containing an invalid security state and parameter. The resulting request didn't contain the expected 'param1' parameter.");
return Constants.TEST_FAILED;
} else if (!paramValue.equals("testValue")) {
testBean.setTestResult(false, "encodeActionURL incorrectly encoded a portlet action URL containing an invalid security state and parameter. The resulting request contained the wrong parameter value. Expected: testValue Received: " + paramValue);
return Constants.TEST_FAILED;
} else {
testBean.setTestResult(true, "encodeActionURL correctly encoded a portlet action URL ontaining an invalid security state and parameter.");
}
// action Navigation result
return "encodeActionURLWithInvalidSecurityRenderTest";
} else {
testBean.setTestComplete(true);
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 EncodeActionURLTests method encodeActionURLDirectLinkFalseTest.
// Test is SingleRequest -- Render only
// Test #6.7
@BridgeTest(test = "encodeActionURLDirectLinkFalseTest")
public String encodeActionURLDirectLinkFalseTest(TestBean testBean) {
testBean.setTestComplete(true);
final String DIRECTLINK_FALSE_TEST_STRING = "/test.jsp?firstParam=value&javax.portlet.faces.DirectLink=false&anotherParam=value";
FacesContext facesContext = FacesContext.getCurrentInstance();
ExternalContext externalContext = facesContext.getExternalContext();
String testString = externalContext.getRequestContextPath() + DIRECTLINK_FALSE_TEST_STRING;
if (!externalContext.encodeActionURL(testString).contains("javax.portlet.faces.DirectLink")) {
testBean.setTestResult(true, "encodeActionURL correctly returned an url string without the javax.portlet.faces.DirectLink parameter when its value was false.");
return Constants.TEST_SUCCESS;
} else {
testBean.setTestResult(false, "encodeActionURL didn't return an url string without the javax.portlet.faces.DirectLink parameter when its value was false. Test parameter: " + testString + " and encodeActionURL returned: " + externalContext.encodeActionURL(testString));
return Constants.TEST_FAILED;
}
}
use of com.liferay.faces.bridge.tck.annotation.BridgeTest in project liferay-faces-bridge-impl by liferay.
the class EncodeActionURLTests method encodeActionURLJSFViewActionTest.
// Test is MultiRequest -- Render/Action
// Test #6.10
@BridgeTest(test = "encodeActionURLJSFViewActionTest")
public String encodeActionURLJSFViewActionTest(TestBean testBean) {
// If this method is reached in the ACTION_PHASE of the portlet lifecycle then the initial render of TestPage091
// must have rendered a form with a postback URL that correctly caused the RESTORE_VIEW phase to restore
// viewId=multiRequestTest.xhtml (meaning, the viewId must have been encoded in a BridgeURL found in the form's
// "action" attribute).
FacesContext facesContext = FacesContext.getCurrentInstance();
if (BridgeUtil.getPortletRequestPhase(facesContext) == Bridge.PortletPhase.ACTION_PHASE) {
// action Navigation result
return "encodeActionURLJSFViewActionTest";
} else // Otherwise, if this method is reached in the HEADER_PHASE of the portlet lifecycle then the bridge executed a
// navigation-rule to viewId=multiRequestTestResultRenderCheck.xhtml in order to display the test results. This
// verifies that the action BridgeURL created in the ACTION_PHASE correctly encoded the viewId (and if client
// window mode is enabled, the "jsfwid" parameter as well).
{
ExternalContext externalContext = facesContext.getExternalContext();
Map<String, String> requestParameterMap = externalContext.getRequestParameterMap();
String clientWindowParam = requestParameterMap.get(ResponseStateManager.CLIENT_WINDOW_URL_PARAM);
String customClientWindowParam = requestParameterMap.get(ClientWindowTestUtil.TCK_CUSTOM_CLIENT_WINDOW_PARAM_NAME);
if (ClientWindowTestUtil.isClientWindowEnabled(externalContext)) {
String clientWindowId = ClientWindowTestUtil.getClientWindowId(externalContext);
if ((clientWindowParam != null) && (clientWindowParam.length() > 0)) {
if (clientWindowParam.equals(clientWindowId)) {
if (ClientWindowTestUtil.TCK_CUSTOM_CLIENT_WINDOW_PARAM_VALUE.equals(customClientWindowParam)) {
testBean.setTestResult(true, "encodeActionURL correctly encoded the viewId in the ACTION_PHASE of the portlet " + "lifecycle and " + ResponseStateManager.CLIENT_WINDOW_URL_PARAM + " request parameter value=[" + clientWindowParam + "] is equal to ClientWindow.getId()." + "It also included the expected custom client window parameter.");
} else {
testBean.setTestResult(false, "encodeActionURL returned a URL that did NOT include the request parameter name=[" + ClientWindowTestUtil.TCK_CUSTOM_CLIENT_WINDOW_PARAM_NAME + "] expected value=[" + ClientWindowTestUtil.TCK_CUSTOM_CLIENT_WINDOW_PARAM_VALUE + "] actual value=[" + customClientWindowParam);
}
} else {
testBean.setTestResult(false, "encodeActionURL returned a URL such that the " + ResponseStateManager.CLIENT_WINDOW_URL_PARAM + " request parameter value=[" + clientWindowParam + "] did NOT equal ClientWindow.getId()=[" + clientWindowId + "].");
}
} else {
testBean.setTestResult(false, "encodeActionURL returned a URL that contained a null value for the " + ResponseStateManager.CLIENT_WINDOW_URL_PARAM + " request parameter.");
}
} else {
if (clientWindowParam == null) {
if (customClientWindowParam == null) {
testBean.setTestResult(true, "encodeActionURL correctly encoded the viewId in the ACTION_PHASE of the portlet " + " lifecycle and did NOT include the " + ResponseStateManager.CLIENT_WINDOW_URL_PARAM + " and " + ClientWindowTestUtil.TCK_CUSTOM_CLIENT_WINDOW_PARAM_NAME + " parameters.");
} else {
testBean.setTestResult(false, "encodeActionURL returned a URL that did included the request parameter name=[" + ClientWindowTestUtil.TCK_CUSTOM_CLIENT_WINDOW_PARAM_NAME + "] value=[" + customClientWindowParam);
}
} else {
testBean.setTestResult(false, "encodeActionURL returned a URL that incorrectly included the " + ResponseStateManager.CLIENT_WINDOW_URL_PARAM + " request parameter with value=[" + clientWindowParam + "] even though the client window feature is disabled.");
}
}
testBean.setTestComplete(true);
if (testBean.getTestStatus()) {
return Constants.TEST_SUCCESS;
} else {
return Constants.TEST_FAILED;
}
}
}
Aggregations