DNSServerTestpublic class DNSServerTest extends TestCase Licensed to the Apache Software Foundation (ASF) under one *
or more contributor license agreements. See the NOTICE file *
distributed with this work for additional information *
regarding copyright ownership. The ASF licenses this file *
to you under the Apache License, Version 2.0 (the *
"License"); you may not use this file except in compliance *
with the License. You may obtain a copy of the License at *
*
http://www.apache.org/licenses/LICENSE-2.0 *
*
Unless required by applicable law or agreed to in writing, *
software distributed under the License is distributed on an *
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
KIND, either express or implied. See the License for the *
specific language governing permissions and limitations *
under the License. * |
Fields Summary |
---|
private TestableDNSServer | dnsServer |
Methods Summary |
---|
protected void | setUp()
dnsServer = new TestableDNSServer();
DefaultConfigurationBuilder db = new DefaultConfigurationBuilder();
Configuration c = db.build(
new ByteArrayInputStream("<dnsserver><autodiscover>true</autodiscover><authoritative>false</authoritative></dnsserver>".getBytes()),
"dnsserver");
dnsServer.enableLogging(new MockLogger());
dnsServer.configure(c);
dnsServer.initialize();
| protected void | tearDown()
dnsServer.setLookupper(null);
dnsServer.dispose();
| public void | testCNAMEasMXrecords()Please note that this is an hardcoded test that works because
brandilyncollins.com. has an MX record that point to mxmail.register.com
and this is a CNAME to the real address.
This test will be invalidated by any change in the brandilyncollins.com dns records
Zone z = new Zone(Name.fromString("brandilyncollins.com."),getClass().getResource("brandilyncollins-com.zone").getFile());
dnsServer.setResolver(null);
dnsServer.setLookupper(new ZoneLookupper(z));
Iterator records = dnsServer.getSMTPHostAddresses("brandilyncollins.com.");
assertEquals(true, records.hasNext());
| public void | testINARecords()Please note that this is an hardcoded test that works because
www.pippo.com. is an alias to pippo.com and pippo.com has
"pippo.com.inbound.mxlogic.net." as its mx record.
This is the first domain with a record proving a previous james bug.
This test will be invalidated by any change in the pippo.com dns records
Zone z = new Zone(Name.fromString("pippo.com."),getClass().getResource("pippo-com.zone").getFile());
dnsServer.setResolver(null);
dnsServer.setLookupper(new ZoneLookupper(z));
Collection records = dnsServer.findMXRecords("www.pippo.com.");
assertEquals(1, records.size());
assertEquals("pippo.com.inbound.mxlogic.net.", records.iterator()
.next());
| public void | testMXCatches()
Zone z = new Zone(Name.fromString("test-zone.com."),getClass().getResource("test-zone-com.zone").getFile());
dnsServer.setResolver(null);
dnsServer.setLookupper(new ZoneLookupper(z));
Collection res = dnsServer.findMXRecords("test-zone.com.");
try {
res.add(new Object());
fail("MX Collection should not be modifiable");
} catch (UnsupportedOperationException e) {
}
assertEquals(1,res.size());
assertEquals("mail.test-zone.com.",res.iterator().next());
|
|