Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [aspectj-users] Poincut questions

I'm not sure if that's the path to take with virtual mocks.  If I was using an actual Mock I think that's what I'd like to do, but so far, it looks like virtual mocks are more flexible.
Perhaps I'm not following you?  My ignorance proceeds me :-)

I'm trying to use virtual mocks so that I don't have to declare actual mock objects, or care about returning a specific Mock'd method.  I'd like to 'mock on the fly' as it were everywhere but in test cases that I want to hit the database.

My thinking, at the moment, is that I'd like to advise every ComponentTestCase derived test to use virtual mocks, while having the DatabaseTestCase derived objects ignore the 'virtual mocks'.

<mind-control>must buy Nicholas Lisieski's book</mind-control>

thanks,
Keith Sader.

> -----Original Message-----
> From: Wes Isberg [mailto:wes@xxxxxxxxxxxxxx]
> Sent: Friday, August 01, 2003 4:51 PM
> To: aspectj-users@xxxxxxxxxxx
> Subject: Re: [aspectj-users] Poincut questions
> 
> 
> pointcut dbCalls() : ...;
> 
> /** substitute Mock.fakeCall() for any dbCalls() to any Mock */
> Object around(Mock mock) : dbCalls()  && target(mock) {
> return mock.fakeCall();
> }
> 
> SADER, KEITH D (Contractor) wrote:
> 
> > I'm using the virtual mock objects technique described in 
> www.xprogramming.com/xpmag/virtualMockObjects.htm
> > along with Manual LaFlamme's exellent dbunit framework 
> www.dbunit.org.
> > 
> > I'm using the following pointcuts, my intent is to advise 
> all of my code with virtual Mocks so that I avoid database 
> access, but to 'un-advise' my DatabaseTestCase+ classes so 
> that they *do* go out and hit the database.
> > 
> > I can't seem to find the idiom(and maybe I'm using bad 
> pointcut idioms) that will allow this.
> > 
> > pointcut allCalls() : execution(* *.*(..)) && 
> !within(ComponentTestCase);
> > 
> > pointcut dbUnitCalls() : execution(* 
> org.dbunit.DatabaseTestCase+.*(..));
> > 
> > pointcut dataCalls() : allCalls() && !dbUnitCalls();
> > 
> > Object around(): dataCalls()
> > {
> > ...
> > }
> > 
> > any ideas?
> > 
> 


Back to the top