Exemplo n.º 1
0
  /**
   * Tests getting the correct SNMP Peer after receiving a configureSNMP event that moves a specific
   * from one definition into another.
   *
   * @throws UnknownHostException
   */
  public void testSplicingSpecificsIntoRanges() throws UnknownHostException {
    assertEquals(3, SnmpPeerFactory.getSnmpConfig().getDefinition(2).getRangeCount());
    assertEquals(6, SnmpPeerFactory.getSnmpConfig().getDefinition(2).getSpecificCount());

    final String specificAddr = "10.1.1.7";
    final EventBuilder bldr = createConfigureSnmpEventBuilder(specificAddr, null);
    final SnmpEventInfo info = new SnmpEventInfo(bldr.getEvent());
    info.setCommunityString("splice-test");
    info.setVersion("v2c");

    SnmpPeerFactory.getInstance().define(info);

    assertEquals(5, SnmpPeerFactory.getSnmpConfig().getDefinition(2).getRangeCount());

    assertEquals("10.1.1.10", SnmpPeerFactory.getSnmpConfig().getDefinition(2).getSpecific(0));
    assertEquals(1, SnmpPeerFactory.getSnmpConfig().getDefinition(2).getSpecificCount());
    assertEquals(m_startingDefCount, SnmpPeerFactory.getSnmpConfig().getDefinitionCount());
  }
Exemplo n.º 2
0
  /**
   * This test should remove the specific 192.168.0.5 from the first definition and replace it with
   * a range 192.168.0.5 - 192.168.0.7.
   *
   * @throws UnknownHostException
   */
  public void testSnmpEventInfoClassWithRangeReplacingSpecific() throws UnknownHostException {
    final String addr1 = "192.168.0.5";
    final String addr2 = "192.168.0.7";

    SnmpAgentConfig agent =
        SnmpPeerFactory.getInstance().getAgentConfig(InetAddressUtils.addr(addr1));
    assertEquals(SnmpAgentConfig.VERSION2C, agent.getVersion());

    EventBuilder bldr = createConfigureSnmpEventBuilder(addr1, addr2);
    SnmpEventInfo info = new SnmpEventInfo(bldr.getEvent());
    info.setVersion("v2c");

    SnmpPeerFactory.getInstance().define(info);

    agent = SnmpPeerFactory.getInstance().getAgentConfig(InetAddressUtils.addr(addr1));
    assertEquals(InetAddressUtils.str(agent.getAddress()), addr1);
    assertEquals(SnmpAgentConfig.VERSION2C, agent.getVersion());
    assertEquals(m_startingDefCount, SnmpPeerFactory.getSnmpConfig().getDefinitionCount());
  }