LdapAutodiscovery { public static String getDnsDomainName() throws UnknownHostException { return getDnsDomainName(InetAddress.getLocalHost().getCanonicalHostName()); }  static String getDnsDomainName(); static String getDnsDomainName(String fqdn); static String getDnsDomainDn(String domain); List<LdapSrvRecord> getLdapServers(String domain);  }
@Test public void testGetDnsDomain() throws UnknownHostException { assertThat(LdapAutodiscovery.getDnsDomainName("localhost")).isNull(); assertThat(LdapAutodiscovery.getDnsDomainName("godin.example.org")).isEqualTo("example.org"); assertThat(LdapAutodiscovery.getDnsDomainName("godin.usr.example.org")).isEqualTo("usr.example.org"); }
@Test public void testGetDnsDomainWithoutParameter() throws UnknownHostException { try { LdapAutodiscovery.getDnsDomainName(); } catch (UnknownHostException e) { fail(e.getMessage()); } }