Example usage for org.aspectj.lang JoinPoint.StaticPart toString

List of usage examples for org.aspectj.lang JoinPoint.StaticPart toString

Introduction

In this page you can find the example usage for org.aspectj.lang JoinPoint.StaticPart toString.

Prototype

String toString();

Source Link

Usage

From source file:org.springframework.aop.aspectj.MethodInvocationProceedingJoinPointTests.java

License:Apache License

@Test
public void toShortAndLongStringFormedCorrectly() throws Exception {
    final Object raw = new TestBean();
    ProxyFactory pf = new ProxyFactory(raw);
    pf.addAdvisor(ExposeInvocationInterceptor.ADVISOR);
    pf.addAdvice(new MethodBeforeAdvice() {
        @Override/*from  ww  w.j  ava2  s.  c  om*/
        public void before(Method method, Object[] args, Object target) throws Throwable {
            // makeEncSJP, although meant for computing the enclosing join point,
            // it serves our purpose here
            JoinPoint.StaticPart aspectJVersionJp = Factory.makeEncSJP(method);
            JoinPoint jp = AbstractAspectJAdvice.currentJoinPoint();

            assertEquals(aspectJVersionJp.getSignature().toLongString(), jp.getSignature().toLongString());
            assertEquals(aspectJVersionJp.getSignature().toShortString(), jp.getSignature().toShortString());
            assertEquals(aspectJVersionJp.getSignature().toString(), jp.getSignature().toString());

            assertEquals(aspectJVersionJp.toLongString(), jp.toLongString());
            assertEquals(aspectJVersionJp.toShortString(), jp.toShortString());
            assertEquals(aspectJVersionJp.toString(), jp.toString());
        }
    });
    ITestBean itb = (ITestBean) pf.getProxy();
    itb.getAge();
    itb.setName("foo");
    itb.getDoctor();
    itb.getStringArray();
    itb.getSpouses();
    itb.setSpouse(new TestBean());
    try {
        itb.unreliableFileOperation();
    } catch (IOException ex) {
        // we don't realy care...
    }
}