コード例 #1
0
  @Before
  public void setUp() {
    m_dbPopulator.populateDatabase();
    OnmsMonitoredService svc2 =
        m_dbPopulator
            .getMonitoredServiceDao()
            .get(m_dbPopulator.getNode2().getId(), InetAddressUtils.addr("192.168.2.1"), "ICMP");
    // This requires every test method to have a new database instance :/
    OnmsEvent event = m_dbPopulator.getEventDao().get(1);

    OnmsOutage unresolved2 = new OnmsOutage(new Date(), event, svc2);
    m_dbPopulator.getOutageDao().save(unresolved2);
    m_dbPopulator.getOutageDao().flush();
  }
コード例 #2
0
  @Test
  @Transactional
  @JUnitTemporaryDatabase
  public void testGetDataLinksOnInterface() {
    List<LinkInterface> dlis =
        NetworkElementFactory.getInstance(m_appContext)
            .getDataLinksOnInterface(m_dbPopulator.getNode1().getId(), 1);
    assertEquals(4, dlis.size());

    List<LinkInterface> dlis2 =
        NetworkElementFactory.getInstance(m_appContext)
            .getDataLinksOnInterface(m_dbPopulator.getNode1().getId(), 9);
    assertEquals(0, dlis2.size());
  }
コード例 #3
0
  @Test
  @Transactional
  public void testGetByCompositeId() {
    final OnmsMonitoredService monSvc =
        m_monitoredServiceDao.get(
            m_databasePopulator.getNode1().getId(), addr("192.168.1.1"), "SNMP");
    assertNotNull(monSvc);

    final OnmsMonitoredService monSvc2 =
        m_monitoredServiceDao.get(
            m_databasePopulator.getNode1().getId(),
            addr("192.168.1.1"),
            monSvc.getIfIndex(),
            monSvc.getServiceId());
    assertNotNull(monSvc2);
  }
  @Before
  public void setUp() throws Exception {
    // Use the mock.logLevel system property to control the log level
    MockLogAppender.setupLogging(true);

    // Set the operation delay to 1 second so that queued operations execute immediately
    m_adapter.setDelay(1);
    m_adapter.setTimeUnit(TimeUnit.SECONDS);

    Assert.notNull(m_nodeDao, "Autowiring failed, NodeDao is null");
    Assert.notNull(m_mockEventIpcManager, "Autowiring failed, IPC manager is null");
    Assert.notNull(m_populator, "Autowiring failed, DB populator is null");
    Assert.notNull(m_adapter, "Autowiring failed, adapter is null");

    // Make sure that the localhost SNMP connection config factory has overridden
    // the normal config factory
    assertTrue(m_adapter.getSnmpPeerFactory() instanceof ProxySnmpAgentConfigFactory);

    m_populator.populateDatabase();

    OnmsNode node = m_nodeDao.get(NODE_ID);
    assertNotNull(node);
    node.setSysObjectId(".1.3");
    m_nodeDao.saveOrUpdate(node);
  }
コード例 #5
0
ファイル: UpsertTest.java プロジェクト: eatlunchnow/opennms
  @Test
  @JUnitTemporaryDatabase
  public void testInsert() {
    String newIfName = "newIf0";
    assertEquals(0, countIfs(m_populator.getNode1().getId(), 1001, newIfName));

    // add non existent snmpiface
    OnmsSnmpInterface snmpIface = new OnmsSnmpInterface();
    snmpIface.setNode(m_populator.getNode1());
    snmpIface.setIfIndex(1001);
    snmpIface.setIfName(newIfName);

    m_upsertService.upsert(m_populator.getNode1().getId() /* nodeid */, snmpIface, 0);

    assertEquals(1, countIfs(m_populator.getNode1().getId(), 1001, newIfName));
  }
コード例 #6
0
ファイル: UpsertTest.java プロジェクト: eatlunchnow/opennms
  @Test
  @JUnitTemporaryDatabase
  public void testUpdate() {
    String oldIfName = "eth0";
    String newIfName = "newIf0";
    assertEquals(1, countIfs(m_populator.getNode1().getId(), 2, oldIfName));
    assertEquals(0, countIfs(m_populator.getNode1().getId(), 2, newIfName));

    // add non existent snmpiface
    OnmsSnmpInterface snmpIface = new OnmsSnmpInterface();
    snmpIface.setIfIndex(2);
    snmpIface.setIfName(newIfName);

    m_upsertService.upsert(m_populator.getNode1().getId(), snmpIface, 0);

    assertEquals(0, countIfs(m_populator.getNode1().getId(), 2, oldIfName));
    assertEquals(1, countIfs(m_populator.getNode1().getId(), 2, newIfName));
  }
コード例 #7
0
 @Test
 @Transactional
 @JUnitTemporaryDatabase
 public void testGetActiveInterfacesOnNode() {
   Interface[] intfs =
       NetworkElementFactory.getInstance(m_appContext)
           .getActiveInterfacesOnNode(m_dbPopulator.getNode1().getId());
   assertEquals("active interfaces", 4, intfs.length);
 }
コード例 #8
0
 @BeforeTransaction
 public void setUp() {
   try {
     if (!m_populated) {
       m_populator.populateDatabase();
     }
   } catch (Throwable e) {
     e.printStackTrace(System.err);
   } finally {
     m_populated = true;
   }
 }
コード例 #9
0
  @Test
  @Transactional
  public void testLazy() {
    final List<OnmsMonitoredService> allSvcs = m_monitoredServiceDao.findAll();
    assertTrue(allSvcs.size() > 1);

    final OnmsMonitoredService svc = allSvcs.iterator().next();
    assertEquals(addr("192.168.1.1"), svc.getIpAddress());
    assertEquals(1, svc.getIfIndex().intValue());
    assertEquals(m_databasePopulator.getNode1().getId(), svc.getIpInterface().getNode().getId());
    assertEquals("M", svc.getIpInterface().getIsManaged());
  }
コード例 #10
0
  @Test
  @Transactional
  @JUnitTemporaryDatabase
  public void testGetAtInterfaces() throws Exception {
    AtInterface atif =
        NetworkElementFactory.getInstance(m_appContext)
            .getAtInterface(m_dbPopulator.getNode2().getId(), "192.168.2.1");
    assertEquals("AA:BB:CC:DD:EE:FF", atif.get_physaddr());

    List<OnmsNode> nodes =
        NetworkElementFactory.getInstance(m_appContext).getNodesFromPhysaddr("AA:BB:CC:DD:EE:FF");
    assertEquals(1, nodes.size());
  }
コード例 #11
0
ファイル: UpsertTest.java プロジェクト: eatlunchnow/opennms
  @Test
  @JUnitTemporaryDatabase
  public void testConcurrentInsert() throws InterruptedException {
    Inserter one = new Inserter(m_upsertService, m_populator.getNode1().getId(), 1001, "ifName1");
    Inserter two = new Inserter(m_upsertService, m_populator.getNode1().getId(), 1001, "ifName2");

    one.start();
    two.start();

    one.join();
    two.join();

    assertNull("Exception on upsert two " + two.getThrowable(), two.getThrowable());
    assertNull("Exception on upsert one " + one.getThrowable(), one.getThrowable());
  }
コード例 #12
0
  @Test
  @Transactional
  @JUnitTemporaryDatabase
  public void testGetInterfacesWithIpAddress() throws Exception {
    Interface[] interfaces =
        NetworkElementFactory.getInstance(m_appContext)
            .getInterfacesWithIpAddress("fe80:0000:0000:0000:aaaa:bbbb:cccc:dddd%5");
    assertEquals("interface count", 1, interfaces.length);
    assertEquals("node ID", m_dbPopulator.getNode1().getId().intValue(), interfaces[0].getNodeId());
    assertEquals("ifIndex", 4, interfaces[0].getIfIndex());

    interfaces =
        NetworkElementFactory.getInstance(m_appContext)
            .getInterfacesWithIpAddress("fe80:0000:0000:0000:aaaa:bbbb:cccc:0001%5");
    assertEquals("interface count", 0, interfaces.length);

    interfaces =
        NetworkElementFactory.getInstance(m_appContext)
            .getInterfacesWithIpAddress("fe80:0000:0000:0000:aaaa:bbbb:cccc:dddd%4");
    assertEquals("interface count", 0, interfaces.length);
  }
コード例 #13
0
ファイル: UpsertTest.java プロジェクト: eatlunchnow/opennms
 @Before
 public void setUp() {
   m_populator.populateDatabase();
 }
コード例 #14
0
 @Before
 public void setUp() {
   assertNotNull(m_outageRepo);
   m_dbPopulator.populateDatabase();
 }
コード例 #15
0
 @Before
 public void setUp() {
   MockLogAppender.setupLogging();
   m_populator.populateDatabase();
   m_interfaces = m_ipInterfaceDao.findAll();
 }
コード例 #16
0
 @AfterTransaction
 public void tearDown() {
   m_populator.resetDatabase();
 }
コード例 #17
0
 @BeforeTransaction
 public void setUp() {
   m_populator.populateDatabase();
 }