### Question:
HttpTransportUtils { public static String generateWsRemoteAddress(HttpServletRequest request) { if (request == null) { throw new IllegalArgumentException("HttpServletRequest must not be null."); } StringBuilder remoteAddress = new StringBuilder(); String scheme = request.getScheme(); remoteAddress.append(scheme != null && scheme.toLowerCase().equals("https") ? "wss: remoteAddress.append(request.getRemoteAddr()); remoteAddress.append(":"); remoteAddress.append(request.getRemotePort()); return remoteAddress.toString(); }  static String generateWsRemoteAddress(HttpServletRequest request); static String generateWsRemoteAddress(HttpServletRequest request, String schemePrefix);  }### Answer:
@Test public void testGenerateWsRemoteAddress() { HttpServletRequest request = mock(HttpServletRequest.class); when(request.getScheme()).thenReturn("http"); when(request.getRemoteAddr()).thenReturn("localhost"); when(request.getRemotePort()).thenReturn(8080); assertEquals("ws: }
@Test public void testGenerateWssRemoteAddress() { HttpServletRequest request = mock(HttpServletRequest.class); when(request.getScheme()).thenReturn("https"); when(request.getRemoteAddr()).thenReturn("localhost"); when(request.getRemotePort()).thenReturn(8443); assertEquals("wss: }
@Test(expected=IllegalArgumentException.class) public void testNullHttpServleRequest() { HttpTransportUtils.generateWsRemoteAddress(null); }