@Test public void testPublish() throws Exception { new Expectations() {{ channel.exchangeDeclare(EXCHANGE, EXCHANGE_TYPE, true); channel.basicPublish(EXCHANGE, ROUTING_KEY, null, MESSAGE.getBytes(StandardCharsets.UTF_8)); channel.isOpen(); result = true; channel.close(); connection.createChannel(); result = channel; connection.isOpen(); result = true; connection.close(); factory.setUri(URI); factory.newConnection(); result = connection; }}; publisher.connect(URI, EXCHANGE, EXCHANGE_TYPE); publisher.publish(MESSAGE, ROUTING_KEY); publisher.close(); }
public boolean publish(String message) { return publish(message, ""); }
Publisher { public boolean publish(String message) { return publish(message, ""); } }
Publisher { public boolean publish(String message) { return publish(message, ""); } @Inject  Publisher(ConnectionFactory factory); }
Publisher { public boolean publish(String message) { return publish(message, ""); } @Inject  Publisher(ConnectionFactory factory); boolean connect(String uri, String exchange, String exchangeType); boolean publish(String message); boolean publish(String message, String routingKey); void close(); String toString(); }
Publisher { public boolean publish(String message) { return publish(message, ""); } @Inject  Publisher(ConnectionFactory factory); boolean connect(String uri, String exchange, String exchangeType); boolean publish(String message); boolean publish(String message, String routingKey); void close(); String toString();  }