DefaultTunnel extends AbstractLifecycleObservable implements Tunnel { @Override public void forwardToBackend(ByteBuf message) { backend().tryWrite(message); } DefaultTunnel(Channel frontendChannel, ProxyConnectProtocol protocol, ProxyConfig config,
                         ResourceManager resourceManager, TunnelMonitorManager tunnelMonitorManager); @Override TunnelIdentity identity(); @Override void forwardToBackend(ByteBuf message); @Override void forwardToFrontend(ByteBuf message); @Override FrontendSession frontend(); @Override BackendSession backend(); @Override TunnelMeta getTunnelMeta(); @Override TunnelState getState(); @Override ProxyConnectProtocol getProxyProtocol(); @Override TunnelMonitor getTunnelMonitor(); @Override void update(Object args, Observable observable); @Override int hashCode(); @Override void release();  }
@Test public void testForwardToBackend() { doAnswer(new Answer<ChannelFuture>() { @Override public ChannelFuture answer(InvocationOnMock invocation) throws Throwable { Object object = invocation.getArguments()[0]; Assert.assertTrue(object instanceof ByteBuf); Assert.assertEquals(testByteBuf, object); return null; } }).when(backend).tryWrite(testByteBuf); tunnel.forwardToBackend(testByteBuf); verify(backend).tryWrite(testByteBuf); verify(frontend, never()).tryWrite(any()); }