From 731d7b2e89a61839f5a0473745f81eec364bafad Mon Sep 17 00:00:00 2001 From: Ben Alex Date: Fri, 25 Nov 2005 04:17:25 +0000 Subject: [PATCH] SEC-113 Provide MethodInvocationUtils. --- .../util/MethodInvocationUtils.java | 134 ++++++++++++++++++ .../util/SimpleMethodInvocation.java} | 12 +- .../AfterInvocationProviderManagerTests.java | 12 +- ...ationCollectionFilteringProviderTests.java | 20 +-- ...cAclEntryAfterInvocationProviderTests.java | 16 +-- ...ntextPropagatingRemoteInvocationTests.java | 4 +- ...ticationCredentialsNotFoundEventTests.java | 6 +- .../AuthorizationFailureEventTests.java | 8 +- .../authorization/AuthorizedEventTests.java | 6 +- .../AbstractSecurityInterceptorTests.java | 4 +- .../InterceptorStatusTokenTests.java | 4 +- .../AbstractMethodDefinitionSourceTests.java | 4 +- .../MethodDefinitionAttributesTests.java | 4 +- .../vote/BasicAclEntryVoterTests.java | 6 +- 14 files changed, 187 insertions(+), 53 deletions(-) create mode 100644 core/src/main/java/org/acegisecurity/util/MethodInvocationUtils.java rename core/src/{test/java/org/acegisecurity/MockMethodInvocation.java => main/java/org/acegisecurity/util/SimpleMethodInvocation.java} (83%) diff --git a/core/src/main/java/org/acegisecurity/util/MethodInvocationUtils.java b/core/src/main/java/org/acegisecurity/util/MethodInvocationUtils.java new file mode 100644 index 0000000000..12ff59443b --- /dev/null +++ b/core/src/main/java/org/acegisecurity/util/MethodInvocationUtils.java @@ -0,0 +1,134 @@ +/* Copyright 2004, 2005 Acegi Technology Pty Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.acegisecurity.util; + +import org.aopalliance.intercept.MethodInvocation; + +import org.springframework.util.Assert; + +import java.lang.reflect.Method; + +import java.util.ArrayList; +import java.util.List; + + +/** + * Static utility methods for creating MethodInvocations usable + * within Acegi Security. + * + *

+ * All methods of this class return a {@link + * org.acegisecurity.util.SimpleMethodInvocation}. + *

+ * + * @author Ben Alex + * @version $Id$ + */ +public class MethodInvocationUtils { + //~ Methods ================================================================ + + /** + * Generates a MethodInvocation for specified + * methodName on the passed object. + * + * @param object the object that will be used to find the relevant + * Method + * @param methodName the name of the method to find + * + * @return a MethodInvocation, or null if there + * was a problem + */ + public static MethodInvocation create(Object object, String methodName) { + return create(object, methodName, null); + } + + /** + * Generates a MethodInvocation for specified + * methodName on the passed object, using the + * args to locate the method. + * + * @param object the object that will be used to find the relevant + * Method + * @param methodName the name of the method to find + * @param args arguments that are required as part of the method signature + * + * @return a MethodInvocation, or null if there + * was a problem + */ + public static MethodInvocation create(Object object, String methodName, + Object[] args) { + Assert.notNull(object, "Object required"); + + Class[] classArgs = null; + + if (args != null) { + List list = new ArrayList(); + + for (int i = 0; i < args.length; i++) { + list.add(args[i].getClass()); + } + + classArgs = (Class[]) list.toArray(); + } + + return createFromClass(object.getClass(), methodName, classArgs); + } + + /** + * Generates a MethodInvocation for specified + * methodName on the passed class. + * + * @param clazz the class of object that will be used to find the relevant + * Method + * @param methodName the name of the method to find + * + * @return a MethodInvocation, or null if there + * was a problem + */ + public static MethodInvocation createFromClass(Class clazz, + String methodName) { + return createFromClass(clazz, methodName); + } + + /** + * Generates a MethodInvocation for specified + * methodName on the passed class, using the + * args to locate the method. + * + * @param clazz the class of object that will be used to find the relevant + * Method + * @param methodName the name of the method to find + * @param args arguments that are required as part of the method signature + * + * @return a MethodInvocation, or null if there + * was a problem + */ + public static MethodInvocation createFromClass(Class clazz, + String methodName, Class[] args) { + Assert.notNull(clazz, "Class required"); + Assert.hasText(methodName, "MethodName required"); + + Method method; + + try { + method = clazz.getMethod(methodName, args); + } catch (Exception e) { + return null; + } + + return new SimpleMethodInvocation(method, args); + } +} diff --git a/core/src/test/java/org/acegisecurity/MockMethodInvocation.java b/core/src/main/java/org/acegisecurity/util/SimpleMethodInvocation.java similarity index 83% rename from core/src/test/java/org/acegisecurity/MockMethodInvocation.java rename to core/src/main/java/org/acegisecurity/util/SimpleMethodInvocation.java index 497d6b32a0..c31428acb3 100644 --- a/core/src/test/java/org/acegisecurity/MockMethodInvocation.java +++ b/core/src/main/java/org/acegisecurity/util/SimpleMethodInvocation.java @@ -1,4 +1,4 @@ -/* Copyright 2004 Acegi Technology Pty Limited +/* Copyright 2004, 2005 Acegi Technology Pty Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,7 +13,7 @@ * limitations under the License. */ -package org.acegisecurity; +package org.acegisecurity.util; import org.aopalliance.intercept.MethodInvocation; @@ -22,12 +22,12 @@ import java.lang.reflect.Method; /** - * Represents the AOP Alliance MethodInvocation secure object. + * Represents the AOP Alliance MethodInvocation. * * @author Ben Alex * @version $Id$ */ -public class MockMethodInvocation implements MethodInvocation { +public class SimpleMethodInvocation implements MethodInvocation { //~ Instance fields ======================================================== private Method method; @@ -35,12 +35,12 @@ public class MockMethodInvocation implements MethodInvocation { //~ Constructors =========================================================== - public MockMethodInvocation(Method method, Object[] arguments) { + public SimpleMethodInvocation(Method method, Object[] arguments) { this.method = method; this.arguments = arguments; } - public MockMethodInvocation() {} + public SimpleMethodInvocation() {} //~ Methods ================================================================ diff --git a/core/src/test/java/org/acegisecurity/afterinvocation/AfterInvocationProviderManagerTests.java b/core/src/test/java/org/acegisecurity/afterinvocation/AfterInvocationProviderManagerTests.java index 85eec45250..f78b10e85a 100644 --- a/core/src/test/java/org/acegisecurity/afterinvocation/AfterInvocationProviderManagerTests.java +++ b/core/src/test/java/org/acegisecurity/afterinvocation/AfterInvocationProviderManagerTests.java @@ -21,9 +21,9 @@ import org.acegisecurity.AccessDeniedException; import org.acegisecurity.Authentication; import org.acegisecurity.ConfigAttribute; import org.acegisecurity.ConfigAttributeDefinition; -import org.acegisecurity.MockMethodInvocation; import org.acegisecurity.SecurityConfig; import org.acegisecurity.intercept.web.FilterInvocation; +import org.acegisecurity.util.SimpleMethodInvocation; import org.aopalliance.intercept.MethodInvocation; @@ -88,23 +88,23 @@ public class AfterInvocationProviderManagerTests extends TestCase { attr4.addConfigAttribute(new SecurityConfig("NEVER_CAUSES_SWAP")); assertEquals("swap1", - manager.decide(null, new MockMethodInvocation(), attr1, + manager.decide(null, new SimpleMethodInvocation(), attr1, "content-before-swapping")); assertEquals("swap2", - manager.decide(null, new MockMethodInvocation(), attr2, + manager.decide(null, new SimpleMethodInvocation(), attr2, "content-before-swapping")); assertEquals("swap3", - manager.decide(null, new MockMethodInvocation(), attr3, + manager.decide(null, new SimpleMethodInvocation(), attr3, "content-before-swapping")); assertEquals("content-before-swapping", - manager.decide(null, new MockMethodInvocation(), attr4, + manager.decide(null, new SimpleMethodInvocation(), attr4, "content-before-swapping")); assertEquals("swap3", - manager.decide(null, new MockMethodInvocation(), attr2and3, + manager.decide(null, new SimpleMethodInvocation(), attr2and3, "content-before-swapping")); } diff --git a/core/src/test/java/org/acegisecurity/afterinvocation/BasicAclEntryAfterInvocationCollectionFilteringProviderTests.java b/core/src/test/java/org/acegisecurity/afterinvocation/BasicAclEntryAfterInvocationCollectionFilteringProviderTests.java index 31523c1275..869df56860 100644 --- a/core/src/test/java/org/acegisecurity/afterinvocation/BasicAclEntryAfterInvocationCollectionFilteringProviderTests.java +++ b/core/src/test/java/org/acegisecurity/afterinvocation/BasicAclEntryAfterInvocationCollectionFilteringProviderTests.java @@ -20,13 +20,13 @@ import junit.framework.TestCase; import org.acegisecurity.AuthorizationServiceException; import org.acegisecurity.ConfigAttributeDefinition; import org.acegisecurity.MockAclManager; -import org.acegisecurity.MockMethodInvocation; import org.acegisecurity.SecurityConfig; import org.acegisecurity.acl.AclEntry; import org.acegisecurity.acl.AclManager; import org.acegisecurity.acl.basic.MockAclObjectIdentity; import org.acegisecurity.acl.basic.SimpleAclEntry; import org.acegisecurity.providers.UsernamePasswordAuthenticationToken; +import org.acegisecurity.util.SimpleMethodInvocation; import java.util.List; import java.util.Vector; @@ -88,7 +88,7 @@ public class BasicAclEntryAfterInvocationCollectionFilteringProviderTests // Filter List filteredList = (List) provider.decide(auth, - new MockMethodInvocation(), attr, list); + new SimpleMethodInvocation(), attr, list); assertEquals(0, filteredList.size()); } @@ -124,7 +124,7 @@ public class BasicAclEntryAfterInvocationCollectionFilteringProviderTests // Filter List filteredList = (List) provider.decide(auth, - new MockMethodInvocation(), attr, list); + new SimpleMethodInvocation(), attr, list); assertEquals(0, filteredList.size()); } @@ -161,7 +161,7 @@ public class BasicAclEntryAfterInvocationCollectionFilteringProviderTests // Filter List filteredList = (List) provider.decide(auth, - new MockMethodInvocation(), attr, list); + new SimpleMethodInvocation(), attr, list); assertEquals(1, filteredList.size()); assertEquals("belmont", filteredList.get(0)); @@ -199,7 +199,7 @@ public class BasicAclEntryAfterInvocationCollectionFilteringProviderTests // Filter String[] filteredList = (String[]) provider.decide(auth, - new MockMethodInvocation(), attr, list); + new SimpleMethodInvocation(), attr, list); assertEquals(1, filteredList.length); assertEquals("belmont", filteredList[0]); @@ -228,7 +228,7 @@ public class BasicAclEntryAfterInvocationCollectionFilteringProviderTests // Filter try { - provider.decide(auth, new MockMethodInvocation(), attr, + provider.decide(auth, new SimpleMethodInvocation(), attr, new String("RETURN_OBJECT_NOT_COLLECTION")); fail("Should have thrown AuthorizationServiceException"); } catch (AuthorizationServiceException expected) { @@ -259,7 +259,7 @@ public class BasicAclEntryAfterInvocationCollectionFilteringProviderTests // Filter List filteredList = (List) provider.decide(auth, - new MockMethodInvocation(), attr, null); + new SimpleMethodInvocation(), attr, null); assertNull(filteredList); } @@ -296,14 +296,14 @@ public class BasicAclEntryAfterInvocationCollectionFilteringProviderTests // As no matching config attrib, ensure provider doesn't change list assertEquals(4, - ((List) provider.decide(auth, new MockMethodInvocation(), attr, list)) + ((List) provider.decide(auth, new SimpleMethodInvocation(), attr, list)) .size()); // Filter, this time with the conf attrib provider setup to answer attr.addConfigAttribute(new SecurityConfig("AFTER_ACL_COLLECTION_ADMIN")); List filteredList = (List) provider.decide(auth, - new MockMethodInvocation(), attr, list); + new SimpleMethodInvocation(), attr, list); assertEquals(1, filteredList.size()); assertEquals("sydney", filteredList.get(0)); @@ -341,7 +341,7 @@ public class BasicAclEntryAfterInvocationCollectionFilteringProviderTests // Filter List filteredList = (List) provider.decide(auth, - new MockMethodInvocation(), attr, list); + new SimpleMethodInvocation(), attr, list); assertEquals(1, filteredList.size()); assertEquals("sydney", filteredList.get(0)); diff --git a/core/src/test/java/org/acegisecurity/afterinvocation/BasicAclEntryAfterInvocationProviderTests.java b/core/src/test/java/org/acegisecurity/afterinvocation/BasicAclEntryAfterInvocationProviderTests.java index 0bacf8f955..1bb23cf69c 100644 --- a/core/src/test/java/org/acegisecurity/afterinvocation/BasicAclEntryAfterInvocationProviderTests.java +++ b/core/src/test/java/org/acegisecurity/afterinvocation/BasicAclEntryAfterInvocationProviderTests.java @@ -20,13 +20,13 @@ import junit.framework.TestCase; import org.acegisecurity.AccessDeniedException; import org.acegisecurity.ConfigAttributeDefinition; import org.acegisecurity.MockAclManager; -import org.acegisecurity.MockMethodInvocation; import org.acegisecurity.SecurityConfig; import org.acegisecurity.acl.AclEntry; import org.acegisecurity.acl.AclManager; import org.acegisecurity.acl.basic.MockAclObjectIdentity; import org.acegisecurity.acl.basic.SimpleAclEntry; import org.acegisecurity.providers.UsernamePasswordAuthenticationToken; +import org.acegisecurity.util.SimpleMethodInvocation; /** @@ -75,7 +75,7 @@ public class BasicAclEntryAfterInvocationProviderTests extends TestCase { attr.addConfigAttribute(new SecurityConfig("AFTER_ACL_READ")); try { - provider.decide(auth, new MockMethodInvocation(), attr, "belmont"); + provider.decide(auth, new SimpleMethodInvocation(), attr, "belmont"); fail("Should have thrown AccessDeniedException"); } catch (AccessDeniedException expected) { assertTrue(true); @@ -104,7 +104,7 @@ public class BasicAclEntryAfterInvocationProviderTests extends TestCase { attr.addConfigAttribute(new SecurityConfig("AFTER_ACL_READ")); try { - provider.decide(auth, new MockMethodInvocation(), attr, "belmont"); + provider.decide(auth, new SimpleMethodInvocation(), attr, "belmont"); fail("Should have thrown AccessDeniedException"); } catch (AccessDeniedException expected) { assertTrue(true); @@ -135,7 +135,7 @@ public class BasicAclEntryAfterInvocationProviderTests extends TestCase { // Filter assertEquals("belmont", - provider.decide(auth, new MockMethodInvocation(), attr, "belmont")); + provider.decide(auth, new SimpleMethodInvocation(), attr, "belmont")); } public void testGrantsAccessIfReturnedObjectIsNull() @@ -160,7 +160,7 @@ public class BasicAclEntryAfterInvocationProviderTests extends TestCase { attr.addConfigAttribute(new SecurityConfig("AFTER_ACL_READ")); // Filter - assertNull(provider.decide(auth, new MockMethodInvocation(), attr, null)); + assertNull(provider.decide(auth, new SimpleMethodInvocation(), attr, null)); } public void testRespectsModificationsToProcessConfigAttribute() @@ -185,12 +185,12 @@ public class BasicAclEntryAfterInvocationProviderTests extends TestCase { // As no matching config attrib, ensure provider returns original obj assertEquals("sydney", - provider.decide(auth, new MockMethodInvocation(), attr, "sydney")); + provider.decide(auth, new SimpleMethodInvocation(), attr, "sydney")); // Filter, this time with the conf attrib provider setup to answer attr.addConfigAttribute(new SecurityConfig("AFTER_ACL_ADMIN")); assertEquals("sydney", - provider.decide(auth, new MockMethodInvocation(), attr, "sydney")); + provider.decide(auth, new SimpleMethodInvocation(), attr, "sydney")); } public void testRespectsModificationsToRequirePermissions() @@ -217,7 +217,7 @@ public class BasicAclEntryAfterInvocationProviderTests extends TestCase { // Filter assertEquals("sydney", - provider.decide(auth, new MockMethodInvocation(), attr, "sydney")); + provider.decide(auth, new SimpleMethodInvocation(), attr, "sydney")); } public void testStartupDetectsMissingAclManager() throws Exception { diff --git a/core/src/test/java/org/acegisecurity/context/rmi/ContextPropagatingRemoteInvocationTests.java b/core/src/test/java/org/acegisecurity/context/rmi/ContextPropagatingRemoteInvocationTests.java index ffd4e359fc..2146b3aff0 100644 --- a/core/src/test/java/org/acegisecurity/context/rmi/ContextPropagatingRemoteInvocationTests.java +++ b/core/src/test/java/org/acegisecurity/context/rmi/ContextPropagatingRemoteInvocationTests.java @@ -18,13 +18,13 @@ package org.acegisecurity.context.rmi; import junit.framework.TestCase; import org.acegisecurity.Authentication; -import org.acegisecurity.MockMethodInvocation; import org.acegisecurity.TargetObject; import org.acegisecurity.context.SecurityContextHolder; import org.acegisecurity.context.SecurityContextImpl; import org.acegisecurity.context.rmi.ContextPropagatingRemoteInvocation; import org.acegisecurity.context.rmi.ContextPropagatingRemoteInvocationFactory; import org.acegisecurity.providers.UsernamePasswordAuthenticationToken; +import org.acegisecurity.util.SimpleMethodInvocation; import org.aopalliance.intercept.MethodInvocation; @@ -112,7 +112,7 @@ public class ContextPropagatingRemoteInvocationTests extends TestCase { Class clazz = TargetObject.class; Method method = clazz.getMethod("makeLowerCase", new Class[] {String.class}); - MethodInvocation mi = new MockMethodInvocation(method, + MethodInvocation mi = new SimpleMethodInvocation(method, new Object[] {"SOME_STRING"}); ContextPropagatingRemoteInvocationFactory factory = new ContextPropagatingRemoteInvocationFactory(); diff --git a/core/src/test/java/org/acegisecurity/event/authorization/AuthenticationCredentialsNotFoundEventTests.java b/core/src/test/java/org/acegisecurity/event/authorization/AuthenticationCredentialsNotFoundEventTests.java index 22a2a33b55..f8f57b54e9 100644 --- a/core/src/test/java/org/acegisecurity/event/authorization/AuthenticationCredentialsNotFoundEventTests.java +++ b/core/src/test/java/org/acegisecurity/event/authorization/AuthenticationCredentialsNotFoundEventTests.java @@ -19,7 +19,7 @@ import junit.framework.TestCase; import org.acegisecurity.AuthenticationCredentialsNotFoundException; import org.acegisecurity.ConfigAttributeDefinition; -import org.acegisecurity.MockMethodInvocation; +import org.acegisecurity.util.SimpleMethodInvocation; /** @@ -56,7 +56,7 @@ public class AuthenticationCredentialsNotFoundEventTests extends TestCase { } try { - new AuthenticationCredentialsNotFoundEvent(new MockMethodInvocation(), + new AuthenticationCredentialsNotFoundEvent(new SimpleMethodInvocation(), null, new AuthenticationCredentialsNotFoundException("test")); fail("Should have thrown IllegalArgumentException"); } catch (IllegalArgumentException expected) { @@ -64,7 +64,7 @@ public class AuthenticationCredentialsNotFoundEventTests extends TestCase { } try { - new AuthenticationCredentialsNotFoundEvent(new MockMethodInvocation(), + new AuthenticationCredentialsNotFoundEvent(new SimpleMethodInvocation(), new ConfigAttributeDefinition(), null); fail("Should have thrown IllegalArgumentException"); } catch (IllegalArgumentException expected) { diff --git a/core/src/test/java/org/acegisecurity/event/authorization/AuthorizationFailureEventTests.java b/core/src/test/java/org/acegisecurity/event/authorization/AuthorizationFailureEventTests.java index c2c82192be..43c8ae8bdb 100644 --- a/core/src/test/java/org/acegisecurity/event/authorization/AuthorizationFailureEventTests.java +++ b/core/src/test/java/org/acegisecurity/event/authorization/AuthorizationFailureEventTests.java @@ -19,9 +19,9 @@ import junit.framework.TestCase; import org.acegisecurity.AccessDeniedException; import org.acegisecurity.ConfigAttributeDefinition; -import org.acegisecurity.MockMethodInvocation; import org.acegisecurity.event.authorization.AuthorizationFailureEvent; import org.acegisecurity.providers.UsernamePasswordAuthenticationToken; +import org.acegisecurity.util.SimpleMethodInvocation; /** @@ -59,7 +59,7 @@ public class AuthorizationFailureEventTests extends TestCase { } try { - new AuthorizationFailureEvent(new MockMethodInvocation(), null, + new AuthorizationFailureEvent(new SimpleMethodInvocation(), null, new UsernamePasswordAuthenticationToken("foo", "bar"), new AccessDeniedException("error")); fail("Should have thrown IllegalArgumentException"); @@ -68,7 +68,7 @@ public class AuthorizationFailureEventTests extends TestCase { } try { - new AuthorizationFailureEvent(new MockMethodInvocation(), + new AuthorizationFailureEvent(new SimpleMethodInvocation(), new ConfigAttributeDefinition(), null, new AccessDeniedException("error")); fail("Should have thrown IllegalArgumentException"); @@ -77,7 +77,7 @@ public class AuthorizationFailureEventTests extends TestCase { } try { - new AuthorizationFailureEvent(new MockMethodInvocation(), + new AuthorizationFailureEvent(new SimpleMethodInvocation(), new ConfigAttributeDefinition(), new UsernamePasswordAuthenticationToken("foo", "bar"), null); fail("Should have thrown IllegalArgumentException"); diff --git a/core/src/test/java/org/acegisecurity/event/authorization/AuthorizedEventTests.java b/core/src/test/java/org/acegisecurity/event/authorization/AuthorizedEventTests.java index 296e14323d..5c6cb43988 100644 --- a/core/src/test/java/org/acegisecurity/event/authorization/AuthorizedEventTests.java +++ b/core/src/test/java/org/acegisecurity/event/authorization/AuthorizedEventTests.java @@ -18,8 +18,8 @@ package org.acegisecurity.event.authorization; import junit.framework.TestCase; import org.acegisecurity.ConfigAttributeDefinition; -import org.acegisecurity.MockMethodInvocation; import org.acegisecurity.providers.UsernamePasswordAuthenticationToken; +import org.acegisecurity.util.SimpleMethodInvocation; /** @@ -55,7 +55,7 @@ public class AuthorizedEventTests extends TestCase { } try { - new AuthorizedEvent(new MockMethodInvocation(), null, + new AuthorizedEvent(new SimpleMethodInvocation(), null, new UsernamePasswordAuthenticationToken("foo", "bar")); fail("Should have thrown IllegalArgumentException"); } catch (IllegalArgumentException expected) { @@ -63,7 +63,7 @@ public class AuthorizedEventTests extends TestCase { } try { - new AuthorizedEvent(new MockMethodInvocation(), + new AuthorizedEvent(new SimpleMethodInvocation(), new ConfigAttributeDefinition(), null); fail("Should have thrown IllegalArgumentException"); } catch (IllegalArgumentException expected) { diff --git a/core/src/test/java/org/acegisecurity/intercept/AbstractSecurityInterceptorTests.java b/core/src/test/java/org/acegisecurity/intercept/AbstractSecurityInterceptorTests.java index c0eeca6355..0aefdcf8b7 100644 --- a/core/src/test/java/org/acegisecurity/intercept/AbstractSecurityInterceptorTests.java +++ b/core/src/test/java/org/acegisecurity/intercept/AbstractSecurityInterceptorTests.java @@ -20,9 +20,9 @@ import junit.framework.TestCase; import org.acegisecurity.MockAccessDecisionManager; import org.acegisecurity.MockAfterInvocationManager; import org.acegisecurity.MockAuthenticationManager; -import org.acegisecurity.MockMethodInvocation; import org.acegisecurity.MockRunAsManager; import org.acegisecurity.intercept.method.MockMethodDefinitionSource; +import org.acegisecurity.util.SimpleMethodInvocation; /** @@ -60,7 +60,7 @@ public class AbstractSecurityInterceptorTests extends TestCase { si.setObjectDefinitionSource(new MockMethodDefinitionSource(false, true)); try { - si.beforeInvocation(new MockMethodInvocation()); + si.beforeInvocation(new SimpleMethodInvocation()); fail("Should have thrown IllegalArgumentException"); } catch (IllegalArgumentException expected) { assertTrue(expected.getMessage().startsWith("Security invocation attempted for object")); diff --git a/core/src/test/java/org/acegisecurity/intercept/InterceptorStatusTokenTests.java b/core/src/test/java/org/acegisecurity/intercept/InterceptorStatusTokenTests.java index 2058aae2f5..b4c3d1bf25 100644 --- a/core/src/test/java/org/acegisecurity/intercept/InterceptorStatusTokenTests.java +++ b/core/src/test/java/org/acegisecurity/intercept/InterceptorStatusTokenTests.java @@ -18,9 +18,9 @@ package org.acegisecurity.intercept; import junit.framework.TestCase; import org.acegisecurity.ConfigAttributeDefinition; -import org.acegisecurity.MockMethodInvocation; import org.acegisecurity.SecurityConfig; import org.acegisecurity.providers.UsernamePasswordAuthenticationToken; +import org.acegisecurity.util.SimpleMethodInvocation; import org.aopalliance.intercept.MethodInvocation; @@ -61,7 +61,7 @@ public class InterceptorStatusTokenTests extends TestCase { ConfigAttributeDefinition attr = new ConfigAttributeDefinition(); attr.addConfigAttribute(new SecurityConfig("FOO")); - MethodInvocation mi = new MockMethodInvocation(); + MethodInvocation mi = new SimpleMethodInvocation(); InterceptorStatusToken token = new InterceptorStatusToken(new UsernamePasswordAuthenticationToken( "marissa", "koala"), true, attr, mi); diff --git a/core/src/test/java/org/acegisecurity/intercept/method/AbstractMethodDefinitionSourceTests.java b/core/src/test/java/org/acegisecurity/intercept/method/AbstractMethodDefinitionSourceTests.java index 28849bfaf5..03b7352037 100644 --- a/core/src/test/java/org/acegisecurity/intercept/method/AbstractMethodDefinitionSourceTests.java +++ b/core/src/test/java/org/acegisecurity/intercept/method/AbstractMethodDefinitionSourceTests.java @@ -17,7 +17,7 @@ package org.acegisecurity.intercept.method; import junit.framework.TestCase; -import org.acegisecurity.MockMethodInvocation; +import org.acegisecurity.util.SimpleMethodInvocation; import org.aopalliance.intercept.MethodInvocation; @@ -85,7 +85,7 @@ public class AbstractMethodDefinitionSourceTests extends TestCase { true); try { - mds.getAttributes(new MockMethodInvocation()); + mds.getAttributes(new SimpleMethodInvocation()); fail("Should have thrown UnsupportedOperationException"); } catch (UnsupportedOperationException expected) { assertTrue(true); diff --git a/core/src/test/java/org/acegisecurity/intercept/method/MethodDefinitionAttributesTests.java b/core/src/test/java/org/acegisecurity/intercept/method/MethodDefinitionAttributesTests.java index 9d98781142..7af874d1b5 100644 --- a/core/src/test/java/org/acegisecurity/intercept/method/MethodDefinitionAttributesTests.java +++ b/core/src/test/java/org/acegisecurity/intercept/method/MethodDefinitionAttributesTests.java @@ -22,13 +22,13 @@ import org.acegisecurity.ConfigAttributeDefinition; import org.acegisecurity.GrantedAuthority; import org.acegisecurity.GrantedAuthorityImpl; import org.acegisecurity.ITargetObject; -import org.acegisecurity.MockMethodInvocation; import org.acegisecurity.OtherTargetObject; import org.acegisecurity.SecurityConfig; import org.acegisecurity.TargetObject; import org.acegisecurity.acl.basic.SomeDomain; import org.acegisecurity.context.SecurityContextHolder; import org.acegisecurity.providers.UsernamePasswordAuthenticationToken; +import org.acegisecurity.util.SimpleMethodInvocation; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; @@ -209,7 +209,7 @@ public class MethodDefinitionAttributesTests extends TestCase { MethodDefinitionAttributes source = new MethodDefinitionAttributes(); source.setAttributes(new MockAttributes()); - ConfigAttributeDefinition config = source.getAttributes(new MockMethodInvocation() { + ConfigAttributeDefinition config = source.getAttributes(new SimpleMethodInvocation() { public Method getMethod() { return method; } diff --git a/core/src/test/java/org/acegisecurity/vote/BasicAclEntryVoterTests.java b/core/src/test/java/org/acegisecurity/vote/BasicAclEntryVoterTests.java index 94dc4d7f42..9fe2a8d870 100644 --- a/core/src/test/java/org/acegisecurity/vote/BasicAclEntryVoterTests.java +++ b/core/src/test/java/org/acegisecurity/vote/BasicAclEntryVoterTests.java @@ -20,13 +20,13 @@ import junit.framework.TestCase; import org.acegisecurity.AuthorizationServiceException; import org.acegisecurity.ConfigAttributeDefinition; import org.acegisecurity.MockAclManager; -import org.acegisecurity.MockMethodInvocation; import org.acegisecurity.SecurityConfig; import org.acegisecurity.acl.AclEntry; import org.acegisecurity.acl.AclManager; import org.acegisecurity.acl.basic.MockAclObjectIdentity; import org.acegisecurity.acl.basic.SimpleAclEntry; import org.acegisecurity.providers.UsernamePasswordAuthenticationToken; +import org.acegisecurity.util.SimpleMethodInvocation; import org.aopalliance.intercept.MethodInvocation; @@ -444,7 +444,7 @@ public class BasicAclEntryVoterTests extends TestCase { Class clazz = String.class; Method method = clazz.getMethod("toString", new Class[] {}); - MethodInvocation mi = new MockMethodInvocation(method, + MethodInvocation mi = new SimpleMethodInvocation(method, new Object[] {domainObject}); try { @@ -462,7 +462,7 @@ public class BasicAclEntryVoterTests extends TestCase { Method method = clazz.getMethod("someServiceMethod", new Class[] {SomeDomainObject.class}); - return new MockMethodInvocation(method, new Object[] {domainObject}); + return new SimpleMethodInvocation(method, new Object[] {domainObject}); } //~ Inner Classes ==========================================================