use of com.walmartlabs.concord.plugins.s3.Result in project struts by apache.
the class XSLTResultTest method testPassingNullInvocation.
public void testPassingNullInvocation() throws Exception {
Result result = new XSLTResult();
try {
result.execute(null);
fail("Exception should be thrown!");
} catch (IllegalArgumentException e) {
assertEquals("Invocation cannot be null!", e.getMessage());
}
}
use of com.walmartlabs.concord.plugins.s3.Result in project struts by apache.
the class SpringObjectFactoryTest method testFallsBackToDefaultObjectFactoryResultBuilding.
public void testFallsBackToDefaultObjectFactoryResultBuilding() throws Exception {
ResultConfig rConfig = new ResultConfig.Builder(Action.SUCCESS, ActionChainResult.class.getName()).build();
Result result = objectFactory.buildResult(rConfig, ActionContext.getContext().getContextMap());
assertEquals(ActionChainResult.class, result.getClass());
}
use of com.walmartlabs.concord.plugins.s3.Result in project struts by apache.
the class DefaultResultFactory method buildResult.
public Result buildResult(ResultConfig resultConfig, Map<String, Object> extraContext) throws Exception {
String resultClassName = resultConfig.getClassName();
Result result = null;
if (resultClassName != null) {
result = (Result) objectFactory.buildBean(resultClassName, extraContext);
Map<String, String> params = resultConfig.getParams();
if (params != null) {
for (Map.Entry<String, String> paramEntry : params.entrySet()) {
try {
reflectionProvider.setProperty(paramEntry.getKey(), paramEntry.getValue(), result, extraContext, true);
} catch (ReflectionException ex) {
if (result instanceof ReflectionExceptionHandler) {
((ReflectionExceptionHandler) result).handle(ex);
}
}
}
}
}
return result;
}
use of com.walmartlabs.concord.plugins.s3.Result in project struts by apache.
the class PlainResultTest method testPassingNullInvocation.
public void testPassingNullInvocation() throws Exception {
Result result = (PlainResult) response -> response.write("ignore");
try {
result.execute(null);
fail("Exception should be thrown!");
} catch (IllegalArgumentException e) {
assertEquals("Invocation cannot be null!", e.getMessage());
}
}
use of com.walmartlabs.concord.plugins.s3.Result in project struts by apache.
the class StrutsResultFactoryTest method testAcceptParams.
public void testAcceptParams() throws Exception {
// given
initDispatcherWithConfigs("struts-default.xml");
StrutsResultFactory builder = (StrutsResultFactory) container.getInstance(ResultFactory.class);
Map<String, String> params = new HashMap<String, String>();
params.put("accept", "ok");
params.put("reject", "bad");
ResultConfig config = new ResultConfig.Builder("struts", MyResult.class.getName()).addParams(params).build();
// when
Result result = builder.buildResult(config, ActionContext.getContext().getContextMap());
// then
assertEquals("ok", ((MyResult) result).getAccept());
assertEquals("ok", ((MyResult) result).getReject());
}
Aggregations