public void testTeredoAddress_nullServer() { InetAddresses.TeredoInfo info = new InetAddresses.TeredoInfo(null, null, 80, 1000); assertEquals(InetAddresses.forString("0.0.0.0"), info.getServer()); assertEquals(InetAddresses.forString("0.0.0.0"), info.getClient()); assertEquals(80, info.getPort()); assertEquals(1000, info.getFlags()); }
public void testUnderPrivateDomain() { for (String name : UNDER_PRIVATE_DOMAIN) { final InternetDomainName domain = InternetDomainName.from(name); assertFalse(name, domain.isPublicSuffix()); assertTrue(name, domain.hasPublicSuffix()); assertTrue(name, domain.isUnderPublicSuffix()); assertFalse(name, domain.isTopPrivateDomain()); } }
public void test3ff31() { try { InetAddresses.forString("3ffe:::1"); fail("IllegalArgumentException expected"); } catch (IllegalArgumentException expected) { } assertFalse(InetAddresses.isInetAddress("016.016.016.016")); }
public void testToUriStringIPv4() { String ipStr = "1.2.3.4"; InetAddress ip = InetAddresses.forString(ipStr); assertEquals("1.2.3.4", InetAddresses.toUriString(ip)); }
public void testToString() { assertEquals("text/plain", MediaType.create("text", "plain").toString()); assertEquals( "text/plain; something=\"cr@zy\"; something-else=\"crazy with spaces\"", MediaType.create("text", "plain") .withParameter("something", "cr@zy") .withParameter("something-else", "crazy with spaces") .toString()); } }
public void testTopPrivateDomain() { for (String name : TOP_PRIVATE_DOMAIN) { final InternetDomainName domain = InternetDomainName.from(name); assertFalse(name, domain.isPublicSuffix()); assertTrue(name, domain.hasPublicSuffix()); assertTrue(name, domain.isUnderPublicSuffix()); assertTrue(name, domain.isTopPrivateDomain()); assertEquals(domain.parent(), domain.publicSuffix()); } }
public void testPublicSuffixExclusion() { InternetDomainName domain = InternetDomainName.from("foo.city.yokohama.jp"); assertTrue(domain.hasPublicSuffix()); assertEquals("yokohama.jp", domain.publicSuffix().toString()); // Behold the weirdness! assertFalse(domain.publicSuffix().isPublicSuffix()); }
public void testParentChild() { InternetDomainName origin = InternetDomainName.from("foo.com"); InternetDomainName parent = origin.parent(); assertEquals("com", parent.toString()); // These would throw an exception if leniency were not preserved during parent() and child() // calls. InternetDomainName child = parent.child(LOTS_OF_DELTAS); child.child(LOTS_OF_DELTAS); }
public void testRegistrySuffixMultipleUnders() { // PSL has both *.uk and *.sch.uk; the latter should win. // See http://code.google.com/p/guava-libraries/issues/detail?id=1176 InternetDomainName domain = InternetDomainName.from("www.essex.sch.uk"); assertTrue(domain.hasRegistrySuffix()); assertEquals("essex.sch.uk", domain.registrySuffix().toString()); assertEquals("www.essex.sch.uk", domain.topDomainUnderRegistrySuffix().toString()); }
public void testWithParameter_invalidAttribute() { MediaType mediaType = MediaType.parse("text/plain"); try { mediaType.withParameter("@", "2"); fail(); } catch (IllegalArgumentException expected) { } }
public void testTopDomainUnderRegistrySuffix() { for (String name : TOP_UNDER_REGISTRY_SUFFIX) { final InternetDomainName domain = InternetDomainName.from(name); assertFalse(name, domain.isRegistrySuffix()); assertTrue(name, domain.hasRegistrySuffix()); assertTrue(name, domain.isUnderRegistrySuffix()); assertTrue(name, domain.isTopDomainUnderRegistrySuffix()); assertEquals(domain.parent(), domain.registrySuffix()); } }
public void testValidTopPrivateDomain() { InternetDomainName googleDomain = InternetDomainName.from("google.com"); assertEquals(googleDomain, googleDomain.topPrivateDomain()); assertEquals(googleDomain, googleDomain.child("mail").topPrivateDomain()); assertEquals(googleDomain, googleDomain.child("foo.bar").topPrivateDomain()); }
public void testUnderRegistrySuffix() { for (String name : SOMEWHERE_UNDER_RS) { final InternetDomainName domain = InternetDomainName.from(name); assertFalse(name, domain.isRegistrySuffix()); assertTrue(name, domain.hasRegistrySuffix()); assertTrue(name, domain.isUnderRegistrySuffix()); } }
public void testCreateAudioType() { MediaType newType = MediaType.createAudioType("yams"); assertEquals("audio", newType.type()); assertEquals("yams", newType.subtype()); }
public void testCreateVideoType() { MediaType newType = MediaType.createVideoType("yams"); assertEquals("video", newType.type()); assertEquals("yams", newType.subtype()); }
private void assertGood(String spec) throws ParseException { HostSpecifier.fromValid(spec); // Throws exception if not working correctly HostSpecifier.from(spec); assertTrue(HostSpecifier.isValid(spec)); }
public void testToUriStringIPv6() { // Unfortunately the InetAddress.toString() method for IPv6 addresses // does not collapse contiguous shorts of zeroes with the :: abbreviation. String ipStr = "3ffe::1"; InetAddress ip = InetAddresses.forString(ipStr); assertEquals("[3ffe::1]", InetAddresses.toUriString(ip)); }