<commit_before>package org.fiteagle.core.logger;

import java.io.FileNotFoundException;

import javax.jms.ConnectionFactory;
import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.MessageConsumer;
import javax.jms.MessageProducer;
import javax.jms.Session;
import javax.naming.NamingException;

import org.apache.activemq.ActiveMQConnectionFactory;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

public class MessageBusLoggerTest {
	ConnectionFactory factory;
	private MessageBus messageBus;

	@Before
	public void setup() throws JMSException {
		this.factory = new ActiveMQConnectionFactory(
				"vm://localhost?broker.persistent=false");
		this.messageBus = new MessageBus("user", "pwd", factory, "topic");
	}

	@After
	public void teardown() throws JMSException {
		this.messageBus.close();
	}

	@Test
	public void testMessageBusConstructorWithString() throws JMSException {
		new MessageBus("user", "pwd", factory, "topic");
	}

	@Test
	public void testMessageBusConstructorWithDestination() throws JMSException {
		Destination destination = this.factory.createConnection()
				.createSession(false, Session.AUTO_ACKNOWLEDGE)
				.createTopic("topic");
		new MessageBus("user", "pwd", factory, destination);
	}

	@Test
	public void testMessageBusLogger() throws JMSException,
			InterruptedException, FileNotFoundException, NamingException {

		final Session session = messageBus.getSession();
		final MessageProducer producer = messageBus.getProducer();
		final MessageConsumer consumer = messageBus.getConsumer();

		final MessageBusLogger mbLogger = new MessageBusLogger(session,
				consumer);

		Assert.assertNotEquals("test", mbLogger.getLastTextMessage());
		producer.send(session.createTextMessage("test"));
		Thread.sleep(50); // todo: find a better way
		Assert.assertEquals("test", mbLogger.getLastTextMessage());
	}
}<commit_msg>better jms testing<commit_after>package org.fiteagle.core.logger;

import java.io.FileNotFoundException;

import javax.jms.ConnectionFactory;
import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageConsumer;
import javax.jms.MessageListener;
import javax.jms.MessageProducer;
import javax.jms.Session;
import javax.naming.NamingException;

import org.apache.activemq.ActiveMQConnectionFactory;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

public class MessageBusLoggerTest {
	ConnectionFactory factory;
	private MessageBus messageBus;
	private MessageBus waitingMessageBus;

	@Before
	public void setup() throws JMSException {
		this.factory = new ActiveMQConnectionFactory(
				"vm://localhost?broker.persistent=false");
		this.messageBus = new MessageBus("user", "pwd", factory, "topic");
		this.waitingMessageBus = new MessageBus("user", "pwd", factory, "topic");
	}

	@After
	public void teardown() throws JMSException {
		this.messageBus.close();
	}

	@Test
	public void testMessageBusConstructorWithString() throws JMSException {
		new MessageBus("user", "pwd", factory, "topic");
	}

	@Test
	public void testMessageBusConstructorWithDestination() throws JMSException {
		Destination destination = this.factory.createConnection()
				.createSession(false, Session.AUTO_ACKNOWLEDGE)
				.createTopic("topic");
		new MessageBus("user", "pwd", factory, destination);
	}

	@Test
	public void testMessageBusLogger() throws JMSException,
			InterruptedException, FileNotFoundException, NamingException {

		final Session session = messageBus.getSession();
		final MessageProducer producer = messageBus.getProducer();
		final MessageConsumer consumer = messageBus.getConsumer();

		final MessageBusLogger mbLogger = new MessageBusLogger(session,
				consumer);

		Assert.assertNotEquals("test", mbLogger.getLastTextMessage());
		producer.send(session.createTextMessage("test"));
		this.waitingMessageBus.getConsumer().receive(50);
		Assert.assertEquals("test", mbLogger.getLastTextMessage());
	}
}
{'fraction_non_alphanumeric': 0.10738255033557047, 'fraction_numerical': 0.0009942828734775043, 'mean_word_length': 6.09700176366843, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4942854', 'n_tokens_mistral': 1232, 'n_tokens_neox': 1155, 'n_words': 260}