@Test public void testPublishTextMessage() 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"); TextMessage msg = session.createTextMessage(); msg.setText("HELLO"); 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")); TextMessage rx_msg = (TextMessage) consumer.receive(); assertNotNull(rx_msg); assertTrue(rx_msg.getText().equals("HELLO")); consumer.close(); receive_session.close(); conn.close(); }
@Test public void testCreateTextMessage() 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"); TextMessage msg = session.createTextMessage(); assertNotNull(msg); connection.disconnect(); }