@Test
 public void testPublishObjectMessage()
     throws FileNotFoundException, JMSException, OpenJMSAdapterException {
   YamlConfigurationHolder holder =
       new YamlConfigurationHolder("C:/NetBeansProjects/openjmsadapter/test/yaml_config.yml");
   ActiveMQConnectionFactoryBuilder builder = new ActiveMQConnectionFactoryBuilder();
   OpenJMSAdapterConnection connection =
       new OpenJMSAdapterConnection(builder.getConnectionFactory(holder.getConfig()));
   connection.connect();
   connection.createQueuePublishingSession("test.queue");
   QueuePublishSession session =
       (QueuePublishSession) connection.getQueuePublishSession("test.queue");
   ObjectMessage msg = session.createObjectMessage();
   msg.setObject(new Integer(1));
   session.publish(msg);
   connection.disconnect();
   Connection conn = builder.getConnectionFactory(holder.getConfig()).createConnection();
   conn.start();
   Session receive_session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
   MessageConsumer consumer =
       receive_session.createConsumer(receive_session.createQueue("test.queue"));
   ObjectMessage rx_msg = (ObjectMessage) consumer.receive();
   assertNotNull(rx_msg);
   assertTrue((Integer) (rx_msg.getObject()) == 1);
   consumer.close();
   receive_session.close();
   conn.close();
 }
 @Test
 public void testPublishBytesMessage()
     throws FileNotFoundException, JMSException, OpenJMSAdapterException {
   YamlConfigurationHolder holder =
       new YamlConfigurationHolder("C:/NetBeansProjects/openjmsadapter/test/yaml_config.yml");
   ActiveMQConnectionFactoryBuilder builder = new ActiveMQConnectionFactoryBuilder();
   OpenJMSAdapterConnection connection =
       new OpenJMSAdapterConnection(builder.getConnectionFactory(holder.getConfig()));
   connection.connect();
   connection.createQueuePublishingSession("test.queue");
   QueuePublishSession session =
       (QueuePublishSession) connection.getQueuePublishSession("test.queue");
   BytesMessage msg = session.createBytesMessage();
   msg.writeBytes("HELLO".getBytes());
   session.publish(msg);
   connection.disconnect();
   Connection conn = builder.getConnectionFactory(holder.getConfig()).createConnection();
   conn.start();
   Session receive_session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
   MessageConsumer consumer =
       receive_session.createConsumer(receive_session.createQueue("test.queue"));
   BytesMessage rx_msg = (BytesMessage) consumer.receive();
   assertNotNull(rx_msg);
   byte[] bytes = new byte[5];
   rx_msg.readBytes(bytes);
   assertTrue((new String(bytes)).equals("HELLO"));
   consumer.close();
   receive_session.close();
   conn.close();
 }
 @Test
 public void testConnectConnectedQueuePublishSession()
     throws FileNotFoundException, JMSException, OpenJMSAdapterException {
   YamlConfigurationHolder holder =
       new YamlConfigurationHolder("C:/NetBeansProjects/openjmsadapter/test/yaml_config.yml");
   ActiveMQConnectionFactoryBuilder builder = new ActiveMQConnectionFactoryBuilder();
   OpenJMSAdapterConnection connection =
       new OpenJMSAdapterConnection(builder.getConnectionFactory(holder.getConfig()));
   // session gets connected here
   connection.connect();
   connection.createQueuePublishingSession("test.queue");
   // try to connect the session again here - this should not fail
   connection.getQueuePublishSession("test.queue").connect();
   connection.disconnect();
 }
 @Test
 public void testCreateBytesMessage()
     throws FileNotFoundException, JMSException, OpenJMSAdapterException {
   YamlConfigurationHolder holder =
       new YamlConfigurationHolder("C:/NetBeansProjects/openjmsadapter/test/yaml_config.yml");
   ActiveMQConnectionFactoryBuilder builder = new ActiveMQConnectionFactoryBuilder();
   OpenJMSAdapterConnection connection =
       new OpenJMSAdapterConnection(builder.getConnectionFactory(holder.getConfig()));
   connection.connect();
   connection.createQueuePublishingSession("test.queue");
   QueuePublishSession session =
       (QueuePublishSession) connection.getQueuePublishSession("test.queue");
   BytesMessage msg = session.createBytesMessage();
   assertNotNull(msg);
   connection.disconnect();
 }