CheramiPublisherImpl implements CheramiPublisher, Reconfigurable { @Override public synchronized void close() { if (isOpen.getAndSet(false)) { connectionManager.close(); while (true) { PutMessageRequest msg = messageQueue.poll(); if (msg == null) { break; } CheramiFuture<SendReceipt> future = msg.getAckFuture(); String msgID = msg.getMessage().getId(); future.setReply(new SendReceipt(msgID, ReceiptStatus.ERR_NO_CONNS, RECEIPT_ERROR_NO_CONNS)); } } logger.info("Publisher closed"); } CheramiPublisherImpl(CheramiClient client, String path, PublisherOptions options, MetricsReporter reporter); @Override synchronized void open(); @Override synchronized void close(); @Override SendReceipt write(PublisherMessage message); @Override CheramiFuture<SendReceipt> writeAsync(PublisherMessage message); @Override void refreshNow();  }
@Test public void closeTest() throws Exception { if (!publisher.isOpen()) { publisher.open(); } assert (publisher.isOpen() == true); publisher.close(); assert (publisher.isOpen() == false); logger.info("CheramiPublisherImplTest: PASSED: CloseTest"); }