### Question:
WriteEntryProcessor extends PacketProcessorBase<ParsedAddRequest> implements WriteCallback { @VisibleForTesting void recycle() { reset(); recyclerHandle.recycle(this); } private  WriteEntryProcessor(Recycler.Handle<WriteEntryProcessor> recyclerHandle); static WriteEntryProcessor create(ParsedAddRequest request, Channel channel,
                                             BookieRequestProcessor requestProcessor); @Override void writeComplete(int rc, long ledgerId, long entryId,
                              BookieId addr, Object ctx); @Override String toString();  }### Answer:
@Test public void testNoneHighPriorityWritesOnReadOnlyBookie() throws Exception { when(bookie.isReadOnly()).thenReturn(true); when(channel.voidPromise()).thenReturn(mock(ChannelPromise.class)); AtomicReference<Object> writtenObject = new AtomicReference<>(); CountDownLatch latch = new CountDownLatch(1); doAnswer(invocationOnMock -> { writtenObject.set(invocationOnMock.getArgument(0)); latch.countDown(); return null; }).when(channel).writeAndFlush(any(), any(ChannelPromise.class)); processor.run(); verify(channel, times(1)).writeAndFlush(any(), any(ChannelPromise.class)); latch.await(); assertTrue(writtenObject.get() instanceof Response); Response response = (Response) writtenObject.get(); assertEquals(BookieProtocol.EREADONLY, response.getErrorCode()); response.release(); response.recycle(); }
@Test public void testHighPriorityWritesOnReadOnlyBookieWhenHighPriorityWritesDisallowed() throws Exception { reinitRequest(BookieProtocol.FLAG_HIGH_PRIORITY); when(bookie.isReadOnly()).thenReturn(true); when(bookie.isAvailableForHighPriorityWrites()).thenReturn(false); when(channel.voidPromise()).thenReturn(mock(ChannelPromise.class)); AtomicReference<Object> writtenObject = new AtomicReference<>(); CountDownLatch latch = new CountDownLatch(1); doAnswer(invocationOnMock -> { writtenObject.set(invocationOnMock.getArgument(0)); latch.countDown(); return null; }).when(channel).writeAndFlush(any(), any(ChannelPromise.class)); processor.run(); verify(channel, times(1)).writeAndFlush(any(), any(ChannelPromise.class)); latch.await(); assertTrue(writtenObject.get() instanceof Response); Response response = (Response) writtenObject.get(); assertEquals(BookieProtocol.EREADONLY, response.getErrorCode()); response.release(); response.recycle(); }