DefaultBackendSession extends AbstractSession implements BackendSession { @Override protected void doStart() throws Exception { super.doStart(); connect(); } DefaultBackendSession(Tunnel tunnel, EventLoopGroup eventLoopGroup, long trafficReportIntervalMillis,
                                 ResourceManager resourceManager); @Override void sendAfterProtocol(ByteBuf byteBuf); @Override SESSION_TYPE getSessionType(); SessionState getSessionState(); @Override SessionMonitor getSessionMonitor();  }
@Test public void doStart() throws Exception { when(selector.selectCounts()).thenReturn(1); when(selector.getCandidates()).thenReturn(Lists.newArrayList()); selector.setSelectStrategy(new SelectOneCycle(selector)); doCallRealMethod().when(selector).nextHop(); Throwable throwable = null; try { session.doStart(); } catch (Exception e) { throwable = e; } Assert.assertNotNull(throwable); Assert.assertTrue(throwable instanceof NoResourceException); }
@Test public void testDoStartWithNoNextAvailable() throws Exception { when(selector.selectCounts()).thenReturn(2); when(selector.getCandidates()).thenReturn(Lists.newArrayList(newProxyEndpoint(true, true), newProxyEndpoint(true, false))); selector.setSelectStrategy(new SelectOneCycle(selector)); doCallRealMethod().when(selector).nextHop(); Throwable throwable = null; try { session.doStart(); } catch (Exception e) { throwable = e; } Assert.assertNotNull(throwable); Assert.assertTrue(throwable instanceof NoResourceException); }
@Test public void testDoStart() throws Exception { session.endpoint = new DefaultProxyEndpoint("TCP: session.setSessionState(new SessionEstablished(session)); session.doStart(); verify(selector, never()).getCandidates(); }