use of com.liferay.faces.bridge.tck.annotation.BridgeTest in project liferay-faces-bridge-impl by liferay.
the class Tests method portletNamingContainerClientIdTest.
// Test is SingleRequest -- Render
// Test #6.91
@BridgeTest(test = "portletNamingContainerClientIdTest")
public String portletNamingContainerClientIdTest(TestBean testBean) {
FacesContext facesContext = FacesContext.getCurrentInstance();
UIViewRoot uiViewRoot = facesContext.getViewRoot();
String namespace = ((MimeResponse) facesContext.getExternalContext().getResponse()).getNamespace();
testBean.setTestComplete(true);
if (uiViewRoot.getClass().getAnnotation(PortletNamingContainer.class) != null) {
if (uiViewRoot.getContainerClientId(facesContext).indexOf(namespace) >= 0) {
testBean.setTestResult(true, "UIViewRoot getClientContainerId includes the portlet namespace id.");
return Constants.TEST_SUCCESS;
} else {
testBean.setTestResult(false, "UIViewRoot getClientContainerId doesn not includes the portlet namespace id.");
return Constants.TEST_FAILED;
}
} else {
testBean.setTestResult(false, "UIViewRoot is not annotated with javax.portlet.faces.annotation.PortletNamingContainer.");
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 eventScopeNotRestoredModeChangedTest.
// Test is MultiRequest -- Render/Action
// Test # -- 5.50
@BridgeTest(test = "eventScopeNotRestoredModeChangedTest")
public String eventScopeNotRestoredModeChangedTest(TestBean testBean) {
FacesContext facesContext = FacesContext.getCurrentInstance();
ExternalContext externalContext = facesContext.getExternalContext();
// are explicitly excluded -- test for presence/absence in render
if (BridgeUtil.getPortletRequestPhase(facesContext) == Bridge.PortletPhase.ACTION_PHASE) {
// Clear settings from previous run of the test
externalContext.getSessionMap().put(Ch5TestEventHandler.EVENT_RECEIVED, null);
externalContext.getSessionMap().put(Ch5TestEventHandler.EVENT_TEST_FAILED, null);
// Place a request attr in scope so we can make sure its not there later
externalContext.getRequestMap().put(Ch5TestEventHandler.EVENTATTR, testBean.getTestName());
// 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 "eventScopeNotRestoredModeChangedTest";
} else {
testBean.setTestComplete(true);
// Values set by portlet at end of action
Event event = (Event) externalContext.getSessionMap().get(Ch5TestEventHandler.EVENT_RECEIVED);
String failedMsg = (String) externalContext.getSessionMap().get(Ch5TestEventHandler.EVENT_TEST_FAILED);
String payload = (String) externalContext.getRequestMap().get(Ch5TestEventHandler.EVENTATTR);
if (event == null) {
testBean.setTestResult(false, "Raised event wasn't received.");
return Constants.TEST_FAILED;
} else if (failedMsg != null) {
testBean.setTestResult(false, failedMsg);
return Constants.TEST_FAILED;
} else if (payload != null) {
testBean.setTestResult(false, "Event navigation indicated a mode change but the request scope was preserved.");
return Constants.TEST_FAILED;
} else {
testBean.setTestResult(true, "Request scope not preserved after event navigation indicated a mode change.");
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 facesContextReleasedActionTest.
// Test is MultiRequest -- Render/Action
// Test #5.25
@BridgeTest(test = "facesContextReleasedActionTest")
public String facesContextReleasedActionTest(TestBean testBean) {
FacesContext facesContext = FacesContext.getCurrentInstance();
ExternalContext externalContext = facesContext.getExternalContext();
// are explicitly excluded -- test for presence/absence in render
if (BridgeUtil.getPortletRequestPhase(facesContext) == Bridge.PortletPhase.ACTION_PHASE) {
// action Navigation result
return "facesContextReleasedActionTest";
} else {
testBean.setTestComplete(true);
// Values set by portlet at end of action
boolean result = ((Boolean) externalContext.getSessionMap().get("org.apache.portlet.faces.tck.testResult")).booleanValue();
testBean.setTestResult(result, (String) externalContext.getSessionMap().get("org.apache.portlet.faces.tck.testDetail"));
if (result) {
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 viewIdWithParam_2_Test.
// Test is MultiRequest -- Render/Action
// Test #5.20 (second test of 2) -- viewId set in the default viewId (initparam)
@BridgeTest(test = "viewIdWithParam_2_Test")
public String viewIdWithParam_2_Test(TestBean testBean) {
FacesContext facesContext = FacesContext.getCurrentInstance();
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, "Bridge correctly included parameter from viewId querystring when using default viewId.");
return Constants.TEST_SUCCESS;
} else {
if (paramValue == null) {
testBean.setTestResult(false, "Bridge didn't included parameter from viewId querystring when using default viewId.");
} else {
testBean.setTestResult(false, "Bridge didn't properly include parameter from viewId querystring when using default viewId. 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 Tests method scopeNotRestoredResourceTest.
// Test is MultiRequest -- Render/Action
// Test # -- 5.65
@BridgeTest(test = "scopeNotRestoredResourceTest")
public String scopeNotRestoredResourceTest(TestBean testBean) {
FacesContext facesContext = FacesContext.getCurrentInstance();
ExternalContext externalContext = facesContext.getExternalContext();
Map<String, Object> requestMap = externalContext.getRequestMap();
if (BridgeUtil.getPortletRequestPhase(facesContext) == Bridge.PortletPhase.ACTION_PHASE) {
// set a request scoped attr and then continue
requestMap.put("testAttr", testBean.getTestName());
return "scopeNotRestoredResourceTest";
}
// are explicitly excluded -- test for presence/absence in render
if (BridgeUtil.getPortletRequestPhase(facesContext) == Bridge.PortletPhase.RESOURCE_PHASE) {
String s = (String) requestMap.get("testAttr");
if (s == null) {
testBean.setTestResult(true, "Resource request correctly executed without restoring request scope.");
return Constants.TEST_SUCCESS;
} else {
testBean.setTestResult(false, "Resource request incorrectly has restored the request scope.");
return Constants.TEST_FAILED;
}
} else {
return "";
}
}
Aggregations