DefaultTunnelMonitorManager implements TunnelMonitorManager { @Override public void remove(Tunnel tunnel) { TunnelMonitor monitor = tunnelMonitors.remove(tunnel); try { if(monitor != null) { monitor.stop(); } } catch (Exception e) { logger.error("[stop tunnel-monitor]", e); } } DefaultTunnelMonitorManager();  DefaultTunnelMonitorManager(ResourceManager resourceManager); @Override TunnelMonitor getOrCreate(Tunnel tunnel); @Override void remove(Tunnel tunnel);  }
@Test public void testRemove() { Tunnel tunnel = mock(Tunnel.class); TunnelMonitor tunnelMonitor = tunnelMonitorManager.getOrCreate(tunnel); Assert.assertNotNull(tunnelMonitor); Assert.assertFalse(tunnelMonitorManager.getTunnelMonitors().isEmpty()); tunnelMonitorManager.remove(tunnel); Assert.assertTrue(tunnelMonitorManager.getTunnelMonitors().isEmpty()); }