Tabnine Logo
com.google.common.net
Code IndexAdd Tabnine to your IDE (free)

How to use com.google.common.net

Best Java code snippets using com.google.common.net (Showing top 20 results out of 2,718)

origin: google/guava

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());
}
origin: google/guava

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());
 }
}
origin: google/guava

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) {
 }
}
origin: google/guava

public void test3ff31() {
 try {
  InetAddresses.forString("3ffe:::1");
  fail("IllegalArgumentException expected");
 } catch (IllegalArgumentException expected) {
 }
 assertFalse(InetAddresses.isInetAddress("016.016.016.016"));
}
origin: google/guava

public void testToUriStringIPv4() {
 String ipStr = "1.2.3.4";
 InetAddress ip = InetAddresses.forString(ipStr);
 assertEquals("1.2.3.4", InetAddresses.toUriString(ip));
}
origin: google/guava

 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());
 }
}
origin: google/guava

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());
 }
}
origin: google/guava

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());
}
origin: google/guava

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);
}
origin: google/guava

public void testGetCharset_illegalCharset() {
 MediaType mediaType = MediaType.parse("text/plain; charset=\"!@#$%^&*()\"");
 try {
  mediaType.charset();
  fail();
 } catch (IllegalCharsetNameException expected) {
 }
}
origin: google/guava

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());
}
origin: google/guava

public void testWithParameter_invalidAttribute() {
 MediaType mediaType = MediaType.parse("text/plain");
 try {
  mediaType.withParameter("@", "2");
  fail();
 } catch (IllegalArgumentException expected) {
 }
}
origin: google/guava

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());
 }
}
origin: google/guava

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());
}
origin: google/guava

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());
 }
}
origin: google/guava

public void testCreateAudioType() {
 MediaType newType = MediaType.createAudioType("yams");
 assertEquals("audio", newType.type());
 assertEquals("yams", newType.subtype());
}
origin: google/guava

public void testCreateVideoType() {
 MediaType newType = MediaType.createVideoType("yams");
 assertEquals("video", newType.type());
 assertEquals("yams", newType.subtype());
}
origin: google/guava

public void testCreate_invalidSubtype() {
 try {
  MediaType.create("text", "pl@intext");
  fail();
 } catch (IllegalArgumentException expected) {
 }
}
origin: google/guava

private void assertGood(String spec) throws ParseException {
 HostSpecifier.fromValid(spec); // Throws exception if not working correctly
 HostSpecifier.from(spec);
 assertTrue(HostSpecifier.isValid(spec));
}
origin: google/guava

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));
}
com.google.common.net

Most used classes

  • HostAndPort
    An immutable representation of a host and port.Example usage: HostAndPort hp = HostAndPort.fromStri
  • InetAddresses
    Static utility methods pertaining to InetAddress instances.Important note: Unlike InetAddress.getByN
  • MediaType
    Represents an Internet Media Type [http://en.wikipedia.org/wiki/Internet_media_type] (also known as
  • UrlEscapers
    Escaper instances suitable for strings to be included in particular sections of URLs.If the resulti
  • InternetDomainName
    An immutable well-formed internet domain name, such as com or foo.co.uk. Only syntactic analysis is
  • HostSpecifier,
  • InetAddresses$TeredoInfo,
  • MediaType$Tokenizer,
  • TrieParser,
  • HostAndPortTest,
  • HostSpecifierTest,
  • HttpHeadersTest,
  • InetAddressesTest,
  • InternetDomainNameTest,
  • MediaTypeTest,
  • PackageSanityTests,
  • PercentEscaperTest,
  • UrlEscapersTest
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now