### Question:
StubBase implements SessionMessage { @SuppressWarnings("unchecked") public final boolean sessionMessage( Who sender, Message msg ) throws Exception { Type type = msg.type(); StubHelper<T> helper = (StubHelper<T>) type.getStubHelper(); if (helper == null) return false; switch (type.getAsyncMode()) { case QUEUED: try { _queued.run( new StubPoolRunnable( sender, msg, helper ) ); } catch ( Exception e ) { sessionNotify( _obj, e ); } break; case FREE: try { _free.run( new StubPoolRunnable( sender, msg, helper ) ); } catch ( Exception e ) { sessionNotify( _obj, e ); } break; case NONE: try { helper.run( _svc, _obj, sender, msg ); } catch ( Exception e ) { sessionNotify( _obj, e ); } break; default: throw new IllegalArgumentException("unknown async mode "+type.getAsyncMode()); } return true; } StubBase( DeliveryService svc, T obj, Pool queued, Pool free ); @SuppressWarnings("unchecked") final boolean sessionMessage( Who sender, Message msg ); Object sessionQuery( Object query ); void sessionControl( Object control, Object value ); void sessionNotify( Object event ); static void sessionNotify( Object obj, Object event );  }### Answer:
@Test public void sessionMessage1() throws Exception { howdy.setAsyncMode( AsyncMode.NONE ); Message msg = new Message( howdy, vf ); boolean msg_handled = stub.sessionMessage( who, msg ); assertTrue( msg_handled ); assertSame( What.HOWDY, session.what ); assertSame( transport, session.svc ); assertSame( who, session.sender ); assertSame( msg, session.msg ); assertFalse( queued.run ); assertFalse( free.run ); }
@Test public void sessionMessage2() throws Exception { howdy.setAsyncMode( AsyncMode.QUEUED ); Message msg = new Message( howdy, vf ); boolean msg_handled = stub.sessionMessage( who, msg ); assertTrue( msg_handled ); assertSame( What.HOWDY, session.what ); assertSame( transport, session.svc ); assertSame( who, session.sender ); assertSame( msg, session.msg ); assertTrue( queued.run ); assertFalse( free.run ); }
@Test public void sessionMessage3() throws Exception { howdy.setAsyncMode( AsyncMode.FREE ); Message msg = new Message( howdy, vf ); boolean msg_handled = stub.sessionMessage( who, msg ); assertTrue( msg_handled ); assertSame( What.HOWDY, session.what ); assertSame( transport, session.svc ); assertSame( who, session.sender ); assertSame( msg, session.msg ); assertFalse( queued.run ); assertTrue( free.run ); }
@Test public void sessionMessage4() throws Exception { howdy.setAsyncMode( AsyncMode.NONE ); Message msg = new Message( nogood, vf ); boolean msg_handled = stub.sessionMessage( who, msg ); assertFalse( msg_handled ); assertNull( session.what ); assertNull( session.svc ); assertNull( session.sender ); assertNull( session.msg ); assertFalse( queued.run ); assertFalse( free.run ); }