Source:
public void testEcho(String message) throws InterruptedException, ExecutionException, ClientConnectionException, IllegalAccessException { final BlockingQueue<byte[]> queue = new ArrayBlockingQueue<>(5); Future<ReactorListener> futureListener = this.listeningReactor.createListener(HOSTNAME, 0, new EventListener() { @Override public void onAcccept(final ReactorClient client) { client.addEventListener(new MessageListener() { @Override public void onMessageReceived(byte[] message) { try { client.sendMessage(message); } catch (ClientConnectionException e) { fail(); } } }); } }); ReactorListener listener = futureListener.get(); assertNotNull(listener); SessionCallbackImpl certCallback = new SessionCallbackImpl(); ReactorClient client = this.sendingReactor.createClient(HOSTNAME, listener.getPort(), certCallback); client.setClientPolicy(new StompClientPolicy(180000, 0, 1000000, DEFAULT_REQUEST_QUEUE, DEFAULT_RESPONSE_QUEUE)); client.addEventListener(new ReactorClient.MessageListener() { @Override public void onMessageReceived(byte[] message) { queue.add(message); } }); client.connect(); client.sendMessage(message.getBytes()); byte[] response = queue.poll(TIMEOUT_SEC, TimeUnit.SECONDS); assertNotNull(response); assertEquals(message, new String(response, UTF8)); client.sendMessage(message.getBytes()); response = queue.poll(TIMEOUT_SEC, TimeUnit.SECONDS); SSLClient.Context context = certCallback.getContext(); assertNotNull(context); List<Certificate> peerCertificates = context.getPeerCertificates(); assertNotNull(peerCertificates); assertFalse(peerCertificates.isEmpty()); client.close(); listener.close(); assertNotNull(response); assertEquals(message, new String(response, UTF8)); }

Target:
public void testEcho(String message) throws InterruptedException, ExecutionException, ClientConnectionException, IllegalAccessException { final BlockingQueue<byte[]> queue = new ArrayBlockingQueue<>(5); Future<ReactorListener> futureListener = this.listeningReactor.createListener(HOSTNAME, 0, new EventListener() { @Override public void onAcccept(final ReactorClient client) { client.addEventListener(new MessageListener() { @Override public void onMessageReceived(byte[] message) { try { client.sendMessage(message); } catch (ClientConnectionException e) { fail(); } } }); } }); ReactorListener listener = futureListener.get(); assertNotNull(listener); ReactorClient client = this.sendingReactor.createClient(HOSTNAME, listener.getPort()); client.setClientPolicy(new StompClientPolicy(180000, 0, 1000000, DEFAULT_REQUEST_QUEUE, DEFAULT_RESPONSE_QUEUE)); client.addEventListener(new ReactorClient.MessageListener() { @Override public void onMessageReceived(byte[] message) { queue.add(message); } }); client.connect(); client.sendMessage(message.getBytes()); byte[] response = queue.poll(TIMEOUT_SEC, TimeUnit.SECONDS); assertNotNull(response); assertEquals(message, new String(response, UTF8)); client.sendMessage(message.getBytes()); response = queue.poll(TIMEOUT_SEC, TimeUnit.SECONDS); List<Certificate> peerCertificates = client.getPeerCertificates(); assertNotNull(peerCertificates); assertFalse(peerCertificates.isEmpty()); client.close(); listener.close(); assertNotNull(response); assertEquals(message, new String(response, UTF8)); }