XMLDomainList extends AbstractDomainList implements Configurable { @Override public void configure(DomainListConfiguration domainListConfiguration) throws ConfigurationException { super.configure(domainListConfiguration); isConfigured = true; } @Inject  XMLDomainList(DNSService dns); @Override void configure(DomainListConfiguration domainListConfiguration); @Override void addDomain(Domain domain); @Override void doRemoveDomain(Domain domain);  }
@Test void testNoConfiguredDomains() throws Exception { XMLDomainList dom = new XMLDomainList(setUpDNSServer("localhost")); dom.configure(DomainListConfiguration.builder() .autoDetect(false) .autoDetectIp(false) .defaultDomain(DEFAULT_DOMAIN)); assertThat(dom.getDomains()).containsOnly(DEFAULT_DOMAIN); }
@Test 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 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 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 void removeDomainShouldFailWhenAlreadyConfigured() throws Exception { XMLDomainList testee = new XMLDomainList(setUpDNSServer("localhost")); testee.configure(DomainListConfiguration.builder() .autoDetect(true) .autoDetectIp(false) .addConfiguredDomain(DOMAIN_1)); assertThatThrownBy(() -> testee.removeDomain(Domain.of("newDomain"))) .isInstanceOf(DomainListException.class); }