@Test
  public void shouldNotOverrideGivenScheme() {
    // pre-conditions

    // operations
    Connection connection = new ConnectionFake("fakeUser", "scheme://openshift.redhat.com");

    // verifications
    assertNotNull(connection.getHost());
    assertTrue(connection.getHost().startsWith("scheme://"));
    assertNotNull(connection.getScheme());
    assertEquals("scheme://", connection.getScheme());
  }
  @Test
  public void shouldHaveHostWithScheme() {
    // pre-conditions

    // operations
    Connection connection = new ConnectionFake("fakeUser", "openshift.redhat.com");

    // verifications
    assertNotNull(connection.getHost());
    assertTrue(connection.getHost().startsWith(UrlUtils.HTTP));
    assertNotNull(connection.getScheme());
    assertTrue(connection.getScheme().startsWith(UrlUtils.HTTP));
  }
  @Test
  public void nullHostShouldBeDefaultHost() {
    // pre-conditions

    // operations
    Connection connection = new ConnectionFake("fakeUser", null);

    // verifications
    assertTrue(connection.isDefaultHost());
    assertEquals(ConnectionUtils.getDefaultHostUrl(), connection.getHost());
  }
  @Test
  public void manuallySetDefaultHostShouldNotBeDefaultHost() {
    // pre-conditions
    String host = ConnectionUtils.getDefaultHostUrl();
    assertNotNull(host);

    // operations
    Connection connection = new ConnectionFake("fakeUser", host);

    // verifications
    assertFalse(connection.isDefaultHost());
    assertEquals(ConnectionUtils.getDefaultHostUrl(), connection.getHost());
  }
  @Test
  public void shouldAllowPortInUrl() throws UnsupportedEncodingException, MalformedURLException {
    // pre-conditions

    // operations
    ConnectionURL connectionUrl =
        ConnectionURL.forURL("http://adietish%40redhat.com@localhost:8081");
    Connection connection =
        new ConnectionFake(
            connectionUrl.getUsername(), connectionUrl.getScheme(), connectionUrl.getHost());

    // verifications
    assertEquals("http://localhost:8081", connection.getHost());
  }
  @Test
  public void shouldExtractUrlPortions()
      throws UnsupportedEncodingException, MalformedURLException {
    // pre-conditions
    String scheme = UrlUtils.SCHEME_HTTP;
    String username = "******";
    String password = "******";
    String server = "openshift.redhat.com";

    // operations
    ConnectionURL connectionUrl =
        ConnectionURL.forURL(
            scheme + URLEncoder.encode(username, "UTF-8") + ":" + password + "@" + server);
    Connection connection =
        new ConnectionFake(
            connectionUrl.getUsername(), connectionUrl.getScheme(), connectionUrl.getHost());

    // verifications
    assertEquals(scheme, connection.getScheme());
    assertEquals(username, connection.getUsername());
    assertEquals(scheme + server, connection.getHost());
  }