Пример #1
0
  /** When INV is received but previous owner is wrong, don't change the owner and reply INV. */
  @Test
  public void whenINVAndWrongPreviousOwnerThenINV() throws Exception {
    when(store.casOwner(id(154), sh(5), sh(10))).thenReturn(sh(20));
    final Message.INV inv = Message.INV(sh(10), id(154), sh(5));
    mm.receive(inv);

    verify(store).casOwner(id(154), sh(5), sh(10));
    verify(comm).send(argThat(equalTo(Message.INV(inv, id(154), sh(20)))));
    verify(monitor).addOwnerServed();
    verifyNoMoreInteractions(monitor);
  }
Пример #2
0
  /**
   * When INV is received, the owner is registered in the store as the owner of the line, and reply
   * INVACK.
   */
  @Test
  public void whenINVThenMarkOwnerAndINVACK() throws Exception {
    when(store.casOwner(id(154), sh(5), sh(10))).thenReturn(sh(10));
    final Message.INV inv = Message.INV(sh(10), id(154), sh(5));
    mm.receive(inv);

    verify(store).casOwner(id(154), sh(5), sh(10));
    verify(comm).send(argThat(equalTo(Message.INVACK(inv))));
    verify(monitor).addOwnerWrite();
    verifyNoMoreInteractions(monitor);
  }