1 18 package org.apache.activemq.command; 19 20 import java.io.IOException ; 21 22 import junit.framework.Test; 23 24 import org.apache.activemq.util.ByteSequence; 25 26 public class MessageSendTest extends DataStructureTestSupport { 27 28 public static Test suite() { 29 return suite(MessageSendTest.class); 30 } 31 32 public static void main(String [] args) { 33 junit.textui.TestRunner.run(suite()); 34 } 35 36 public void initCombosForTestMessageSendMarshaling() { 37 addCombinationValues("cacheEnabled", new Object [] { Boolean.TRUE, Boolean.FALSE }); 38 } 39 40 public void testMessageSendMarshaling() throws IOException { 41 ActiveMQMessage message = new ActiveMQMessage(); 42 message.setCommandId((short) 1); 43 message.setDestination(new ActiveMQQueue("queue")); 44 message.setGroupID("group"); 45 message.setGroupSequence(4); 46 message.setCorrelationId("correlation"); 47 message.setMessageId(new MessageId("c1:1:1", 1)); 48 49 assertBeanMarshalls(message); 50 assertBeanMarshalls(message); 51 52 } 53 54 public void xtestPerformance() throws IOException { 55 ActiveMQMessage message = new ActiveMQMessage(); 56 message.setProducerId(new ProducerId(new SessionId(new ConnectionId(new ConnectionId("test")), 1), 1)); 57 message.setMessageId(new MessageId(message.getProducerId(), 1)); 58 message.setCommandId((short) 1); 59 message.setGroupID("group"); 60 message.setGroupSequence(4); 61 message.setCorrelationId("correlation"); 62 message.setContent(new ByteSequence(new byte[1024], 0, 1024)); 63 message.setTimestamp(System.currentTimeMillis()); 64 message.setDestination(new ActiveMQQueue("TEST")); 65 66 int p = 1000000; 67 68 long start = System.currentTimeMillis(); 69 for (int i = 0; i < p; i++) { 70 marshalAndUnmarshall(message, wireFormat); 71 } 72 long end = System.currentTimeMillis(); 73 74 log.info("marshaled/unmarshaled: " + p + " msgs at " + (p * 1000f / (end - start)) + " msgs/sec"); 75 } 76 } 77 | Popular Tags |