Hi,

>From what I've seen, mock objects are fantastic - but use them only as
a last resort.  If possible break up your functionality in a way that
you can call it from your unit test without mocking any objects.

If you do go and create a mock object of ProtocolSession, then I'd
advise you to do so against a final MINA release so that you dont have
to keep changing the recorded method calls.

I believe MINA uses easymock for mock objects.

HTH,
Vinod.

On 4/14/06, Serkan Demir <[EMAIL PROTECTED]> wrote:
> Hi guys,
>
> I have implemented a protocol stack with MINA. Now, I have to increase
> my unit tests coverage. I have stuck at the testing of my
> ProtocolHandler's methods (sessionCreated,sessionOpened, sessionClosed
> etc..) Therefore i need a concrete or mock class of Protocol Session for
> my tests. I noticed the TestSession class in your codebase, but it is
> private class like as ProtocolSessionImpl. Is there any session factory
> or a public concrete class of ProtocolSession which I can use for tests?
> If your answer is no, i will pass to my second alternative, JMock.
>
> I am talking about unit tests of such method.Unless i create a session
> in unit test scope, i cannot test its functionality. Could you recommend
> a way for testing such methods?
>
>     public void messageReceived(ProtocolSession session, Object message) {
>         if (BaseStackLogger.logger.isDebugEnabled()){
>             BaseStackLogger.logger.debug("Message is received. Message
> is:"+message.toString());
>         }
>
>  // some other actions have been done
> //
> //
>      if(!message instanceof MyMessageType) {
>     session.close();
>     }
>      resetTimer();
>     }
>

Reply via email to