Package org.aopalliance.intercept

Examples of org.aopalliance.intercept.MethodInvocation


        am.vote(joe, mi, createAttributes(new PreInvocationExpressionAttribute("(filterObject == 'joe')", "collection", null)));
    }

    @Test
    public void ruleDefinedInAClassMethodIsApplied() throws Exception {
        MethodInvocation mi = new SimpleMethodInvocation(new TargetImpl(), methodTakingAString(), "joe");
        assertEquals(AccessDecisionVoter.ACCESS_GRANTED, am.vote(joe, mi,
                createAttributes(new PreInvocationExpressionAttribute(null, null, "T(org.springframework.security.access.expression.method.SecurityRules).isJoe(#argument)"))));
    }
View Full Code Here


    @Test
    public void createFromClassReturnsMethodWithNoArgInfoForMethodWithNoArgs() {
        new MethodInvocationUtils();

        MethodInvocation mi = MethodInvocationUtils.createFromClass(String.class, "length");
        assertNotNull(mi);
    }
View Full Code Here

        assertNotNull(mi);
    }

    @Test
    public void createFromClassReturnsMethodIfArgInfoOmittedAndMethodNameIsUnique() {
        MethodInvocation mi = MethodInvocationUtils.createFromClass(BusinessServiceImpl.class, "methodReturningAnArray");
        assertNotNull(mi);
    }
View Full Code Here

        MethodInvocationUtils.createFromClass(BusinessServiceImpl.class, "methodReturningAList");
    }

    @Test
    public void createFromClassReturnsMethodIfGivenArgInfoForMethodWithArgs() {
        MethodInvocation mi = MethodInvocationUtils.createFromClass(null, String.class, "compareTo",
                new Class<?>[]{String.class}, new Object[] {""});
        assertNotNull(mi);
    }
View Full Code Here

    public void createFromObjectLocatesExistingMethods() throws Exception {
        AdvisedTarget t = new AdvisedTarget();
        // Just lie about interfaces
        t.setInterfaces(new Class[] {Serializable.class, MethodInvocation.class, Blah.class});

        MethodInvocation mi = MethodInvocationUtils.create(t, "blah");
        assertNotNull(mi);

        t.setProxyTargetClass(true);
        mi = MethodInvocationUtils.create(t, "blah");
        assertNotNull(mi);
View Full Code Here

        when(delegate.getAttributes(Matchers.<Method>any(), Matchers.any(Class.class))).thenReturn(null);
        sources.add(delegate);
        mds = new DelegatingMethodSecurityMetadataSource(sources);
        assertSame(sources, mds.getMethodSecurityMetadataSources());
        assertTrue(mds.getAllConfigAttributes().isEmpty());
        MethodInvocation mi = new SimpleMethodInvocation(null, String.class.getMethod("toString"));
        assertEquals(Collections.emptyList(), mds.getAttributes(mi));
        // Exercise the cached case
        assertEquals(Collections.emptyList(), mds.getAttributes(mi));
    }
View Full Code Here

        when(delegate.getAttributes(toString, String.class)).thenReturn(attributes);
        sources.add(delegate);
        mds = new DelegatingMethodSecurityMetadataSource(sources);
        assertSame(sources, mds.getMethodSecurityMetadataSources());
        assertTrue(mds.getAllConfigAttributes().isEmpty());
        MethodInvocation mi = new SimpleMethodInvocation("", toString);
        assertSame(attributes, mds.getAttributes(mi));
        // Exercise the cached case
        assertSame(attributes, mds.getAttributes(mi));
        assertTrue(mds.getAttributes(new SimpleMethodInvocation(null, String.class.getMethod("length"))).isEmpty());
    }
View Full Code Here

public class InterceptorStatusTokenTests {

    @Test
    public void testOperation() {
        List<ConfigAttribute> attr = SecurityConfig.createList("FOO");
        MethodInvocation mi = new SimpleMethodInvocation();
        SecurityContext ctx = SecurityContextHolder.createEmptyContext();
        InterceptorStatusToken token = new InterceptorStatusToken(ctx, true, attr, mi);

        assertTrue(token.isContextHolderRefreshRequired());
        assertEquals(attr, token.getAttributes());
View Full Code Here

    }

    @Test
    public void allowsAccessUsingCreate() throws Exception {
        Object object = new TargetObject();
        final MethodInvocation mi = MethodInvocationUtils.create(object, "makeLowerCase", "foobar");

        MethodInvocationPrivilegeEvaluator mipe = new MethodInvocationPrivilegeEvaluator();
        when(mds.getAttributes(mi)).thenReturn(role);

        mipe.setSecurityInterceptor(interceptor);
View Full Code Here

        assertTrue(mipe.isAllowed(mi, token));
    }

    @Test
    public void allowsAccessUsingCreateFromClass() throws Exception {
        final MethodInvocation mi = MethodInvocationUtils.createFromClass(new OtherTargetObject(), ITargetObject.class, "makeLowerCase",
                new Class[] {String.class}, new Object[] {"Hello world"});
        MethodInvocationPrivilegeEvaluator mipe = new MethodInvocationPrivilegeEvaluator();
        mipe.setSecurityInterceptor(interceptor);
        when(mds.getAttributes(mi)).thenReturn(role);
View Full Code Here

TOP

Related Classes of org.aopalliance.intercept.MethodInvocation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.