예제 #1
0
 /** When receiving NeighborSolicitation, updates location and IP. */
 @Test
 public void testReceiveNs() {
   testProcessor.process(new TestNsPacketContext(DEV4));
   HostDescription descr = providerService.added;
   assertThat(descr.location(), is(LOCATION2));
   assertThat(descr.hwAddress(), is(MAC2));
   assertThat(descr.ipAddress().toArray()[0], is(IP_ADDRESS2));
   assertThat(descr.vlan(), is(VLAN));
 }
예제 #2
0
 /** When receiving IPv4, updates location only. */
 @Test
 public void testReceiveIpv4() {
   testProcessor.process(new TestIpv4PacketContext(DEV1));
   HostDescription descr = providerService.added;
   assertThat(descr.location(), is(LOCATION));
   assertThat(descr.hwAddress(), is(MAC));
   assertThat(descr.ipAddress().size(), is(0));
   assertThat(descr.vlan(), is(VLAN));
 }
예제 #3
0
  @Test
  public void removeHostByDeviceRemove() {
    provider.modified(CTX_FOR_REMOVE);
    testProcessor.process(new TestArpPacketContext(DEV1));
    testProcessor.process(new TestNaPacketContext(DEV4));

    Device device =
        new DefaultDevice(
            ProviderId.NONE, deviceId(DEV1), SWITCH, "m", "h", "s", "n", new ChassisId(0L));
    deviceService.listener.event(new DeviceEvent(DEVICE_REMOVED, device));
    assertEquals("incorrect remove count", 1, providerService.removeCount);

    device =
        new DefaultDevice(
            ProviderId.NONE, deviceId(DEV4), SWITCH, "m", "h", "s", "n", new ChassisId(0L));
    deviceService.listener.event(new DeviceEvent(DEVICE_REMOVED, device));
    assertEquals("incorrect remove count", 2, providerService.removeCount);
  }
예제 #4
0
  @Test
  public void events() {
    // new host
    testProcessor.process(new TestArpPacketContext(DEV1));
    assertNotNull("new host expected", providerService.added);
    assertNull("host motion unexpected", providerService.moved);

    // the host moved to new switch
    testProcessor.process(new TestArpPacketContext(DEV2));
    assertNotNull("host motion expected", providerService.moved);

    // the host was misheard on a spine
    testProcessor.process(new TestArpPacketContext(DEV3));
    assertNull("host misheard on spine switch", providerService.spine);

    providerService.clear();

    // new host
    testProcessor.process(new TestNaPacketContext(DEV4));
    assertNotNull("new host expected", providerService.added);
    assertNull("host motion unexpected", providerService.moved);

    // the host moved to new switch
    testProcessor.process(new TestNaPacketContext(DEV5));
    assertNotNull("host motion expected", providerService.moved);

    // the host was misheard on a spine
    testProcessor.process(new TestNaPacketContext(DEV6));
    assertNull("host misheard on spine switch", providerService.spine);
  }
예제 #5
0
  @Test
  public void removeHostByDevicePortDown() {
    provider.modified(CTX_FOR_REMOVE);
    testProcessor.process(new TestArpPacketContext(DEV1));
    testProcessor.process(new TestArpPacketContext(DEV4));

    Device device =
        new DefaultDevice(
            ProviderId.NONE, deviceId(DEV1), SWITCH, "m", "h", "s", "n", new ChassisId(0L));
    deviceService.listener.event(
        new DeviceEvent(PORT_UPDATED, device, new DefaultPort(device, portNumber(INPORT), false)));
    assertEquals("incorrect remove count", 1, providerService.removeCount);

    device =
        new DefaultDevice(
            ProviderId.NONE, deviceId(DEV4), SWITCH, "m", "h", "s", "n", new ChassisId(0L));
    deviceService.listener.event(
        new DeviceEvent(PORT_UPDATED, device, new DefaultPort(device, portNumber(INPORT), false)));
    assertEquals("incorrect remove count", 2, providerService.removeCount);
  }
예제 #6
0
 /** When receiving IPv6 multicast packet, ignores it. */
 @Test
 public void testReceiveIpv6Multicast() {
   testProcessor.process(new TestIpv6McastPacketContext(DEV4));
   assertNull(providerService.added);
 }
예제 #7
0
 /** When receiving Duplicate Address Detection (DAD), ignores it. */
 @Test
 public void testReceiveDad() {
   testProcessor.process(new TestDadPacketContext(DEV4));
   assertNull(providerService.added);
 }