Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RES: [aspectj-users] How to?

Thanks Ramnivas,

But still not working... Now, my pointcut picks nothing...

My program is attached (Eclipse project).

PDVTest.testeEntrarItem() calls PDV.entrarItem(int,int) that calls
CatalogoProdutos.getEspecificacao(int) that must me intercepted.

In addition it possible to get the caller 'test' method too? (in this case
testeEntrarItem)

Thanks,

André



-----Mensagem original-----
De: aspectj-users-admin@xxxxxxxxxxx [mailto:aspectj-users-admin@xxxxxxxxxxx]
Em nome de Ramnivas Laddad
Enviada em: segunda-feira, 13 de setembro de 2004 22:07
Para: aspectj-users@xxxxxxxxxxx
Assunto: Re: [aspectj-users] How to?

Use the following aspect:

public aspect Analizer {
  pointcut testsFlow(TestCase testCase) :
      call(* MyClass.myMethod(..)) &&
      cflow(execution (* junit.framework.TestCase+.test*()) &&
this(testCase));
  
  before(TestCase testCase) : testsFlow(testCase) {
    System.out.println(testCase.getClass());
  }
}

And you have just used the wormhole design pattern!

-Ramnivas

===
Ramnivas Laddad,
Author, AspectJ in Action
http://ramnivas.com



André Dantas Rocha wrote:

> Hi,
>  
> I'd like to print the TestCase name from witch myMethod is called (not 
> directly, but in the TestCase control-flow).
> Is it possible via pointcut declaration? my code is shown below... 
>  
> public class MyClass {
>   void xx() { myMethod(); }
>   void myMethod() {...}
> }
>  
> public void testM() {
>   new MyClass().xx();
> }
>  
> public aspect Analizer {
>   pointcut testsFlow() :
>       call(* MyClass.myMethod(..)) &&
>       cflow(execution (* junit.framework.TestCase+.test*()));
>   
>   before() : testsFlow() {
>     System.out.println(thisJoinPoint); // not working, must print 
> "testM"...
>   }
> }
>  
> Thanks,
>  
> André

_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/aspectj-users

Attachment: pdv.zip
Description: Binary data


Back to the top