/** * When GET is received and owner is not found but line is reserved, then create line and reply * with PUTX */ @Test public void whenGETReservedAndNoOwnerThenCreateAndReplyPUTX() throws Exception { when(store.casOwner(15, sh(-1), sh(10))).thenReturn(sh(10)); final LineMessage get = Message.GET(sh(10), 15); mm.receive(get); verify(store).casOwner(15, sh(-1), sh(10)); verify(store).write(15, sh(10), 1, new byte[0], null); verify(comm).send(argThat(equalTo(Message.PUTX(get, 15, new short[0], 0, 1, null)))); verify(monitor).addObjectServed(); verify(monitor).addOwnerWrite(); verifyNoMoreInteractions(monitor); }
/** When GET is received and server is owner then reply with PUTX */ @Test public void whenGETAndServerIsOwnerThenReplyPUTX() throws Exception { when(store.casOwner(id(154), sh(0), sh(10))).thenReturn(sh(10)); when(store.read(id(154))).thenReturn(new MainMemoryEntry(1234, new byte[] {3, 4, 5})); final LineMessage get = Message.GET(sh(10), id(154)); mm.receive(get); verify(store).casOwner(id(154), sh(0), sh(10)); verify(store).read(id(154)); verify(comm) .send( argThat( equalTo( Message.PUTX( get, id(154), new short[0], 0, 1234, ByteBuffer.wrap(new byte[] {3, 4, 5}))))); verify(monitor).addObjectServed(); verify(monitor).addOwnerWrite(); verifyNoMoreInteractions(monitor); }