@Test public void testButtonClick() { normalWindow.buttonClick(null); assertEquals("Failed to log in", normalWindow.testString); noPortWindow.portField.setValue(invalidPort); noPortWindow.buttonClick(null); assertEquals("Port must be between 1 and 65535", noPortWindow.testString); invalidHostWindow.buttonClick(null); assertEquals("Failed to connect to host", invalidHostWindow.testString); emptyWindow.portField.setValue(invalidPortString); emptyWindow.buttonClick(null); assertEquals("Port must be an integer", emptyWindow.testString); emptyWindow.portField.setValue(validPort); emptyWindow.hostField.setValue(invalidHost); emptyWindow.buttonClick(null); assertEquals("Failed to connect to host", emptyWindow.testString); }
@Override public void buttonClick(ClickEvent event) { String login = (String)usernameField.getValue(); String password = (String)passwordField.getValue(); boolean validInput = false; try { if (showOptions) { validInput = validateInput(); if (!validInput) { testString = "Port must be between 1 and 65535"; getApplication().getMainWindow().showNotification("Port must be between 1 and 65535", Notification.TYPE_WARNING_MESSAGE); } } else validInput = true; } catch (NumberFormatException e) { testString = "Port must be an integer"; getApplication().getMainWindow().showNotification("Port must be an integer", Notification.TYPE_WARNING_MESSAGE); } if (validInput) { try { session = client.connect(m_host, m_port).await().getSession(); int ret = ClientSession.WAIT_AUTH; if (session != null){ while ((ret & ClientSession.WAIT_AUTH) != 0) { session.authPassword(login, password); ret = session.waitFor(ClientSession.WAIT_AUTH | ClientSession.CLOSED | ClientSession.AUTHED, 0); } if ((ret & ClientSession.CLOSED) != 0) { testString = "Failed to log in"; getApplication().getMainWindow().showNotification("Failed to log in", Notification.TYPE_WARNING_MESSAGE); return; } showSSHWindow(); } } catch (Exception e) { testString = "Failed to connect to host"; getApplication().getMainWindow().showNotification("Failed to connect to host", Notification.TYPE_WARNING_MESSAGE); } } }
AuthWindow extends Window implements Button.ClickListener { @Override public void buttonClick(ClickEvent event) { String login = (String)usernameField.getValue(); String password = (String)passwordField.getValue(); boolean validInput = false; try { if (showOptions) { validInput = validateInput(); if (!validInput) { testString = "Port must be between 1 and 65535"; getApplication().getMainWindow().showNotification("Port must be between 1 and 65535", Notification.TYPE_WARNING_MESSAGE); } } else validInput = true; } catch (NumberFormatException e) { testString = "Port must be an integer"; getApplication().getMainWindow().showNotification("Port must be an integer", Notification.TYPE_WARNING_MESSAGE); } if (validInput) { try { session = client.connect(m_host, m_port).await().getSession(); int ret = ClientSession.WAIT_AUTH; if (session != null){ while ((ret & ClientSession.WAIT_AUTH) != 0) { session.authPassword(login, password); ret = session.waitFor(ClientSession.WAIT_AUTH | ClientSession.CLOSED | ClientSession.AUTHED, 0); } if ((ret & ClientSession.CLOSED) != 0) { testString = "Failed to log in"; getApplication().getMainWindow().showNotification("Failed to log in", Notification.TYPE_WARNING_MESSAGE); return; } showSSHWindow(); } } catch (Exception e) { testString = "Failed to connect to host"; getApplication().getMainWindow().showNotification("Failed to connect to host", Notification.TYPE_WARNING_MESSAGE); } } } }
AuthWindow extends Window implements Button.ClickListener { @Override public void buttonClick(ClickEvent event) { String login = (String)usernameField.getValue(); String password = (String)passwordField.getValue(); boolean validInput = false; try { if (showOptions) { validInput = validateInput(); if (!validInput) { testString = "Port must be between 1 and 65535"; getApplication().getMainWindow().showNotification("Port must be between 1 and 65535", Notification.TYPE_WARNING_MESSAGE); } } else validInput = true; } catch (NumberFormatException e) { testString = "Port must be an integer"; getApplication().getMainWindow().showNotification("Port must be an integer", Notification.TYPE_WARNING_MESSAGE); } if (validInput) { try { session = client.connect(m_host, m_port).await().getSession(); int ret = ClientSession.WAIT_AUTH; if (session != null){ while ((ret & ClientSession.WAIT_AUTH) != 0) { session.authPassword(login, password); ret = session.waitFor(ClientSession.WAIT_AUTH | ClientSession.CLOSED | ClientSession.AUTHED, 0); } if ((ret & ClientSession.CLOSED) != 0) { testString = "Failed to log in"; getApplication().getMainWindow().showNotification("Failed to log in", Notification.TYPE_WARNING_MESSAGE); return; } showSSHWindow(); } } catch (Exception e) { testString = "Failed to connect to host"; getApplication().getMainWindow().showNotification("Failed to connect to host", Notification.TYPE_WARNING_MESSAGE); } } } AuthWindow(String host, int port); }
AuthWindow extends Window implements Button.ClickListener { @Override public void buttonClick(ClickEvent event) { String login = (String)usernameField.getValue(); String password = (String)passwordField.getValue(); boolean validInput = false; try { if (showOptions) { validInput = validateInput(); if (!validInput) { testString = "Port must be between 1 and 65535"; getApplication().getMainWindow().showNotification("Port must be between 1 and 65535", Notification.TYPE_WARNING_MESSAGE); } } else validInput = true; } catch (NumberFormatException e) { testString = "Port must be an integer"; getApplication().getMainWindow().showNotification("Port must be an integer", Notification.TYPE_WARNING_MESSAGE); } if (validInput) { try { session = client.connect(m_host, m_port).await().getSession(); int ret = ClientSession.WAIT_AUTH; if (session != null){ while ((ret & ClientSession.WAIT_AUTH) != 0) { session.authPassword(login, password); ret = session.waitFor(ClientSession.WAIT_AUTH | ClientSession.CLOSED | ClientSession.AUTHED, 0); } if ((ret & ClientSession.CLOSED) != 0) { testString = "Failed to log in"; getApplication().getMainWindow().showNotification("Failed to log in", Notification.TYPE_WARNING_MESSAGE); return; } showSSHWindow(); } } catch (Exception e) { testString = "Failed to connect to host"; getApplication().getMainWindow().showNotification("Failed to connect to host", Notification.TYPE_WARNING_MESSAGE); } } } AuthWindow(String host, int port); @Override void attach(); @Override void buttonClick(ClickEvent event); }
AuthWindow extends Window implements Button.ClickListener { @Override public void buttonClick(ClickEvent event) { String login = (String)usernameField.getValue(); String password = (String)passwordField.getValue(); boolean validInput = false; try { if (showOptions) { validInput = validateInput(); if (!validInput) { testString = "Port must be between 1 and 65535"; getApplication().getMainWindow().showNotification("Port must be between 1 and 65535", Notification.TYPE_WARNING_MESSAGE); } } else validInput = true; } catch (NumberFormatException e) { testString = "Port must be an integer"; getApplication().getMainWindow().showNotification("Port must be an integer", Notification.TYPE_WARNING_MESSAGE); } if (validInput) { try { session = client.connect(m_host, m_port).await().getSession(); int ret = ClientSession.WAIT_AUTH; if (session != null){ while ((ret & ClientSession.WAIT_AUTH) != 0) { session.authPassword(login, password); ret = session.waitFor(ClientSession.WAIT_AUTH | ClientSession.CLOSED | ClientSession.AUTHED, 0); } if ((ret & ClientSession.CLOSED) != 0) { testString = "Failed to log in"; getApplication().getMainWindow().showNotification("Failed to log in", Notification.TYPE_WARNING_MESSAGE); return; } showSSHWindow(); } } catch (Exception e) { testString = "Failed to connect to host"; getApplication().getMainWindow().showNotification("Failed to connect to host", Notification.TYPE_WARNING_MESSAGE); } } } AuthWindow(String host, int port); @Override void attach(); @Override void buttonClick(ClickEvent event);  }