HttpUtils { public static String completeUrlWithHttpIfProtocolIsNotHttpOrHttpsOrPropertyExpansion(String endpoint) { if (StringUtils.isNullOrEmpty(endpoint)) { return endpoint; } endpoint = endpoint.trim(); String lowerCaseEndpoint = endpoint.toLowerCase(); if (!lowerCaseEndpoint.startsWith("http: return "http: } return endpoint; }  static boolean isErrorStatus(int statusCode); static String extractHttpHeaderParameter(String headerString, String parameterName); static String completeUrlWithHttpIfProtocolIsNotHttpOrHttpsOrPropertyExpansion(String endpoint); static String completeUrlWithHttpIfProtocolIsMissing(String endpoint); static boolean ping(String host, int timeout); static String urlEncodeWithUtf8(String input); static String getPingErrorMessage(); static java.net.URI createUri(URI uri); static java.net.URI createUri(String scheme, String userinfo, String host, int port, String escapedPath,
                                         String escapedQuery, String escapedFragment);  }
@Test public void nullURLShouldBeReturnNull() throws Exception{ assertEquals(null, HttpUtils.completeUrlWithHttpIfProtocolIsNotHttpOrHttpsOrPropertyExpansion(null)); }
@Test public void emptyURLShouldBeReturnEmpty() throws Exception{ assertEquals("", HttpUtils.completeUrlWithHttpIfProtocolIsNotHttpOrHttpsOrPropertyExpansion("")); }
@Test public void mixedCaseURLsShouldNotGetForcedToLowerCase() throws Exception { assertEquals(mixedCaseURL1, HttpUtils.completeUrlWithHttpIfProtocolIsNotHttpOrHttpsOrPropertyExpansion(mixedCaseURL1)); }
@Test public void trailingSpaceURLsShouldStillGetTrimmed() throws Exception { assertEquals("http: }
@Test public void missingProtocolURLsShouldGetHTTPProtocolAdded() throws Exception { assertEquals("http: }
@Test public void entirelyUppercaseHTTPURLShouldRemainUnchanged() throws Exception { assertEquals("HTTP: }
@Test public void entirelyUppercaseHTTPSURLShouldRemainUnchanged() throws Exception { assertEquals("HTTPS: }
@Test public void propertyExpansionsShouldNotGoToLowerCaseEither() throws Exception { assertEquals(propertyExpansionExample, HttpUtils.completeUrlWithHttpIfProtocolIsNotHttpOrHttpsOrPropertyExpansion(propertyExpansionExample)); }