コード例 #1
0
 @Override
 protected void setUp() throws Exception {
   super.setUp();
   invalidateObjectManager =
       new InvalidateObjectManagerImpl(Mockito.mock(ServerTransactionManager.class));
   validateSink = new TestSinkAdaptor();
   inValidateSink = new TestSinkAdaptor();
   configurationContext = new TestConfigurationContext();
   invalidateObjectManager.initializeContext(configurationContext);
 }
  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());
  }