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")));
}
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"));
}
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));
}
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")));
}
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"));
}
Aggregations