### Question:
ChromeServiceImpl implements ChromeService { @Override public synchronized ChromeDevToolsService createDevToolsService(ChromeTab tab) throws ChromeServiceException { return createDevToolsService(tab, new ChromeDevToolsServiceConfiguration()); } ChromeServiceImpl(String host, int port, WebSocketServiceFactory webSocketServiceFactory);  ChromeServiceImpl(String host, int port);  ChromeServiceImpl(int port);  ChromeServiceImpl(int port, WebSocketServiceFactory webSocketServiceFactory); void setWebSocketServiceFactory(WebSocketServiceFactory webSocketServiceFactory); @Override List<ChromeTab> getTabs(); @Override ChromeTab createTab(); @Override ChromeTab createTab(String tab); @Override void activateTab(ChromeTab tab); @Override void closeTab(ChromeTab tab); @Override ChromeVersion getVersion(); @Override synchronized ChromeDevToolsService createDevToolsService(ChromeTab tab); @Override synchronized ChromeDevToolsService createDevToolsService(
      ChromeTab tab, ChromeDevToolsServiceConfiguration chromeDevToolsServiceConfiguration); int getPort(); String getHost(); void clearChromeDevToolsServiceCache(ChromeTab tab); static String inputStreamToString(InputStream inputStream); static final String ABOUT_BLANK_PAGE; }### Answer:
@Test public void testGetDevTools() throws IOException, ChromeServiceException, WebSocketServiceException { ChromeServiceImpl service = new ChromeServiceImpl(9222, webSocketServiceFactory); ObjectMapper objectMapper = new ObjectMapper(); ChromeTab tab = objectMapper.readerFor(ChromeTab.class).readValue(getFixture("chrome/tab.json")); expect(webSocketServiceFactory.createWebSocketService(tab.getWebSocketDebuggerUrl())) .andReturn(webSocketService); webSocketService.addMessageHandler(anyObject()); replayAll(); ChromeDevTools devTools = service.createDevToolsService(tab); verifyAll(); assertNotNull(devTools); }
@Test public void testGetDevToolsIsCachedPerTab() throws IOException, ChromeServiceException, WebSocketServiceException { ChromeServiceImpl service = new ChromeServiceImpl(9222, webSocketServiceFactory); ObjectMapper objectMapper = new ObjectMapper(); ChromeTab tab = objectMapper.readerFor(ChromeTab.class).readValue(getFixture("chrome/tab.json")); expect(webSocketServiceFactory.createWebSocketService(tab.getWebSocketDebuggerUrl())) .andReturn(webSocketService); webSocketService.addMessageHandler(anyObject()); replayAll(); ChromeDevTools devTools = service.createDevToolsService(tab); assertTrue(devTools == service.createDevToolsService(tab)); assertTrue(devTools == service.createDevToolsService(tab)); assertTrue(devTools == service.createDevToolsService(tab)); verifyAll(); devTools = null; System.gc(); resetAll(); expect(webSocketServiceFactory.createWebSocketService(tab.getWebSocketDebuggerUrl())) .andReturn(webSocketService); webSocketService.addMessageHandler(anyObject()); replayAll(); devTools = service.createDevToolsService(tab); assertNotNull(devTools); }
@Test public void testGetDevToolsSubTypeIsCachedPerTab() throws IOException, ChromeServiceException, WebSocketServiceException { ChromeServiceImpl service = new ChromeServiceImpl(9222, webSocketServiceFactory); ObjectMapper objectMapper = new ObjectMapper(); ChromeTab tab = objectMapper.readerFor(ChromeTab.class).readValue(getFixture("chrome/tab.json")); expect(webSocketServiceFactory.createWebSocketService(tab.getWebSocketDebuggerUrl())) .andReturn(webSocketService); webSocketService.addMessageHandler(anyObject()); replayAll(); Network network = service.createDevToolsService(tab).getNetwork(); assertTrue(network == service.createDevToolsService(tab).getNetwork()); assertTrue(network == service.createDevToolsService(tab).getNetwork()); assertTrue(network == service.createDevToolsService(tab).getNetwork()); verifyAll(); assertNotNull(network); }