use of org.opennms.core.test.dns.annotations.JUnitDNSServer in project opennms by OpenNMS.
the class DnsRequisitionUrlConnectionIT method dwoUrlAsResourceUsingMatchingExpression.
@Test
@JUnitDNSServer(port = 9153, zones = { @DNSZone(name = "example.com", entries = { @DNSEntry(hostname = "www", address = "72.14.204.99"), @DNSEntry(hostname = "monkey", address = "72.14.204.99") }) })
public void dwoUrlAsResourceUsingMatchingExpression() throws IOException, JAXBException {
String urlString = "dns://localhost:9153/example.com/?expression=[Ww]ww.*";
Resource resource = new UrlResource(urlString);
Assert.assertEquals(urlString, resource.getURL().toString());
Requisition req = null;
Assert.assertNotNull(resource);
InputStream resourceStream = resource.getInputStream();
JAXBContext context = JAXBContext.newInstance(Requisition.class);
Unmarshaller um = context.createUnmarshaller();
um.setSchema(null);
req = (Requisition) um.unmarshal(resourceStream);
Assert.assertEquals(1, req.getNodeCount());
resourceStream.close();
}
Aggregations