public void testInvalid() { for (String name : INVALID_NAME) { try { InternetDomainName.from(name); fail("Should have been invalid: '" + name + "'"); } catch (IllegalArgumentException expected) { } } }
public void testInvalidTopPrivateDomain() { ImmutableSet<String> badCookieDomains = ImmutableSet.of("co.uk", "foo", "com"); for (String domain : badCookieDomains) { try { InternetDomainName.from(domain).topPrivateDomain(); fail(domain); } catch (IllegalStateException expected) { } } }
public void testChild() { InternetDomainName domain = InternetDomainName.from("foo.com"); assertEquals("www.foo.com", domain.child("www").toString()); try { domain.child("www."); fail("www..google.com should have been invalid"); } catch (IllegalArgumentException expected) { } }
public void testParent() { assertEquals("com", InternetDomainName.from("google.com").parent().toString()); assertEquals("uk", InternetDomainName.from("co.uk").parent().toString()); assertEquals("google.com", InternetDomainName.from("www.google.com").parent().toString()); try { InternetDomainName.from("com").parent(); fail("'com' should throw ISE on .parent() call"); } catch (IllegalStateException expected) { } }
public void testInvalid() { for (String name : INVALID_NAME) { try { InternetDomainName.from(name); fail("Should have been invalid: '" + name + "'"); } catch (IllegalArgumentException expected) { } } }
public void testInvalidTopPrivateDomain() { ImmutableSet<String> badCookieDomains = ImmutableSet.of("co.uk", "foo", "com"); for (String domain : badCookieDomains) { try { InternetDomainName.from(domain).topPrivateDomain(); fail(domain); } catch (IllegalStateException expected) { } } }
public void testChild() { InternetDomainName domain = InternetDomainName.from("foo.com"); assertEquals("www.foo.com", domain.child("www").toString()); try { domain.child("www."); fail("www..google.com should have been invalid"); } catch (IllegalArgumentException expected) { } }
public void testParent() { assertEquals( "com", InternetDomainName.from("google.com").parent().toString()); assertEquals( "uk", InternetDomainName.from("co.uk").parent().toString()); assertEquals( "google.com", InternetDomainName.from("www.google.com").parent().toString()); try { InternetDomainName.from("com").parent(); fail("'com' should throw ISE on .parent() call"); } catch (IllegalStateException expected) { } }