Search in sources :

Example 1 with JUnitDNSServer

use of org.opennms.core.test.dns.annotations.JUnitDNSServer in project opennms by OpenNMS.

the class DnsMonitorIT method testNoAnswer.

@Test
@JUnitDNSServer(port = 9153, zones = {})
public void testNoAnswer() throws Exception {
    final Lookup l = new Lookup("example.com", Type.AAAA);
    // make sure we use a temporary cache so don't get results from a previously cached query
    // from another test
    l.setCache(null);
    final SimpleResolver resolver = new SimpleResolver("::1");
    resolver.setPort(9153);
    l.setResolver(resolver);
    l.run();
    // and NXRRSET record should be sent meaning that the server has no records for
    // example.com at all.  This results in a null answers.  This is result 4 I think
    System.out.println("result: " + l.getResult());
    final Record[] answers = l.getAnswers();
    assertNull(answers);
}
Also used : Lookup(org.xbill.DNS.Lookup) Record(org.xbill.DNS.Record) SimpleResolver(org.xbill.DNS.SimpleResolver) JUnitDNSServer(org.opennms.core.test.dns.annotations.JUnitDNSServer) Test(org.junit.Test)

Example 2 with JUnitDNSServer

use of org.opennms.core.test.dns.annotations.JUnitDNSServer in project opennms by OpenNMS.

the class DnsProvisioningAdapterTest method testDelete.

@Test
@JUnitDNSServer(port = 9153, zones = { @DNSZone(name = "example.com", entries = { @DNSEntry(hostname = "test", data = "192.168.0.1") }) })
public void testDelete() throws Exception {
    OnmsNode n = m_nodeDao.findByForeignId("dns", "1");
    m_adapter.deleteNode(n.getId());
    m_adapter.processPendingOperationForNode(m_deleteOperation);
}
Also used : OnmsNode(org.opennms.netmgt.model.OnmsNode) JUnitDNSServer(org.opennms.core.test.dns.annotations.JUnitDNSServer) Test(org.junit.Test)

Example 3 with JUnitDNSServer

use of org.opennms.core.test.dns.annotations.JUnitDNSServer in project opennms by OpenNMS.

the class DnsProvisioningAdapterTest method testAdd.

@Test
@JUnitDNSServer(port = 9153, zones = { @DNSZone(name = "example.com", entries = { @DNSEntry(hostname = "test", data = "192.168.0.1") }) })
public void testAdd() throws Exception {
    OnmsNode n = m_nodeDao.findByForeignId("dns", "1");
    m_adapter.addNode(n.getId());
    m_adapter.processPendingOperationForNode(m_addOperation);
}
Also used : OnmsNode(org.opennms.netmgt.model.OnmsNode) JUnitDNSServer(org.opennms.core.test.dns.annotations.JUnitDNSServer) Test(org.junit.Test)

Example 4 with JUnitDNSServer

use of org.opennms.core.test.dns.annotations.JUnitDNSServer in project opennms by OpenNMS.

the class ProvisionerIT method testDnsVisit.

/**
 * We have to ignore this test until there is a DNS service available in the test harness
 *
 * @throws ForeignSourceRepositoryException
 * @throws MalformedURLException
 */
@Test(timeout = 300000)
@JUnitDNSServer(port = 9153, zones = { @DNSZone(name = "opennms.com.", v4address = "1.2.3.4", entries = { @DNSEntry(hostname = "www", data = "1.2.3.4"), @DNSEntry(hostname = "www", data = "::1:2:3:4", type = "AAAA") }) })
public void testDnsVisit() throws ForeignSourceRepositoryException, MalformedURLException {
    final Requisition requisition = m_foreignSourceRepository.importResourceRequisition(new UrlResource("dns://localhost:9153/opennms.com"));
    final CountingVisitor visitor = new CountingVisitor() {

        @Override
        public void visitNode(final OnmsNodeRequisition req) {
            LOG.debug("visitNode: {}/{} {}", req.getForeignSource(), req.getForeignId(), req.getNodeLabel());
            m_nodes.add(req);
            m_nodeCount++;
        }

        @Override
        public void visitInterface(final OnmsIpInterfaceRequisition req) {
            LOG.debug("visitInterface: {}", req.getIpAddr());
            m_ifaces.add(req);
            m_ifaceCount++;
        }
    };
    requisition.visit(visitor);
    verifyDnsImportCounts(visitor);
}
Also used : OnmsIpInterfaceRequisition(org.opennms.netmgt.provision.persist.OnmsIpInterfaceRequisition) UrlResource(org.springframework.core.io.UrlResource) OnmsNodeCategoryRequisition(org.opennms.netmgt.provision.persist.OnmsNodeCategoryRequisition) OnmsNodeRequisition(org.opennms.netmgt.provision.persist.OnmsNodeRequisition) Requisition(org.opennms.netmgt.provision.persist.requisition.Requisition) OnmsMonitoredServiceRequisition(org.opennms.netmgt.provision.persist.OnmsMonitoredServiceRequisition) OnmsServiceCategoryRequisition(org.opennms.netmgt.provision.persist.OnmsServiceCategoryRequisition) OnmsIpInterfaceRequisition(org.opennms.netmgt.provision.persist.OnmsIpInterfaceRequisition) OnmsAssetRequisition(org.opennms.netmgt.provision.persist.OnmsAssetRequisition) OnmsNodeRequisition(org.opennms.netmgt.provision.persist.OnmsNodeRequisition) JUnitDNSServer(org.opennms.core.test.dns.annotations.JUnitDNSServer) Test(org.junit.Test)

Example 5 with JUnitDNSServer

use of org.opennms.core.test.dns.annotations.JUnitDNSServer in project opennms by OpenNMS.

the class DnsRequisitionUrlConnectionIT method dwoConnect.

/**
 * Just test that connection doesn't get implementation without fixing this test
 * @throws IOException
 */
@Test
@JUnitDNSServer(port = 9153, zones = { @DNSZone(name = "example.com", entries = { @DNSEntry(hostname = "www", data = "72.14.204.99") }) })
public void dwoConnect() throws IOException {
    URLConnection c = new DnsRequisitionUrlConnection(new URL(TEST_URL));
    c.connect();
}
Also used : URLConnection(java.net.URLConnection) URL(java.net.URL) 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 Matcher (java.util.regex.Matcher)1 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