HttpHeaderResultTestpublic class HttpHeaderResultTest extends org.apache.struts2.StrutsTestCase
Fields Summary |
---|
com.opensymphony.xwork2.ActionInvocation | invocation | HttpHeaderResult | result | HttpServletResponse | response | com.mockobjects.dynamic.Mock | responseMock |
Methods Summary |
---|
protected void | setUp()
super.setUp();
result = new HttpHeaderResult();
responseMock = new Mock(HttpServletResponse.class);
response = (HttpServletResponse) responseMock.proxy();
invocation = (ActionInvocation) new Mock(ActionInvocation.class).proxy();
ServletActionContext.setResponse(response);
XWorkConverter.getInstance().setObjectTypeDeterminer(ObjectTypeDeterminerFactory.getInstance());
| protected void | tearDown()
super.tearDown();
ServletActionContext.setResponse(null);
ActionContext.setContext(null);
XWorkConverter.resetInstance();
| public void | testHeaderValuesAreNotParsedWhenParseIsFalse()
Map params = new HashMap();
params.put("headers.foo", "${bar}");
params.put("headers.baz", "baz");
Map values = new HashMap();
values.put("bar", "abc");
ActionContext.getContext().getValueStack().push(values);
OgnlUtil.setProperties(params, result);
responseMock.expect("addHeader", C.args(C.eq("foo"), C.eq("${bar}")));
responseMock.expect("addHeader", C.args(C.eq("baz"), C.eq("baz")));
result.setParse(false);
result.execute(invocation);
responseMock.verify();
| public void | testHeaderValuesAreParsedAndSet()
Map params = new HashMap();
params.put("headers.foo", "${bar}");
params.put("headers.baz", "baz");
Map values = new HashMap();
values.put("bar", "abc");
ActionContext.getContext().getValueStack().push(values);
OgnlUtil.setProperties(params, result);
responseMock.expect("addHeader", C.args(C.eq("foo"), C.eq("abc")));
responseMock.expect("addHeader", C.args(C.eq("baz"), C.eq("baz")));
result.execute(invocation);
responseMock.verify();
| public void | testStatusIsSet()
responseMock.expect("setStatus", C.eq(123));
result.setStatus(123);
result.execute(invocation);
responseMock.verify();
|
|