activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r1481930 - in /activemq/trunk: activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ activemq-unit-tests/src/test/java/org/apache/activemq/bugs/ activemq-unit-tests/src/test/java/org/apache/activemq/command/
Date Mon, 13 May 2013 15:36:04 GMT
Author: tabish
Date: Mon May 13 15:36:03 2013
New Revision: 1481930

URL: http://svn.apache.org/r1481930
Log:
apply fix and patch for: https://issues.apache.org/jira/browse/AMQ-4530

Added:
    activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4530Test.java
  (with props)
Modified:
    activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/OpenTypeSupport.java
    activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/command/ActiveMQMessageTest.java

Modified: activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/OpenTypeSupport.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/OpenTypeSupport.java?rev=1481930&r1=1481929&r2=1481930&view=diff
==============================================================================
--- activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/OpenTypeSupport.java
(original)
+++ activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/OpenTypeSupport.java
Mon May 13 15:36:03 2013
@@ -16,13 +16,16 @@
  */
 package org.apache.activemq.broker.jmx;
 
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import org.apache.activemq.broker.region.policy.SlowConsumerEntry;
+import org.apache.activemq.broker.scheduler.Job;
+import org.apache.activemq.command.ActiveMQBlobMessage;
+import org.apache.activemq.command.ActiveMQBytesMessage;
+import org.apache.activemq.command.ActiveMQMapMessage;
+import org.apache.activemq.command.ActiveMQMessage;
+import org.apache.activemq.command.ActiveMQObjectMessage;
+import org.apache.activemq.command.ActiveMQStreamMessage;
+import org.apache.activemq.command.ActiveMQTextMessage;
+import org.fusesource.hawtbuf.UTF8Buffer;
 
 import javax.jms.DeliveryMode;
 import javax.jms.JMSException;
@@ -35,16 +38,13 @@ import javax.management.openmbean.OpenTy
 import javax.management.openmbean.SimpleType;
 import javax.management.openmbean.TabularDataSupport;
 import javax.management.openmbean.TabularType;
-
-import org.apache.activemq.broker.region.policy.SlowConsumerEntry;
-import org.apache.activemq.broker.scheduler.Job;
-import org.apache.activemq.command.ActiveMQBlobMessage;
-import org.apache.activemq.command.ActiveMQBytesMessage;
-import org.apache.activemq.command.ActiveMQMapMessage;
-import org.apache.activemq.command.ActiveMQMessage;
-import org.apache.activemq.command.ActiveMQObjectMessage;
-import org.apache.activemq.command.ActiveMQStreamMessage;
-import org.apache.activemq.command.ActiveMQTextMessage;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
 
 public final class OpenTypeSupport {
 
@@ -239,6 +239,11 @@ public final class OpenTypeSupport {
             Set<Map.Entry<String,Object>> entries = m.getProperties().entrySet();
             for (Map.Entry<String, Object> entry : entries) {
                 Object value = entry.getValue();
+                if (value instanceof UTF8Buffer && valueType.equals(String.class))
{
+                    String actual = value.toString();
+                    CompositeDataSupport compositeData = createTabularRowValue(type, entry.getKey(),
actual);
+                    answer.put(compositeData);
+                }
                 if (valueType.isInstance(value)) {
                     CompositeDataSupport compositeData = createTabularRowValue(type, entry.getKey(),
value);
                     answer.put(compositeData);

Added: activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4530Test.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4530Test.java?rev=1481930&view=auto
==============================================================================
--- activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4530Test.java
(added)
+++ activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4530Test.java
Mon May 13 15:36:03 2013
@@ -0,0 +1,100 @@
+package org.apache.activemq.bugs;
+
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.greaterThan;
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThat;
+
+import java.util.Map;
+
+import javax.jms.Connection;
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.TabularDataSupport;
+
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.activemq.broker.BrokerService;
+import org.apache.activemq.broker.jmx.CompositeDataConstants;
+import org.apache.activemq.broker.jmx.QueueViewMBean;
+import org.apache.activemq.command.ActiveMQQueue;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class AMQ4530Test {
+
+    private static BrokerService brokerService;
+    private static String TEST_QUEUE = "testQueue";
+    private static ActiveMQQueue queue = new ActiveMQQueue(TEST_QUEUE);
+    private static String BROKER_ADDRESS = "tcp://localhost:0";
+    private static String KEY = "testproperty";
+    private static String VALUE = "propvalue";
+
+    private ActiveMQConnectionFactory connectionFactory;
+    private String connectionUri;
+
+    @Before
+    public void setUp() throws Exception {
+        brokerService = new BrokerService();
+        brokerService.setPersistent(false);
+        brokerService.setUseJmx(true);
+        connectionUri = brokerService.addConnector(BROKER_ADDRESS).getPublishableConnectString();
+        brokerService.start();
+        brokerService.waitUntilStarted();
+
+        connectionFactory = new ActiveMQConnectionFactory(connectionUri);
+        sendMessage();
+    }
+
+    public void sendMessage() throws Exception {
+        final Connection conn = connectionFactory.createConnection();
+        try {
+            conn.start();
+            final Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+            final Destination queue = session.createQueue(TEST_QUEUE);
+            final Message toSend = session.createMessage();
+            toSend.setStringProperty(KEY, VALUE);
+            final MessageProducer producer = session.createProducer(queue);
+            producer.send(queue, toSend);
+        } finally {
+            conn.close();
+        }
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        brokerService.stop();
+        brokerService.waitUntilStopped();
+    }
+
+    @SuppressWarnings("unchecked")
+    @Test
+    public void testStringPropertiesFromCompositeData() throws Exception {
+        final QueueViewMBean queueView = getProxyToQueueViewMBean();
+        final CompositeData message = queueView.browse()[0];
+        assertNotNull(message);
+        TabularDataSupport stringProperties = (TabularDataSupport) message.get(CompositeDataConstants.STRING_PROPERTIES);
+        assertNotNull(stringProperties);
+        assertThat(stringProperties.size(), is(greaterThan(0)));
+        Map.Entry<Object, Object> compositeDataEntry = (Map.Entry<Object, Object>)
stringProperties.entrySet().toArray()[0];
+        CompositeData stringEntry = (CompositeData) compositeDataEntry.getValue();
+        assertThat(String.valueOf(stringEntry.get("key")), equalTo(KEY));
+        assertThat(String.valueOf(stringEntry.get("value")), equalTo(VALUE));
+    }
+
+    private QueueViewMBean getProxyToQueueViewMBean() throws MalformedObjectNameException,
NullPointerException,
+            JMSException {
+        final ObjectName queueViewMBeanName = new ObjectName("org.apache.activemq:type=Broker,brokerName=localhost,destinationType=Queue,destinationName="
+ queue.getQueueName());
+        final QueueViewMBean proxy = (QueueViewMBean) brokerService.getManagementContext().newProxyInstance(
+                queueViewMBeanName, QueueViewMBean.class, true);
+        return proxy;
+    }
+
+}

Propchange: activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4530Test.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/command/ActiveMQMessageTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/command/ActiveMQMessageTest.java?rev=1481930&r1=1481929&r2=1481930&view=diff
==============================================================================
--- activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/command/ActiveMQMessageTest.java
(original)
+++ activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/command/ActiveMQMessageTest.java
Mon May 13 15:36:03 2013
@@ -70,6 +70,7 @@ public class ActiveMQMessageTest extends
     /*
      * @see TestCase#setUp()
      */
+    @Override
     protected void setUp() throws Exception {
         super.setUp();
         this.jmsMessageID = "testid";
@@ -92,6 +93,7 @@ public class ActiveMQMessageTest extends
     /*
      * @see TestCase#tearDown()
      */
+    @Override
     protected void tearDown() throws Exception {
         super.tearDown();
     }
@@ -432,18 +434,22 @@ public class ActiveMQMessageTest extends
 
     public void testConvertProperties() throws Exception {
         org.apache.activemq.command.Message msg = new org.apache.activemq.command.Message()
{
+            @Override
             public org.apache.activemq.command.Message copy() {
                 return null;
             }
 
+            @Override
             public void beforeMarshall(WireFormat wireFormat) throws IOException {
                 super.beforeMarshall(wireFormat);
             }
 
+            @Override
             public byte getDataStructureType() {
                 return 0;
             }
 
+            @Override
             public Response visit(CommandVisitor visitor) throws Exception {
                 return null;
             }
@@ -455,6 +461,11 @@ public class ActiveMQMessageTest extends
             @Override
             public void storeContent() {
             }
+
+            @Override
+            public void storeContentAndClear() {
+
+            }
         };
 
         msg.setProperty("stringProperty", "string");
@@ -630,7 +641,7 @@ public class ActiveMQMessageTest extends
     public void testIntPropertyConversion() throws JMSException {
         ActiveMQMessage msg = new ActiveMQMessage();
         String propertyName = "property";
-        msg.setIntProperty(propertyName, (int)1);
+        msg.setIntProperty(propertyName, 1);
 
         assertEquals(((Integer)msg.getObjectProperty(propertyName)).intValue(), 1);
         assertEquals(msg.getIntProperty(propertyName), 1);



Mime
View raw message