Search in sources :

Example 1 with IPAddressRange

use of org.opennms.core.network.IPAddressRange in project opennms by OpenNMS.

the class SnmpEventInfoTest method testCombine.

@Test
public void testCombine() {
    IPAddressRange rr = new IPAddressRange("192.168.1.10", "192.168.1.20");
    assertEquals(rr, rr.combine(new IPAddressRange("192.168.1.10", "192.168.1.20")));
    assertEquals(rr, rr.combine(new IPAddressRange("192.168.1.11", "192.168.1.20")));
    assertEquals(rr, rr.combine(new IPAddressRange("192.168.1.10", "192.168.1.19")));
    assertEquals(rr, rr.combine(new IPAddressRange("192.168.1.11", "192.168.1.19")));
    assertEquals(new IPAddressRange("192.168.1.9", "192.168.1.20"), rr.combine(new IPAddressRange("192.168.1.9", "192.168.1.12")));
    assertEquals(new IPAddressRange("192.168.1.10", "192.168.1.22"), rr.combine(new IPAddressRange("192.168.1.13", "192.168.1.22")));
    assertEquals(new IPAddressRange("192.168.1.9", "192.168.1.22"), rr.combine(new IPAddressRange("192.168.1.9", "192.168.1.22")));
    assertEquals(new IPAddressRange("192.168.1.7", "192.168.1.20"), rr.combine(new IPAddressRange("192.168.1.7", "192.168.1.9")));
    assertEquals(new IPAddressRange("192.168.1.10", "192.168.1.24"), rr.combine(new IPAddressRange("192.168.1.21", "192.168.1.24")));
}
Also used : IPAddressRange(org.opennms.core.network.IPAddressRange) Test(org.junit.Test)

Example 2 with IPAddressRange

use of org.opennms.core.network.IPAddressRange in project opennms by OpenNMS.

the class SnmpEventInfoTest method testContainsAddrIPv6.

@Test
public void testContainsAddrIPv6() {
    IPAddressRange r = new IPAddressRange("2001:db8::10", "2001:db8::20");
    assertFalse(r.contains("192.168.0.1"));
    assertFalse(r.contains("2001:db8::1"));
    assertTrue(r.contains("2001:db8::10"));
    assertTrue(r.contains("2001:db8::15"));
    assertTrue(r.contains("2001:db8::20"));
    assertFalse(r.contains("2001:db8::21"));
}
Also used : IPAddressRange(org.opennms.core.network.IPAddressRange) Test(org.junit.Test)

Example 3 with IPAddressRange

use of org.opennms.core.network.IPAddressRange in project opennms by OpenNMS.

the class SnmpEventInfoTest method testFollows.

@Test
public void testFollows() {
    IPAddressRange s = new IPAddressRange("192.168.1.5", "192.168.1.6");
    IPAddressRange q = new IPAddressRange("192.168.1.1", "192.168.1.2");
    IPAddressRange r = new IPAddressRange("192.168.1.3", "192.168.1.4");
    assertTrue(r.comesAfter(q));
    assertFalse(r.comesAfter(r));
    assertFalse(r.comesAfter(s));
}
Also used : IPAddressRange(org.opennms.core.network.IPAddressRange) Test(org.junit.Test)

Example 4 with IPAddressRange

use of org.opennms.core.network.IPAddressRange in project opennms by OpenNMS.

the class SnmpEventInfoTest method testAdjacentRange.

@Test
public void testAdjacentRange() {
    IPAddressRange r = new IPAddressRange("192.168.1.10", "192.168.1.20");
    assertTrue(r.adjoins(new IPAddressRange("192.168.1.7", "192.168.1.9")));
    assertFalse(r.adjoins(new IPAddressRange("192.168.1.7", "192.168.1.8")));
    assertFalse(r.adjoins(new IPAddressRange("192.168.1.7", "192.168.1.21")));
    assertTrue(r.adjoins(new IPAddressRange("192.168.1.21", "192.168.1.21")));
}
Also used : IPAddressRange(org.opennms.core.network.IPAddressRange) Test(org.junit.Test)

Example 5 with IPAddressRange

use of org.opennms.core.network.IPAddressRange in project opennms by OpenNMS.

the class SnmpEventInfoTest method testContainsAddr.

@Test
public void testContainsAddr() {
    IPAddressRange range = new IPAddressRange("192.168.1.1", "192.168.1.3");
    assertFalse(range.contains("192.168.0.1"));
    assertTrue(range.contains("192.168.1.1"));
    assertTrue(range.contains("192.168.1.2"));
    assertTrue(range.contains("192.168.1.3"));
    assertFalse(range.contains("192.168.1.4"));
}
Also used : IPAddressRange(org.opennms.core.network.IPAddressRange) Test(org.junit.Test)

Aggregations

IPAddressRange (org.opennms.core.network.IPAddressRange)15 Test (org.junit.Test)12 IPAddressRangeSet (org.opennms.core.network.IPAddressRangeSet)2 Range (org.opennms.netmgt.config.snmp.Range)2 IPAddress (org.opennms.core.network.IPAddress)1 SnmpEventInfo (org.opennms.netmgt.config.SnmpEventInfo)1 EventHandler (org.opennms.netmgt.events.api.annotations.EventHandler)1