Repository: qpid-broker-j
Updated Branches:
  refs/heads/master 42c182f0b -> 31037b059


QPID-8083 [System Tests] [REST/HTTP] Move some messaging tests.


Project: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/commit/31037b05
Tree: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/tree/31037b05
Diff: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/diff/31037b05

Branch: refs/heads/master
Commit: 31037b05974ee6354011b4cee361d8502af31029
Parents: 42c182f
Author: Keith Wall <kw...@apache.org>
Authored: Wed Feb 7 07:50:12 2018 +0000
Committer: Keith Wall <kw...@apache.org>
Committed: Thu Feb 8 15:01:34 2018 +0000

----------------------------------------------------------------------
 .../endtoend/message/MessageManagementTest.java | 245 +++++++
 .../http/endtoend/message/MessageTest.java      | 231 ++++++-
 .../qpid/systest/rest/MessagesRestTest.java     | 651 -------------------
 .../systest/rest/PublishMessageRestTest.java    | 236 -------
 test-profiles/Java10BrokenTestsExcludes         |   8 -
 5 files changed, 455 insertions(+), 916 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/31037b05/systests/qpid-systests-http-management/src/test/java/org/apache/qpid/tests/http/endtoend/message/MessageManagementTest.java
----------------------------------------------------------------------
diff --git 
a/systests/qpid-systests-http-management/src/test/java/org/apache/qpid/tests/http/endtoend/message/MessageManagementTest.java
 
b/systests/qpid-systests-http-management/src/test/java/org/apache/qpid/tests/http/endtoend/message/MessageManagementTest.java
new file mode 100644
index 0000000..ae992c5
--- /dev/null
+++ 
b/systests/qpid-systests-http-management/src/test/java/org/apache/qpid/tests/http/endtoend/message/MessageManagementTest.java
@@ -0,0 +1,245 @@
+/*
+ *
+ * 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.qpid.tests.http.endtoend.message;
+
+import static javax.servlet.http.HttpServletResponse.SC_OK;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.hasEntry;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.junit.Assert.assertThat;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import javax.servlet.http.HttpServletResponse;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import org.apache.qpid.tests.http.HttpRequestConfig;
+import org.apache.qpid.tests.http.HttpTestBase;
+
+@HttpRequestConfig
+public class MessageManagementTest extends HttpTestBase
+{
+    private static final String SOURCE_QUEUE_NAME = "sourceQueue";
+    private static final String DESTINATION_QUEUE_NAME = "destinationQueue";
+    private static final String INDEX = "index";
+    private Set<String> _messageIds;
+
+    @Before
+    public void setUp() throws Exception
+    {
+        getBrokerAdmin().createQueue(SOURCE_QUEUE_NAME);
+        getBrokerAdmin().createQueue(DESTINATION_QUEUE_NAME);
+
+        getHelper().setTls(true);
+
+        final Map<String, Object> odd = Collections.singletonMap(INDEX, 1);
+        final Map<String, Object> even = Collections.singletonMap(INDEX, 0);
+
+        _messageIds = 
Stream.generate(UUID::randomUUID).map(UUID::toString).limit(4).collect(Collectors.toSet());
+
+        int i = 0;
+        for (final String uuid : _messageIds)
+        {
+            publishMessage(SOURCE_QUEUE_NAME, uuid, i % 2 == 0 ? even : odd);
+            i++;
+        }
+    }
+
+    @Test
+    public void moveMessagesByInternalIdRange() throws Exception
+    {
+        final Set<Long> ids = new HashSet<>(getMesssageIds(SOURCE_QUEUE_NAME));
+
+        Iterator<Long> iterator = ids.iterator();
+        Set<Long> toMove = new HashSet<>();
+
+        toMove.add(iterator.next());
+        iterator.remove();
+
+        toMove.add(iterator.next());
+        iterator.remove();
+
+        Map<String, Object> parameters = new HashMap<>();
+        parameters.put("messageIds", toMove);
+        parameters.put("destination", DESTINATION_QUEUE_NAME);
+
+        getHelper().submitRequest(String.format("queue/%s/moveMessages", 
SOURCE_QUEUE_NAME),
+                                  "POST",
+                                  parameters,
+                                  HttpServletResponse.SC_OK);
+
+        Set<Long> destQueueContents = getMesssageIds(DESTINATION_QUEUE_NAME);
+        assertThat("Unexpected dest queue contents after move", 
destQueueContents, is(equalTo(toMove)));
+
+        Set<Long> sourceQueueContents = getMesssageIds(SOURCE_QUEUE_NAME);
+        assertThat("Unexpected source queue contents after move", 
sourceQueueContents, is(equalTo(ids)));
+    }
+
+    @Test
+    public void moveMessagesWithSelector() throws Exception
+    {
+        Map<String, Object> parameters = new HashMap<>();
+        parameters.put("selector", "index % 2 = 0");
+        parameters.put("destination", DESTINATION_QUEUE_NAME);
+
+        getHelper().submitRequest(String.format("queue/%s/moveMessages", 
SOURCE_QUEUE_NAME),
+                                  "POST",
+                                  parameters,
+                                  HttpServletResponse.SC_OK);
+
+        List<Map<String, Object>> destQueueMessages = 
getMessageDetails(DESTINATION_QUEUE_NAME);
+
+        for (Map<String, Object> message : destQueueMessages)
+        {
+            assertThat(message, is(notNullValue()));
+            @SuppressWarnings("unchecked") final Map<String, Object> headers =
+                    (Map<String, Object>) message.get("headers");
+            assertThat(headers, hasEntry(INDEX, 0));
+        }
+
+        List<Map<String, Object>> sourceQueueMessages = 
getMessageDetails(SOURCE_QUEUE_NAME);
+
+        for (Map<String, Object> message : sourceQueueMessages)
+        {
+            assertThat(message, is(notNullValue()));
+            @SuppressWarnings("unchecked")
+            final Map<String, Object> headers = (Map<String, Object>) 
message.get("headers");
+            assertThat(headers, hasEntry(INDEX, 1));
+        }
+    }
+
+    @Test
+    public void copyAllMessages() throws Exception
+    {
+        final int sourceQueueDepthMessagesBefore = 
getBrokerAdmin().getQueueDepthMessages(SOURCE_QUEUE_NAME);
+        assertThat(sourceQueueDepthMessagesBefore, 
is(equalTo(_messageIds.size())));
+
+        Map<String, Object> parameters = new HashMap<>();
+        parameters.put("destination", DESTINATION_QUEUE_NAME);
+
+        getHelper().submitRequest(String.format("queue/%s/copyMessages", 
SOURCE_QUEUE_NAME),
+                                  "POST",
+                                  parameters,
+                                  HttpServletResponse.SC_OK);
+
+        final int sourceQueueDepthMessagesAfter = 
getBrokerAdmin().getQueueDepthMessages(SOURCE_QUEUE_NAME);
+        final int destQueueDepthMessagesAfter = 
getBrokerAdmin().getQueueDepthMessages(DESTINATION_QUEUE_NAME);
+        assertThat(sourceQueueDepthMessagesAfter, 
is(equalTo(sourceQueueDepthMessagesBefore)));
+        assertThat(destQueueDepthMessagesAfter, 
is(equalTo(sourceQueueDepthMessagesBefore)));
+    }
+
+    @Test
+    public void deleteMessagesByInternalId() throws Exception
+    {
+        final Set<Long> ids = new HashSet<>(getMesssageIds(SOURCE_QUEUE_NAME));
+        Iterator<Long> iterator = ids.iterator();
+        Set<Long> toDelete = Collections.singleton(iterator.next());
+        iterator.remove();
+
+        Map<String, Object> parameters = new HashMap<>();
+        parameters.put("messageIds", toDelete);
+        getHelper().submitRequest(String.format("queue/%s/deleteMessages", 
SOURCE_QUEUE_NAME),
+                                  "POST",
+                                  parameters,
+                                  HttpServletResponse.SC_OK);
+
+        Set<Long> remainIds = getMesssageIds(SOURCE_QUEUE_NAME);
+        assertThat("Unexpected queue contents after delete", remainIds, 
is(equalTo(ids)));
+    }
+
+    @Test
+    public void testDeleteMessagesWithLimit() throws Exception
+    {
+        final int totalMessage = _messageIds.size();
+        final int numberToMove = totalMessage / 2;
+        final int remainingMessages = totalMessage - numberToMove;
+
+        // delete messages
+        Map<String, Object> parameters = new HashMap<>();
+        parameters.put("limit", numberToMove);
+
+        getHelper().submitRequest(String.format("queue/%s/deleteMessages", 
SOURCE_QUEUE_NAME),
+                                  "POST",
+                                  parameters,
+                                  HttpServletResponse.SC_OK);
+
+        assertThat(getBrokerAdmin().getQueueDepthMessages(SOURCE_QUEUE_NAME), 
is(equalTo(remainingMessages)));
+    }
+
+    @Test
+    public void testClearQueue() throws Exception
+    {
+        getHelper().submitRequest(String.format("queue/%s/clearQueue", 
SOURCE_QUEUE_NAME), "POST",
+                                  Collections.emptyMap(), 
HttpServletResponse.SC_OK);
+
+        assertThat(getBrokerAdmin().getQueueDepthMessages(SOURCE_QUEUE_NAME), 
is(equalTo(0)));
+    }
+
+
+    private List<Map<String, Object>> getMessageDetails(final String 
queueName) throws IOException
+    {
+        List<Map<String, Object>> destQueueMessages =
+                
getHelper().getJsonAsList(String.format("queue/%s/getMessageInfo?includeHeaders=true",
+                                                        queueName));
+        assertThat(destQueueMessages, is(notNullValue()));
+        return destQueueMessages;
+    }
+
+    private Set<Long> getMesssageIds(final String queueName) throws IOException
+    {
+        List<Map<String, Object>> messages =
+                
getHelper().getJsonAsList(String.format("queue/%s/getMessageInfo", queueName));
+        Set<Long> ids = new HashSet<>();
+        for (Map<String, Object> message : messages)
+        {
+            ids.add(((Number) message.get("id")).longValue());
+        }
+        return ids;
+    }
+
+    private void publishMessage(final String queueName, final String 
messageId, final Map<String, Object> headers) throws Exception
+    {
+        Map<String, Object> messageBody = new HashMap<>();
+        messageBody.put("address", queueName);
+        messageBody.put("messageId", messageId);
+        messageBody.put("headers", headers);
+
+        getHelper().submitRequest("virtualhost/publishMessage",
+                                  "POST",
+                                  Collections.singletonMap("message", 
messageBody),
+                                  SC_OK);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/31037b05/systests/qpid-systests-http-management/src/test/java/org/apache/qpid/tests/http/endtoend/message/MessageTest.java
----------------------------------------------------------------------
diff --git 
a/systests/qpid-systests-http-management/src/test/java/org/apache/qpid/tests/http/endtoend/message/MessageTest.java
 
b/systests/qpid-systests-http-management/src/test/java/org/apache/qpid/tests/http/endtoend/message/MessageTest.java
index cb92341..30e6a2f 100644
--- 
a/systests/qpid-systests-http-management/src/test/java/org/apache/qpid/tests/http/endtoend/message/MessageTest.java
+++ 
b/systests/qpid-systests-http-management/src/test/java/org/apache/qpid/tests/http/endtoend/message/MessageTest.java
@@ -23,30 +23,41 @@ package org.apache.qpid.tests.http.endtoend.message;
 
 import static javax.servlet.http.HttpServletResponse.SC_OK;
 import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.greaterThanOrEqualTo;
 import static org.hamcrest.Matchers.is;
 import static org.hamcrest.Matchers.not;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.hamcrest.Matchers.nullValue;
+import static org.hamcrest.Matchers.typeCompatibleWith;
 import static org.junit.Assert.assertThat;
 import static org.junit.Assume.assumeThat;
 
 import java.io.InputStream;
 import java.net.HttpURLConnection;
+import java.util.ArrayList;
 import java.util.Collections;
+import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.UUID;
+import java.util.concurrent.TimeUnit;
 import java.util.stream.IntStream;
 
 import javax.jms.BytesMessage;
 import javax.jms.Connection;
 import javax.jms.MapMessage;
 import javax.jms.Message;
+import javax.jms.MessageConsumer;
 import javax.jms.MessageProducer;
+import javax.jms.Queue;
 import javax.jms.Session;
 import javax.jms.StreamMessage;
+import javax.jms.TextMessage;
 
 import com.fasterxml.jackson.core.type.TypeReference;
+import com.google.common.base.Strings;
 import com.google.common.io.ByteStreams;
-import org.hamcrest.CoreMatchers;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -57,26 +68,30 @@ import org.apache.qpid.tests.http.HttpTestBase;
 @HttpRequestConfig
 public class MessageTest extends HttpTestBase
 {
-
     private static final String QUEUE_NAME = "myqueue";
     private static final TypeReference<List<Map<String, Object>>> 
LIST_MAP_TYPE_REF =
-            new TypeReference<List<Map<String, Object>>>() {};
+            new TypeReference<List<Map<String, Object>>>()
+            {
+            };
     private static final TypeReference<Map<String, Object>> MAP_TYPE_REF =
-            new TypeReference<Map<String, Object>>() {};
+            new TypeReference<Map<String, Object>>()
+            {
+            };
     private static final TypeReference<List<Object>> LIST_TYPE_REF =
-            new TypeReference<List<Object>>() {};
+            new TypeReference<List<Object>>()
+            {
+            };
 
     @Before
     public void setUp()
     {
         getBrokerAdmin().createQueue(QUEUE_NAME);
+        getHelper().setTls(true);
     }
 
     @Test
     public void getJmsMessage() throws Exception
     {
-        getHelper().setTls(true);
-
         final String messageProperty = "myProp";
         final String messagePropertyValue = "myValue";
 
@@ -95,7 +110,8 @@ public class MessageTest extends HttpTestBase
         }
 
         List<Map<String, Object>> messages = 
getHelper().postJson("queue/myqueue/getMessageInfo",
-                                                                  
Collections.singletonMap("includeHeaders", Boolean.TRUE),
+                                                                  
Collections.singletonMap("includeHeaders",
+                                                                               
            Boolean.TRUE),
                                                                   
LIST_MAP_TYPE_REF, SC_OK);
         assertThat(messages.size(), is(equalTo(1)));
 
@@ -108,7 +124,6 @@ public class MessageTest extends HttpTestBase
     @Test
     public void getJmsMapMessage() throws Exception
     {
-        getHelper().setTls(true);
         final String mapKey = "key";
         final String mapKeyValue = "value";
 
@@ -127,7 +142,8 @@ public class MessageTest extends HttpTestBase
         }
 
         List<Map<String, Object>> messages = 
getHelper().postJson("queue/myqueue/getMessageInfo",
-                                                                  
Collections.singletonMap("includeHeaders", Boolean.TRUE),
+                                                                  
Collections.singletonMap("includeHeaders",
+                                                                               
            Boolean.TRUE),
                                                                   
LIST_MAP_TYPE_REF, SC_OK);
         assertThat(messages.size(), is(equalTo(1)));
         Map<String, Object> message = messages.get(0);
@@ -138,8 +154,8 @@ public class MessageTest extends HttpTestBase
         contentParams.put("returnJson", Boolean.TRUE);
 
         Map<String, Object> content = 
getHelper().postJson("queue/myqueue/getMessageContent",
-                                                                  
contentParams,
-                                                                  
MAP_TYPE_REF, SC_OK);
+                                                           contentParams,
+                                                           MAP_TYPE_REF, 
SC_OK);
         assertThat(content.size(), is(equalTo(1)));
         assertThat(content.get(mapKey), is(equalTo(mapKeyValue)));
     }
@@ -147,8 +163,6 @@ public class MessageTest extends HttpTestBase
     @Test
     public void getJmsStreamMessage() throws Exception
     {
-        getHelper().setTls(true);
-
         Connection connection = getConnection();
         try
         {
@@ -166,7 +180,8 @@ public class MessageTest extends HttpTestBase
         }
 
         List<Map<String, Object>> messages = 
getHelper().postJson("queue/myqueue/getMessageInfo",
-                                                                  
Collections.singletonMap("includeHeaders", Boolean.TRUE),
+                                                                  
Collections.singletonMap("includeHeaders",
+                                                                               
            Boolean.TRUE),
                                                                   
LIST_MAP_TYPE_REF, SC_OK);
         assertThat(messages.size(), is(equalTo(1)));
         Map<String, Object> message = messages.get(0);
@@ -177,8 +192,8 @@ public class MessageTest extends HttpTestBase
         contentParams.put("returnJson", Boolean.TRUE);
 
         List<Object> content = 
getHelper().postJson("queue/myqueue/getMessageContent",
-                                                                  
contentParams,
-                                                                  
LIST_TYPE_REF, SC_OK);
+                                                    contentParams,
+                                                    LIST_TYPE_REF, SC_OK);
         assertThat(content.size(), is(equalTo(3)));
         assertThat(content.get(0), is(equalTo(Long.MAX_VALUE)));
         assertThat(content.get(1), is(equalTo(Boolean.TRUE)));
@@ -188,8 +203,6 @@ public class MessageTest extends HttpTestBase
     @Test
     public void getJmsBytesMessage() throws Exception
     {
-        getHelper().setTls(true);
-
         final byte[] content = new byte[512];
         IntStream.range(0, content.length).forEachOrdered(i -> content[i] = 
(byte) (i % 256));
 
@@ -208,7 +221,8 @@ public class MessageTest extends HttpTestBase
         }
 
         List<Map<String, Object>> messages = 
getHelper().postJson("queue/myqueue/getMessageInfo",
-                                                                  
Collections.singletonMap("includeHeaders", Boolean.TRUE),
+                                                                  
Collections.singletonMap("includeHeaders",
+                                                                               
            Boolean.TRUE),
                                                                   
LIST_MAP_TYPE_REF, SC_OK);
         assertThat(messages.size(), is(equalTo(1)));
         Map<String, Object> message = messages.get(0);
@@ -219,7 +233,7 @@ public class MessageTest extends HttpTestBase
         httpCon.connect();
 
         byte[] receivedContent;
-        try(InputStream is = httpCon.getInputStream())
+        try (InputStream is = httpCon.getInputStream())
         {
             receivedContent = ByteStreams.toByteArray(is);
         }
@@ -230,5 +244,180 @@ public class MessageTest extends HttpTestBase
         assertThat(receivedContent, is(equalTo(content)));
     }
 
+    @Test
+    public void publishEmptyMessage() throws Exception
+    {
+        Map<String, Object> messageBody = new HashMap<>();
+        messageBody.put("address", QUEUE_NAME);
+
+        getHelper().submitRequest("virtualhost/publishMessage",
+                                  "POST",
+                                  Collections.singletonMap("message", 
messageBody),
+                                  SC_OK);
+
+        Connection connection = getConnection();
+        try
+        {
+            connection.start();
+            Session session = connection.createSession(false, 
Session.AUTO_ACKNOWLEDGE);
+            Queue queue = session.createQueue(QUEUE_NAME);
+            MessageConsumer consumer = session.createConsumer(queue);
+            Message message = consumer.receive(getReceiveTimeout());
+            assertThat(message, is(notNullValue()));
+        }
+        finally
+        {
+            connection.close();
+        }
+    }
+
+    @Test
+    public void publishMessageApplicationHeaders() throws Exception
+    {
+        final String stringPropValue = "mystring";
+        final String longStringPropValue = Strings.repeat("*", 256);
+        final Map<String, Object> headers = new HashMap<>();
+        headers.put("stringprop", stringPropValue);
+        headers.put("longstringprop", longStringPropValue);
+        headers.put("intprop", Integer.MIN_VALUE);
+        headers.put("longprop", Long.MAX_VALUE);
+        headers.put("boolprop", Boolean.TRUE);
+
+        final Map<String, Object> messageBody = new HashMap<>();
+        messageBody.put("address", QUEUE_NAME);
+        messageBody.put("headers", headers);
+
+        getHelper().submitRequest("virtualhost/publishMessage",
+                                  "POST",
+                                  Collections.singletonMap("message", 
messageBody),
+                                  SC_OK);
+
+        Connection connection = getConnection();
+        try
+        {
+            connection.start();
+            Session session = connection.createSession(false, 
Session.AUTO_ACKNOWLEDGE);
+            Queue queue = session.createQueue(QUEUE_NAME);
+            MessageConsumer consumer = session.createConsumer(queue);
+            Message message = consumer.receive(getReceiveTimeout());
+            assertThat(message, is(notNullValue()));
+            assertThat(message.getStringProperty("stringprop"), 
is(equalTo(stringPropValue)));
+            assertThat(message.getIntProperty("intprop"), 
is(equalTo(Integer.MIN_VALUE)));
+            assertThat(message.getLongProperty("longprop"), 
is(equalTo(Long.MAX_VALUE)));
+            assertThat(message.getBooleanProperty("boolprop"), 
is(equalTo(Boolean.TRUE)));
+        }
+        finally
+        {
+            connection.close();
+        }
+    }
+
+    @Test
+    public void publishMessageHeaders() throws Exception
+    {
+        final String messageId = "ID:" + UUID.randomUUID().toString();
+        final long expiration = TimeUnit.DAYS.toMillis(1) + 
System.currentTimeMillis();
+
+        Map<String, Object> messageBody = new HashMap<>();
+        messageBody.put("address", QUEUE_NAME);
+        messageBody.put("messageId", messageId);
+        messageBody.put("expiration", expiration);
+
+        getHelper().submitRequest("virtualhost/publishMessage",
+                                  "POST",
+                                  Collections.singletonMap("message", 
messageBody),
+                                  SC_OK);
+
+        Connection connection = getConnection();
+        try
+        {
+            connection.start();
+            Session session = connection.createSession(false, 
Session.AUTO_ACKNOWLEDGE);
+            Queue queue = session.createQueue(QUEUE_NAME);
+            MessageConsumer consumer = session.createConsumer(queue);
+            Message message = consumer.receive(getReceiveTimeout());
+            assertThat(message, is(notNullValue()));
+            assertThat(message.getJMSMessageID(), is(equalTo(messageId)));
+            assertThat(message.getJMSExpiration(), 
is(greaterThanOrEqualTo(expiration)));
+        }
+        finally
+        {
+            connection.close();
+        }
+    }
+
+    @Test
+    public void publishStringMessage() throws Exception
+    {
+        final String content = "Hello world";
+        TextMessage message = publishMessageWithContent(content, 
TextMessage.class);
+        assertThat("Unexpected message content", message.getText(), 
is(equalTo(content)));
+    }
+
+    @Test
+    public void publishMapMessage() throws Exception
+    {
+        final Map<String, Object> content = new HashMap<>();
+        content.put("key1", "astring");
+        content.put("key2", Integer.MIN_VALUE);
+        content.put("key3", Long.MAX_VALUE);
+        content.put("key4", null);
+        MapMessage message = publishMessageWithContent(content, 
MapMessage.class);
+        final Enumeration mapNames = message.getMapNames();
+        int entryCount = 0;
+        while(mapNames.hasMoreElements())
+        {
+            String key = (String) mapNames.nextElement();
+            assertThat("Unexpected map content for key : " + key, 
message.getObject(key), is(equalTo(content.get(key))));
+            entryCount++;
+        }
+        assertThat("Unexpected number of key/value pairs in map message", 
entryCount, is(equalTo(content.size())));
+    }
+
+    @Test
+    public void publishListMessage() throws Exception
+    {
+        final List<Object> content = new ArrayList<>();
+        content.add("astring");
+        content.add(Integer.MIN_VALUE);
+        content.add(Long.MAX_VALUE);
+        content.add(null);
+        StreamMessage message = publishMessageWithContent(content, 
StreamMessage.class);
+        assertThat(message.readString(), is(equalTo("astring")));
+        assertThat(message.readInt(), is(equalTo((Integer.MIN_VALUE))));
+        assertThat(message.readLong(), is(equalTo(Long.MAX_VALUE)));
+        assertThat(message.readObject(), is(nullValue()));
+    }
+
+    private <M extends Message> M publishMessageWithContent(final Object 
content, final Class<M> expectedMessageClass)
+            throws Exception
+    {
+        Map<String, Object> messageBody = new HashMap<>();
+        messageBody.put("address", QUEUE_NAME);
+        messageBody.put("content", content);
+
+        getHelper().submitRequest("virtualhost/publishMessage",
+                                  "POST",
+                                  Collections.singletonMap("message", 
messageBody),
+                                  SC_OK);
 
+        Connection connection = getConnection();
+        try
+        {
+            connection.start();
+            Session session = connection.createSession(false, 
Session.AUTO_ACKNOWLEDGE);
+            Queue queue = session.createQueue(QUEUE_NAME);
+            MessageConsumer consumer = session.createConsumer(queue);
+
+            @SuppressWarnings("unchecked")
+            M message = (M) consumer.receive(getReceiveTimeout());
+            assertThat(message, is(notNullValue()));
+            assertThat(message.getClass(), 
is(typeCompatibleWith(expectedMessageClass)));
+            return message;
+        }
+        finally
+        {
+            connection.close();
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/31037b05/systests/src/test/java/org/apache/qpid/systest/rest/MessagesRestTest.java
----------------------------------------------------------------------
diff --git 
a/systests/src/test/java/org/apache/qpid/systest/rest/MessagesRestTest.java 
b/systests/src/test/java/org/apache/qpid/systest/rest/MessagesRestTest.java
deleted file mode 100644
index 1db8e30..0000000
--- a/systests/src/test/java/org/apache/qpid/systest/rest/MessagesRestTest.java
+++ /dev/null
@@ -1,651 +0,0 @@
-/*
- *
- * 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.qpid.systest.rest;
-
-import java.io.IOException;
-import java.nio.charset.StandardCharsets;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.TimeUnit;
-
-import javax.jms.BytesMessage;
-import javax.jms.Connection;
-import javax.jms.DeliveryMode;
-import javax.jms.Destination;
-import javax.jms.MapMessage;
-import javax.jms.Message;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.jms.StreamMessage;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.qpid.server.model.Port;
-import org.apache.qpid.test.utils.TestBrokerConfiguration;
-
-public class MessagesRestTest extends QpidRestTestCase
-{
-
-    /**
-     * Message number to publish into queue
-     */
-    private static final int MESSAGE_NUMBER = 12;
-    private static final String STRING_PROP = "shortstring";
-    // Dollar Pound Euro: 1 byte, 2 byte, and 3 byte UTF-8 encodings 
respectively
-    private static final String STRING_VALUE = "\u0024 \u00A3 \u20AC";
-    private static final String GET_MESSAGE_CONTENT_BY_ID =
-            "queue/test/test/%s/getMessageContent?returnJson=%s&messageId=%d";
-    private static final String GET_MESSAGE_INFO_BY_ID = 
"queue/test/test/%s/getMessageInfoById?messageId=%d";
-    private static final String GET_MESSAGE_INFO = 
"queue/test/test/%s/getMessageInfo";
-
-    private Connection _connection;
-    private Session _session;
-    private MessageProducer _producer;
-    private long _startTime;
-    private long _ttl;
-
-    @Override
-    public void setUp() throws Exception
-    {
-        super.setUp();
-        _startTime = System.currentTimeMillis();
-        _connection = getConnection();
-        _session = _connection.createSession(true, Session.SESSION_TRANSACTED);
-        Destination queue = createTestQueue(_session);
-        _session.commit();
-        _producer = _session.createProducer(queue);
-
-        _ttl = TimeUnit.DAYS.toMillis(1);
-        for (int i = 0; i < MESSAGE_NUMBER; i++)
-        {
-            Message m = _session.createTextMessage("Test-" + i);
-            m.setIntProperty("index", i);
-            if (i % 2 == 0)
-            {
-                _producer.send(m);
-            }
-            else
-            {
-                _producer.send(m, DeliveryMode.NON_PERSISTENT, 5, _ttl);
-            }
-        }
-        _session.commit();
-    }
-
-    @Override
-    protected void customizeConfiguration() throws Exception
-    {
-        super.customizeConfiguration();
-        // Allow retrieval of message information on an insecure (non-tls) 
connection
-        getDefaultBrokerConfiguration().setObjectAttribute(Port.class, 
TestBrokerConfiguration.ENTRY_NAME_HTTP_PORT,
-                                                           
Port.ALLOW_CONFIDENTIAL_OPERATIONS_ON_INSECURE_CHANNELS,
-                                                           true);
-    }
-
-    public void testGet() throws Exception
-    {
-        String queueName = getTestQueueName();
-        List<Map<String, Object>> messages =
-                
getRestTestHelper().getJsonAsList(String.format(GET_MESSAGE_INFO, queueName));
-        assertNotNull("Messages are not found", messages);
-        assertEquals("Unexpected number of messages", MESSAGE_NUMBER, 
messages.size());
-        int position = 0;
-        for (Map<String, Object> message : messages)
-        {
-            assertMessage(position, message);
-            position++;
-        }
-    }
-
-    public void testGetMessageContent() throws Exception
-    {
-        String queueName = getTestQueueName();
-
-        // add bytes message
-        Message textMessage = _session.createTextMessage(STRING_VALUE);
-        textMessage.setStringProperty(STRING_PROP, STRING_VALUE);
-        _producer.send(textMessage);
-        _session.commit();
-
-        final Map<String, Object> messageSummary = getLastMessage(queueName);
-        int lastMessageId = (int) messageSummary.get("id");
-        assertMessageAttributes(messageSummary);
-        assertEquals("Unexpected mimeType", isBroker10() ? null : 
"text/plain", messageSummary.get("mimeType"));
-
-        Map<String, Object> message = 
getRestTestHelper().getJsonAsMap(String.format(GET_MESSAGE_INFO_BY_ID,
-                                                                               
      queueName,
-                                                                               
      lastMessageId));
-        @SuppressWarnings("unchecked")
-        Map<String, Object> messageHeader = (Map<String, Object>) 
message.get("headers");
-        assertNotNull("Message headers are not found", messageHeader);
-        assertEquals("Unexpected message header value", STRING_VALUE, 
messageHeader.get(STRING_PROP));
-
-        // get content
-        byte[] data = 
getRestTestHelper().getBytes(String.format(GET_MESSAGE_CONTENT_BY_ID,
-                                                                 queueName,
-                                                                 false,
-                                                                 
lastMessageId));
-        assertTrue("Unexpected message for id " + lastMessageId + ":" + 
data.length,
-                   isBroker10() || 
Arrays.equals(STRING_VALUE.getBytes(StandardCharsets.UTF_8), data));
-    }
-
-    public void testGetMapMessageContentAsJson() throws Exception
-    {
-        String queueName = getTestQueueName();
-        MapMessage mapMessage = _session.createMapMessage();
-        mapMessage.setString("testStringProperty", "My String");
-        mapMessage.setInt("testIntProperty", 999999);
-        _producer.send(mapMessage);
-        _session.commit();
-
-        final Map<String, Object> message = getLastMessage(queueName);
-        int lastMessageId = (int) message.get("id");
-        assertMessageAttributes(message);
-        assertEquals("Unexpected mimeType", isBroker10() ? null : "amqp/map", 
message.get("mimeType"));
-
-        Map<String, Object> jsonMessageData = 
getRestTestHelper().getJsonAsMap(String.format(
-                GET_MESSAGE_CONTENT_BY_ID,
-                queueName,
-                true,
-                lastMessageId));
-        assertEquals("Unexpected map content size", 2, jsonMessageData.size());
-        assertEquals("Unexpected testStringProperty", "My String", 
jsonMessageData.get("testStringProperty"));
-        assertEquals("Unexpected testIntProperty", 999999, 
jsonMessageData.get("testIntProperty"));
-    }
-
-    public void testGetStreamMessageContentAsJson() throws Exception
-    {
-        String queueName = getTestQueueName();
-        StreamMessage streamMessage = _session.createStreamMessage();
-        streamMessage.writeLong(Long.MAX_VALUE);
-        streamMessage.writeBoolean(true);
-        streamMessage.writeString("Hello world");
-        _producer.send(streamMessage);
-        _session.commit();
-
-        final Map<String, Object> message = getLastMessage(queueName);
-        int lastMessageId = (int) message.get("id");
-        assertMessageAttributes(message);
-        assertEquals("Unexpected mimeType", isBroker10() ? null : 
"jms/stream-message", message.get("mimeType"));
-
-        List<Object> jsonMessageData = 
getRestTestHelper().getJsonAsSimpleList(String.format(
-                GET_MESSAGE_CONTENT_BY_ID,
-                queueName,
-                true,
-                lastMessageId));
-        assertEquals("Unexpected list content size", 3, 
jsonMessageData.size());
-        assertEquals("Unexpected value at index 0", Long.MAX_VALUE, 
jsonMessageData.get(0));
-        assertEquals("Unexpected value at index 1", true, 
jsonMessageData.get(1));
-        assertEquals("Unexpected value at index 2", "Hello world", 
jsonMessageData.get(2));
-    }
-
-    public void testGetBytesMessageContentAsJson() throws Exception
-    {
-        String queueName = getTestQueueName();
-        BytesMessage bytesMessage = _session.createBytesMessage();
-        final byte[] payloadBytes = {1, 2, 3, 4};
-        bytesMessage.writeBytes(payloadBytes);
-        _producer.send(bytesMessage);
-        _session.commit();
-
-        final Map<String, Object> message = getLastMessage(queueName);
-        int lastMessageId = (int) message.get("id");
-        assertMessageAttributes(message);
-        assertEquals("Unexpected mimeType", "application/octet-stream", 
message.get("mimeType"));
-
-        List<Object> jsonMessageData = 
getRestTestHelper().getJsonAsSimpleList(String.format(
-                GET_MESSAGE_CONTENT_BY_ID,
-                queueName,
-                true,
-                lastMessageId));
-        assertEquals("Unexpected list content size", payloadBytes.length, 
jsonMessageData.size());
-        for(int i = 0; i < payloadBytes.length; i++)
-        {
-            assertEquals("Unexpected value at index " + i, 
((Number)payloadBytes[i]).intValue(), jsonMessageData.get(i));
-        }
-    }
-
-    public void testGetListMessageContentAsJson() throws Exception
-    {
-        String queueName = getTestQueueName();
-        StreamMessage listMessage = _session.createStreamMessage();
-        listMessage.writeInt(999999);
-        listMessage.writeString("My String");
-        _producer.send(listMessage);
-        _session.commit();
-
-        final Map<String, Object> message = getLastMessage(queueName);
-        int lastMessageId = (int) message.get("id");
-        assertMessageAttributes(message);
-        assertEquals("Unexpected mimeType", isBroker10() ? null : 
"jms/stream-message", message.get("mimeType"));
-
-        List<Object> jsonMessageData = 
getRestTestHelper().getJsonAsSimpleList(String.format(
-                GET_MESSAGE_CONTENT_BY_ID,
-                queueName,
-                true,
-                lastMessageId));
-        assertEquals("Unexpected list size", 2, jsonMessageData.size());
-        assertEquals("Unexpected value at index 0", 999999, 
jsonMessageData.get(0));
-        assertEquals("Unexpected value at index 1", "My String", 
jsonMessageData.get(1));
-    }
-
-    public void testPostMoveMessages() throws Exception
-    {
-        String queueName = getTestQueueName();
-        String queueName2 = queueName + "_2";
-        Destination queue2 = createTestQueue(_session, queueName2);
-        _session.commit();
-
-        // get message IDs
-        List<Long> ids = getMesssageIds(queueName);
-
-        // move half of the messages
-        int movedNumber = ids.size() / 2;
-        List<Long> movedMessageIds = new ArrayList<>();
-        for (int i = 0; i < movedNumber; i++)
-        {
-            movedMessageIds.add(ids.remove(i));
-        }
-
-        // move messages
-
-        Map<String, Object> messagesData = new HashMap<>();
-        messagesData.put("messageIds", movedMessageIds);
-        messagesData.put("destination", queueName2);
-
-        getRestTestHelper().submitRequest("queue/test/test/" + queueName + 
"/moveMessages",
-                                          "POST",
-                                          messagesData,
-                                          HttpServletResponse.SC_OK);
-
-        // check messages on target queue
-        List<Map<String, Object>> messages =
-                
getRestTestHelper().getJsonAsList(String.format(GET_MESSAGE_INFO, queueName2));
-        assertNotNull("Messages are not found", messages);
-        assertEquals("Unexpected number of messages", movedMessageIds.size(), 
messages.size());
-        for (Long id : movedMessageIds)
-        {
-            Map<String, Object> message = getRestTestHelper().find("id", 
id.intValue(), messages);
-            assertMessageAttributes(message);
-        }
-
-        // check messages on original queue
-        messages = 
getRestTestHelper().getJsonAsList(String.format(GET_MESSAGE_INFO, queueName));
-        assertNotNull("Messages are not found", messages);
-        assertEquals("Unexpected number of messages", ids.size(), 
messages.size());
-        for (Long id : ids)
-        {
-            Map<String, Object> message = getRestTestHelper().find("id", 
id.intValue(), messages);
-            assertMessageAttributes(message);
-        }
-        for (Long id : movedMessageIds)
-        {
-            Map<String, Object> message = getRestTestHelper().find("id", 
id.intValue(), messages);
-            assertNull("Moved message " + id + " is found on original queue", 
message);
-        }
-    }
-
-    public void testPostMoveMessagesWithSelector() throws Exception
-    {
-        String queueName = getTestQueueName();
-        String queueName2 = queueName + "_2";
-        createTestQueue(_session, queueName2);
-        _session.commit();
-        // move messages
-
-        Map<String, Object> messagesData = new HashMap<>();
-        messagesData.put("selector", "index % 2 = 0");
-        messagesData.put("destination", queueName2);
-
-        getRestTestHelper().submitRequest("queue/test/test/" + queueName + 
"/moveMessages",
-                                          "POST",
-                                          messagesData,
-                                          HttpServletResponse.SC_OK);
-
-        // check messages on target queue
-        List<Map<String, Object>> messages =
-                
getRestTestHelper().getJsonAsList(String.format(GET_MESSAGE_INFO, queueName2));
-        assertNotNull("Messages are not found", messages);
-        assertEquals("Unexpected number of messages", MESSAGE_NUMBER / 2, 
messages.size());
-        final List<Long> movedMessageIds = getMesssageIds(queueName2);
-        for (Long id : movedMessageIds)
-        {
-            Map<String, Object> message = getRestTestHelper().find("id", 
id.intValue(), messages);
-            assertMessageAttributes(message);
-            assertMessageAttributeValues(message, true);
-        }
-
-        // check messages on original queue
-        messages = 
getRestTestHelper().getJsonAsList(String.format(GET_MESSAGE_INFO, queueName));
-        assertNotNull("Messages are not found", messages);
-        assertEquals("Unexpected number of messages", MESSAGE_NUMBER / 2, 
messages.size());
-
-        for (Long id : getMesssageIds(queueName))
-        {
-            Map<String, Object> message = getRestTestHelper().find("id", 
id.intValue(), messages);
-            assertMessageAttributes(message);
-            assertMessageAttributeValues(message, false);
-        }
-        for (Long id : movedMessageIds)
-        {
-            Map<String, Object> message = getRestTestHelper().find("id", 
id.intValue(), messages);
-            assertNull("Moved message " + id + " is found on original queue", 
message);
-        }
-    }
-
-
-    public void testPostMoveAllMessages() throws Exception
-    {
-        String queueName = getTestQueueName();
-        String queueName2 = queueName + "_2";
-        createTestQueue(_session, queueName2);
-        _session.commit();
-
-        // move messages
-
-        Map<String, Object> messagesData = new HashMap<>();
-        messagesData.put("destination", queueName2);
-
-        getRestTestHelper().submitRequest("queue/test/test/" + queueName + 
"/moveMessages",
-                                          "POST",
-                                          messagesData,
-                                          HttpServletResponse.SC_OK);
-
-        // check messages on target queue
-        List<Map<String, Object>> messages =
-                
getRestTestHelper().getJsonAsList(String.format(GET_MESSAGE_INFO, queueName2));
-        assertNotNull("Messages are not found", messages);
-        assertEquals("Unexpected number of messages", MESSAGE_NUMBER, 
messages.size());
-        final List<Long> movedMessageIds = getMesssageIds(queueName2);
-        for (Long id : movedMessageIds)
-        {
-            Map<String, Object> message = getRestTestHelper().find("id", 
id.intValue(), messages);
-            assertMessageAttributes(message);
-        }
-
-        // check messages on original queue
-        messages = 
getRestTestHelper().getJsonAsList(String.format(GET_MESSAGE_INFO, queueName));
-        assertNotNull("Messages are not found", messages);
-        assertEquals("Unexpected number of messages", 0, messages.size());
-    }
-
-
-    public void testPostCopyMessages() throws Exception
-    {
-        String queueName = getTestQueueName();
-        String queueName2 = queueName + "_2";
-        Destination queue2 = createTestQueue(_session, queueName2);
-        _session.commit();
-        // get message IDs
-        List<Long> ids = getMesssageIds(queueName);
-
-        // copy half of the messages
-        int copyNumber = ids.size() / 2;
-        List<Long> copyMessageIds = new ArrayList<>();
-        for (int i = 0; i < copyNumber; i++)
-        {
-            copyMessageIds.add(ids.remove(i));
-        }
-
-        // copy messages
-        Map<String, Object> messagesData = new HashMap<>();
-        messagesData.put("messageIds", copyMessageIds);
-        messagesData.put("destination", queueName2);
-
-        getRestTestHelper().submitRequest("queue/test/test/" + queueName + 
"/copyMessages",
-                                          "POST",
-                                          messagesData,
-                                          HttpServletResponse.SC_OK);
-
-        // check messages on target queue
-        List<Map<String, Object>> messages =
-                
getRestTestHelper().getJsonAsList(String.format(GET_MESSAGE_INFO, queueName2));
-        assertNotNull("Messages are not found", messages);
-        assertEquals("Unexpected number of messages", copyMessageIds.size(), 
messages.size());
-        for (Long id : copyMessageIds)
-        {
-            Map<String, Object> message = getRestTestHelper().find("id", 
id.intValue(), messages);
-            assertMessageAttributes(message);
-        }
-
-        // check messages on original queue
-        messages = 
getRestTestHelper().getJsonAsList(String.format(GET_MESSAGE_INFO, queueName));
-        assertNotNull("Messages are not found", messages);
-        assertEquals("Unexpected number of messages", MESSAGE_NUMBER, 
messages.size());
-        for (Long id : ids)
-        {
-            Map<String, Object> message = getRestTestHelper().find("id", 
id.intValue(), messages);
-            assertMessageAttributes(message);
-        }
-        for (Long id : copyMessageIds)
-        {
-            Map<String, Object> message = getRestTestHelper().find("id", 
id.intValue(), messages);
-            assertMessageAttributes(message);
-        }
-    }
-
-    public void testPostCopyMessagesWithSelectorAndLimit() throws Exception
-    {
-        String queueName = getTestQueueName();
-        String queueName2 = queueName + "_2";
-        Destination queue2 = createTestQueue(_session, queueName2);
-        _session.commit();
-
-        // copy messages
-        Map<String, Object> messagesData = new HashMap<>();
-        messagesData.put("selector", "index % 2 = 0");
-        messagesData.put("limit", 1);
-        messagesData.put("destination", queueName2);
-
-        getRestTestHelper().submitRequest("queue/test/test/" + queueName + 
"/copyMessages",
-                                          "POST",
-                                          messagesData,
-                                          HttpServletResponse.SC_OK);
-
-        // check messages on target queue
-        List<Map<String, Object>> messages =
-                
getRestTestHelper().getJsonAsList(String.format(GET_MESSAGE_INFO, queueName2));
-        assertNotNull("Messages are not found", messages);
-        assertEquals("Unexpected number of messages", 1, messages.size());
-        for (Long id : getMesssageIds(queueName2))
-        {
-            Map<String, Object> message = getRestTestHelper().find("id", 
id.intValue(), messages);
-            assertMessageAttributes(message);
-            assertMessageAttributeValues(message, true);
-        }
-
-        // check messages on original queue
-        messages = 
getRestTestHelper().getJsonAsList(String.format(GET_MESSAGE_INFO, queueName));
-        assertNotNull("Messages are not found", messages);
-        assertEquals("Unexpected number of messages", MESSAGE_NUMBER, 
messages.size());
-    }
-
-
-    public void testDeleteMessages() throws Exception
-    {
-        String queueName = getTestQueueName();
-
-        // get message IDs
-        List<Long> ids = getMesssageIds(queueName);
-
-        // delete half of the messages
-        int deleteNumber = ids.size() / 2;
-        List<Long> deleteMessageIds = new ArrayList<>();
-        for (int i = 0; i < deleteNumber; i++)
-        {
-            Long id = ids.remove(i);
-            deleteMessageIds.add(id);
-        }
-
-        // delete messages
-        Map<String, Object> parameters = new HashMap<>();
-        parameters.put("messageIds", deleteMessageIds);
-        getRestTestHelper().submitRequest("queue/test/test/" + queueName + 
"/deleteMessages",
-                                          "POST",
-                                          parameters,
-                                          HttpServletResponse.SC_OK);
-
-        // check messages on queue
-        List<Map<String, Object>> messages =
-                
getRestTestHelper().getJsonAsList(String.format(GET_MESSAGE_INFO, queueName));
-        assertNotNull("Messages are not found", messages);
-        assertEquals("Unexpected number of messages", ids.size(), 
messages.size());
-        for (Long id : ids)
-        {
-            Map<String, Object> message = getRestTestHelper().find("id", 
id.intValue(), messages);
-            assertMessageAttributes(message);
-        }
-        for (Long id : deleteMessageIds)
-        {
-            Map<String, Object> message = getRestTestHelper().find("id", 
id.intValue(), messages);
-            assertNull("Message with id " + id + " was not deleted", message);
-        }
-    }
-
-    public void testDeleteMessagesWithLimit() throws Exception
-    {
-        String queueName = getTestQueueName();
-
-        // delete half of the messages
-        int deleteNumber = MESSAGE_NUMBER / 2;
-
-        // delete messages
-        Map<String, Object> parameters = new HashMap<>();
-        parameters.put("limit", deleteNumber);
-        getRestTestHelper().submitRequest("queue/test/test/" + queueName + 
"/deleteMessages",
-                                          "POST",
-                                          parameters,
-                                          HttpServletResponse.SC_OK);
-
-        // check messages on queue
-        List<Map<String, Object>> messages =
-                
getRestTestHelper().getJsonAsList(String.format(GET_MESSAGE_INFO, queueName));
-        assertNotNull("Messages are not found", messages);
-        assertEquals("Unexpected number of messages", MESSAGE_NUMBER / 2, 
messages.size());
-    }
-
-
-    public void testClearQueue() throws Exception
-    {
-        String queueName = getTestQueueName();
-
-        // clear queue
-        getRestTestHelper().submitRequest("queue/test/test/" + queueName + 
"/clearQueue", "POST",
-                                          Collections.<String, 
Object>emptyMap(), HttpServletResponse.SC_OK);
-
-        // check messages on queue
-        List<Map<String, Object>> messages =
-                
getRestTestHelper().getJsonAsList(String.format(GET_MESSAGE_INFO, queueName));
-        assertNotNull("Messages are not found", messages);
-        assertEquals("Unexpected number of messages", 0, messages.size());
-    }
-
-
-    private List<Long> getMesssageIds(String queueName) throws IOException
-    {
-        List<Map<String, Object>> messages =
-                
getRestTestHelper().getJsonAsList(String.format(GET_MESSAGE_INFO, queueName));
-        List<Long> ids = new ArrayList<>();
-        for (Map<String, Object> message : messages)
-        {
-            ids.add(((Number) message.get("id")).longValue());
-        }
-        return ids;
-    }
-
-    private void assertMessage(int position, Map<String, Object> message)
-    {
-        assertMessageAttributes(message);
-
-        final int size = (int) message.get("size");
-        assertTrue("Unexpected message attribute size", size > 0);
-        boolean even = position % 2 == 0;
-        assertMessageAttributeValues(message, even);
-    }
-
-    private void assertMessageAttributeValues(Map<String, Object> message, 
boolean even)
-    {
-        if (even)
-        {
-            assertNull("Unexpected message attribute expirationTime", 
message.get("expirationTime"));
-            assertEquals("Unexpected message attribute priority", 4, 
message.get("priority"));
-            assertEquals("Unexpected message attribute persistent", 
Boolean.TRUE, message.get("persistent"));
-        }
-        else
-        {
-            final long expirationTime = ((Number) 
message.get("expirationTime")).longValue();
-            final long currentTime = System.currentTimeMillis();
-            assertTrue(String.format("Unexpected message attribute 
expirationTime. got %d which is not >= %d",
-                                     expirationTime,
-                                     _startTime + _ttl), expirationTime >= 
_startTime + _ttl);
-            assertTrue(String.format("Unexpected message attribute 
expirationTime. got %d which is not <= %d",
-                                     expirationTime,
-                                     currentTime + _ttl), expirationTime <= 
currentTime + _ttl);
-            assertEquals("Unexpected message attribute priority", 5, 
message.get("priority"));
-            assertEquals("Unexpected message attribute persistent", 
Boolean.FALSE, message.get("persistent"));
-        }
-        if (!isBroker10())
-        {
-            assertEquals("Unexpected message attribute mimeType", 
"text/plain", message.get("mimeType"));
-        }
-        assertEquals("Unexpected message attribute userId", "guest", 
message.get("userId"));
-        assertEquals("Unexpected message attribute deliveryCount", 0, 
message.get("deliveryCount"));
-        assertEquals("Unexpected message attribute state", "Available", 
message.get("state"));
-    }
-
-    private void assertMessageAttributes(Map<String, Object> message)
-    {
-        assertNotNull("Message map cannot be null", message);
-        assertNotNull("Unexpected message attribute deliveryCount", 
message.get("deliveryCount"));
-        assertNotNull("Unexpected message attribute state", 
message.get("state"));
-        assertNotNull("Unexpected message attribute id", message.get("id"));
-        assertNotNull("Message arrivalTime cannot be null", 
message.get("arrivalTime"));
-        assertNotNull("Message timestamp cannot be null", 
message.get("timestamp"));
-        assertTrue("Message arrivalTime cannot be null",
-                   ((Number) message.get("arrivalTime")).longValue() > 
_startTime);
-        assertNotNull("Message messageId cannot be null", 
message.get("messageId"));
-        if (!isBroker10())
-        {
-            assertNotNull("Unexpected message attribute mimeType", 
message.get("mimeType"));
-        }
-        assertNotNull("Unexpected message attribute userId", 
message.get("userId"));
-        assertNotNull("Message priority cannot be null", 
message.get("priority"));
-        assertNotNull("Message persistent cannot be null", 
message.get("persistent"));
-    }
-
-    private Map<String, Object> getLastMessage(final String queueName) throws 
Exception
-    {
-        List<Long> ids = getMesssageIds(queueName);
-        int lastMessageIndex = ids.size() - 1;
-        List<Map<String, Object>> messages = 
getRestTestHelper().getJsonAsList("queue/test/test/"
-                                                                               
+ queueName
-                                                                               
+ "/getMessageInfo?first="
-                                                                               
+ lastMessageIndex
-                                                                               
+ "&last="
-                                                                               
+ lastMessageIndex);
-        assertEquals("Unexpected message number returned", 1, messages.size());
-        return messages.get(0);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/31037b05/systests/src/test/java/org/apache/qpid/systest/rest/PublishMessageRestTest.java
----------------------------------------------------------------------
diff --git 
a/systests/src/test/java/org/apache/qpid/systest/rest/PublishMessageRestTest.java
 
b/systests/src/test/java/org/apache/qpid/systest/rest/PublishMessageRestTest.java
deleted file mode 100644
index 44838e3..0000000
--- 
a/systests/src/test/java/org/apache/qpid/systest/rest/PublishMessageRestTest.java
+++ /dev/null
@@ -1,236 +0,0 @@
-/*
- * 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.qpid.systest.rest;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-import java.util.concurrent.TimeUnit;
-
-import javax.jms.Connection;
-import javax.jms.Destination;
-import javax.jms.JMSException;
-import javax.jms.MapMessage;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.Session;
-import javax.jms.StreamMessage;
-import javax.jms.TextMessage;
-import javax.servlet.http.HttpServletResponse;
-
-import com.google.common.base.Strings;
-
-import org.apache.qpid.server.model.Port;
-import org.apache.qpid.server.model.Queue;
-import org.apache.qpid.test.utils.TestBrokerConfiguration;
-
-public class PublishMessageRestTest extends QpidRestTestCase
-{
-    private Connection _connection;
-    private Session _session;
-    private String _queueName;
-    private MessageConsumer _consumer;
-    private String _publishMessageOpUrl;
-    private String _queueUrl;
-
-    @Override
-    public void setUp() throws Exception
-    {
-        super.setUp();
-
-        _connection = getConnection();
-        _connection.start();
-
-        _session = _connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-        _queueName = getTestQueueName();
-        Destination queue = createTestQueue(_session);
-
-        _consumer = _session.createConsumer(queue);
-
-        _publishMessageOpUrl = 
String.format("virtualhost/%s/%s/publishMessage", TEST1_VIRTUALHOST, 
TEST1_VIRTUALHOST);
-        _queueUrl = String.format("queue/%s/%s/", TEST1_VIRTUALHOST, 
TEST1_VIRTUALHOST);
-    }
-
-    @Override
-    protected void customizeConfiguration() throws Exception
-    {
-        super.customizeConfiguration();
-        getDefaultBrokerConfiguration().setObjectAttribute(Port.class, 
TestBrokerConfiguration.ENTRY_NAME_HTTP_PORT,
-                                                           
Port.ALLOW_CONFIDENTIAL_OPERATIONS_ON_INSECURE_CHANNELS,
-                                                           true);
-    }
-
-    public void testPublishMinimalEmptyMessage() throws Exception
-    {
-        Map<String, Object> messageBody = new HashMap<>();
-        messageBody.put("address", _queueName);
-
-        getRestTestHelper().submitRequest(_publishMessageOpUrl,
-                                          "POST",
-                                          Collections.singletonMap("message", 
messageBody), HttpServletResponse.SC_OK);
-
-        Message message = _consumer.receive(getLongReceiveTimeout());
-        assertNotNull("Expected message not received", message);
-        assertNull("Unexpected JMSMessageID", message.getJMSMessageID());
-        assertNull("Unexpected JMSCorrelationID", 
message.getJMSCorrelationID());
-        assertEquals("Unexpected JMSExpiration", 0, 
message.getJMSExpiration());
-        assertNotSame("Unexpected JMSTimestamp", 0, message.getJMSTimestamp());
-
-        // remove any JMSX properties which may be added by the client library
-        List<String> applicationHeaders = 
getApplicationHeaders(message.getPropertyNames());
-        assertTrue("Unexpected number of message properties: " + 
applicationHeaders, applicationHeaders.isEmpty());
-    }
-
-    public void testPublishMessageWithPropertiesAndHeaders() throws Exception
-    {
-        final String messageId = "ID:" + UUID.randomUUID().toString();
-        final long tomorrow = TimeUnit.DAYS.toMillis(1) + 
System.currentTimeMillis();
-        final Map<String, Object> headers = new HashMap<>();
-        headers.put("stringprop", "mystring");
-        headers.put("longstringprop", Strings.repeat("*", 256));
-        headers.put("intprop", Integer.MIN_VALUE);
-        headers.put("longprop", Long.MAX_VALUE);
-        final Map<String, Object> messageBody = new HashMap<>();
-        messageBody.put("messageId", messageId);
-        messageBody.put("address", _queueName);
-        messageBody.put("expiration", tomorrow);
-        messageBody.put("headers", headers);
-
-        getRestTestHelper().submitRequest(_publishMessageOpUrl,
-                                          "POST",
-                                          Collections.singletonMap("message", 
messageBody), HttpServletResponse.SC_OK);
-
-        Message message = _consumer.receive(getLongReceiveTimeout());
-        assertNotNull("Expected message not received", message);
-        final String jmsMessageID = message.getJMSMessageID();
-        assertEquals("Unexpected JMSMessageID", messageId, jmsMessageID);
-        assertFalse("Unexpected JMSRedelivered", message.getJMSRedelivered());
-        // In AMQP 1.0 TTLs are compute relative to the message's arrival time 
at server.
-        assertTrue(String.format("Unexpected JMSExpiration expected %d actual 
%d", tomorrow, message.getJMSExpiration()),
-                   message.getJMSExpiration() >= tomorrow && 
message.getJMSExpiration() - tomorrow < 5000);
-
-        // remove any JMSX properties which may be added by the client library
-        List<String> applicationHeaders = 
getApplicationHeaders(message.getPropertyNames());
-
-        for(String key : applicationHeaders)
-        {
-            assertEquals("Unexpected property value fo key : " + key,
-                         headers.get(key),
-                         message.getObjectProperty(key));
-        }
-        assertEquals("Unexpected number of properties", headers.size(), 
applicationHeaders.size());
-    }
-
-    public void testPublishStringMessage() throws Exception
-    {
-        final String content = "Hello world";
-        TextMessage message = publishMessageWithContent(content, 
TextMessage.class);
-        assertEquals("Unexpected message content", content, message.getText());
-    }
-
-    public void testPublishMapMessage() throws Exception
-    {
-        final Map<String, Object> content = new HashMap<>();
-        content.put("key1", "astring");
-        content.put("key2", Integer.MIN_VALUE);
-        content.put("key3", Long.MAX_VALUE);
-        content.put("key4", null);
-        MapMessage message = publishMessageWithContent(content, 
MapMessage.class);
-        final Enumeration mapNames = message.getMapNames();
-        int entryCount = 0;
-        while(mapNames.hasMoreElements())
-        {
-            String key = (String) mapNames.nextElement();
-            assertEquals("Unexpected map content for key : " + key, 
content.get(key), message.getObject(key));
-            entryCount++;
-        }
-        assertEquals("Unexpected number of key/value pairs in map message", 
content.size(), entryCount);
-    }
-
-    public void testPublishListMessage() throws Exception
-    {
-        final List<Object> content = new ArrayList<>();
-        content.add("astring");
-        content.add(Integer.MIN_VALUE);
-        content.add(Long.MAX_VALUE);
-        content.add(null);
-        StreamMessage message = publishMessageWithContent(content, 
StreamMessage.class);
-        assertEquals("astring", message.readString());
-        assertEquals(Integer.MIN_VALUE, message.readInt());
-        assertEquals(Long.MAX_VALUE, message.readLong());
-        assertNull(message.readObject());
-    }
-
-    public void testPublishRouting() throws Exception
-    {
-        final String queueName = UUID.randomUUID().toString();
-        Map<String, Object> messageBody = Collections.<String, 
Object>singletonMap("address", queueName);
-
-        int enqueues = getRestTestHelper().postJson(_publishMessageOpUrl,
-                                                    
Collections.singletonMap("message", messageBody),
-                                                    Integer.class);
-        assertEquals("Unexpected number of enqueues", 0, enqueues);
-
-        getRestTestHelper().submitRequest(_queueUrl, "POST", 
Collections.singletonMap(Queue.NAME, queueName), 
HttpServletResponse.SC_CREATED);
-
-        enqueues = getRestTestHelper().postJson(_publishMessageOpUrl,
-                                                
Collections.singletonMap("message", messageBody),
-                                                Integer.class);
-
-
-        assertEquals("Unexpected number of enqueues after queue creation", 1, 
enqueues);
-    }
-
-    private <M extends Message> M publishMessageWithContent(final Object 
content, final Class<M> expectedMessageClass) throws Exception
-    {
-        Map<String, Object> messageBody = new HashMap<>();
-        messageBody.put("address", _queueName);
-        messageBody.put("content", content);
-
-        getRestTestHelper().submitRequest(_publishMessageOpUrl,
-                                          "POST",
-                                          Collections.singletonMap("message", 
messageBody), HttpServletResponse.SC_OK);
-
-        M message = (M) _consumer.receive(getLongReceiveTimeout());
-        assertNotNull("Expected message not received", message);
-        assertTrue(String.format("Unexpected message type. Expecting %s got 
%s", expectedMessageClass, message.getClass()),
-                   expectedMessageClass.isAssignableFrom(message.getClass()));
-        return message;
-    }
-
-    private List<String> getApplicationHeaders(final Enumeration 
propertyNames1) throws JMSException
-    {
-        List<String> copy = new 
ArrayList<>(Collections.list((Enumeration<String>) propertyNames1));
-        Iterator iter = copy.iterator();
-        while(iter.hasNext())
-        {
-            if(iter.next().toString().startsWith("JMSX"))
-            {
-                iter.remove();
-            }
-        }
-        return copy;
-    }
-}

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/31037b05/test-profiles/Java10BrokenTestsExcludes
----------------------------------------------------------------------
diff --git a/test-profiles/Java10BrokenTestsExcludes 
b/test-profiles/Java10BrokenTestsExcludes
index 5686325..501ff3b 100644
--- a/test-profiles/Java10BrokenTestsExcludes
+++ b/test-profiles/Java10BrokenTestsExcludes
@@ -21,13 +21,5 @@
 // Tests which fail, indicating a potential issue or a missing feature
 //-----------------------------------------------------
 
-// Broker side defect - not creating temp queues with prefixes
-
-// the received message is being treated as an object message (because it 
lacks the necessary JMS annotation?)
-org.apache.qpid.systest.rest.PublishMessageRestTest#testPublishMapMessage
-org.apache.qpid.systest.rest.PublishMessageRestTest#testPublishListMessage
-
-// this test fails - likely a client bug with the modification racing the send
-org.apache.qpid.test.unit.basic.BytesMessageTest#testModificationAfterSend
 
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org
For additional commands, e-mail: commits-h...@qpid.apache.org

Reply via email to