Skip to main content

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


You made a bracing error.  The "this(testCase)" pointcut must be within the cflow() context.

cheers,
-adrian.
--
Adrian Powell
Centre for IBM e-Business Innovation :: Vancouver
apowell@xxxxxxxxxx / 604-297-3194



André Dantas Rocha <ad-rocha@xxxxxxxxxx>
Sent by: aspectj-users-admin@xxxxxxxxxxx

11/13/2004 10:53 PM

Please respond to
aspectj-users

To
<aspectj-users@xxxxxxxxxxx>
cc
Subject
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: Zip archive


Back to the top