Configuration { void validatePort() throws UserErrorException { Integer port = getPort(); if (port == null) { throw new UserErrorException("a port must be specified with --port=... or as part of the address"); } Util.validatePort(port); } Configuration(String[] args);  Configuration(); boolean isVerbose(); void validate(); Mode getMode(); Protocol getProtocol(); String getLocalAddress(); InetAddress getLocalInetAddress(); Integer getLocalPort(); String getAddress(); InetAddress getInetAddress(); Integer getPort(); String getInterface(); NetworkInterface getNetworkInterface(); String getInterfaceName(); List<InterfaceAddress> getNetworkInterfaceAddresses(); InetAddress getNetworkInterfaceAddress(AddressType type); String getPayload(); @Override String toString(); void setAddress(String s); void setProtocol(Protocol p); void setMode(Mode m); void setNetworkInterface(NetworkInterface n); void setPort(Integer i); static final String VERBOSE_SYSTEM_PROPERTY_NAME; }
@Test public void validatePort() throws Exception { Configuration c = new Configuration(); try { c.validatePort(); fail("should throw exception"); } catch(UserErrorException e) { String msg = e.getMessage(); assertTrue(msg.contains("a port must be specified")); } }