Removed assertions on response buffer size.

This commit is contained in:
Luke Taylor 2007-09-19 16:25:31 +00:00
parent dde3803532
commit 7139cbafbb
1 changed files with 13 additions and 37 deletions

View File

@ -54,7 +54,6 @@ public class AbstractProcessingFilterTests extends TestCase {
//~ Constructors =================================================================================================== //~ Constructors ===================================================================================================
public AbstractProcessingFilterTests() { public AbstractProcessingFilterTests() {
super();
} }
public AbstractProcessingFilterTests(String arg0) { public AbstractProcessingFilterTests(String arg0) {
@ -83,10 +82,6 @@ public class AbstractProcessingFilterTests extends TestCase {
filter.destroy(); filter.destroy();
} }
public static void main(String[] args) {
junit.textui.TestRunner.run(AbstractProcessingFilterTests.class);
}
private SavedRequest makeSavedRequestForUrl() { private SavedRequest makeSavedRequestForUrl() {
MockHttpServletRequest request = createMockRequest(); MockHttpServletRequest request = createMockRequest();
request.setServletPath("/some_protected_file.html"); request.setServletPath("/some_protected_file.html");
@ -117,8 +112,7 @@ public class AbstractProcessingFilterTests extends TestCase {
assertTrue(filter.requiresAuthentication(request, response)); assertTrue(filter.requiresAuthentication(request, response));
} }
public void testDoFilterWithNonHttpServletRequestDetected() public void testDoFilterWithNonHttpServletRequestDetected() throws Exception {
throws Exception {
AbstractProcessingFilter filter = new MockAbstractProcessingFilter(); AbstractProcessingFilter filter = new MockAbstractProcessingFilter();
try { try {
@ -129,8 +123,7 @@ public class AbstractProcessingFilterTests extends TestCase {
} }
} }
public void testDoFilterWithNonHttpServletResponseDetected() public void testDoFilterWithNonHttpServletResponseDetected() throws Exception {
throws Exception {
AbstractProcessingFilter filter = new MockAbstractProcessingFilter(); AbstractProcessingFilter filter = new MockAbstractProcessingFilter();
try { try {
@ -141,8 +134,7 @@ public class AbstractProcessingFilterTests extends TestCase {
} }
} }
public void testFailedAuthenticationRedirectsAppropriately() public void testFailedAuthenticationRedirectsAppropriately() throws Exception {
throws Exception {
// Setup our HTTP request // Setup our HTTP request
MockHttpServletRequest request = createMockRequest(); MockHttpServletRequest request = createMockRequest();
@ -177,11 +169,9 @@ public class AbstractProcessingFilterTests extends TestCase {
assertEquals("/mycontext/accountExpired.jsp", response.getRedirectedUrl()); assertEquals("/mycontext/accountExpired.jsp", response.getRedirectedUrl());
assertNull(SecurityContextHolder.getContext().getAuthentication()); assertNull(SecurityContextHolder.getContext().getAuthentication());
assertEquals(8*1024, response.getBufferSize());
} }
public void testFilterProcessesUrlVariationsRespected() public void testFilterProcessesUrlVariationsRespected() throws Exception {
throws Exception {
// Setup our HTTP request // Setup our HTTP request
MockHttpServletRequest request = createMockRequest(); MockHttpServletRequest request = createMockRequest();
request.setServletPath("/j_OTHER_LOCATION"); request.setServletPath("/j_OTHER_LOCATION");
@ -204,7 +194,6 @@ public class AbstractProcessingFilterTests extends TestCase {
assertEquals("/mycontext/logged_in.jsp", response.getRedirectedUrl()); assertEquals("/mycontext/logged_in.jsp", response.getRedirectedUrl());
assertNotNull(SecurityContextHolder.getContext().getAuthentication()); assertNotNull(SecurityContextHolder.getContext().getAuthentication());
assertEquals("test", SecurityContextHolder.getContext().getAuthentication().getPrincipal().toString()); assertEquals("test", SecurityContextHolder.getContext().getAuthentication().getPrincipal().toString());
assertEquals(8*1024, response.getBufferSize());
} }
public void testGettersSetters() { public void testGettersSetters() {
@ -242,8 +231,7 @@ public class AbstractProcessingFilterTests extends TestCase {
} catch (IllegalArgumentException expected) {} } catch (IllegalArgumentException expected) {}
} }
public void testIgnoresAnyServletPathOtherThanFilterProcessesUrl() public void testIgnoresAnyServletPathOtherThanFilterProcessesUrl() throws Exception {
throws Exception {
// Setup our HTTP request // Setup our HTTP request
MockHttpServletRequest request = createMockRequest(); MockHttpServletRequest request = createMockRequest();
request.setServletPath("/some.file.html"); request.setServletPath("/some.file.html");
@ -263,8 +251,7 @@ public class AbstractProcessingFilterTests extends TestCase {
executeFilterInContainerSimulator(config, filter, request, response, chain); executeFilterInContainerSimulator(config, filter, request, response, chain);
} }
public void testNormalOperationWithDefaultFilterProcessesUrl() public void testNormalOperationWithDefaultFilterProcessesUrl() throws Exception {
throws Exception {
// Setup our HTTP request // Setup our HTTP request
MockHttpServletRequest request = createMockRequest(); MockHttpServletRequest request = createMockRequest();
@ -288,11 +275,9 @@ public class AbstractProcessingFilterTests extends TestCase {
assertEquals("/mycontext/logged_in.jsp", response.getRedirectedUrl()); assertEquals("/mycontext/logged_in.jsp", response.getRedirectedUrl());
assertNotNull(SecurityContextHolder.getContext().getAuthentication()); assertNotNull(SecurityContextHolder.getContext().getAuthentication());
assertEquals("test", SecurityContextHolder.getContext().getAuthentication().getPrincipal().toString()); assertEquals("test", SecurityContextHolder.getContext().getAuthentication().getPrincipal().toString());
assertEquals(8*1024, response.getBufferSize());
} }
public void testStartupDetectsInvalidAuthenticationFailureUrl() public void testStartupDetectsInvalidAuthenticationFailureUrl() throws Exception {
throws Exception {
AbstractProcessingFilter filter = new MockAbstractProcessingFilter(); AbstractProcessingFilter filter = new MockAbstractProcessingFilter();
filter.setAuthenticationManager(new MockAuthenticationManager()); filter.setAuthenticationManager(new MockAuthenticationManager());
filter.setDefaultTargetUrl("/"); filter.setDefaultTargetUrl("/");
@ -306,8 +291,7 @@ public class AbstractProcessingFilterTests extends TestCase {
} }
} }
public void testStartupDetectsInvalidAuthenticationManager() public void testStartupDetectsInvalidAuthenticationManager() throws Exception {
throws Exception {
AbstractProcessingFilter filter = new MockAbstractProcessingFilter(); AbstractProcessingFilter filter = new MockAbstractProcessingFilter();
filter.setAuthenticationFailureUrl("/failed.jsp"); filter.setAuthenticationFailureUrl("/failed.jsp");
filter.setDefaultTargetUrl("/"); filter.setDefaultTargetUrl("/");
@ -321,8 +305,7 @@ public class AbstractProcessingFilterTests extends TestCase {
} }
} }
public void testStartupDetectsInvalidDefaultTargetUrl() public void testStartupDetectsInvalidDefaultTargetUrl() throws Exception {
throws Exception {
AbstractProcessingFilter filter = new MockAbstractProcessingFilter(); AbstractProcessingFilter filter = new MockAbstractProcessingFilter();
filter.setAuthenticationFailureUrl("/failed.jsp"); filter.setAuthenticationFailureUrl("/failed.jsp");
filter.setAuthenticationManager(new MockAuthenticationManager()); filter.setAuthenticationManager(new MockAuthenticationManager());
@ -336,8 +319,7 @@ public class AbstractProcessingFilterTests extends TestCase {
} }
} }
public void testStartupDetectsInvalidFilterProcessesUrl() public void testStartupDetectsInvalidFilterProcessesUrl() throws Exception {
throws Exception {
AbstractProcessingFilter filter = new MockAbstractProcessingFilter(); AbstractProcessingFilter filter = new MockAbstractProcessingFilter();
filter.setAuthenticationFailureUrl("/failed.jsp"); filter.setAuthenticationFailureUrl("/failed.jsp");
filter.setAuthenticationManager(new MockAuthenticationManager()); filter.setAuthenticationManager(new MockAuthenticationManager());
@ -352,8 +334,7 @@ public class AbstractProcessingFilterTests extends TestCase {
} }
} }
public void testSuccessLoginThenFailureLoginResultsInSessionLosingToken() public void testSuccessLoginThenFailureLoginResultsInSessionLosingToken() throws Exception {
throws Exception {
// Setup our HTTP request // Setup our HTTP request
MockHttpServletRequest request = createMockRequest(); MockHttpServletRequest request = createMockRequest();
@ -374,7 +355,6 @@ public class AbstractProcessingFilterTests extends TestCase {
assertEquals("/mycontext/logged_in.jsp", response.getRedirectedUrl()); assertEquals("/mycontext/logged_in.jsp", response.getRedirectedUrl());
assertNotNull(SecurityContextHolder.getContext().getAuthentication()); assertNotNull(SecurityContextHolder.getContext().getAuthentication());
assertEquals("test", SecurityContextHolder.getContext().getAuthentication().getPrincipal().toString()); assertEquals("test", SecurityContextHolder.getContext().getAuthentication().getPrincipal().toString());
assertEquals(8*1024, response.getBufferSize());
// Now try again but this time have filter deny access // Now try again but this time have filter deny access
// Setup our HTTP request // Setup our HTTP request
@ -419,8 +399,7 @@ public class AbstractProcessingFilterTests extends TestCase {
assertNotNull(SecurityContextHolder.getContext().getAuthentication()); assertNotNull(SecurityContextHolder.getContext().getAuthentication());
} }
public void testSuccessfulAuthenticationCausesRedirectToSessionSpecifiedUrl() public void testSuccessfulAuthenticationCausesRedirectToSessionSpecifiedUrl() throws Exception {
throws Exception {
// Setup our HTTP request // Setup our HTTP request
MockHttpServletRequest request = createMockRequest(); MockHttpServletRequest request = createMockRequest();
request.getSession().setAttribute(AbstractProcessingFilter.ACEGI_SAVED_REQUEST_KEY, makeSavedRequestForUrl()); request.getSession().setAttribute(AbstractProcessingFilter.ACEGI_SAVED_REQUEST_KEY, makeSavedRequestForUrl());
@ -440,7 +419,6 @@ public class AbstractProcessingFilterTests extends TestCase {
executeFilterInContainerSimulator(config, filter, request, response, chain); executeFilterInContainerSimulator(config, filter, request, response, chain);
assertEquals(makeSavedRequestForUrl().getFullRequestUrl(), response.getRedirectedUrl()); assertEquals(makeSavedRequestForUrl().getFullRequestUrl(), response.getRedirectedUrl());
assertNotNull(SecurityContextHolder.getContext().getAuthentication()); assertNotNull(SecurityContextHolder.getContext().getAuthentication());
assertEquals(8*1024, response.getBufferSize());
} }
/** /**
@ -481,7 +459,6 @@ public class AbstractProcessingFilterTests extends TestCase {
} }
private MockAbstractProcessingFilter() { private MockAbstractProcessingFilter() {
super();
} }
public Authentication attemptAuthentication(HttpServletRequest request) public Authentication attemptAuthentication(HttpServletRequest request)
@ -513,7 +490,6 @@ public class AbstractProcessingFilterTests extends TestCase {
} }
private MockFilterChain() { private MockFilterChain() {
super();
} }
public void doFilter(ServletRequest request, ServletResponse response) public void doFilter(ServletRequest request, ServletResponse response)