@Test public void validateFormWithSSHTunnelingAndPassphraseAuthMethodToBeAsked() { frameFixture.textBox("labelField").setText("MyServer"); frameFixture.textBox("serverUrlsField").setText("localhost:25"); frameFixture.tabbedPane("tabbedSettings") .selectTab("SSH"); frameFixture.textBox("sshProxyUrlField").setText("remotehost:22"); frameFixture.comboBox("sshAuthenticationMethodComboBox").requireSelection("Private key"); frameFixture.label("passLabel").requireText("Passphrase:"); frameFixture.textBox("sshPrivateKeyPathField").setText("/Users/myself/.ssh/id_rsa"); frameFixture.textBox("sshProxyUsernameField").setText("john.doe"); ServerConfiguration configuration = new ServerConfiguration(); configurationPanel.applyConfigurationData(configuration); assertThat(configuration.getServerUrls()).containsExactly("localhost:25"); SshTunnelingConfiguration sshTunnelingConfiguration = configuration.getSshTunnelingConfiguration(); assertThat(sshTunnelingConfiguration).isNotNull(); assertThat(sshTunnelingConfiguration.getProxyUrl()).isEqualTo("remotehost:22"); assertThat(sshTunnelingConfiguration.getAuthenticationMethod()).isEqualTo(AuthenticationMethod.PRIVATE_KEY); assertThat(sshTunnelingConfiguration.getPrivateKeyPath()).isEqualTo("/Users/myself/.ssh/id_rsa"); assertThat(sshTunnelingConfiguration.getProxyUser()).isEqualTo("john.doe"); }
@RunsInEDT @Override @Nonnull public JTabbedPaneFixture tabbedPane(@Nonnull GenericTypeMatcher<? extends JTabbedPane> matcher) { return new JTabbedPaneFixture(robot(), find(matcher)); }
@RunsInEDT @Override @Nonnull public JTabbedPaneFixture tabbedPane(@Nullable String name) { return new JTabbedPaneFixture(robot(), findByName(name, JTabbedPane.class)); }
/** * Simulates a user selecting the tab located at the given index. * * @param index the index of the tab to select. * @return this fixture. * @throws IllegalStateException if this fixture's {@code JTabbedPane} is disabled. * @throws IllegalStateException if this fixture's {@code JTabbedPane} is not showing on the screen. * @throws IndexOutOfBoundsException if the given index is not within the {@code JTabbedPane} bounds. */ @Nonnull public JTabbedPaneFixture selectTab(int index) { driver().selectTab(target(), index); return this; }
@Test public void validateFormWithSSHTunnelingAndPassphraseAuthMethod() { frameFixture.textBox("labelField").setText("MyServer"); frameFixture.textBox("serverUrlsField").setText("localhost:25"); frameFixture.tabbedPane("tabbedSettings") .selectTab("SSH"); frameFixture.textBox("sshProxyUrlField").setText("remotehost:22"); frameFixture.comboBox("sshAuthenticationMethodComboBox").requireSelection("Private key"); frameFixture.label("passLabel").requireText("Passphrase:"); frameFixture.textBox("sshPrivateKeyPathField").setText("/Users/myself/.ssh/id_rsa"); frameFixture.textBox("sshProxyUsernameField").setText("john.doe"); frameFixture.textBox("sshProxyPasswordField").setText("mySecuredPassphrase"); ServerConfiguration configuration = new ServerConfiguration(); configurationPanel.applyConfigurationData(configuration); assertThat(configuration.getServerUrls()).containsExactly("localhost:25"); SshTunnelingConfiguration sshTunnelingConfiguration = configuration.getSshTunnelingConfiguration(); assertThat(sshTunnelingConfiguration).isNotNull(); assertThat(sshTunnelingConfiguration.getProxyUrl()).isEqualTo("remotehost:22"); assertThat(sshTunnelingConfiguration.getAuthenticationMethod()).isEqualTo(AuthenticationMethod.PRIVATE_KEY); assertThat(sshTunnelingConfiguration.getPrivateKeyPath()).isEqualTo("/Users/myself/.ssh/id_rsa"); assertThat(sshTunnelingConfiguration.getProxyUser()).isEqualTo("john.doe"); assertThat(sshTunnelingConfiguration.getProxyPassword()).isEqualTo("mySecuredPassphrase"); }
@RunsInEDT @Override @Nonnull public JTabbedPaneFixture tabbedPane() { return new JTabbedPaneFixture(robot(), findByType(JTabbedPane.class)); }
/** * Asserts that this fixture's {@code JTabbedPane} has the tab at the given index selected. * * @param expected the expected index of the selected tab. * @return this fixture. * @throws AssertionError if this fixture's {@code JTabbedPane}'s selected tab does not have the given index. */ @Nonnull public JTabbedPaneFixture requireSelectedTab(@Nonnull Index expected) { driver().requireSelectedTab(target(), expected); return this; }
@Test public void validateFormWithSSHTunnelingAndPasswordAuthMethod() { frameFixture.textBox("labelField").setText("MyServer"); frameFixture.textBox("serverUrlsField").setText("localhost:25"); frameFixture.tabbedPane("tabbedSettings") .selectTab("SSH"); frameFixture.textBox("sshProxyUrlField").setText("remotehost:22"); frameFixture.comboBox("sshAuthenticationMethodComboBox").selectItem("Password"); frameFixture.label("passLabel").requireText("Password:"); frameFixture.panel(new TextFieldWithBrowseButtonGenericTypeMatcher("sshPrivateKeyPathComponent")).requireNotVisible(); frameFixture.textBox("sshProxyUsernameField").setText("john.doe"); frameFixture.textBox("sshProxyPasswordField").setText("myPassword"); ServerConfiguration configuration = new ServerConfiguration(); configurationPanel.applyConfigurationData(configuration); assertThat(configuration.getServerUrls()).containsExactly("localhost:25"); SshTunnelingConfiguration sshTunnelingConfiguration = configuration.getSshTunnelingConfiguration(); assertThat(sshTunnelingConfiguration).isNotNull(); assertThat(sshTunnelingConfiguration.getProxyUrl()).isEqualTo("remotehost:22"); assertThat(sshTunnelingConfiguration.getAuthenticationMethod()).isEqualTo(AuthenticationMethod.PASSWORD); assertThat(sshTunnelingConfiguration.getProxyUser()).isEqualTo("john.doe"); assertThat(sshTunnelingConfiguration.getPrivateKeyPath()).isNull(); assertThat(sshTunnelingConfiguration.getProxyPassword()).isEqualTo("myPassword"); }
/** * Asserts that the tabs of this fixture's {@code JTabbedPane} have the given titles. The tab titles are evaluated by * index order, for example, the first tab is expected to have the first title in the given array, and so on. * * @param titles the expected titles. * @return this fixture. * @throws AssertionError if the title of any of the tabs is not equal to the expected titles. */ @Nonnull public JTabbedPaneFixture requireTabTitles(@Nonnull String... titles) { driver().requireTabTitles(target(), titles); return this; }
@Test public void validateFormWithOneServerUrl() { frameFixture.textBox("labelField").setText("MyServer"); frameFixture.textBox("serverUrlsField").setText("localhost:25"); frameFixture.checkBox("sslConnectionField").check(); JComboBoxFixture readPreferenceComboBox = frameFixture.comboBox("readPreferenceComboBox"); readPreferenceComboBox.replaceCellReader(new ReadPreferenceComboBoxCellReader()); readPreferenceComboBox.requireSelection("primary"); readPreferenceComboBox.selectItem("secondary"); frameFixture.textBox("userDatabaseField").setText("mydatabase"); frameFixture.tabbedPane("tabbedSettings") .selectTab("Authentication"); frameFixture.textBox("usernameField").setText("john"); frameFixture.textBox("passwordField").setText("johnpassword"); frameFixture.radioButton("scramSHA1AuthField").requireSelected(); frameFixture.radioButton("mongoCRAuthField").click(); ServerConfiguration configuration = new ServerConfiguration(); configurationPanel.applyConfigurationData(configuration); assertThat(configuration.getLabel()).isEqualTo("MyServer"); assertThat(configuration.getServerUrls()).containsExactly("localhost:25"); assertThat(configuration.isSslConnection()).isTrue(); assertThat(configuration.getReadPreference()).isEqualTo(ReadPreference.secondary()); assertThat(configuration.getUsername()).isEqualTo("john"); assertThat(configuration.getPassword()).isEqualTo("johnpassword"); assertThat(configuration.getUserDatabase()).isEqualTo("mydatabase"); assertThat(configuration.getAuthenticationMechanism()).isEqualTo(AuthenticationMechanism.MONGODB_CR); assertThat(configuration.getSshTunnelingConfiguration()).isEqualTo(SshTunnelingConfiguration.EMPTY); }
/** * Asserts that the tab at the given index is enabled. * * @param index the index of the tab. * @return this fixture. * @throws IndexOutOfBoundsException if the given index is not within the {@code JTabbedPane} bounds. * @throws AssertionError if the tab at the given index is not enabled. */ @Nonnull public JTabbedPaneFixture requireEnabled(@Nonnull Index index) { driver().requireTabEnabled(target(), index); return this; }
@Test public void loadFormWithSSHTunneling() { ServerConfiguration configuration = ServerConfiguration.byDefault(); configuration.setSshTunnelingConfiguration( new SshTunnelingConfiguration("remotehost:22", "john.doe", AuthenticationMethod.PASSWORD, "", "mySecuredPassword")); configurationPanel.loadConfigurationData(configuration); frameFixture.tabbedPane("tabbedSettings") .selectTab("SSH"); frameFixture.textBox("sshProxyUrlField").requireText("remotehost:22"); frameFixture.textBox("sshProxyUsernameField").requireText("john.doe"); frameFixture.comboBox("sshAuthenticationMethodComboBox").requireSelection("Password"); frameFixture.textBox("sshProxyPasswordField").requireText("mySecuredPassword"); }
/** * Simulates a user selecting the tab whose title matches the given value. * * @param title the title to match. It can be a regular expression. * @return this fixture. * @throws IllegalStateException if this fixture's {@code JTabbedPane} is disabled. * @throws IllegalStateException if this fixture's {@code JTabbedPane} is not showing on the screen. * @throws org.assertj.swing.exception.LocationUnavailableException if a tab matching the given title could not be found. */ @Nonnull public JTabbedPaneFixture selectTab(@Nullable String title) { driver().selectTab(target(), title); return this; }
@Test public void loadFormWithEmptyConfiguration() { ServerConfiguration configuration = ServerConfiguration.byDefault(); configuration.setUsername("john"); configuration.setPassword("johnpassword"); configuration.setReadPreference(ReadPreference.nearest()); configurationPanel.loadConfigurationData(configuration); frameFixture.textBox("serverUrlsField").requireText("localhost:27017"); JComboBoxFixture readPreferenceComboBox = frameFixture.comboBox("readPreferenceComboBox"); readPreferenceComboBox.replaceCellReader(new ReadPreferenceComboBoxCellReader()); readPreferenceComboBox.requireSelection("nearest"); frameFixture.tabbedPane("tabbedSettings") .selectTab("Authentication"); frameFixture.textBox("usernameField").requireText("john"); frameFixture.textBox("passwordField").requireText("johnpassword"); frameFixture.tabbedPane("tabbedSettings") .selectTab("SSH"); frameFixture.textBox("sshProxyUrlField").requireEmpty(); frameFixture.comboBox("sshAuthenticationMethodComboBox").requireSelection("Private key"); frameFixture.textBox("sshPrivateKeyPathField").requireEmpty(); frameFixture.textBox("sshProxyUsernameField").requireEmpty(); frameFixture.textBox("sshProxyPasswordField").requireEmpty(); }
/** * Asserts that the tab at the given index is disabled. * * @param index the index of the tab. * @return this fixture. * @throws IndexOutOfBoundsException if the given index is not within the {@code JTabbedPane} bounds. * @throws AssertionError if the tab at the given index is not disabled. */ @Nonnull public JTabbedPaneFixture requireDisabled(@Nonnull Index index) { driver().requireTabDisabled(target(), index); return this; } }
public void chooseTab(int index) { me().selectTab(index); }
/** * Asserts that the toolTipText of the tab at the given index matches the given value. * * @param toolTipText the expected toolTipText. It can be a regular expression. * @param index the index of the tab. * @return this fixture. * @throws IndexOutOfBoundsException if the given index is not within the {@code JTabbedPane} bounds. * @throws AssertionError if the toolTipText of the tab at the given index does not match the given one. */ @Nonnull public JTabbedPaneFixture requireToolTipText(@Nullable String toolTipText, @Nonnull Index index) { driver().requireTabToolTipText(target(), toolTipText, index); return this; }
/** * Simulates a user selecting the tab whose title matches the given regular expression pattern. * * @param pattern the regular expression pattern to match. * @return this fixture. * @throws IllegalStateException if this fixture's {@code JTabbedPane} is disabled. * @throws IllegalStateException if this fixture's {@code JTabbedPane} is not showing on the screen. * @throws NullPointerException if the given regular expression pattern is {@code null}. * @throws org.assertj.swing.exception.LocationUnavailableException if a tab matching the given regular expression pattern could not be found. */ @Nonnull public JTabbedPaneFixture selectTab(@Nonnull Pattern pattern) { driver().selectTab(target(), pattern); return this; }
/** * Asserts that the toolTipText of the tab at the given index matches the given regular expression pattern. * * @param pattern the regular expression pattern to match. * @param index the index of the tab. * @return this fixture. * @throws NullPointerException if the given regular expression pattern is {@code null}. * @throws AssertionError if the toolTipText of the tab at the given index does not match the given regular expression * pattern. */ @Nonnull public JTabbedPaneFixture requireToolTipText(@Nonnull Pattern pattern, @Nonnull Index index) { driver().requireTabToolTipText(target(), pattern, index); return this; }