Search in sources :

Example 1 with CorrelationEngine

use of org.opennms.netmgt.correlation.CorrelationEngine in project opennms by OpenNMS.

the class ReloadConfigurationIT method testAddAndRemoveEngine.

/**
 * Test add and remove engine.
 *
 * @throws Exception the exception
 */
@Test
public void testAddAndRemoveEngine() throws Exception {
    Collection<CorrelationEngine> engines = m_correlator.getEngines();
    Assert.assertNotNull(engines);
    Assert.assertEquals(1, engines.size());
    FileUtils.copyDirectory(new File(DROOLS_SRC, "persistState"), new File(DROOLS_HOME, "persistState"));
    sendReloadDaemonConfig();
    engines = m_correlator.getEngines();
    Assert.assertEquals(2, engines.size());
    FileUtils.deleteDirectory(new File(DROOLS_HOME, "simpleRules"));
    sendReloadDaemonConfig();
    engines = m_correlator.getEngines();
    Assert.assertEquals(1, engines.size());
}
Also used : CorrelationEngine(org.opennms.netmgt.correlation.CorrelationEngine) File(java.io.File) Test(org.junit.Test)

Example 2 with CorrelationEngine

use of org.opennms.netmgt.correlation.CorrelationEngine in project opennms by OpenNMS.

the class ReloadConfigurationIT method testEditExistingEngineWithValidContent.

/**
 * Test edit existing engine with valid content.
 *
 * @throws Exception the exception
 */
@Test
public void testEditExistingEngineWithValidContent() throws Exception {
    Collection<CorrelationEngine> engines = m_correlator.getEngines();
    Assert.assertNotNull(engines);
    Assert.assertEquals(1, engines.size());
    FileUtils.copyDirectory(new File(DROOLS_SRC2, "simpleRules"), new File(DROOLS_HOME, "simpleRules"));
    sendReloadDaemonConfig();
    EventBuilder eb = new EventBuilder("uei.opennms.org/junit/myTestEvent", "Junit");
    m_eventIpcMgr.send(eb.getEvent());
    Thread.sleep(1000);
    File file = new File("target/sample-file.txt");
    Assert.assertTrue(file.exists());
    file.delete();
}
Also used : EventBuilder(org.opennms.netmgt.model.events.EventBuilder) CorrelationEngine(org.opennms.netmgt.correlation.CorrelationEngine) File(java.io.File) Test(org.junit.Test)

Example 3 with CorrelationEngine

use of org.opennms.netmgt.correlation.CorrelationEngine in project opennms by OpenNMS.

the class ReloadConfigurationIT method testEditExistingEngineWithInvalidContent.

/**
 * Test edit existing engine with invalid content.
 *
 * @throws Exception the exception
 */
@Test
public void testEditExistingEngineWithInvalidContent() throws Exception {
    Collection<CorrelationEngine> engines = m_correlator.getEngines();
    Assert.assertNotNull(engines);
    Assert.assertEquals(1, engines.size());
    FileUtils.copyDirectory(new File(DROOLS_SRC2, "brokenRules"), new File(DROOLS_HOME, "brokenRules"));
    sendReloadDaemonConfig();
    engines = m_correlator.getEngines();
    Assert.assertEquals(1, engines.size());
}
Also used : CorrelationEngine(org.opennms.netmgt.correlation.CorrelationEngine) File(java.io.File) Test(org.junit.Test)

Example 4 with CorrelationEngine

use of org.opennms.netmgt.correlation.CorrelationEngine in project opennms by OpenNMS.

the class ReloadConfigurationIT method testAddingEngineWithInvalidContent.

/**
 * Test adding engine with invalid content.
 *
 * @throws Exception the exception
 */
@Test
public void testAddingEngineWithInvalidContent() throws Exception {
    Collection<CorrelationEngine> engines = m_correlator.getEngines();
    Assert.assertNotNull(engines);
    Assert.assertEquals(1, engines.size());
    FileUtils.copyDirectory(new File(DROOLS_SRC2, "brokenRules"), new File(DROOLS_HOME, "brokenRules"));
    sendReloadDaemonConfig();
    engines = m_correlator.getEngines();
    // Instead of 2
    Assert.assertEquals(1, engines.size());
}
Also used : CorrelationEngine(org.opennms.netmgt.correlation.CorrelationEngine) File(java.io.File) Test(org.junit.Test)

Aggregations

File (java.io.File)4 Test (org.junit.Test)4 CorrelationEngine (org.opennms.netmgt.correlation.CorrelationEngine)4 EventBuilder (org.opennms.netmgt.model.events.EventBuilder)1