ActionContextCleanUpTestpublic class ActionContextCleanUpTest extends TestCase
Fields Summary |
---|
protected org.springframework.mock.web.MockFilterConfig | filterConfig | protected org.springframework.mock.web.MockHttpServletRequest | request | protected org.springframework.mock.web.MockHttpServletResponse | response | protected com.mockobjects.servlet.MockFilterChain | filterChain | protected com.mockobjects.servlet.MockFilterChain | filterChain2 | protected org.springframework.mock.web.MockServletContext | servletContext | protected Counter | counter | protected Map | _tmpStore | protected InnerDispatcher | _dispatcher | protected InnerDispatcher | _dispatcher2 | protected ActionContextCleanUp | cleanUp | protected ActionContextCleanUp | cleanUp2 |
Methods Summary |
---|
protected void | setUp()
Dispatcher.setInstance(null);
counter = new Counter();
_tmpStore = new LinkedHashMap<String, Integer>();
filterConfig = new MockFilterConfig();
request = new MockHttpServletRequest();
response = new MockHttpServletResponse();
servletContext = new MockServletContext();
_dispatcher = new InnerDispatcher(servletContext) {
@Override
public String toString() {
return "dispatcher";
}
};
_dispatcher2 = new InnerDispatcher(servletContext){
@Override
public String toString() {
return "dispatcher2";
}
};
filterChain = new MockFilterChain() {
@Override
public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException {
_tmpStore.put("counter"+(counter.count++), (Integer) request.getAttribute("__cleanup_recursion_counter"));
}
};
cleanUp = new ActionContextCleanUp();
cleanUp2 = new ActionContextCleanUp();
filterChain2 = new MockFilterChain() {
@Override
public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException {
_tmpStore.put("counter"+(counter.count++), (Integer) request.getAttribute("__cleanup_recursion_counter"));
cleanUp2.doFilter(request, response, filterChain);
}
};
| protected void | tearDown()
filterConfig = null;
request = null;
response = null;
filterChain = null;
filterChain2 = null;
servletContext = null;
counter = null;
_tmpStore = null;
_dispatcher = null;
_dispatcher2 = null;
cleanUp = null;
cleanUp2 = null;
| public void | testMultiple()
assertNull(request.getAttribute("__cleanup_recursion_counter"));
cleanUp.init(filterConfig);
cleanUp2.init(filterConfig);
cleanUp.doFilter(request, response, filterChain2);
cleanUp2.destroy();
cleanUp.destroy();
assertEquals(_tmpStore.size(), 2);
assertEquals(_tmpStore.get("counter0"), new Integer(1));
assertEquals(_tmpStore.get("counter1"), new Integer(2));
assertEquals(request.getAttribute("__cleanup_recursion_counter"), new Integer("0"));
| public void | testSingle()
assertNull(request.getAttribute("__cleanup_recursion_counter"));
cleanUp.init(filterConfig);
cleanUp.doFilter(request, response, filterChain);
cleanUp.destroy();
assertEquals(_tmpStore.size(), 1);
assertEquals(_tmpStore.get("counter0"), new Integer(1));
assertEquals(request.getAttribute("__cleanup_recursion_counter"), new Integer("0"));
|
|