Search in sources :

Example 31 with DirtiesContext

use of org.springframework.test.annotation.DirtiesContext in project opennms by OpenNMS.

the class EventMappingRulesIT method testMapMplsLspPathDown.

@Test
@DirtiesContext
public void testMapMplsLspPathDown() throws Exception {
    Event event = createMplsLspPathDownEvent(37, m_pe2NodeId, "10.1.1.1", "lspA-PE2-PE1");
    testEventMapping(event, ComponentDownEvent.class, "ServiceElementComponent", "NA-SvcElemComp", "9876,lspA-PE2-PE1");
}
Also used : Event(org.opennms.netmgt.xml.event.Event) Test(org.junit.Test) DirtiesContext(org.springframework.test.annotation.DirtiesContext)

Example 32 with DirtiesContext

use of org.springframework.test.annotation.DirtiesContext in project opennms by OpenNMS.

the class EventMappingRulesIT method testMapPwDown.

@Test
@DirtiesContext
public void testMapPwDown() throws Exception {
    Event event = createVpnPwDownEvent(17, m_pe2NodeId, "10.1.1.1", "5", "ge-3/1/4.50");
    testEventMapping(event, ComponentDownEvent.class, "ServiceElementComponent", "NA-SvcElemComp", "9876,jnxVpnPw-vcid(50)");
}
Also used : Event(org.opennms.netmgt.xml.event.Event) Test(org.junit.Test) DirtiesContext(org.springframework.test.annotation.DirtiesContext)

Example 33 with DirtiesContext

use of org.springframework.test.annotation.DirtiesContext in project opennms by OpenNMS.

the class DependencyRulesIT method testDependencyAnyRules.

@Test
@DirtiesContext
@Ignore("Non Deterministic!!!")
public void testDependencyAnyRules() throws Exception {
    // Get engine
    DroolsCorrelationEngine engine = findEngineByName("dependencyRules");
    // Anticipate component lspA down event
    getAnticipator().reset();
    anticipate(createComponentImpactedEvent(findSubcomponent(m_svc, "NA-SvcElemComp", "8765,lspA-PE1-PE2"), 17));
    // Generate down event
    System.err.println("SENDING MplsLspPathDown on LspA EVENT!!");
    engine.correlate(createMplsLspPathDownEvent(17, m_pe1NodeId, "10.1.1.1", "lspA-PE1-PE2"));
    // Check lspA component impacted
    getAnticipator().verifyAnticipated();
    // Anticipate component lspB down event
    // Parent should go down too
    getAnticipator().reset();
    anticipate(createComponentImpactedEvent(findSubcomponent(m_svc, "NA-SvcElemComp", "8765,lspB-PE1-PE2"), 18));
    anticipate(createComponentImpactedEvent(findSubcomponent(m_svc, "NA-SvcElemComp", "8765,jnxVpnPw-vcid(50)"), 18));
    anticipate(createComponentImpactedEvent(findSubcomponent(m_svc, "NA-ServiceElement", "8765"), 18));
    anticipate(createComponentImpactedEvent(findSubcomponent(m_svc, "NA-Service", "123"), 18));
    // Generate down event
    System.err.println("SENDING MplsLspPathDown on LspB EVENT!!");
    engine.correlate(createMplsLspPathDownEvent(18, m_pe1NodeId, "10.1.1.1", "lspB-PE1-PE2"));
    // verify components were impacted
    getAnticipator().verifyAnticipated();
    // Anticipate impacted resolved when we send up event
    getAnticipator().reset();
    anticipate(createComponentResolvedEvent(findSubcomponent(m_svc, "NA-SvcElemComp", "8765,lspA-PE1-PE2"), 18));
    anticipate(createComponentResolvedEvent(findSubcomponent(m_svc, "NA-SvcElemComp", "8765,jnxVpnPw-vcid(50)"), 18));
    anticipate(createComponentResolvedEvent(findSubcomponent(m_svc, "NA-ServiceElement", "8765"), 18));
    anticipate(createComponentResolvedEvent(findSubcomponent(m_svc, "NA-Service", "123"), 18));
    // Generate up event
    System.err.println("SENDING MplsLspPathUp on LspA EVENT!!");
    engine.correlate(createMplsLspPathUpEvent(19, m_pe1NodeId, "10.1.1.1", "lspA-PE1-PE2"));
    // verify components are resolved
    getAnticipator().verifyAnticipated();
}
Also used : DroolsCorrelationEngine(org.opennms.netmgt.correlation.drools.DroolsCorrelationEngine) Ignore(org.junit.Ignore) Test(org.junit.Test) DirtiesContext(org.springframework.test.annotation.DirtiesContext)

Example 34 with DirtiesContext

use of org.springframework.test.annotation.DirtiesContext in project opennms by OpenNMS.

the class SpringSecurityUserDaoImplIT method testGetByUsernameDashboard.

@Test
@DirtiesContext
public void testGetByUsernameDashboard() throws Exception {
    final OnmsUser newUser = new OnmsUser("dashboard");
    newUser.setPassword("DC7161BE3DBF2250C8954E560CC35060");
    newUser.getRoles().add(Authentication.ROLE_DASHBOARD);
    m_userManager.save(newUser);
    SpringSecurityUser user = ((SpringSecurityUserDao) m_springSecurityDao).getByUsername("dashboard");
    assertNotNull("user object should not be null", user);
    assertEquals("OnmsUser name", "dashboard", user.getUsername());
    assertEquals("Full name", null, user.getFullName());
    assertEquals("Comments", null, user.getComments());
    assertEquals("Password", "DC7161BE3DBF2250C8954E560CC35060", user.getPassword());
    Collection<? extends GrantedAuthority> authorities = user.getAuthorities();
    assertNotNull("authorities should not be null", authorities);
    assertEquals("authorities size", 1, authorities.size());
    assertContainsAuthority(Authentication.ROLE_DASHBOARD, authorities);
    assertNoWarningsOrGreater();
}
Also used : OnmsUser(org.opennms.netmgt.model.OnmsUser) Test(org.junit.Test) DirtiesContext(org.springframework.test.annotation.DirtiesContext)

Example 35 with DirtiesContext

use of org.springframework.test.annotation.DirtiesContext in project opennms by OpenNMS.

the class TrapHandlerITCase method testV2EnterpriseIdAndGenericAndSpecificAndMatchWithVarbinds.

@Test
@DirtiesContext
public void testV2EnterpriseIdAndGenericAndSpecificAndMatchWithVarbinds() throws Exception {
    SnmpValueFactory valueFactory = SnmpUtils.getValueFactory();
    LinkedHashMap<String, SnmpValue> varbinds = new LinkedHashMap<String, SnmpValue>();
    varbinds.put(".1.3.6.1.4.1.11.2.14.11.1.7.2.1.4.2404", valueFactory.getInt32(3));
    varbinds.put(".1.3.6.1.4.1.11.2.14.11.1.7.2.1.5.2404", valueFactory.getInt32(2));
    varbinds.put(".1.3.6.1.4.1.11.2.14.11.1.7.2.1.6.2404", valueFactory.getInt32(5));
    varbinds.put(".1.3.6.1.4.1.11.2.14.11.1.7.3.0.2404", valueFactory.getOctetString("http://a.b.c.d/cgi/fDetail?index=2404".getBytes()));
    anticipateAndSend(false, true, "uei.opennms.org/vendor/HP/traps/hpicfFaultFinderTrap", "v2c", ".1.3.6.1.4.1.11.2.14.12.1", 6, 5, varbinds);
}
Also used : SnmpValueFactory(org.opennms.netmgt.snmp.SnmpValueFactory) SnmpValue(org.opennms.netmgt.snmp.SnmpValue) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.Test) DirtiesContext(org.springframework.test.annotation.DirtiesContext)

Aggregations

DirtiesContext (org.springframework.test.annotation.DirtiesContext)86 Test (org.junit.Test)83 Exchange (org.apache.camel.Exchange)21 Event (org.opennms.netmgt.xml.event.Event)19 Processor (org.apache.camel.Processor)11 DroolsCorrelationEngine (org.opennms.netmgt.correlation.drools.DroolsCorrelationEngine)10 IOException (java.io.IOException)9 NCSComponent (org.opennms.netmgt.model.ncs.NCSComponent)9 ProducerTemplate (org.apache.camel.ProducerTemplate)7 Ignore (org.junit.Ignore)7 SnmpValue (org.opennms.netmgt.snmp.SnmpValue)6 JsonNode (com.fasterxml.jackson.databind.JsonNode)5 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)5 LinkedHashMap (java.util.LinkedHashMap)5 CommonBindyTest (org.apache.camel.dataformat.bindy.CommonBindyTest)5 FactHandle (org.kie.api.runtime.rule.FactHandle)5 SnmpValueFactory (org.opennms.netmgt.snmp.SnmpValueFactory)5 Message (org.apache.camel.Message)4 BigDecimal (java.math.BigDecimal)3 Registration (org.opennms.core.soa.Registration)3