use of org.opennms.core.test.db.annotations.JUnitTemporaryDatabase in project opennms by OpenNMS.
the class SnmpAssetProvisioningAdapterFullIT method testAddNodeDirectly.
@Test
// Relies on records created in @Before so we need a fresh database
@JUnitTemporaryDatabase
@Transactional
public void testAddNodeDirectly() throws InterruptedException {
OnmsNode node = m_nodeDao.get(NODE_ID);
assertNotNull(node);
int firstNodeId = node.getId();
m_adapter.doAddNode(firstNodeId);
node = m_nodeDao.get(firstNodeId);
assertNotNull(node);
assertNotNull("AssetRecord comment is null", node.getAssetRecord().getComment());
assertEquals(EXPECTED_COMMENT_FIELD, node.getAssetRecord().getComment());
}
use of org.opennms.core.test.db.annotations.JUnitTemporaryDatabase in project opennms by OpenNMS.
the class SnmpAssetProvisioningAdapterIT method testDelete.
@Test
// Relies on records created in @Before so we need a fresh database
@JUnitTemporaryDatabase
@JUnitSnmpAgent(resource = "snmpAssetTestData.properties")
public void testDelete() throws Exception {
AdapterOperationChecker verifyOperations = new AdapterOperationChecker(1);
m_adapter.getOperationQueue().addListener(verifyOperations);
OnmsNode n = m_nodeDao.findByForeignId("rancid", "1");
assertNotNull(n);
m_adapter.deleteNode(n.getId());
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(n.getId()).size());
// TODO: Add assertions to check that the deleteNode() adapter call updated the asset record
}
use of org.opennms.core.test.db.annotations.JUnitTemporaryDatabase in project opennms by OpenNMS.
the class SnmpAssetProvisioningAdapterFullIT method testAddNode.
@Test
// Relies on records created in @Before so we need a fresh database
@JUnitTemporaryDatabase
public void testAddNode() throws InterruptedException {
AdapterOperationChecker verifyOperations = new AdapterOperationChecker(1);
m_adapter.getOperationQueue().addListener(verifyOperations);
try {
OnmsNode node = m_nodeDao.get(NODE_ID);
assertNotNull(node);
int firstNodeId = node.getId();
m_adapter.addNode(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());
node = m_nodeDao.get(firstNodeId);
assertNotNull(node);
System.out.println("ID: " + node.getAssetRecord().getId());
System.out.println("Comment: " + node.getAssetRecord().getComment());
assertNotNull("AssetRecord comment is null", node.getAssetRecord().getComment());
assertEquals(EXPECTED_COMMENT_FIELD, node.getAssetRecord().getComment());
} finally {
m_adapter.getOperationQueue().removeListener(verifyOperations);
}
}
use of org.opennms.core.test.db.annotations.JUnitTemporaryDatabase in project opennms by OpenNMS.
the class SnmpAssetProvisioningAdapterFullIT method testNodeConfigChanged.
@Test
// Relies on records created in @Before so we need a fresh database
@JUnitTemporaryDatabase
public void testNodeConfigChanged() throws InterruptedException {
AdapterOperationChecker verifyOperations = new AdapterOperationChecker(1);
m_adapter.getOperationQueue().addListener(verifyOperations);
try {
OnmsNode node = m_nodeDao.get(NODE_ID);
assertNotNull(node);
int firstNodeId = node.getId();
m_adapter.nodeConfigChanged(firstNodeId);
} finally {
m_adapter.getOperationQueue().removeListener(verifyOperations);
}
}
use of org.opennms.core.test.db.annotations.JUnitTemporaryDatabase in project opennms by OpenNMS.
the class SnmpAssetProvisioningAdapterFullIT method testDeleteNode.
@Test
// Relies on records created in @Before so we need a fresh database
@JUnitTemporaryDatabase
public void testDeleteNode() throws InterruptedException {
AdapterOperationChecker verifyOperations = new AdapterOperationChecker(1);
m_adapter.getOperationQueue().addListener(verifyOperations);
try {
OnmsNode node = m_nodeDao.get(NODE_ID);
assertNotNull(node);
int firstNodeId = node.getId();
m_adapter.deleteNode(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());
} finally {
m_adapter.getOperationQueue().removeListener(verifyOperations);
}
}
Aggregations