[Prev][Next][Index][Thread]

Re: Proxy objects [was: Re: [Q]Why are all classes rooted by <object>]



Jeff Dalton wrote:

>> >  In Dylan you have to do pretty
>> > much the same as in C++/Java/etc.: write a wrapper class with a
>> > bunch of "forwarding" methods. ...
> 
> But see
> 
> http://java.sun.com/j2se/1.3/docs/api/java/lang/reflect/Proxy.html

A very cool use of Java proxy classes is exemplified by EasyMock

    http://tammofreese.de/easymock/index.html

<quote>
Mock objects emulate parts of the behaviour of domain code, and are 
able to check whether they are used as defined. Domain classes can be 
tested independently by simulating the classes they use with mock 
objects.
</quote>

The idea is, that in a test case you prime a mock object -- a stand-in 
that for some finite set of cases acts as if it was the real thing -- 
with the expected calls and responses. Then, the mock object is passed 
to the code to be tested and it records if it is called appropriately. 


Michael