Return-Path: Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: (qmail 21908 invoked from network); 29 Jan 2010 18:41:07 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 29 Jan 2010 18:41:07 -0000 Received: (qmail 54540 invoked by uid 500); 29 Jan 2010 18:41:07 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 54503 invoked by uid 500); 29 Jan 2010 18:41:06 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 54494 invoked by uid 99); 29 Jan 2010 18:41:06 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 29 Jan 2010 18:41:06 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 29 Jan 2010 18:41:04 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 451E22388993; Fri, 29 Jan 2010 18:40:43 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r904585 - in /activemq/trunk/activemq-core/src: main/java/org/apache/activemq/command/ActiveMQTextMessage.java test/java/org/apache/activemq/bugs/AMQ2585Test.java Date: Fri, 29 Jan 2010 18:40:43 -0000 To: commits@activemq.apache.org From: gtully@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100129184043.451E22388993@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: gtully Date: Fri Jan 29 18:40:42 2010 New Revision: 904585 URL: http://svn.apache.org/viewvc?rev=904585&view=rev Log: resolve https://issues.apache.org/activemq/browse/AMQ-2585 with thanks. modified version of test applied, min size override is only relevant on the broker as it is calculated on demand on the client Added: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/bugs/AMQ2585Test.java (with props) Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQTextMessage.java Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQTextMessage.java URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQTextMessage.java?rev=904585&r1=904584&r2=904585&view=diff ============================================================================== --- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQTextMessage.java (original) +++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQTextMessage.java Fri Jan 29 18:40:42 2010 @@ -145,7 +145,7 @@ if (marshalledProperties != null) { size += marshalledProperties.getLength(); } - size = text.length() * 2; + size += text.length() * 2; } return super.getSize(); } Added: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/bugs/AMQ2585Test.java URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/bugs/AMQ2585Test.java?rev=904585&view=auto ============================================================================== --- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/bugs/AMQ2585Test.java (added) +++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/bugs/AMQ2585Test.java Fri Jan 29 18:40:42 2010 @@ -0,0 +1,82 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.activemq.bugs; + +import javax.jms.Destination; +import javax.jms.MessageConsumer; +import javax.jms.MessageProducer; +import javax.jms.Session; +import javax.jms.TextMessage; + +import org.apache.activemq.EmbeddedBrokerAndConnectionTestSupport; +import org.apache.activemq.command.ActiveMQQueue; +import org.apache.activemq.command.ActiveMQTextMessage; +import org.apache.activemq.spring.ConsumerBean; + +public class AMQ2585Test extends EmbeddedBrokerAndConnectionTestSupport { + private final Destination destination = new ActiveMQQueue("MyQueue"); + final static String LENGTH10STRING = "1234567890"; + private Session session; + private MessageProducer producer; + private ConsumerBean messageList; + + public void testOneMessageWithProperties() throws Exception { + TextMessage message = session.createTextMessage(LENGTH10STRING); + message.setStringProperty(LENGTH10STRING, LENGTH10STRING); + producer.send(message); + + messageList.assertMessagesArrived(1); + + ActiveMQTextMessage received = ((ActiveMQTextMessage) messageList + .flushMessages().get(0)); + + assertEquals(LENGTH10STRING, received.getText()); + assertTrue(received.getProperties().size() > 0); + assertTrue(received.propertyExists(LENGTH10STRING)); + assertEquals(LENGTH10STRING, received.getStringProperty(LENGTH10STRING)); + + /** + * As specified by getSize(), the size (memory usage) of the body should + * be length of text * 2. Unsure of how memory usage is calculated for + * properties, but should probably not be less than the sum of (string) + * lengths for the key name and value. + */ + + final int sizeShouldBeNoLessThan = LENGTH10STRING.length() * 4 + received.DEFAULT_MINIMUM_MESSAGE_SIZE; + assertTrue("Message size was smaller than expected: " + received.getSize(), + received.getSize() >= sizeShouldBeNoLessThan); + assertFalse(LENGTH10STRING.length() * 2 == received.getSize()); + } + + @Override + protected void setUp() throws Exception { + bindAddress = bindAddress + "?marshal=true"; + super.setUp(); + messageList = new ConsumerBean(); + messageList.setVerbose(true); + + session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + + MessageConsumer messageConsumer = session.createConsumer(destination); + + messageConsumer.setMessageListener(messageList); + + producer = session.createProducer(destination); + } +} Propchange: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/bugs/AMQ2585Test.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/bugs/AMQ2585Test.java ------------------------------------------------------------------------------ svn:keywords = Rev Date