Search in sources :

Example 11 with JUnitDNSServer

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();
}
Also used : UrlResource(org.springframework.core.io.UrlResource) InputStream(java.io.InputStream) UrlResource(org.springframework.core.io.UrlResource) Resource(org.springframework.core.io.Resource) JAXBContext(javax.xml.bind.JAXBContext) Unmarshaller(javax.xml.bind.Unmarshaller) Requisition(org.opennms.netmgt.provision.persist.requisition.Requisition) JUnitDNSServer(org.opennms.core.test.dns.annotations.JUnitDNSServer) Test(org.junit.Test)

Aggregations

JUnitDNSServer (org.opennms.core.test.dns.annotations.JUnitDNSServer)11 Test (org.junit.Test)10 InputStream (java.io.InputStream)5 Requisition (org.opennms.netmgt.provision.persist.requisition.Requisition)5 UrlResource (org.springframework.core.io.UrlResource)5 JAXBContext (javax.xml.bind.JAXBContext)4 Unmarshaller (javax.xml.bind.Unmarshaller)4 Resource (org.springframework.core.io.Resource)4 URL (java.net.URL)2 URLConnection (java.net.URLConnection)2 OnmsNode (org.opennms.netmgt.model.OnmsNode)2 DNSEntry (org.opennms.core.test.dns.annotations.DNSEntry)1 DNSZone (org.opennms.core.test.dns.annotations.DNSZone)1 OnmsAssetRequisition (org.opennms.netmgt.provision.persist.OnmsAssetRequisition)1 OnmsIpInterfaceRequisition (org.opennms.netmgt.provision.persist.OnmsIpInterfaceRequisition)1 OnmsMonitoredServiceRequisition (org.opennms.netmgt.provision.persist.OnmsMonitoredServiceRequisition)1 OnmsNodeCategoryRequisition (org.opennms.netmgt.provision.persist.OnmsNodeCategoryRequisition)1 OnmsNodeRequisition (org.opennms.netmgt.provision.persist.OnmsNodeRequisition)1 OnmsServiceCategoryRequisition (org.opennms.netmgt.provision.persist.OnmsServiceCategoryRequisition)1 AAAARecord (org.xbill.DNS.AAAARecord)1