Methods Summary |
---|
protected com.opensymphony.xwork2.ActionProxy | buildProxy(java.lang.String actionName)
return actionProxyFactory.createActionProxy("", actionName, context);
|
protected void | setUp()
loadConfigurationProviders(new WaitConfigurationProvider());
session = new HashMap();
params = new HashMap();
context = new HashMap();
context.put(ActionContext.SESSION, session);
context.put(ActionContext.PARAMETERS, params);
request = new StrutsMockHttpServletRequest();
httpSession = new StrutsMockHttpSession();
request.setSession(httpSession);
request.setParameterMap(params);
context.put(ServletActionContext.HTTP_REQUEST, request);
|
protected void | tearDown()
configurationManager.clearConfigurationProviders();
configurationManager.destroyConfiguration();
ActionContext.setContext(null);
|
public void | testOneWait()
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);
|
public void | testOneWaitWithDelay()
waitInterceptor.setDelay(200);
waitInterceptor.setDelaySleepInterval(100);
ActionProxy proxy = buildProxy("action1");
long before = System.currentTimeMillis();
String result = proxy.execute();
long after = System.currentTimeMillis();
assertEquals("wait", result);
assertTrue("delay should be ca. 200 millis", (after - before) >= 190);
Thread.sleep(400);
ActionProxy proxy2 = buildProxy("action1");
String result2 = proxy2.execute();
assertEquals("success", result2);
|
public void | testTwoWait()
waitInterceptor.setDelay(0);
waitInterceptor.setDelaySleepInterval(0);
ActionProxy proxy = buildProxy("action1");
String result = proxy.execute();
assertEquals("wait", result);
Thread.sleep(300);
ActionProxy proxy2 = buildProxy("action1");
String result2 = proxy2.execute();
assertEquals("wait", result2);
Thread.sleep(300);
ActionProxy proxy3 = buildProxy("action1");
String result3 = proxy3.execute();
assertEquals("success", result3);
|
public void | testTwoWaitWithDelay()
waitInterceptor.setDelay(100);
waitInterceptor.setDelaySleepInterval(100);
ActionProxy proxy = buildProxy("action1");
long before = System.currentTimeMillis();
String result = proxy.execute();
long after = System.currentTimeMillis();
assertEquals("wait", result);
assertTrue("delay should be ca. 100 millis", (after - before) >= 90);
Thread.sleep(100);
ActionProxy proxy2 = buildProxy("action1");
long before2 = System.currentTimeMillis();
String result2 = proxy2.execute();
long after2 = System.currentTimeMillis();
assertEquals("wait", result2);
assertTrue("there should be no delay", (after2 - before2) < 110);
Thread.sleep(400);
ActionProxy proxy3 = buildProxy("action1");
String result3 = proxy3.execute();
assertEquals("success", result3);
|
public void | testWaitDelayAndJobAlreadyDone()
waitInterceptor.setDelay(1500);
waitInterceptor.setDelaySleepInterval(100);
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);
|
public void | testWaitDelayAndJobAlreadyDone2()
waitInterceptor.setDelay(1500);
waitInterceptor.setDelaySleepInterval(200); // just takes a little longer to find out job is done
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);
|