use of org.opennms.core.test.http.annotations.JUnitHttpServer in project opennms by OpenNMS.
the class TcpMonitorIT method testLocalhostIPv6Connection.
@Test
@JUnitHttpServer(port = 10342)
public void testLocalhostIPv6Connection() throws UnknownHostException {
assumeTrue(!Boolean.getBoolean("skipIpv6Tests"));
Map<String, Object> m = new ConcurrentSkipListMap<String, Object>();
Parameter p = new Parameter();
ServiceMonitor monitor = new TcpMonitor();
MonitoredService svc = MonitorTestUtils.getMonitoredService(3, "::1", addr("::1"), "TCP");
p.setKey("port");
p.setValue("10342");
m.put(p.getKey(), p.getValue());
p.setKey("retry");
p.setValue("1");
m.put(p.getKey(), p.getValue());
p.setKey("timeout");
p.setValue("500");
m.put(p.getKey(), p.getValue());
PollStatus status = monitor.poll(svc, m);
MockUtil.println("Reason: " + status.getReason());
assertEquals(PollStatus.SERVICE_AVAILABLE, status.getStatusCode());
assertNull(status.getReason());
}
use of org.opennms.core.test.http.annotations.JUnitHttpServer in project opennms by OpenNMS.
the class HttpNorthBounderTest method testForwardAlarms.
/**
* Test forward alarms.
*
* @throws InterruptedException the interrupted exception
*/
@Test
@JUnitHttpServer(port = 10342)
public void testForwardAlarms() throws InterruptedException {
HttpNorthbounder nb = new HttpNorthbounder();
HttpNorthbounderConfig config = new HttpNorthbounderConfig("localhost");
config.setMethod(HttpMethod.POST);
config.setPath("/jms/post");
config.setPort(Integer.valueOf(10342));
nb.setConfig(config);
OnmsAlarm alarm = new OnmsAlarm();
alarm.setId(1);
alarm.setUei("uei.opennms.org/test/httpNorthBounder");
NorthboundAlarm a = new NorthboundAlarm(alarm);
nb.onAlarm(a);
}
use of org.opennms.core.test.http.annotations.JUnitHttpServer in project opennms by OpenNMS.
the class RancidProvisioningAdapterIT method testDelete.
/**
* TODO: This test needs to be updated so that it properly connects to the JUnitHttpServer
* for simulated RANCID REST operations.
* TODO: This test seems to pass even though it fails to connect with a mock RANCID server
*/
@Test
@Transactional
@JUnitHttpServer(port = 7081, basicAuth = true)
public void testDelete() throws Exception {
OnmsNode n = m_nodeDao.findByForeignId("rancid", "1");
m_adapter.deleteNode(n.getId());
m_adapter.processPendingOperationForNode(m_deleteOperation);
Thread.sleep(3000);
}
use of org.opennms.core.test.http.annotations.JUnitHttpServer in project opennms by OpenNMS.
the class RancidProvisioningAdapterIntegrationIT method testAddSameOperationTwice.
/**
* TODO: This test needs to be updated so that it properly connects to the JUnitHttpServer
* for simulated RANCID REST operations.
*/
@Test
@Transactional
@JUnitHttpServer(port = 7081, basicAuth = true)
@Ignore
public void testAddSameOperationTwice() throws InterruptedException {
// AdapterOperationChecker verifyOperations = new AdapterOperationChecker(2);
// m_adapter.getOperationQueue().addListener(verifyOperations);
OnmsNode node = m_nodeDao.get(NODE_ID);
assertNotNull(node);
int firstNodeId = node.getId();
m_adapter.addNode(firstNodeId);
// should get deduplicated
m_adapter.addNode(firstNodeId);
m_adapter.updateNode(firstNodeId);
// assertTrue(verifyOperations.enqueueLatch.await(4, TimeUnit.SECONDS));
// assertTrue(verifyOperations.dequeueLatch.await(4, TimeUnit.SECONDS));
// assertTrue(verifyOperations.executeLatch.await(4, TimeUnit.SECONDS));
assertEquals(0, m_adapter.getOperationQueue().getOperationQueueForNode(firstNodeId).size());
}
use of org.opennms.core.test.http.annotations.JUnitHttpServer in project opennms by OpenNMS.
the class HttpCollectorIT method testCollect.
/**
* Test method for {@link org.opennms.netmgt.collectd.HttpCollector#collect(
* org.opennms.netmgt.collection.api.CollectionAgent, org.opennms.netmgt.model.events.EventProxy, Map)}.
*/
@Test
@JUnitHttpServer(port = 10342, vhosts = { "127.0.0.1" })
@JUnitCollector(datacollectionConfig = "/org/opennms/netmgt/config/http-datacollection-config.xml", datacollectionType = "http", anticipateRrds = { "1/documentCount", "1/greatAnswer", "1/someNumber" }, anticipateFiles = { "1/strings.properties" })
public final void testCollect() throws Exception {
CollectionSet collectionSet = m_collectionSpecification.collect(m_collectionAgent);
assertEquals("collection status", CollectionStatus.SUCCEEDED, collectionSet.getStatus());
CollectorTestUtils.persistCollectionSet(m_rrdStrategy, m_resourceStorageDao, m_collectionSpecification, collectionSet);
}
Aggregations