Package org.aspectj.lang.reflect

Examples of org.aspectj.lang.reflect.SourceLocation


    final Object raw = new TestBean();
    ProxyFactory pf = new ProxyFactory(raw);
    pf.addAdvisor(ExposeInvocationInterceptor.ADVISOR);
    pf.addAdvice(new MethodBeforeAdvice() {
      public void before(Method method, Object[] args, Object target) throws Throwable {
        SourceLocation sloc = AbstractAspectJAdvice.currentJoinPoint().getSourceLocation();
        assertEquals("Same source location must be returned on subsequent requests",  sloc, AbstractAspectJAdvice.currentJoinPoint().getSourceLocation());
        assertEquals(TestBean.class, sloc.getWithinType());
        try {
          sloc.getLine();
          fail("Can't get line number");
        }
        catch (UnsupportedOperationException ex) {
          // Expected
        }
       
        try {
          sloc.getFileName();
          fail("Can't get file name");
        }
        catch (UnsupportedOperationException ex) {
          // Expected
        }
View Full Code Here


        Signature sig = mock(Signature.class);
        when(jp.getSignature()).thenReturn(sig);
        when(sig.getName()).thenReturn("GreatHeapingMethod");
        when(jp.getArgs()).thenReturn(new String[]{"one", "two"});
        JoinPoint.StaticPart staticPart = mock(JoinPoint.StaticPart.class);
        SourceLocation sl = mock(SourceLocation.class);
        when(sl.getFileName()).thenReturn("Test.java");
        when(sl.getLine()).thenReturn(100);
        when(sl.getWithinType()).thenReturn(this.getClass());
        when(staticPart.getSourceLocation()).thenReturn(sl);
        MethodSignature msig = mock(MethodSignature.class);
        when(staticPart.getSignature()).thenReturn(msig);
        when(jp.getStaticPart()).thenReturn(staticPart);
View Full Code Here

    ProxyFactory pf = new ProxyFactory(raw);
    pf.addAdvisor(ExposeInvocationInterceptor.ADVISOR);
    pf.addAdvice(new MethodBeforeAdvice() {
      @Override
      public void before(Method method, Object[] args, Object target) throws Throwable {
        SourceLocation sloc = AbstractAspectJAdvice.currentJoinPoint().getSourceLocation();
        assertEquals("Same source location must be returned on subsequent requests", sloc, AbstractAspectJAdvice.currentJoinPoint().getSourceLocation());
        assertEquals(TestBean.class, sloc.getWithinType());
        try {
          sloc.getLine();
          fail("Can't get line number");
        }
        catch (UnsupportedOperationException ex) {
          // Expected
        }

        try {
          sloc.getFileName();
          fail("Can't get file name");
        }
        catch (UnsupportedOperationException ex) {
          // Expected
        }
View Full Code Here

TOP

Related Classes of org.aspectj.lang.reflect.SourceLocation

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.