@Test public void testValidatePortNumberValidValue() { String portStringValue = "821"; final int portNumber; portNumber = Integer.parseInt(portStringValue); assertEquals(portNumber, Utils.validatePortNumber(portStringValue)); }
public static int validatePortNumber(String portStringValue) { final int portNumber; final StringBuilder exceptionMessageBuilder = new StringBuilder(); exceptionMessageBuilder.append("Invalid value '").append(portStringValue) .append("' for input '").append(HttpClientInputs.PROXY_PORT) .append("'. Valid Values: -1 and integer values greater than 0. "); try { portNumber = Integer.parseInt(portStringValue); if ((portNumber <= 0) && (portNumber != -1)) { throw new IllegalArgumentException(exceptionMessageBuilder.toString()); } } catch (NumberFormatException e) { throw new IllegalArgumentException(exceptionMessageBuilder.toString(), e); } return portNumber; }
Utils { public static int validatePortNumber(String portStringValue) { final int portNumber; final StringBuilder exceptionMessageBuilder = new StringBuilder(); exceptionMessageBuilder.append("Invalid value '").append(portStringValue) .append("' for input '").append(HttpClientInputs.PROXY_PORT) .append("'. Valid Values: -1 and integer values greater than 0. "); try { portNumber = Integer.parseInt(portStringValue); if ((portNumber <= 0) && (portNumber != -1)) { throw new IllegalArgumentException(exceptionMessageBuilder.toString()); } } catch (NumberFormatException e) { throw new IllegalArgumentException(exceptionMessageBuilder.toString(), e); } return portNumber; } }
Utils { public static int validatePortNumber(String portStringValue) { final int portNumber; final StringBuilder exceptionMessageBuilder = new StringBuilder(); exceptionMessageBuilder.append("Invalid value '").append(portStringValue) .append("' for input '").append(HttpClientInputs.PROXY_PORT) .append("'. Valid Values: -1 and integer values greater than 0. "); try { portNumber = Integer.parseInt(portStringValue); if ((portNumber <= 0) && (portNumber != -1)) { throw new IllegalArgumentException(exceptionMessageBuilder.toString()); } } catch (NumberFormatException e) { throw new IllegalArgumentException(exceptionMessageBuilder.toString(), e); } return portNumber; }  }
Utils { public static int validatePortNumber(String portStringValue) { final int portNumber; final StringBuilder exceptionMessageBuilder = new StringBuilder(); exceptionMessageBuilder.append("Invalid value '").append(portStringValue) .append("' for input '").append(HttpClientInputs.PROXY_PORT) .append("'. Valid Values: -1 and integer values greater than 0. "); try { portNumber = Integer.parseInt(portStringValue); if ((portNumber <= 0) && (portNumber != -1)) { throw new IllegalArgumentException(exceptionMessageBuilder.toString()); } } catch (NumberFormatException e) { throw new IllegalArgumentException(exceptionMessageBuilder.toString(), e); } return portNumber; }  static List<? extends NameValuePair> urlEncodeMultipleParams(String params, boolean urlEncode); static String urlEncodeQueryParams(String params, boolean urlEncode); static int validatePortNumber(String portStringValue); }
Utils { public static int validatePortNumber(String portStringValue) { final int portNumber; final StringBuilder exceptionMessageBuilder = new StringBuilder(); exceptionMessageBuilder.append("Invalid value '").append(portStringValue) .append("' for input '").append(HttpClientInputs.PROXY_PORT) .append("'. Valid Values: -1 and integer values greater than 0. "); try { portNumber = Integer.parseInt(portStringValue); if ((portNumber <= 0) && (portNumber != -1)) { throw new IllegalArgumentException(exceptionMessageBuilder.toString()); } } catch (NumberFormatException e) { throw new IllegalArgumentException(exceptionMessageBuilder.toString(), e); } return portNumber; }  static List<? extends NameValuePair> urlEncodeMultipleParams(String params, boolean urlEncode); static String urlEncodeQueryParams(String params, boolean urlEncode); static int validatePortNumber(String portStringValue); static final String DEFAULT_CHARACTER_SET; }