public Builder addConfiguredDomains(Domain... domains) { return this.addConfiguredDomains(Arrays.asList(domains)); }
public static DomainListConfiguration from(HierarchicalConfiguration config) { ImmutableList<Domain> configuredDomains = StreamUtils.ofNullable(config.getStringArray(CONFIGURE_DOMAIN_NAMES)) .filter(s -> !s.isEmpty()) .map(Domain::of) .collect(Guavate.toImmutableList()); return builder() .autoDetect(Optional.ofNullable(config.getBoolean(CONFIGURE_AUTODETECT, null))) .autoDetectIp(Optional.ofNullable(config.getBoolean(CONFIGURE_AUTODETECT_IP, null))) .defaultDomain(Optional.ofNullable(config.getString(CONFIGURE_DEFAULT_DOMAIN, null)) .map(Domain::of)) .addConfiguredDomains(configuredDomains) .build(); }
@Test public void testGetDomainsAutoDetectNotLocalHost() throws Exception { XMLDomainList dom = new XMLDomainList(setUpDNSServer("local")); dom.configure(DomainListConfiguration.builder() .autoDetect(true) .autoDetectIp(false) .addConfiguredDomains(Domain.of("domain1.")) .defaultDomain(DEFAULT_DOMAIN)); assertThat(dom.getDomains()).hasSize(3); }
@Test public void testGetDomainsAutoDetectLocalHost() throws Exception { XMLDomainList dom = new XMLDomainList(setUpDNSServer("localhost")); dom.configure(DomainListConfiguration.builder() .autoDetect(false) .autoDetectIp(false) .addConfiguredDomains(Domain.of("domain1.")) .defaultDomain(DEFAULT_DOMAIN)); assertThat(dom.getDomains()).hasSize(2); }
@Test public void testGetDomains() throws Exception { XMLDomainList dom = new XMLDomainList(setUpDNSServer("localhost")); dom.configure(DomainListConfiguration.builder() .autoDetect(false) .autoDetectIp(false) .addConfiguredDomains(Domain.of("domain1."), Domain.of("domain2.")) .defaultDomain(DEFAULT_DOMAIN)); assertThat(dom.getDomains()).hasSize(3); }
@Test public void configuredDomainShouldBeAddedUponConfiguration() throws Exception { Domain domain1 = Domain.of("conf1.tld"); Domain domain2 = Domain.of("conf2.tld"); domainList.configure(DomainListConfiguration.builder() .autoDetect(false) .autoDetectIp(false) .addConfiguredDomains(domain1, domain2)); assertThat(domainList.getDomains()).contains(domain1, domain2); }