use of com.liferay.faces.bridge.tck.annotation.BridgeTest in project liferay-faces-bridge-impl by liferay.
the class Tests method lifecycleTest.
/*
* Because Lifecycle_ID is a web.xml (application) config setting we need a different portlet app for each test.
* Because of this we can test all policies in a single test method.
*/
@BridgeTest(test = "lifecycleTest")
public String lifecycleTest(TestBean testBean) {
Boolean pass = false;
String msg;
// Get the configured render policy
ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
Map<String, Object> requestMap = externalContext.getRequestMap();
// Lifecycle check done in the FacesContextFactory -- so test/results set on every request
msg = (String) requestMap.get("javax.portlet.faces.tck.testLifecyclePass");
if (msg != null) {
pass = true;
} else {
msg = (String) requestMap.get("javax.portlet.faces.tck.testLifecycleFail");
}
// remove them in case we are called to render more than once
requestMap.remove("javax.portlet.faces.tck.testLifecyclePass");
requestMap.remove("javax.portlet.faces.tck.testLifecycleFail");
testBean.setTestResult(pass, msg);
if (pass) {
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 portletSetsViewPathTest.
@BridgeTest(test = "portletSetsViewPathTest")
public String portletSetsViewPathTest(TestBean testBean) {
FacesContext facesContext = FacesContext.getCurrentInstance();
testBean.setTestComplete(true);
// Are we in the rightview???
String s = facesContext.getViewRoot().getViewId();
if (s.contains("Success")) {
testBean.setTestResult(true, "correctly rendered the view explicitly set by the portlet: " + s);
return Constants.TEST_SUCCESS;
} else {
testBean.setTestResult(false, "didn't render the view 'PorletSetsViewIdSuccess.jsp' explicitly set by the portlet, instead rendered: " + s);
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 defaultRenderKitIdTest.
// Test #3.22
@BridgeTest(test = "defaultRenderKitIdTest")
public String defaultRenderKitIdTest(TestBean testBean) {
FacesContext facesContext = FacesContext.getCurrentInstance();
ExternalContext externalContext = facesContext.getExternalContext();
testBean.setTestComplete(true);
// Test that the defaultRenderKit parameter is set
String renderKitId = externalContext.getRequestParameterMap().get(ResponseStateManager.RENDER_KIT_ID_PARAM);
if (renderKitId == null) {
testBean.setTestResult(false, "ResponseStateManager.RENDER_KIT_ID_PARAM request parameter isn't set though this portlet has configured a defaultRenderKitId.");
return Constants.TEST_FAILED;
} else if (!renderKitId.equalsIgnoreCase(RenderKitFactory.HTML_BASIC_RENDER_KIT)) {
testBean.setTestResult(false, "ResponseStateManager.RENDER_KIT_ID_PARAM request parameter is set but has an incorrect value. Expected: " + RenderKitFactory.HTML_BASIC_RENDER_KIT + " received: " + renderKitId);
return Constants.TEST_FAILED;
}
testBean.setTestResult(true, "ResponseStateManager.RENDER_KIT_ID_PARAM request parameter properly set to value of defaultRenderKitId portlet initParam.");
return Constants.TEST_SUCCESS;
}
use of com.liferay.faces.bridge.tck.annotation.BridgeTest in project liferay-faces-bridge-impl by liferay.
the class Tests method portletSetsViewIdTest.
@BridgeTest(test = "portletSetsViewIdTest")
public String portletSetsViewIdTest(TestBean testBean) {
FacesContext facesContext = FacesContext.getCurrentInstance();
testBean.setTestComplete(true);
// Are we in the rightview???
String s = facesContext.getViewRoot().getViewId();
if (s.contains("Success")) {
testBean.setTestResult(true, "correctly rendered the view explicitly set by the portlet: " + s);
return Constants.TEST_SUCCESS;
} else {
testBean.setTestResult(false, "didn't render the view 'PorletSetsViewIdSuccess.jsp' explicitly set by the portlet, instead rendered: " + s);
return Constants.TEST_FAILED;
}
}
use of com.liferay.faces.bridge.tck.annotation.BridgeTest in project liferay-faces-bridge-impl by liferay.
the class ScopeCommonTests method scopeAfterRedisplayResourcePPRTest.
// Test is MultiRequest -- Render/Action
// Test # -- 5.66
@BridgeTest(test = "scopeAfterRedisplayResourcePPRTest")
public String scopeAfterRedisplayResourcePPRTest(TestBean testBean) {
FacesContext facesContext = FacesContext.getCurrentInstance();
ExternalContext externalContext = facesContext.getExternalContext();
Map<String, Object> requestMap = externalContext.getRequestMap();
Bridge.PortletPhase portletRequestPhase = BridgeUtil.getPortletRequestPhase(facesContext);
// parameter is true.
if (portletRequestPhase == Bridge.PortletPhase.RESOURCE_PHASE) {
requestMap.put("testAttr", testBean.getTestName());
return "";
} else // Otherwise, if this method is reached in the HEADER_PHASE of the portlet lifecycle, then
if (Bridge.PortletPhase.HEADER_PHASE.equals(portletRequestPhase)) {
String bridgeRequestScopeAjaxEnabledParam = externalContext.getInitParameter(Bridge.BRIDGE_REQUEST_SCOPE_AJAX_ENABLED);
boolean bridgeRequestScopeAjaxEnabled = "true".equalsIgnoreCase(bridgeRequestScopeAjaxEnabledParam);
// a re-render of the page which was invoked by a RenderURL.
if (externalContext.getRequestParameterMap().get("org.apache.portlet.faces.tck.redisplay") != null) {
testBean.setTestComplete(true);
// the portlet lifecycle when the "Run Test" button was clicked.
if (requestMap.get("com.liferay.faces.bridge.tck.pprSubmitted") != null) {
requestMap.remove("com.liferay.faces.bridge.tck.pprSubmitted");
// If the "pprSubmitted" request attribute has the expected value, then that means that this test
// method was properly called during the RESOURCE_PHASE of the portlet lifecycle.
Object testAttr = requestMap.get("testAttr");
if ((testAttr != null) && testAttr.equals(testBean.getTestName())) {
// If the bridge request scope is supposed to include Ajax requests, then the test has passed.
if (bridgeRequestScopeAjaxEnabled) {
testBean.setTestResult(true, "Redisplay after resource request CORRECTLY restored scoped attr that was added " + "during resource execution since the bridge request scope is supposed to include " + "Ajax requests.");
return Constants.TEST_SUCCESS;
} else // Otherwise, since the bridge request scope is not supposed to include Ajax requests, then
// the test has failed.
{
testBean.setTestResult(false, "Redisplay after resource request INCORRECTLY restored scoped attr that was added " + "during resource execution since the bridge request scope is not supposed to include " + "Ajax requests. NOTE: MAKE SURE YOU USED A NEW BROWSER TAB!");
return Constants.TEST_FAILED;
}
} else // Otherwise, the test has failed since the "pprSubmitted" request attribute does not have the
// expected value.
{
testBean.setTestResult(false, "Redisplay after resource request didn't restore the scoped attr that was added during " + "resource execution. NOTE: MAKE SURE YOU USED A NEW BROWSER TAB!");
return Constants.TEST_FAILED;
}
} else // Otherwise, since the "pprSubmitted" request attribute is not present, then
{
// portlet lifecycle into the RENDER_PHASE.
if (bridgeRequestScopeAjaxEnabled) {
testBean.setTestResult(false, "Redisplay after resource request INCORRECTLY did not restore the scoped attr that was " + "added during resource execution since the bridge request scope is supposed to include " + "Ajax requests. NOTE: MAKE SURE YOU USED A NEW BROWSER TAB!");
return Constants.TEST_FAILED;
} else // Otherwise, since the bridge request scope is not supposed to include Ajax requests, then the test
// is successful because the "pprSubmitted" attribute should not be preserved from the
// RESOURCE_PHASE of the portlet lifecycle into the RENDER_PHASE.
{
testBean.setTestResult(true, "Redisplay after resource request CORRECTLY did not restore the scoped attr that was added during " + "resource execution since the bridge request scope is not supposed to include Ajax requests.");
return Constants.TEST_SUCCESS;
}
}
}
}
// Otherwise -- no output
return "";
}
Aggregations