Model implements ExceptionListener, MessageListener, JMSConnectionListener { @SuppressWarnings("nls") public Model(final String url, final String user, final String password, final String topic_names) throws Exception { this.topic_names = topic_names; if (url == null || url.length() <= 0) throw new Exception(Messages.ErrorNoURL); if (topic_names.length() <= 0) throw new Exception(Messages.ErrorNoTopic); final Runnable connector = new Runnable() { @Override public void run() { try { connect(url, user, password); while (run) { synchronized (Model.this) { Model.this.wait(); } } disconnect(); } catch (Exception ex) { Logger.getLogger(Activator.ID).log(Level.SEVERE, "JMSMonitorConnector thread error", ex); } } }; final Thread thread = new Thread(connector, "JMSMonitorConnector"); thread.setDaemon(true); thread.start(); } @SuppressWarnings("nls")  Model(final String url, final String user, final String password,
                 final String topic_names); void close(); void addListener(final ModelListener listener); String getServerName(); ReceivedMessage[] getMessages(); void clear(); @Override void linkDown(); @Override void linkUp(final String server); @Override void onMessage(final Message message); @Override void onException(final JMSException ex);  }
@Test public void testModel() throws Exception { String url = "failover:(tcp: String topic = "LOG"; final Model model = new Model(url, null, null, topic); model.addListener(this); System.out.println("Listening to messages, " + "so start something that produces them..."); Thread.sleep(20 * 1000); model.close(); System.out.println("Done."); assertTrue(messages > 0); }