use of com.liferay.faces.bridge.tck.annotation.BridgeTest in project liferay-faces-bridge-impl by liferay.
the class EncodeActionURLTests method encodeActionURLDirectLinkTrueTest.
// Test is SingleRequest -- Render only
// Test #6.6
@BridgeTest(test = "encodeActionURLDirectLinkTrueTest")
public String encodeActionURLDirectLinkTrueTest(TestBean testBean) {
testBean.setTestComplete(true);
final String DIRECTLINK_TRUE_TEST_STRING = "/test.jsp?firstParam=value&javax.portlet.faces.DirectLink=true&anotherParam=value";
FacesContext facesContext = FacesContext.getCurrentInstance();
ExternalContext externalContext = facesContext.getExternalContext();
PortletRequest portletRequest = (PortletRequest) externalContext.getRequest();
String testString = externalContext.getRequestContextPath() + DIRECTLINK_TRUE_TEST_STRING;
String absoluteURL = portletRequest.getScheme() + "://" + portletRequest.getServerName() + ":" + portletRequest.getServerPort() + testString;
if (externalContext.encodeActionURL(testString).equalsIgnoreCase(absoluteURL)) {
testBean.setTestResult(true, "encodeActionURL correctly returned an absolute URL representing the DirectLink url and it correctly contains the javax.portlet.faces.DirectLink parameter with a value of true.");
return Constants.TEST_SUCCESS;
} else {
testBean.setTestResult(false, "encodeActionURL didn't return an absolute URL representing the DirectLink url or it didn't contain the javax.portlet.faces.DirectLink parameter with a value of true. Expected: " + absoluteURL + " 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 encodeActionURLPoundCharTest.
// Test is SingleRequest -- Render only
// Test #6.4
@BridgeTest(test = "encodeActionURLPoundCharTest")
public String encodeActionURLPoundCharTest(TestBean testBean) {
testBean.setTestComplete(true);
final String POUNDCHAR_TEST_STRING = "#AnchorReference";
FacesContext facesContext = FacesContext.getCurrentInstance();
ExternalContext externalContext = facesContext.getExternalContext();
if (externalContext.encodeActionURL(POUNDCHAR_TEST_STRING).equals(POUNDCHAR_TEST_STRING)) {
testBean.setTestResult(true, "encodeActionURL correctly returned an unchanged string when the string was prefixed with #.");
return Constants.TEST_SUCCESS;
} else {
testBean.setTestResult(false, "encodeActionURL didn't return an unchanged string when the string was prefixed with #. Test parameter: " + POUNDCHAR_TEST_STRING + " and encodeActionURL returned: " + externalContext.encodeActionURL(POUNDCHAR_TEST_STRING));
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 encodeActionURLWithInvalidModeEventTest.
// Test is MultiRequest -- Render/Action
// Test #6.105
@BridgeTest(test = "encodeActionURLWithInvalidModeEventTest")
public String encodeActionURLWithInvalidModeEventTest(TestBean testBean) {
FacesContext facesContext = FacesContext.getCurrentInstance();
ExternalContext externalContext = facesContext.getExternalContext();
// This tests that we can encode an invalid mode in an actionURL done by navigation rule.
if (BridgeUtil.getPortletRequestPhase(facesContext) == Bridge.PortletPhase.ACTION_PHASE) {
// Create and raise the event
StateAwareResponse stateAwareResponse = (StateAwareResponse) externalContext.getResponse();
stateAwareResponse.setEvent(new QName(Constants.EVENT_QNAME, Constants.EVENT_NAME), testBean.getTestName());
// action Navigation result
return Constants.TEST_SUCCESS;
} else {
testBean.setTestComplete(true);
PortletRequest portletRequest = (PortletRequest) facesContext.getExternalContext().getRequest();
// Parameter/Mode encoded in the faces-config.xml target
PortletMode portletMode = portletRequest.getPortletMode();
if ((portletMode == null) || !portletMode.toString().equalsIgnoreCase("view")) {
testBean.setTestResult(false, "encodeActionURL incorrectly encoded the invalid portlet mode. The resulting request should have ignored the invalid mode and remained in 'view' mode.");
return Constants.TEST_FAILED;
}
// Check that the parameter came along too
String paramValue = facesContext.getExternalContext().getRequestParameterMap().get("param1");
if (paramValue == null) {
testBean.setTestResult(false, "encodeActionURL incorrectly encoded a portlet action URL containing an invalid mode and parameter. The resulting request didn't contain the expected 'param1' parameter.");
return Constants.TEST_FAILED;
}
if (!paramValue.equals("testValue")) {
testBean.setTestResult(false, "encodeActionURL incorrectly encoded a portlet action URL containing an invalid mode and parameter. The resulting request contained the wrong parameter value. Expected: testValue Received: " + paramValue);
return Constants.TEST_FAILED;
}
testBean.setTestResult(true, "encodeActionURL correctly encoded a portlet action URL by ignoring the invalid mode and properly encoding the parameter.");
return Constants.TEST_SUCCESS;
}
}
use of com.liferay.faces.bridge.tck.annotation.BridgeTest in project liferay-faces-bridge-impl by liferay.
the class EncodeActionURLTests method encodeActionURLWithInvalidModeRenderTest.
// Test is MultiRequest -- Render/Action
// Test #6.20
@BridgeTest(test = "encodeActionURLWithInvalidModeRenderTest")
public String encodeActionURLWithInvalidModeRenderTest(TestBean testBean) {
// This tests that we can encode an invalid mode 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
PortletMode portletMode = portletRequest.getPortletMode();
// Check that the parameter came along too
String paramValue = facesContext.getExternalContext().getRequestParameterMap().get("param1");
if ((portletMode == null) || !portletMode.toString().equalsIgnoreCase("view")) {
testBean.setTestResult(false, "encodeActionURL incorrectly encoded the invalid portlet mode. The resulting request should have ignored the invalid mode and remained in 'view' mode.");
} else if (paramValue == null) {
testBean.setTestResult(false, "encodeActionURL incorrectly encoded a portlet action URL containing an invalid mode 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 mode 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 mode and properly encoding the parameter.");
}
// action Navigation result
return "encodeActionURLWithInvalidModeActionTest";
} 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 encodeActionURLWithModeEventTest.
// Test is MultiRequest -- Render/Action
// Test #6.104
@BridgeTest(test = "encodeActionURLWithModeEventTest")
public String encodeActionURLWithModeEventTest(TestBean testBean) {
FacesContext facesContext = FacesContext.getCurrentInstance();
ExternalContext externalContext = facesContext.getExternalContext();
// This tests that we can encode a new mode in an actionURL done by navigation rule.
if (BridgeUtil.getPortletRequestPhase(facesContext) == Bridge.PortletPhase.ACTION_PHASE) {
// Create and raise the event
StateAwareResponse stateAwareResponse = (StateAwareResponse) externalContext.getResponse();
stateAwareResponse.setEvent(new QName(Constants.EVENT_QNAME, Constants.EVENT_NAME), testBean.getTestName());
// action Navigation result
return Constants.TEST_SUCCESS;
} else {
testBean.setTestComplete(true);
PortletRequest portletRequest = (PortletRequest) facesContext.getExternalContext().getRequest();
// Parameter/Mode encoded in the faces-config.xml target
PortletMode portletMode = portletRequest.getPortletMode();
if ((portletMode == null) || !portletMode.toString().equalsIgnoreCase("edit")) {
testBean.setTestResult(false, "encodeActionURL incorrectly encoded the new portlet mode. The resulting request wasn't in the expected 'edit' mode.");
return Constants.TEST_FAILED;
}
// Check that the parameter came along too
String paramValue = facesContext.getExternalContext().getRequestParameterMap().get("param1");
if (paramValue == null) {
testBean.setTestResult(false, "encodeActionURL incorrectly encoded a portlet action URL containing a new mode and parameter during the event phase. The resulting request didn't contain the expected 'param1' parameter.");
return Constants.TEST_FAILED;
}
if (!paramValue.equals("testValue")) {
testBean.setTestResult(false, "encodeActionURL incorrectly encoded a portlet action URL containing a new mode and parameter during the event phase. The resulting request contained the wrong parameter value. Expected: testValue Received: " + paramValue);
return Constants.TEST_FAILED;
}
testBean.setTestResult(true, "encodeActionURL correctly encoded a portlet action URL containing a new mode and parameter during the event phase.");
return Constants.TEST_SUCCESS;
}
}
Aggregations