HttpUtil { public static HttpMethod createHttpMethod(String httpMethodString) { return Optional.ofNullable(HttpMethod.fromString(httpMethodString)) .filter(m -> m == GET || m == POST || m == PUT || m == DELETE) .orElseThrow(() -> new IllegalArgumentException("Given HTTP Method '" + httpMethodString + "' is unknown")); }  static String executeUrl(String httpMethod, String url, int timeout); static String executeUrl(String httpMethod, String url, InputStream content, String contentType, int timeout); static String executeUrl(String httpMethod, String url, Properties httpHeaders, InputStream content,
            String contentType, int timeout); static String executeUrl(String httpMethod, String url, Properties httpHeaders, InputStream content,
            String contentType, int timeout, String proxyHost, Integer proxyPort, String proxyUser,
            String proxyPassword, String nonProxyHosts); static HttpMethod createHttpMethod(String httpMethodString); static RawType downloadImage(String url); static RawType downloadImage(String url, int timeout); static RawType downloadImage(String url, boolean scanTypeInContent, long maxContentLength); static RawType downloadImage(String url, boolean scanTypeInContent, long maxContentLength, int timeout); static RawType downloadData(String url, String contentTypeRegex, boolean scanTypeInContent,
            long maxContentLength); static RawType downloadData(String url, String contentTypeRegex, boolean scanTypeInContent,
            long maxContentLength, int timeout); static String guessContentTypeFromData(byte[] data);  }
@Test public void testCreateHttpMethod() { assertEquals(HttpMethod.GET, HttpUtil.createHttpMethod("GET")); assertEquals(HttpMethod.PUT, HttpUtil.createHttpMethod("PUT")); assertEquals(HttpMethod.POST, HttpUtil.createHttpMethod("POST")); assertEquals(HttpMethod.DELETE, HttpUtil.createHttpMethod("DELETE")); }
@Test public void testCreateHttpMethodForUnsupportedFake() { IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, () -> HttpUtil.createHttpMethod("FAKE")); assertEquals("Given HTTP Method 'FAKE' is unknown", exception.getMessage()); }
@Test public void testCreateHttpMethodForUnsupportedTrace() { IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, () -> HttpUtil.createHttpMethod("TRACE")); assertEquals("Given HTTP Method 'TRACE' is unknown", exception.getMessage()); }