use of com.liferay.faces.bridge.tck.annotation.BridgeTest in project liferay-faces-bridge-impl by liferay.
the class ScopeCommonTests method scopeAfterRedisplayResourcePPRTestListener.
// ActionListener
@BridgeTest(test = "scopeAfterRedisplayResourcePPRTestActionListener")
public void scopeAfterRedisplayResourcePPRTestListener(TestBean testBean, ActionEvent action) {
FacesContext facesContext = FacesContext.getCurrentInstance();
ExternalContext externalContext = facesContext.getExternalContext();
Map<String, Object> requestMap = externalContext.getRequestMap();
requestMap.put("com.liferay.faces.bridge.tck.pprSubmitted", Boolean.TRUE);
}
use of com.liferay.faces.bridge.tck.annotation.BridgeTest in project liferay-faces-bridge-impl by liferay.
the class Tests method isPortletNamingContainerTest.
// Test is SingleRequest -- Render
// Test #6.86
@BridgeTest(test = "isPortletNamingContainerTest")
public String isPortletNamingContainerTest(TestBean testBean) {
UIViewRoot uiViewRoot = FacesContext.getCurrentInstance().getViewRoot();
testBean.setTestComplete(true);
if (uiViewRoot.getClass().getAnnotation(PortletNamingContainer.class) != null) {
testBean.setTestResult(true, "UIViewRoot is correctly annotated with javax.portlet.faces.annotation.PortletNamingContainer.");
return Constants.TEST_SUCCESS;
} 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 processPRPInRestoreViewPhaseTest.
// Test is MultiRequest -- Render/Action
// Test #5.69
@BridgeTest(test = "processPRPInRestoreViewPhaseTest")
public String processPRPInRestoreViewPhaseTest(TestBean testBean) {
FacesContext facesContext = FacesContext.getCurrentInstance();
ExternalContext externalContext = facesContext.getExternalContext();
if (BridgeUtil.getPortletRequestPhase(facesContext) == Bridge.PortletPhase.ACTION_PHASE) {
if (externalContext.getSessionMap().get("tck.processPRPInRestoreViewPhaseTest.modelPRPSet") == null) {
externalContext.getRequestMap().put("modelPRP", testBean.getTestName());
externalContext.getRequestMap().put("modelPRP2", testBean.getTestName());
// Put it on the request Map -- to carry forward to the render -- which will set it on the session --
// this avoids having the render that follows this action from thinking the test is done.
externalContext.getRequestMap().put("tck.processPRPInRestoreViewPhaseTest.modelPRPSet", Boolean.TRUE);
// returns from edit mode
return "processPRPInRestoreViewPhaseTest";
} else {
return "processPRPInRestoreViewPhaseTestResult";
}
} else {
if (Boolean.TRUE.equals((Boolean) externalContext.getSessionMap().get("tck.processPRPInRestoreViewPhaseTest.modelPRPSet"))) {
testBean.setTestComplete(true);
externalContext.getSessionMap().remove("tck.processPRPInRestoreViewPhaseTest.modelPRPSet");
// Marked as true in the phaseListener so command link name would change.
externalContext.getSessionMap().remove("com.liferay.faces.bridge.tck.testCompleted");
if (externalContext.getRequestMap().get("tck.notSetBeforeRestoreView") == null) {
testBean.setTestResult(false, "PRP set before RestoreView phase. It should be set after the RestoreView phase and before other phases.");
return Constants.TEST_FAILED;
} else if (externalContext.getRequestMap().get("tck.setAfterRestoreView") == null) {
testBean.setTestResult(false, "PRP not set in the after RestoreView phase. It wasn't set in any of the other phases before phase.");
return Constants.TEST_FAILED;
} else {
testBean.setTestResult(true, "PRP correctly updated the model after the RestoreView phase and before other phases.");
return Constants.TEST_SUCCESS;
}
} else {
if (externalContext.getRequestMap().get("tck.processPRPInRestoreViewPhaseTest.modelPRPSet") != null) {
// Place on session so next action triggers running the test.
externalContext.getSessionMap().put("tck.processPRPInRestoreViewPhaseTest.modelPRPSet", Boolean.TRUE);
}
return "Test is still being run.";
}
}
}
use of com.liferay.faces.bridge.tck.annotation.BridgeTest in project liferay-faces-bridge-impl by liferay.
the class Tests method prpModelUpdateTest.
// Test is MultiRequest -- Render/Action
// Test #5.70 and 5.71
@BridgeTest(test = "prpModelUpdateTest")
public String prpModelUpdateTest(TestBean testBean) {
FacesContext facesContext = FacesContext.getCurrentInstance();
ExternalContext externalContext = facesContext.getExternalContext();
if (BridgeUtil.getPortletRequestPhase(facesContext) == Bridge.PortletPhase.ACTION_PHASE) {
if (externalContext.getSessionMap().get("tck.prpModelUpdateTest.modelPRPSet") == null) {
externalContext.getRequestMap().put("modelPRP", testBean.getTestName());
externalContext.getRequestMap().put("modelPRP2", testBean.getTestName());
// Put it on the request Map -- to carry forward to the render -- which will set it on the session --
// this avoids having the render that follows this action from thinking the test is done.
externalContext.getRequestMap().put("tck.prpModelUpdateTest.modelPRPSet", Boolean.TRUE);
// returns from edit mode
return "prpModelUpdateTest";
} else {
return "prpModelUpdateTest";
}
} else {
if (Boolean.TRUE.equals((Boolean) externalContext.getSessionMap().get("tck.prpModelUpdateTest.modelPRPSet"))) {
testBean.setTestComplete(true);
externalContext.getSessionMap().remove("tck.prpModelUpdateTest.modelPRPSet");
String modelPRP = (String) externalContext.getRequestMap().get("modelPRP");
String modelPRP2 = (String) externalContext.getRequestMap().get("modelPRP2");
if (modelPRP == null) {
testBean.setTestResult(false, "Expect 'modelPRP' PRP not set.");
return Constants.TEST_FAILED;
} else if (!modelPRP.equals(testBean.getTestName())) {
testBean.setTestResult(false, "Expect 'modelPRP' doesn't have expected value. Expected: " + testBean.getTestName() + " but PRP has a value of: " + modelPRP);
return Constants.TEST_FAILED;
} else if (modelPRP2 == null) {
testBean.setTestResult(false, "Expect 'modelPRP2' PRP not set.");
return Constants.TEST_FAILED;
} else if (!modelPRP2.equals(testBean.getTestName())) {
testBean.setTestResult(false, "Expect 'modelPRP2' doesn't have expected value. Expected: " + testBean.getTestName() + " but PRP has a value of: " + modelPRP2);
return Constants.TEST_FAILED;
} else if (externalContext.getRequestMap().get("tck.prpProcessUpdatesCalled") == null) {
testBean.setTestResult(false, "Though incoming PRPs updated their models, the registered processUpdates handler wasn't called.");
return Constants.TEST_FAILED;
} else {
testBean.setTestResult(true, "Both PRPs correctly updated their models with expected values and the processUpdates handler was called.");
return Constants.TEST_SUCCESS;
}
} else {
if (externalContext.getRequestMap().get("tck.prpModelUpdateTest.modelPRPSet") != null) {
// Place on session so next action triggers running the test.
externalContext.getSessionMap().put("tck.prpModelUpdateTest.modelPRPSet", Boolean.TRUE);
}
return "Test is still being run.";
}
}
}
use of com.liferay.faces.bridge.tck.annotation.BridgeTest in project liferay-faces-bridge-impl by liferay.
the class Tests method getResponseCharacterEncodingActionTest.
// Test #6.61
@BridgeTest(test = "getResponseCharacterEncodingActionTest")
public String getResponseCharacterEncodingActionTest(TestBean testBean) {
FacesContext facesContext = FacesContext.getCurrentInstance();
ExternalContext externalContext = facesContext.getExternalContext();
if (BridgeUtil.getPortletRequestPhase(facesContext) == Bridge.PortletPhase.ACTION_PHASE) {
try {
String encoding = externalContext.getResponseCharacterEncoding();
testBean.setTestResult(false, "externalContext.getResponseCharacterEncoding() didn't throw an IllegalStateException when called during an Action.");
} catch (IllegalStateException e) {
testBean.setTestResult(true, "externalContext.getResponseCharacterEncoding() correctly threw an IllegalStateException when called during an Action.");
}
return "getResponseCharacterEncodingActionTest";
} else {
testBean.setTestComplete(true);
if (testBean.getTestStatus()) {
return Constants.TEST_SUCCESS;
} else {
return Constants.TEST_FAILED;
}
}
}
Aggregations