2
0
Luke Taylor 15 жил өмнө
parent
commit
577ec27507

+ 1 - 1
core/src/main/java/org/springframework/security/access/intercept/aspectj/AspectJCallback.java

@@ -16,7 +16,7 @@
 package org.springframework.security.access.intercept.aspectj;
 
 /**
- * Called by the {@link AspectJSecurityInterceptor} when it wishes for the
+ * Called by the {@link AspectJMethodSecurityInterceptor} when it wishes for the
  * AspectJ processing to continue. Typically implemented in the
  * <code>around()</code> advice as a simple <code>return proceed();</code>
  * statement.

+ 16 - 1
core/src/test/java/org/springframework/security/access/intercept/aspectj/AspectJMethodSecurityInterceptorTests.java

@@ -15,7 +15,7 @@
 
 package org.springframework.security.access.intercept.aspectj;
 
-import static org.junit.Assert.fail;
+import static org.junit.Assert.*;
 import static org.mockito.Matchers.any;
 import static org.mockito.Mockito.*;
 
@@ -37,6 +37,7 @@ import org.springframework.security.authentication.AuthenticationManager;
 import org.springframework.security.authentication.TestingAuthenticationToken;
 import org.springframework.security.core.Authentication;
 import org.springframework.security.core.context.SecurityContextHolder;
+import org.springframework.util.ClassUtils;
 
 import java.lang.reflect.Method;
 import java.util.Collection;
@@ -114,4 +115,18 @@ public class AspectJMethodSecurityInterceptorTests {
         }
         verify(aspectJCallback, never()).proceedWithObject();
     }
+
+    @Test
+    public void adapterHoldsCorrectData() throws Exception {
+        TargetObject to = new TargetObject();
+        Method m = ClassUtils.getMethodIfAvailable(TargetObject.class, "countLength", new Class[] {String.class});
+
+        when(joinPoint.getTarget()).thenReturn(to);
+        when(joinPoint.getArgs()).thenReturn(new Object[] {"Hi"});
+        MethodInvocationAdapter mia = new MethodInvocationAdapter(joinPoint);
+        assertEquals("Hi", mia.getArguments()[0]);
+        assertEquals(m, mia.getStaticPart());
+        assertEquals(m, mia.getMethod());
+        assertSame(to, mia.getThis());
+    }
 }