mirror of https://github.com/apache/activemq.git
Adds a little test to show that messages cross the network bridge that are sent compressed remain compressed.
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1349030 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
4a7f870593
commit
a307c57e98
|
@ -16,9 +16,32 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.activemq.network;
|
package org.apache.activemq.network;
|
||||||
|
|
||||||
|
import static junit.framework.Assert.assertNotNull;
|
||||||
|
import static junit.framework.Assert.assertNull;
|
||||||
|
import static junit.framework.Assert.assertTrue;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
import javax.jms.Connection;
|
||||||
|
import javax.jms.DeliveryMode;
|
||||||
|
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.jms.TextMessage;
|
||||||
|
import javax.jms.TopicRequestor;
|
||||||
|
import javax.jms.TopicSession;
|
||||||
|
|
||||||
|
import org.apache.activemq.ActiveMQConnection;
|
||||||
import org.apache.activemq.ActiveMQConnectionFactory;
|
import org.apache.activemq.ActiveMQConnectionFactory;
|
||||||
import org.apache.activemq.broker.BrokerService;
|
import org.apache.activemq.broker.BrokerService;
|
||||||
import org.apache.activemq.command.ActiveMQDestination;
|
import org.apache.activemq.command.ActiveMQDestination;
|
||||||
|
import org.apache.activemq.command.ActiveMQMessage;
|
||||||
import org.apache.activemq.command.ActiveMQTopic;
|
import org.apache.activemq.command.ActiveMQTopic;
|
||||||
import org.apache.activemq.command.ConsumerId;
|
import org.apache.activemq.command.ConsumerId;
|
||||||
import org.apache.activemq.util.Wait;
|
import org.apache.activemq.util.Wait;
|
||||||
|
@ -27,23 +50,12 @@ import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Ignore;
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.context.support.AbstractApplicationContext;
|
import org.springframework.context.support.AbstractApplicationContext;
|
||||||
import org.springframework.core.io.ClassPathResource;
|
import org.springframework.core.io.ClassPathResource;
|
||||||
import org.springframework.core.io.Resource;
|
import org.springframework.core.io.Resource;
|
||||||
|
|
||||||
import javax.jms.*;
|
|
||||||
import java.net.URI;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
|
|
||||||
|
|
||||||
import static junit.framework.Assert.assertNotNull;
|
|
||||||
import static junit.framework.Assert.assertNull;
|
|
||||||
import static junit.framework.Assert.assertTrue;
|
|
||||||
|
|
||||||
public class SimpleNetworkTest {
|
public class SimpleNetworkTest {
|
||||||
|
|
||||||
protected static final int MESSAGE_COUNT = 10;
|
protected static final int MESSAGE_COUNT = 10;
|
||||||
|
@ -60,6 +72,30 @@ public class SimpleNetworkTest {
|
||||||
protected ActiveMQTopic excluded;
|
protected ActiveMQTopic excluded;
|
||||||
protected String consumerName = "durableSubs";
|
protected String consumerName = "durableSubs";
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMessageCompression() throws Exception {
|
||||||
|
|
||||||
|
ActiveMQConnection localAmqConnection = (ActiveMQConnection) localConnection;
|
||||||
|
localAmqConnection.setUseCompression(true);
|
||||||
|
|
||||||
|
MessageConsumer consumer1 = remoteSession.createConsumer(included);
|
||||||
|
MessageProducer producer = localSession.createProducer(included);
|
||||||
|
producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
|
||||||
|
|
||||||
|
waitForConsumerRegistration(localBroker, 1, included);
|
||||||
|
|
||||||
|
for (int i = 0; i < MESSAGE_COUNT; i++) {
|
||||||
|
Message test = localSession.createTextMessage("test-" + i);
|
||||||
|
producer.send(test);
|
||||||
|
Message msg = consumer1.receive(1000);
|
||||||
|
assertNotNull(msg);
|
||||||
|
ActiveMQMessage amqMessage = (ActiveMQMessage) msg;
|
||||||
|
assertTrue(amqMessage.isCompressed());
|
||||||
|
}
|
||||||
|
// ensure no more messages received
|
||||||
|
assertNull(consumer1.receive(1000));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRequestReply() throws Exception {
|
public void testRequestReply() throws Exception {
|
||||||
final MessageProducer remoteProducer = remoteSession.createProducer(null);
|
final MessageProducer remoteProducer = remoteSession.createProducer(null);
|
||||||
|
|
Loading…
Reference in New Issue