From ef2e45df77217ad3063740dc23dbdf10ba5ea2e1 Mon Sep 17 00:00:00 2001 From: Ben Alex Date: Mon, 15 Nov 2004 00:36:12 +0000 Subject: [PATCH] Update tests to support incompatible collaborator detection now in AbstractSecurityInterceptor. --- .../MethodSecurityInterceptorTests.java | 16 +++++++++------- .../web/FilterSecurityInterceptorTests.java | 4 ++-- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/core/src/test/java/org/acegisecurity/intercept/method/aopalliance/MethodSecurityInterceptorTests.java b/core/src/test/java/org/acegisecurity/intercept/method/aopalliance/MethodSecurityInterceptorTests.java index dea7e2c6ed..a3f9182f50 100644 --- a/core/src/test/java/org/acegisecurity/intercept/method/aopalliance/MethodSecurityInterceptorTests.java +++ b/core/src/test/java/org/acegisecurity/intercept/method/aopalliance/MethodSecurityInterceptorTests.java @@ -28,7 +28,6 @@ import net.sf.acegisecurity.GrantedAuthorityImpl; import net.sf.acegisecurity.ITargetObject; import net.sf.acegisecurity.MockAccessDecisionManager; import net.sf.acegisecurity.MockAuthenticationManager; -import net.sf.acegisecurity.MockMethodInvocation; import net.sf.acegisecurity.MockRunAsManager; import net.sf.acegisecurity.RunAsManager; import net.sf.acegisecurity.context.ContextHolder; @@ -246,7 +245,7 @@ public class MethodSecurityInterceptorTests extends TestCase { si.afterPropertiesSet(); fail("Should have thrown IllegalArgumentException"); } catch (IllegalArgumentException expected) { - assertEquals("AccessDecisionManager does not support MethodInvocation", + assertEquals("AccessDecisionManager does not support secure object class: interface org.aopalliance.intercept.MethodInvocation", expected.getMessage()); } } @@ -255,12 +254,16 @@ public class MethodSecurityInterceptorTests extends TestCase { throws Throwable { MethodSecurityInterceptor interceptor = new MethodSecurityInterceptor(); interceptor.setObjectDefinitionSource(new MockObjectDefinitionSourceWhichOnlySupportsStrings()); + interceptor.setAccessDecisionManager(new MockAccessDecisionManager()); + interceptor.setAuthenticationManager(new MockAuthenticationManager()); + interceptor.setRunAsManager(new MockRunAsManager()); try { - interceptor.invoke(new MockMethodInvocation()); + interceptor.afterPropertiesSet(); fail("Should have thrown IllegalArgumentException"); } catch (IllegalArgumentException expected) { - assertTrue(expected.getMessage().startsWith("ObjectDefinitionSource does not support objects of type")); + assertEquals("ObjectDefinitionSource does not support secure object class: interface org.aopalliance.intercept.MethodInvocation", + expected.getMessage()); } } @@ -286,7 +289,7 @@ public class MethodSecurityInterceptorTests extends TestCase { si.afterPropertiesSet(); fail("Should have thrown IllegalArgumentException"); } catch (IllegalArgumentException expected) { - assertEquals("RunAsManager does not support MethodInvocation", + assertEquals("RunAsManager does not support secure object class: interface org.aopalliance.intercept.MethodInvocation", expected.getMessage()); } } @@ -430,8 +433,7 @@ public class MethodSecurityInterceptorTests extends TestCase { private class MockObjectDefinitionSourceWhichOnlySupportsStrings extends AbstractMethodDefinitionSource { public Iterator getConfigAttributeDefinitions() { - throw new UnsupportedOperationException( - "mock method not implemented"); + return null; } public boolean supports(Class clazz) { diff --git a/core/src/test/java/org/acegisecurity/intercept/web/FilterSecurityInterceptorTests.java b/core/src/test/java/org/acegisecurity/intercept/web/FilterSecurityInterceptorTests.java index 4d60e7c26c..d977e15c6b 100644 --- a/core/src/test/java/org/acegisecurity/intercept/web/FilterSecurityInterceptorTests.java +++ b/core/src/test/java/org/acegisecurity/intercept/web/FilterSecurityInterceptorTests.java @@ -101,7 +101,7 @@ public class FilterSecurityInterceptorTests extends TestCase { interceptor.afterPropertiesSet(); fail("Should have thrown IllegalArgumentException"); } catch (IllegalArgumentException expected) { - assertEquals("AccessDecisionManager does not support FilterInvocation", + assertEquals("AccessDecisionManager does not support secure object class: class net.sf.acegisecurity.intercept.web.FilterInvocation", expected.getMessage()); } } @@ -133,7 +133,7 @@ public class FilterSecurityInterceptorTests extends TestCase { interceptor.afterPropertiesSet(); fail("Should have thrown IllegalArgumentException"); } catch (IllegalArgumentException expected) { - assertEquals("RunAsManager does not support FilterInvocation", + assertEquals("RunAsManager does not support secure object class: class net.sf.acegisecurity.intercept.web.FilterInvocation", expected.getMessage()); } }