src/test/java/pityoulish/sockets/server/MsgBoardRequestHandlerImplTest.java
@Test public void listMessages_illegal()
    throws Exception
  {
    //@@@ use JMockit for prereq objects, instead of creating default impls
    MsgBoardRequestHandler mbrh = new MsgBoardRequestHandlerImpl
      (new MixedMessageBoardImpl(8), new DefaultTicketManager(), false);


    try {
      MsgBoardRequest mbreq = null;
      MsgBoardResponse<MessageBatch> rsp = mbrh.listMessages(mbreq, ADDRESS);
      fail("missing request not detected: " + rsp);
    } catch (RuntimeException expected) {
      // expected
    }

    try {
      MsgBoardRequest mbreq = MsgBoardRequestImpl.newObtainTicket("un1t");
      MsgBoardResponse<MessageBatch> rsp = mbrh.listMessages(mbreq, ADDRESS);
      fail("wrong request type not detected: " + rsp);
    } catch (RuntimeException expected) {
      // expected
    }

    try {
      MsgBoardRequest mbreq = new MsgBoardRequestImpl
        (ReqType.LIST_MESSAGES, null, null, null, null, null);
      MsgBoardResponse<MessageBatch> rsp = mbrh.listMessages(mbreq, ADDRESS);
      fail("missing mandatory value not detected: " + rsp);
    } catch (RuntimeException expected) {
      // expected
    }
  }
// test error cases reported as exceptions
test error cases reported as exceptions
test error cases reported as exceptions
@Test public void listMessages_illegal()
    throws Exception
  {
    MsgBoardRequestHandler mbrh = new MsgBoardRequestHandlerImpl
      (new MixedMessageBoardImpl(8), new DefaultTicketManager(), false);
    try {
      MsgBoardRequest mbreq = null;
      MsgBoardResponse<MessageBatch> rsp = mbrh.listMessages(mbreq, ADDRESS);
      fail("missing request not detected: " + rsp);
    } catch (RuntimeException expected) {
    }
    try {
      MsgBoardRequest mbreq = MsgBoardRequestImpl.newObtainTicket("un1t");
      MsgBoardResponse<MessageBatch> rsp = mbrh.listMessages(mbreq, ADDRESS);
      fail("wrong request type not detected: " + rsp);
    } catch (RuntimeException expected) {
    }
    try {
      MsgBoardRequest mbreq = new MsgBoardRequestImpl
        (ReqType.LIST_MESSAGES, null, null, null, null, null);
      MsgBoardResponse<MessageBatch> rsp = mbrh.listMessages(mbreq, ADDRESS);
      fail("missing mandatory value not detected: " + rsp);
    } catch (RuntimeException expected) {
    }
  }
@ Test public void listMessages_illegal ( ) throws Exception { MsgBoardRequestHandler mbrh = new MsgBoardRequestHandlerImpl ( new MixedMessageBoardImpl ( 8 ) , new DefaultTicketManager ( ) , false ) ; try { MsgBoardRequest mbreq = null ; MsgBoardResponse < MessageBatch > rsp = mbrh . listMessages ( mbreq , ADDRESS ) ; fail ( "missing request not detected: " + rsp ) ; } catch ( RuntimeException expected ) { } try { MsgBoardRequest mbreq = MsgBoardRequestImpl . newObtainTicket ( "un1t" ) ; MsgBoardResponse < MessageBatch > rsp = mbrh . listMessages ( mbreq , ADDRESS ) ; fail ( "wrong request type not detected: " + rsp ) ; } catch ( RuntimeException expected ) { } try { MsgBoardRequest mbreq = new MsgBoardRequestImpl ( ReqType . LIST_MESSAGES , null , null , null , null , null ) ; MsgBoardResponse < MessageBatch > rsp = mbrh . listMessages ( mbreq , ADDRESS ) ; fail ( "missing mandatory value not detected: " + rsp ) ; } catch ( RuntimeException expected ) { } }
test error cases reported as exceptions
test error cases reported as exceptions
//@@@ use JMockit for prereq objects, instead of creating default impls // expected // expected // expected