@Test public void portTest() { int port = URLInfo.getDefaultPort("ws"); Assert.assertEquals(80, port); port = URLInfo.getDefaultPort("wss"); Assert.assertEquals(443, port); port = URLInfo.getDefaultPort("http"); Assert.assertEquals(80, port); port = URLInfo.getDefaultPort("https"); Assert.assertEquals(443, port); port = URLInfo.getDefaultPort("unknown"); Assert.assertEquals(-1, port); }
public static int getDefaultPort(String scheme) { if (scheme == null) { throw new NullPointerException("scheme"); } if ("ws".equals(scheme) || "http".equals(scheme)) { return 80; } else if ("wss".equals(scheme) || "https".equals(scheme)) { return 443; } return -1; }
URLInfo { public static int getDefaultPort(String scheme) { if (scheme == null) { throw new NullPointerException("scheme"); } if ("ws".equals(scheme) || "http".equals(scheme)) { return 80; } else if ("wss".equals(scheme) || "https".equals(scheme)) { return 443; } return -1; } }
URLInfo { public static int getDefaultPort(String scheme) { if (scheme == null) { throw new NullPointerException("scheme"); } if ("ws".equals(scheme) || "http".equals(scheme)) { return 80; } else if ("wss".equals(scheme) || "https".equals(scheme)) { return 443; } return -1; } URLInfo(String protocol, String host,
                   int port, String path, boolean secure); }
URLInfo { public static int getDefaultPort(String scheme) { if (scheme == null) { throw new NullPointerException("scheme"); } if ("ws".equals(scheme) || "http".equals(scheme)) { return 80; } else if ("wss".equals(scheme) || "https".equals(scheme)) { return 443; } return -1; } URLInfo(String protocol, String host,
                   int port, String path, boolean secure); static int getDefaultPort(String scheme); static boolean getDefaultProtocolSecurity(String scheme); boolean getTrustAllCertificates(); static URLInfo parse(String url); static URLInfo parse(String url, Boolean secureOverride); void setTrustAllCertificates(boolean trust); }
URLInfo { public static int getDefaultPort(String scheme) { if (scheme == null) { throw new NullPointerException("scheme"); } if ("ws".equals(scheme) || "http".equals(scheme)) { return 80; } else if ("wss".equals(scheme) || "https".equals(scheme)) { return 443; } return -1; } URLInfo(String protocol, String host,
                   int port, String path, boolean secure); static int getDefaultPort(String scheme); static boolean getDefaultProtocolSecurity(String scheme); boolean getTrustAllCertificates(); static URLInfo parse(String url); static URLInfo parse(String url, Boolean secureOverride); void setTrustAllCertificates(boolean trust); final String protocol; final String host; final int port; final String path; final boolean secure; }