On Nov 29, 2007 10:18 AM, Trustin Lee <[EMAIL PROTECTED]> wrote: > Hi Steve, > > On Nov 29, 2007 1:37 AM, Steve Ulrich (proemion) > <[EMAIL PROTECTED]> wrote: > > > > Hi Mina-folks, > > > > we're using the trunk/2.0 version of mina in some of our apps. > > For test purposes I used a DummySession and mocked the write() and > > close()-methods with easyMock classextension, because I'm not interested in > > any other method calls, like get/setAttribute. Some of these Methods are > > called from the Statemachine or other sources and I don't want to change > > mock expectations everytime a library changes. > > Today we made an update and the test failed, or to be more specific: the > > mock didn't work as expected. After some investigation I found out that > > EasyMock couldn't mock the methods because *all* methods at the > > AbstractIoSession are final or private. > > An abstract class with just final and private methods looks very odd to me. > > Normally, if you declare a class abstract it means to me that I can extend > > its functionality for my own use. But this isn't given anymore if you > > declare all methods final. I think that this will lead into lots of copies > > with the name "MyAbstractIoSession", just because people wants to extend the > > AbstractIoSession functionality. > > Can someone explain me the reason of the change, because I can't see any > > (maybe I'm blind 8-) ). > > Or do you have any ideas how to solve this without writing a new > > DummySession from scratch? > > The reason I changed all the methods in AbstractIoSession to be final > was because I didn't see much room for extension there. If there's > any need for extension, I thought it's better idea to provide > additional protected abstract methods while retaining them as final. > > All I/O requests to AbstractIoSession will be forwarded to an > IoProcessor. You can set the processor of the DummySession by calling > setProcessor() and you can override flush() there > > However, it's very inconvenient to implement a dummy IoProcessor > comparing to just overriding write() method. Let me rewrite > DummySession not extending AbstractIoSession for maximum flexibility.
Alternatively, you could simply set your IoHandler to get notified when write() method is invoked? Doesn't it make sense? Trustin -- what we call human nature is actually human habit -- http://gleamynode.net/ -- PGP Key ID: 0x0255ECA6
