### Question:
AbstractSessionHandler extends MessageToMessageCodec<FixMessage, FixMessageBuilder> { @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { if (cause instanceof BusinessRejectException) { FixMessageBuilderImpl businessMessageReject = createBusinessReject((BusinessRejectException) cause); ctx.channel().writeAndFlush(businessMessageReject); } else { super.exceptionCaught(ctx, cause); } } protected  AbstractSessionHandler(FixApplication fixApplication,
                                     FixClock fixClock,
                                     SessionRepository sessionRepository); @Override void channelInactive(ChannelHandlerContext ctx); @Override void exceptionCaught(ChannelHandlerContext ctx, Throwable cause); static final AttributeKey<FixSession> FIX_SESSION_KEY; }### Answer:
@Test public void testHandleBusinessRejectException() throws Exception { int refSeqNum = RANDOM.nextInt(100) + 1; String refMsgType = randomAscii(2); int rejectReason = RANDOM.nextInt(5) + 1; String rejectText = randomAscii(10); BusinessRejectException exception = new BusinessRejectException(refSeqNum, refMsgType, rejectReason, rejectText); when(ctx.channel()).thenReturn(channel); sessionHandler.exceptionCaught(ctx, exception); verify(channel, times(1)).writeAndFlush(rejectCaptor.capture()); FixMessage businessReject = rejectCaptor.getValue(); assertEquals(MessageTypes.BUSINESS_MESSAGE_REJECT, businessReject.getMessageType()); assertEquals(rejectReason, businessReject.getInt(FieldType.BusinessRejectReason).intValue()); assertEquals(refSeqNum, businessReject.getInt(FieldType.RefSeqNum).intValue()); assertEquals(refMsgType, businessReject.getString(FieldType.RefMsgType)); assertEquals(rejectText, businessReject.getString(FieldType.Text)); }