コード例 #1
0
  @Test
  public void shouldUpdate() {
    // pre-conditions
    ConnectionFake connection = new ConnectionFake("fakeUser", null);
    connection.setRememberPassword(true);
    connection.setConnected(true);
    assertTrue(connection.isConnected());
    assertTrue(connection.isDefaultHost());

    String newUsername = "******";
    String newHost = "http://www.redhat.com";
    String newPassword = "******";
    Connection updatingConnection = new ConnectionFake(newUsername, newHost);
    updatingConnection.setPassword(newPassword);
    updatingConnection.setRememberPassword(false);

    // operations
    connection.update(updatingConnection);

    // verifications
    assertEquals(newUsername, connection.getUsername());
    assertEquals(newHost, connection.getHost());
    assertFalse(newUsername, connection.isDefaultHost());
    assertEquals(newPassword, connection.getPassword());
    assertFalse(connection.isRememberPassword());
    assertFalse(connection.isConnected());
  }
コード例 #2
0
  @Test
  public void setHostShouldDisconnect() {
    // pre-conditions
    ConnectionFake connection = new ConnectionFake("fakeUser", "openshift.redhat.com");
    connection.setConnected(true);
    assertTrue(connection.isConnected());

    // operations
    connection.setHost("fakeHost");

    // verifications
    assertFalse(connection.isConnected());
  }