@Test public void testBuildURL_nonIntegerInput() { pingWindow.numericalDataCheckBox.setValue(true); pingWindow.packetSizeDropdown.setValue("1024"); pingWindow.requestsField.setValue("abcd"); pingWindow.timeoutField.setValue("abcd"); assertNull(pingWindow.buildURL()); }
protected URL buildURL() { boolean validInput = false; try { validInput = validateInput(); } catch (NumberFormatException e) { getApplication().getMainWindow().showNotification("Inputs must be integers", Notification.TYPE_WARNING_MESSAGE); return null; } if (validInput) { final URL baseUrl = getApplication().getURL(); final StringBuilder options = new StringBuilder(baseAddress); options.append("&address=").append(ipDropdown.getValue()) .append("&timeout=").append(timeoutField.getValue()) .append("&numberOfRequests=").append(requestsField.getValue()) .append("&packetSize=").append(Integer.parseInt(packetSizeDropdown.getValue().toString()) - 8); if (numericalDataCheckBox.getValue().equals(true)) { options.append("&numericOutput=true"); } try { return new URL(baseUrl, options.toString()); } catch (final MalformedURLException e) { getApplication().getMainWindow().showNotification("Could not build URL: " + options.toString(), Notification.TYPE_WARNING_MESSAGE); return null; } } else { getApplication().getMainWindow().showNotification("Inputs must be between 0 and 9999", Notification.TYPE_WARNING_MESSAGE); return null; } }
PingWindow extends Window { protected URL buildURL() { boolean validInput = false; try { validInput = validateInput(); } catch (NumberFormatException e) { getApplication().getMainWindow().showNotification("Inputs must be integers", Notification.TYPE_WARNING_MESSAGE); return null; } if (validInput) { final URL baseUrl = getApplication().getURL(); final StringBuilder options = new StringBuilder(baseAddress); options.append("&address=").append(ipDropdown.getValue()) .append("&timeout=").append(timeoutField.getValue()) .append("&numberOfRequests=").append(requestsField.getValue()) .append("&packetSize=").append(Integer.parseInt(packetSizeDropdown.getValue().toString()) - 8); if (numericalDataCheckBox.getValue().equals(true)) { options.append("&numericOutput=true"); } try { return new URL(baseUrl, options.toString()); } catch (final MalformedURLException e) { getApplication().getMainWindow().showNotification("Could not build URL: " + options.toString(), Notification.TYPE_WARNING_MESSAGE); return null; } } else { getApplication().getMainWindow().showNotification("Inputs must be between 0 and 9999", Notification.TYPE_WARNING_MESSAGE); return null; } } }
PingWindow extends Window { protected URL buildURL() { boolean validInput = false; try { validInput = validateInput(); } catch (NumberFormatException e) { getApplication().getMainWindow().showNotification("Inputs must be integers", Notification.TYPE_WARNING_MESSAGE); return null; } if (validInput) { final URL baseUrl = getApplication().getURL(); final StringBuilder options = new StringBuilder(baseAddress); options.append("&address=").append(ipDropdown.getValue()) .append("&timeout=").append(timeoutField.getValue()) .append("&numberOfRequests=").append(requestsField.getValue()) .append("&packetSize=").append(Integer.parseInt(packetSizeDropdown.getValue().toString()) - 8); if (numericalDataCheckBox.getValue().equals(true)) { options.append("&numericOutput=true"); } try { return new URL(baseUrl, options.toString()); } catch (final MalformedURLException e) { getApplication().getMainWindow().showNotification("Could not build URL: " + options.toString(), Notification.TYPE_WARNING_MESSAGE); return null; } } else { getApplication().getMainWindow().showNotification("Inputs must be between 0 and 9999", Notification.TYPE_WARNING_MESSAGE); return null; } } PingWindow(final Node node, final String baseAddress); }
PingWindow extends Window { protected URL buildURL() { boolean validInput = false; try { validInput = validateInput(); } catch (NumberFormatException e) { getApplication().getMainWindow().showNotification("Inputs must be integers", Notification.TYPE_WARNING_MESSAGE); return null; } if (validInput) { final URL baseUrl = getApplication().getURL(); final StringBuilder options = new StringBuilder(baseAddress); options.append("&address=").append(ipDropdown.getValue()) .append("&timeout=").append(timeoutField.getValue()) .append("&numberOfRequests=").append(requestsField.getValue()) .append("&packetSize=").append(Integer.parseInt(packetSizeDropdown.getValue().toString()) - 8); if (numericalDataCheckBox.getValue().equals(true)) { options.append("&numericOutput=true"); } try { return new URL(baseUrl, options.toString()); } catch (final MalformedURLException e) { getApplication().getMainWindow().showNotification("Could not build URL: " + options.toString(), Notification.TYPE_WARNING_MESSAGE); return null; } } else { getApplication().getMainWindow().showNotification("Inputs must be between 0 and 9999", Notification.TYPE_WARNING_MESSAGE); return null; } } PingWindow(final Node node, final String baseAddress); @Override void attach(); }
PingWindow extends Window { protected URL buildURL() { boolean validInput = false; try { validInput = validateInput(); } catch (NumberFormatException e) { getApplication().getMainWindow().showNotification("Inputs must be integers", Notification.TYPE_WARNING_MESSAGE); return null; } if (validInput) { final URL baseUrl = getApplication().getURL(); final StringBuilder options = new StringBuilder(baseAddress); options.append("&address=").append(ipDropdown.getValue()) .append("&timeout=").append(timeoutField.getValue()) .append("&numberOfRequests=").append(requestsField.getValue()) .append("&packetSize=").append(Integer.parseInt(packetSizeDropdown.getValue().toString()) - 8); if (numericalDataCheckBox.getValue().equals(true)) { options.append("&numericOutput=true"); } try { return new URL(baseUrl, options.toString()); } catch (final MalformedURLException e) { getApplication().getMainWindow().showNotification("Could not build URL: " + options.toString(), Notification.TYPE_WARNING_MESSAGE); return null; } } else { getApplication().getMainWindow().showNotification("Inputs must be between 0 and 9999", Notification.TYPE_WARNING_MESSAGE); return null; } } PingWindow(final Node node, final String baseAddress); @Override void attach();  }