use of com.opensymphony.xwork2.Result in project struts by apache.
the class TokenInterceptorTest method testCAllExecute2Times.
public void testCAllExecute2Times() throws Exception {
setToken(request);
ActionProxy proxy = buildProxy(getActionName());
assertEquals(Action.SUCCESS, proxy.execute());
ActionProxy proxy2 = buildProxy(getActionName());
// must not call setToken
// double post will result in a invalid.token return code
assertEquals(TokenInterceptor.INVALID_TOKEN_CODE, proxy2.execute());
}
use of com.opensymphony.xwork2.Result in project struts by apache.
the class HttpHeaderResultTest method setUp.
protected void setUp() throws Exception {
super.setUp();
result = new HttpHeaderResult();
responseMock = new Mock(HttpServletResponse.class);
response = (HttpServletResponse) responseMock.proxy();
invocationMock = new Mock(ActionInvocation.class);
invocationMock.expectAndReturn("getInvocationContext", ActionContext.getContext());
invocationMock.expectAndReturn("getStack", ActionContext.getContext().getValueStack());
invocation = (ActionInvocation) invocationMock.proxy();
reflectionProvider = container.getInstance(ReflectionProvider.class);
ServletActionContext.setResponse(response);
}
use of com.opensymphony.xwork2.Result in project struts by apache.
the class ExecuteAndWaitInterceptorTest method testFromDeserializedSession.
public void testFromDeserializedSession() throws Exception {
waitInterceptor.setDelay(0);
waitInterceptor.setDelaySleepInterval(0);
ActionProxy proxy = buildProxy("action1");
String result = proxy.execute();
assertEquals("wait", result);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
// WW-4900 action1 and invocation are not serializable but we should not fail at this line
oos.writeObject(session);
oos.close();
byte[] b = baos.toByteArray();
baos.close();
ByteArrayInputStream bais = new ByteArrayInputStream(b);
ObjectInputStream ois = new ObjectInputStream(bais);
session = (Map<String, Object>) ois.readObject();
context = ActionContext.of(context).withSession(session).getContextMap();
ois.close();
bais.close();
Thread.sleep(1000);
ActionProxy proxy2 = buildProxy("action1");
String result2 = proxy2.execute();
// WW-4900 A new thread should be started when background thread missed
assertEquals("wait", result2);
Thread.sleep(1000);
ActionProxy proxy3 = buildProxy("action1");
String result3 = proxy3.execute();
assertEquals("success", result3);
}
use of com.opensymphony.xwork2.Result in project struts by apache.
the class ExecuteAndWaitInterceptorTest method testOneWait.
public void testOneWait() throws Exception {
waitInterceptor.setDelay(0);
waitInterceptor.setDelaySleepInterval(0);
ActionProxy proxy = buildProxy("action1");
String result = proxy.execute();
assertEquals("wait", result);
Thread.sleep(1000);
ActionProxy proxy2 = buildProxy("action1");
String result2 = proxy2.execute();
assertEquals("success", result2);
}
use of com.opensymphony.xwork2.Result in project struts by apache.
the class ExecuteAndWaitInterceptorTest method testWaitDelayAndJobAlreadyDone2.
public void testWaitDelayAndJobAlreadyDone2() throws Exception {
waitInterceptor.setDelay(1500);
// just takes a little longer to find out job is done
waitInterceptor.setDelaySleepInterval(200);
ActionProxy proxy = buildProxy("action1");
long before = System.currentTimeMillis();
String result = proxy.execute();
long diff = System.currentTimeMillis() - before;
assertEquals("success", result);
assertTrue("Job done already after 500 so there should not be such long delay", diff <= 1000);
}
Aggregations