Package org.aspectj.lang

Examples of org.aspectj.lang.ProceedingJoinPoint


        verify(mockAnnotation);
        verify(mockSignature);
    }

    private static ProceedingJoinPoint createPjpMock(Signature mockSignature) {
        ProceedingJoinPoint mockPjp = createMock(ProceedingJoinPoint.class);
        // XXX: the following two interactions are for logging, so they may happen
        //      0 or n times, pending logging configuration
        expect(mockPjp.getTarget()).andReturn("Target").times(0, 1);
        expect(mockPjp.getSignature()).andReturn(mockSignature).times(0, 1);
        return mockPjp;
    }
View Full Code Here


        replay(mockSignature);
    }

    private static ProceedingJoinPoint createPjpMock(Signature mockSignature,
                                                     int times) {
        ProceedingJoinPoint mockPjp = createMock(ProceedingJoinPoint.class);
        // XXX: the following two interactions are for logging, so they may happen
        //      0 or n times, pending logging configuration
        expect(mockPjp.getTarget()).andReturn("Target").times(0, times);
        expect(mockPjp.getSignature()).andReturn(mockSignature).times(0, times);
        return mockPjp;
    }
View Full Code Here

        return mockPjp;
    }

    @Test
    public void testMonitor() throws Throwable {
        ProceedingJoinPoint mockPjp = createPjpMock(mockSignature, 2);
        expect(mockPjp.proceed()).andReturn(null).times(2);
        replay(mockPjp);

        // Test monitor without pre-existing perf monitor.
        aspect.monitor(mockPjp, mockAnnotation);

        // Test monitor with pre-existing perf monitor.
        aspect.monitor(mockPjp, mockAnnotation);

        String otherMonitor = "OtherMonitor";

        ProceedingJoinPoint otherMockPjp = createPjpMock(mockSignature, 1);
        expect(otherMockPjp.proceed()).andReturn(null).times(1);
        replay(otherMockPjp);

        PerformanceMonitor otherMockAnnotation = createMock(PerformanceMonitor.class);
        expect(otherMockAnnotation.value()).andReturn(otherMonitor);
        replay(otherMockAnnotation);
View Full Code Here

        verify(otherMockAnnotation);
    }

    @Test
    public void testSetPerformanceMonitorFactory() throws Throwable {
        ProceedingJoinPoint mockPjp = createPjpMock(mockSignature, 1);
        expect(mockPjp.proceed()).andReturn(null);
        replay(mockPjp);

        PerformanceMonitorFactory factory = new PerformanceMonitorFactory();
        aspect.setPerformanceMonitorFactory(factory);
View Full Code Here

    }

    @Test(expected = Throwable.class)
    public void testMonitorWithThrowable() throws Throwable {

        ProceedingJoinPoint mockPjp = createPjpMock(mockSignature, 1);
        expect(mockPjp.proceed()).andThrow(new Throwable());
        replay(mockPjp);

        aspect.monitor(mockPjp, mockAnnotation);
        verifyMonitor(TEST_MONITOR, 0, 1);
View Full Code Here

        verify(mockSignature);
    }

    @Test(expected = Exception.class)
    public void testMonitorWithException() throws Throwable {
        ProceedingJoinPoint mockPjp = createPjpMock(mockSignature, 1);
        expect(mockPjp.proceed()).andThrow(new Exception());
        replay(mockPjp);

        aspect.monitor(mockPjp, mockAnnotation);
        verifyMonitor(TEST_MONITOR, 0, 1);
View Full Code Here

     * This method is called to implicitly associate the closure with the joinpoint
     * as required for @AJ aspect proceed()
     */
    public ProceedingJoinPoint linkClosureAndJoinPoint() {
        //TODO is this cast safe ?
        ProceedingJoinPoint jp = (ProceedingJoinPoint)state[state.length-1];
        jp.set$AroundClosure(this);
        return jp;
    }
View Full Code Here

     * This method is called to implicitly associate the closure with the joinpoint
     * as required for @AJ aspect proceed()
     */
    public ProceedingJoinPoint linkClosureAndJoinPoint(int flags) {
        //TODO is this cast safe ?
        ProceedingJoinPoint jp = (ProceedingJoinPoint)state[state.length-1];
        jp.set$AroundClosure(this);
        this.bitflags = flags;
        return jp;
    }
View Full Code Here

        "evalauteBeanWithParameterAnnotation", MockBean.class, Boolean.TYPE);

    MockBean bean = new MockBean();
    bean.setId("id");

    ProceedingJoinPoint pjp = ProceedingJoinPointFactory.create(impl, impl,
        MockService.class, method, bean, false);
    Object value = manager.evaluate(pjp);

    assertEquals("test", value);
    assertEquals(1, impl.getEvalauteBeanWithParameterAnnotationCount());

    value = manager.evaluate(pjp);

    assertEquals("test", value);
    assertEquals(1, impl.getEvalauteBeanWithParameterAnnotationCount());

    /**
     * This time we indicate we want a cache refresh
     */
    ProceedingJoinPoint pjp2 = ProceedingJoinPointFactory.create(impl, impl,
        MockService.class, method, bean, true);
    value = manager.evaluate(pjp2);

    assertEquals("test", value);
    assertEquals(2, impl.getEvalauteBeanWithParameterAnnotationCount());
View Full Code Here

  public void test01() throws SecurityException, NoSuchMethodException {

    MockServiceImpl service = new MockServiceImpl();
    Method method = MockService.class.getMethod("evalaute", String.class);

    ProceedingJoinPoint pjp = ProceedingJoinPointFactory.create(service,
        service, MockService.class, method, "value");

    CacheableObjectKeyFactory[] keyFactories = {new DefaultCacheableObjectKeyFactory()};
    DefaultCacheableKeyFactory factory = new DefaultCacheableKeyFactory(
        keyFactories);
View Full Code Here

TOP

Related Classes of org.aspectj.lang.ProceedingJoinPoint

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.