### Question:
RemoteReceiverStreamClient extends ContextAwareBase implements RemoteReceiverClient { public boolean offer(Serializable event) { if (queue == null) { throw new IllegalStateException("client has no event queue"); } return queue.offer(event); } RemoteReceiverStreamClient(String id, Socket socket);   RemoteReceiverStreamClient(String id, OutputStream outputStream); void setQueue(BlockingQueue<Serializable> queue); boolean offer(Serializable event); void close(); void run();  }### Answer:
@Test public void testOfferEventAndRun() throws Exception { client.offer(TEST_EVENT); Thread thread = new Thread(client); thread.start(); thread.join(1000); assertFalse(thread.isAlive()); ObjectInputStream ois = new ObjectInputStream( new ByteArrayInputStream(outputStream.toByteArray())); assertEquals(TEST_EVENT, ois.readObject()); }
@Test public void testOfferEventSequenceAndRun() throws Exception { for (int i = 0; i < 10; i++) { client.offer(TEST_EVENT + i); } Thread thread = new Thread(client); thread.start(); thread.join(1000); assertFalse(thread.isAlive()); ObjectInputStream ois = new ObjectInputStream( new ByteArrayInputStream(outputStream.toByteArray())); for (int i = 0; i < 10; i++) { assertEquals(TEST_EVENT + i, ois.readObject()); } }
@Test public void testOfferEventAndRun() throws Exception { client.offer(TEST_EVENT); Thread thread = new Thread(client); thread.start(); thread.join(1000); assertFalse(thread.isAlive()); ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(outputStream.toByteArray())); assertEquals(TEST_EVENT, ois.readObject()); }
@Test public void testOfferEventSequenceAndRun() throws Exception { for (int i = 0; i < 10; i++) { client.offer(TEST_EVENT + i); } Thread thread = new Thread(client); thread.start(); thread.join(1000); assertFalse(thread.isAlive()); ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(outputStream.toByteArray())); for (int i = 0; i < 10; i++) { assertEquals(TEST_EVENT + i, ois.readObject()); } }