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());
  }