use of com.liferay.faces.bridge.tck.annotation.BridgeTest in project liferay-faces-bridge-impl by liferay.
the class TestsCDI1 method actionRequestAlternativeTest.
@BridgeTest(test = "actionRequestAlternativeTest")
public String actionRequestAlternativeTest(TestBean testBean) {
FacesContext facesContext = FacesContext.getCurrentInstance();
Bridge.PortletPhase portletPhase = BridgeUtil.getPortletRequestPhase(facesContext);
if (portletPhase == Bridge.PortletPhase.ACTION_PHASE) {
bridgeRequestScopedBean.setFoo(actionRequest.getClass().getSimpleName());
return "multiRequestTestResultRenderCheck";
} else if (portletPhase == Bridge.PortletPhase.HEADER_PHASE) {
if ("ActionRequestTCKImpl".equals(bridgeRequestScopedBean.getFoo())) {
testBean.setTestResult(true, "The bridge's alternative producer for ActionRequest was properly invoked");
return Constants.TEST_SUCCESS;
} else {
testBean.setTestResult(false, "The bridge's alternative producer for ActionRequest was not invoked");
return Constants.TEST_FAILED;
}
}
testBean.setTestResult(false, "Unexpected portletPhase=" + portletPhase);
return Constants.TEST_FAILED;
}
use of com.liferay.faces.bridge.tck.annotation.BridgeTest in project liferay-faces-bridge-impl by liferay.
the class TestsCDI1 method stateAwareResponseAlternativeTest.
@BridgeTest(test = "stateAwareResponseAlternativeTest")
public String stateAwareResponseAlternativeTest(TestBean testBean) {
FacesContext facesContext = FacesContext.getCurrentInstance();
Bridge.PortletPhase portletPhase = BridgeUtil.getPortletRequestPhase(facesContext);
if (portletPhase == Bridge.PortletPhase.ACTION_PHASE) {
bridgeRequestScopedBean.setFoo(stateAwareResponse.getClass().getSimpleName());
return "multiRequestTestResultRenderCheck";
} else if (portletPhase == Bridge.PortletPhase.HEADER_PHASE) {
if ("ActionResponseTCKImpl".equals(bridgeRequestScopedBean.getFoo())) {
testBean.setTestResult(true, "The bridge's alternative producer for StateAwareResponse was properly invoked");
return Constants.TEST_SUCCESS;
} else {
testBean.setTestResult(false, "The bridge's alternative producer for StateAwareResponse was not invoked");
return Constants.TEST_FAILED;
}
}
testBean.setTestResult(false, "Unexpected portletPhase=" + portletPhase);
return Constants.TEST_FAILED;
}
use of com.liferay.faces.bridge.tck.annotation.BridgeTest in project liferay-faces-bridge-impl by liferay.
the class TestsCDI1 method bridgeRequestScopedBeanTest.
@BridgeTest(test = "bridgeRequestScopedBeanTest")
public String bridgeRequestScopedBeanTest(TestBean testBean) {
FacesContext facesContext = FacesContext.getCurrentInstance();
Bridge.PortletPhase portletPhase = BridgeUtil.getPortletRequestPhase(facesContext);
if (portletPhase == Bridge.PortletPhase.ACTION_PHASE) {
bridgeRequestScopedBean.setFoo("setInActionPhase");
return "multiRequestTestResultRenderCheck";
} else if (portletPhase == Bridge.PortletPhase.HEADER_PHASE) {
testBean.setTestComplete(true);
if ("setInActionPhase".equals(bridgeRequestScopedBean.getFoo())) {
testBean.setTestResult(true, "@BridgeRequestScoped is behaving like faces-config <managed-bean> <scope>request</scope> (bridge request scope)");
return Constants.TEST_SUCCESS;
} else {
testBean.setTestResult(false, "@BridgeRequestScoped is behaving like @PortletRequestScoped");
return Constants.TEST_FAILED;
}
}
testBean.setTestResult(false, "Unexpected portletPhase=" + portletPhase);
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 portletRequestScopedBeanExtensionTest.
@BridgeTest(test = "portletRequestScopedBeanExtensionTest")
public String portletRequestScopedBeanExtensionTest(TestBean testBean) {
FacesContext facesContext = FacesContext.getCurrentInstance();
Bridge.PortletPhase portletPhase = BridgeUtil.getPortletRequestPhase(facesContext);
if (portletPhase == Bridge.PortletPhase.ACTION_PHASE) {
portletRequestScopedBeanExtension.setFoo("setInActionPhase");
return "multiRequestTestResultRenderCheck";
} else if (portletPhase == Bridge.PortletPhase.HEADER_PHASE) {
testBean.setTestComplete(true);
if ("setInActionPhase".equals(portletRequestScopedBeanExtension.getFoo())) {
testBean.setTestResult(true, "@PortletRequestScoped is behaving like faces-config <managed-bean> <scope>request</scope> (bridge request scope)");
return Constants.TEST_SUCCESS;
} else {
testBean.setTestResult(false, "@PortletRequestScoped is behaving like Portlet 3.0 @PortletRequestScoped rather than @BridgeRequestScoped");
return Constants.TEST_FAILED;
}
}
testBean.setTestResult(false, "Unexpected portletPhase=" + portletPhase);
return Constants.TEST_FAILED;
}
use of com.liferay.faces.bridge.tck.annotation.BridgeTest in project liferay-faces-bridge-impl by liferay.
the class EncodeActionURLResourceTests method encodeActionURLWithModeResourceTest.
// Test is MultiRequest -- Render/Action
// Test #6.112
@BridgeTest(test = "encodeActionURLWithModeResourceTest")
public String encodeActionURLWithModeResourceTest(TestBean testBean) {
// Somewhat of a weird test -- we can't test this directly in that there isn't a way to encode an JSF view
// actionURL into the response of the resource and have it clicked on. We also can't generate such an url and
// compare against the one generated by the underlying response because encodeActionURL will encode the JSF view
// into the returned string in a manner that is bridge impl specific (so we can't account for this encoding). So
// instead, perform the same encoding in both other phased request and the resource request. If they are the
// same then the test passes. This works (indirectly) because we have an existing test that verifies this
// encoding during a render/action phase. So the presumption is if it works for render/action and you get the
// same url during from the encoding during a resource then all is good.
FacesContext facesContext = FacesContext.getCurrentInstance();
ExternalContext externalContext = facesContext.getExternalContext();
Map<String, Object> requestMap = externalContext.getRequestMap();
Map<String, Object> sessionMap = externalContext.getSessionMap();
final String ENCODE_ACTIONURL_TEST_STRING = "/tests/viewLink.jsf?javax.portlet.faces.PortletMode=edit¶m1=testValue";
// ensure this url is prefixed by the ContextPath as all encode routines expect this for things starting with /
String testString = externalContext.getRequestContextPath() + ENCODE_ACTIONURL_TEST_STRING;
if (BridgeUtil.getPortletRequestPhase(facesContext) == Bridge.PortletPhase.RESOURCE_PHASE) {
// mark the resource request as having occurred so the button changes names appropriately
requestMap.put("com.liferay.faces.bridge.tck.pprSubmitted", Boolean.TRUE);
// Now run the test
testBean.setTestComplete(true);
// PortletContainers can return "URLs" with strict XML encoding -- as the bridge
// encoding depends on what is past in to it -- make sure we send in a string
// with the same encoding as compare string.
String resourceEncoded = externalContext.encodeActionURL(testString);
String otherPhaseEncoded = (String) sessionMap.get("com.liferay.faces.bridge.tck.encodedURL");
// remove it for future/other tests
sessionMap.remove("com.liferay.faces.bridge.tck.encodedURL");
if (otherPhaseEncoded == null) {
testBean.setTestResult(false, "test failed because it relies on comparing the encoded result with one generated during a prior phase, however the one generated from the prior phase isn't there.");
return Constants.TEST_FAILED;
} else if (resourceEncoded.equals(otherPhaseEncoded)) {
testBean.setTestResult(true, "encodeActionURL correctly encoded a JSF View url with mode as an actionURL during a resource request.");
return Constants.TEST_SUCCESS;
} else {
testBean.setTestResult(false, "encodeActionURL incorrectly encoded a JSF View url with mode as an actionURL during a resource request. In encoding: " + testString + " the bridge returned: " + resourceEncoded + " but the corresponding portletURL encoding returned: " + otherPhaseEncoded);
return Constants.TEST_FAILED;
}
}
// Otherwise -- no output
if (sessionMap.get("com.liferay.faces.bridge.tck.encodedURL") == null) {
sessionMap.put("com.liferay.faces.bridge.tck.encodedURL", externalContext.encodeActionURL(testString));
}
return "";
}
Aggregations