well, you're partially right. The problem is that the VirtualInstanceContextHolder contains a private constructor,an the way that class is used is by invoking a
VirtualInstanceContextHolder.getContext() which would return a VirtualInstanceContext object.
The bottom line is: I want to return a DTOFactory from my metod getDTOFactory in the Service class. Can I do that without setting up mock of all the things that the getDTOFactory is using?
Regards,
Viggo
On Mon, Nov 23, 2009 at 11:15 AM, Julian Hall
<jules@meridiandigital.co.uk> wrote:
Viggo Navarsete wrote:
I'm having a unit test which is supposed to test a Service. The Service in turn calls another class. I want to mock the invocations to the class the Service uses.
MyTest-->Service-->AConcreteClass
So, MyTest executes a method on Service, which in turn execute a method on a concrete class, AConcreteClass.
I want to mock the execution on the AConcreteClass in Service, but it doesn't seem to mock it.
Some code:
************************************************************************************************************************************************************************************************
MyTest:
@Test
public void testDataLoad() throws Exception {
Mockery context = new Mockery() {{
setImposteriser( ClassImposteriser.INSTANCE );
}};
final VirtualInstanceContextHolder vich = context.mock( VirtualInstanceContextHolder.class );
final VirtualInstanceContext vic = context.mock( VirtualInstanceContext.class );
final ApplicationContext ac = context.mock( ApplicationContext.class );
final Persistence persistence = context.mock( Persistence.class );
final Map<String, String> emMap = new HashMap<String, String>();
context.checking( new Expectations() {{
allowing( vich );
will( returnValue( new VirtualInstanceContext()));
Shouldn't this be returning vic?
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email
--
Viggo Navarsete
Senior Developer
TraceTracker AS
Øvre Slottsgt.4, 4th floor, N-0157 Oslo, Norway
Central number: +47 47 70 44 00
Direct number: +47 92 43 14 90
E-mail:
viggo@tracetracker.comTraceTracker was selected Technology Pioneer 2009 by the World Economic Forum.
This is a confidential business communication. If you have received it in error please notify the sender and delete it. Any unauthorized use of this communication is prohibited.Copyright 2009 TraceTracker AS, Oslo - Norway