@Test public void preparedConnectionCountShouldBeAutomaticallySetToAtLeastNumberOfIoThreads() throws Exception { Mockery context = new Mockery() {{ setImposteriser(ClassImposteriser.INSTANCE); }}; final AbstractProxyHandler handler = context.mock(AbstractProxyHandler.class); final ServiceContext service = context.mock(ServiceContext.class); final Logger logger = context.mock(Logger.class); final BridgeServiceFactory bridgeServiceFactory = context.mock(BridgeServiceFactory.class); final TransportFactory transportFactory = context.mock(TransportFactory.class); final Transport transport = context.mock(Transport.class); final NioSocketAcceptor acceptor = context.mock(NioSocketAcceptor.class); final String CONNECT_URI = "http: final int PREPARED_CONNECTION_COUNT = 2; final int IO_THREADS = 3; context.checking(new Expectations() { { allowing(service).getLogger(); will(returnValue(logger)); allowing(service).getProcessorCount(); will(returnValue(IO_THREADS)); allowing(logger).isDebugEnabled(); will(returnValue(true)); allowing(service).getSchedulerProvider(); will(returnValue(null)); allowing(service).getServiceType(); will(returnValue("proxy")); oneOf(logger).debug(with(any(String.class))); allowing(logger).isWarnEnabled(); will(returnValue(true)); oneOf(logger).warn(with(any(String.class))); allowing(logger).isTraceEnabled(); will(returnValue(false)); allowing(bridgeServiceFactory).getTransportFactory(); will(returnValue(transportFactory)); allowing(transportFactory).getTransport("tcp"); will(returnValue(transport)); allowing(transport).getAcceptor(); will(returnValue(acceptor)); } }); final ServiceConnectManager manager = new ServiceConnectManager(service, handler, bridgeServiceFactory, CONNECT_URI, 0 , PREPARED_CONNECTION_COUNT ); assertEquals(IO_THREADS, manager.getPreparedConnectionCount()); context.assertIsSatisfied(); }
int getPreparedConnectionCount() { return preparedConnectionCount; }
ServiceConnectManager { int getPreparedConnectionCount() { return preparedConnectionCount; } }
ServiceConnectManager { int getPreparedConnectionCount() { return preparedConnectionCount; } ServiceConnectManager(ServiceContext service,
                                 AbstractProxyHandler connectHandler,
                                 BridgeServiceFactory bridgeServiceFactory,
                                 String connectURI,
                                 int interval,
                                 final int preparedConnectionCount); }
ServiceConnectManager { int getPreparedConnectionCount() { return preparedConnectionCount; } ServiceConnectManager(ServiceContext service,
                                 AbstractProxyHandler connectHandler,
                                 BridgeServiceFactory bridgeServiceFactory,
                                 String connectURI,
                                 int interval,
                                 final int preparedConnectionCount); void start(); ConnectFuture getNextConnectFuture(final IoSessionInitializer<ConnectFuture> connectInitializer); long getLastSuccessfulConnectTime(); long getLastFailedConnectTime(); boolean getLastHeartbeatPingResult(); long getLastHeartbeatPingTimestamp(); int getHeartbeatPingCount(); int getHeartbeatPingSuccessesCount(); int getHeartbeatPingFailuresCount(); boolean isServiceConnected(); boolean isHeartbeatRunning(); }
ServiceConnectManager { int getPreparedConnectionCount() { return preparedConnectionCount; } ServiceConnectManager(ServiceContext service,
                                 AbstractProxyHandler connectHandler,
                                 BridgeServiceFactory bridgeServiceFactory,
                                 String connectURI,
                                 int interval,
                                 final int preparedConnectionCount); void start(); ConnectFuture getNextConnectFuture(final IoSessionInitializer<ConnectFuture> connectInitializer); long getLastSuccessfulConnectTime(); long getLastFailedConnectTime(); boolean getLastHeartbeatPingResult(); long getLastHeartbeatPingTimestamp(); int getHeartbeatPingCount(); int getHeartbeatPingSuccessesCount(); int getHeartbeatPingFailuresCount(); boolean isServiceConnected(); boolean isHeartbeatRunning();  }