public void testL1ProbingL2AndServerUnResponsive() throws Exception {
    HealthCheckerConfig hcConfig =
        new HealthCheckerConfigImpl(5000, 2000, 2, "ClientCommsHC-Test05", false);
    this.setUp(null, hcConfig);
    ((CommunicationsManagerImpl) serverComms)
        .setConnHealthChecker(new ConnectionHealthCheckerDummyImpl());
    ClientMessageChannel clientMsgCh = createClientMsgCh();
    clientMsgCh.open();

    // Verifications
    ConnectionHealthCheckerImpl connHC =
        (ConnectionHealthCheckerImpl)
            ((CommunicationsManagerImpl) clientComms).getConnHealthChecker();
    assertNotNull(connHC);

    while (!connHC.isRunning() && (connHC.getTotalConnsUnderMonitor() <= 0)) {
      System.out.println("Yet to start the connection health cheker thread...");
      ThreadUtil.reallySleep(1000);
    }

    SequenceGenerator sq = new SequenceGenerator();
    for (int i = 1; i <= 5; i++) {
      PingMessage ping = (PingMessage) clientMsgCh.createMessage(TCMessageType.PING_MESSAGE);
      ping.initialize(sq);
      ping.send();
    }

    System.out.println("Sleeping for " + getMinSleepTimeToConirmDeath(hcConfig));
    ThreadUtil.reallySleep(getMinSleepTimeToConirmDeath(hcConfig));

    assertEquals(0, connHC.getTotalConnsUnderMonitor());
  }
  ClientMessageChannel createClientMsgCh(CommunicationsManager clientCommsMgr) {

    CommunicationsManager commsMgr = (clientCommsMgr == null ? clientComms : clientCommsMgr);
    commsMgr.addClassMapping(TCMessageType.PING_MESSAGE, PingMessage.class);
    ((CommunicationsManagerImpl) commsMgr)
        .getMessageRouter()
        .routeMessageType(
            TCMessageType.PING_MESSAGE,
            new TCMessageSink() {

              @Override
              public void putMessage(TCMessage message) throws UnsupportedMessageTypeException {
                PingMessage pingMsg = (PingMessage) message;
                try {
                  pingMsg.hydrate();
                  System.out.println(" Client RECEIVE - PING seq no " + pingMsg.getSequence());
                } catch (Exception e) {
                  System.out.println("Client Exception during PingMessage hydrate:");
                  e.printStackTrace();
                }
              }
            });

    ClientMessageChannel clientMsgCh =
        commsMgr.createClientChannel(
            new NullSessionManager(),
            0,
            TCSocketAddress.LOOPBACK_IP,
            serverLsnr.getBindPort(),
            1000,
            new ConnectionAddressProvider(
                new ConnectionInfo[] {new ConnectionInfo("localhost", serverLsnr.getBindPort())}));

    return clientMsgCh;
  }
  protected void setUp(HealthCheckerConfig serverHCConf, HealthCheckerConfig clientHCConf)
      throws Exception {
    super.setUp();

    NetworkStackHarnessFactory networkStackHarnessFactory = new PlainNetworkStackHarnessFactory();

    logger.setLevel(LogLevelImpl.DEBUG);

    serverMessageRouter = new TCMessageRouterImpl();
    clientMessageRouter = new TCMessageRouterImpl();

    if (serverHCConf != null) {
      serverComms =
          new CommunicationsManagerImpl(
              "TestCommsMgr-Server",
              new NullMessageMonitor(),
              serverMessageRouter,
              networkStackHarnessFactory,
              new NullConnectionPolicy(),
              serverHCConf,
              Collections.EMPTY_MAP,
              Collections.EMPTY_MAP);
    } else {
      serverComms =
          new CommunicationsManagerImpl(
              "TestCommsMgr-Server",
              new NullMessageMonitor(),
              serverMessageRouter,
              networkStackHarnessFactory,
              new NullConnectionPolicy(),
              new DisabledHealthCheckerConfigImpl(),
              Collections.EMPTY_MAP,
              Collections.EMPTY_MAP);
    }

    if (clientHCConf != null) {
      clientComms =
          new CommunicationsManagerImpl(
              "TestCommsMgr-Client",
              new NullMessageMonitor(),
              clientMessageRouter,
              networkStackHarnessFactory,
              new NullConnectionPolicy(),
              clientHCConf,
              Collections.EMPTY_MAP,
              Collections.EMPTY_MAP);
    } else {
      clientComms =
          new CommunicationsManagerImpl(
              "TestCommsMgr-Client",
              new NullMessageMonitor(),
              clientMessageRouter,
              networkStackHarnessFactory,
              new NullConnectionPolicy(),
              new DisabledHealthCheckerConfigImpl(),
              Collections.EMPTY_MAP,
              Collections.EMPTY_MAP);
    }

    serverComms.addClassMapping(TCMessageType.PING_MESSAGE, PingMessage.class);
    ((CommunicationsManagerImpl) serverComms)
        .getMessageRouter()
        .routeMessageType(
            TCMessageType.PING_MESSAGE,
            new TCMessageSink() {

              @Override
              public void putMessage(TCMessage message) throws UnsupportedMessageTypeException {

                PingMessage pingMsg = (PingMessage) message;
                try {
                  pingMsg.hydrate();
                  System.out.println("Server RECEIVE - PING seq no " + pingMsg.getSequence());
                } catch (Exception e) {
                  System.out.println("Server Exception during PingMessage hydrate:");
                  e.printStackTrace();
                }

                PingMessage pingRplyMsg = pingMsg.createResponse();
                pingRplyMsg.send();
              }
            });
    serverLsnr =
        serverComms.createListener(
            new NullSessionManager(),
            new TCSocketAddress(0),
            false,
            new DefaultConnectionIdFactory());

    serverLsnr.start(new HashSet());
  }