@@ -0,0 +1,2695 @@
+package io.enmasse.systemtest.brokered;%0A%0Aimport io.enmasse.systemtest.AddressSpace;%0Aimport io.enmasse.systemtest.Destination;%0Aimport io.enmasse.systemtest.MultiTenantTestBase;%0Aimport io.enmasse.systemtest.amqp.AmqpClient;%0Aimport io.enmasse.systemtest.amqp.AmqpClientFactory;%0Aimport org.apache.qpid.proton.amqp.messaging.AmqpValue;%0Aimport org.apache.qpid.proton.message.Message;%0Aimport org.junit.Test;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0Aimport java.util.concurrent.Future;%0Aimport java.util.concurrent.TimeUnit;%0A%0Aimport static org.hamcrest.CoreMatchers.is;%0Aimport static org.junit.Assert.*;%0A%0Apublic class QueueTest extends MultiTenantTestBase %7B%0A%0A    /**%0A     * related github issue: #387%0A     */%0A    @Test%0A    public void messageGroupTest() throws Exception%7B%0A        AddressSpace addressSpace = new AddressSpace(%22brokered-message-group%22, %22brokered-message-group%22);%0A        createAddressSpace(addressSpace, %22none%22, %22brokered%22);%0A        addressSpaces.add(addressSpace);%0A        Destination dest = Destination.queue(%22messageGroupQueue%22);%0A        setAddresses(addressSpace, dest);%0A%0A        AmqpClientFactory amqpFactory = createAmqpClientFactory(addressSpace);%0A        AmqpClient client = amqpFactory.createQueueClient(addressSpace);%0A        client.getConnectOptions().setUsername(%22test%22).setPassword(%22test%22);%0A%0A        int msgsCount = 20;%0A        int msgCountGroupA = 15;%0A        int msgCountGroupB = 5;%0A        List%3CMessage%3E listOfMessages = new ArrayList%3C%3E();%0A        for (int i = 0; i %3C msgsCount; i++) %7B%0A            Message msg = Message.Factory.create();%0A            msg.setAddress(dest.getAddress());%0A            msg.setBody(new AmqpValue(dest.getAddress()));%0A            msg.setSubject(%22subject%22);%0A            msg.setGroupId(((i + 1) %25 4 != 0) ? %22group A%22 : %22group B%22);%0A            listOfMessages.add(msg);%0A        %7D%0A%0A        Future%3CList%3CMessage%3E%3E receivedGroupA = client.recvMessages(dest.getAddress(), msgCountGroupA);%0A        Future%3CList%3CMessage%3E%3E receivedGroupB = client.recvMessages(dest.getAddress(), msgCountGroupB);%0A        Thread.sleep(2000);%0A%0A        Future%3CInteger%3E sent = client.sendMessages(dest.getAddress(),%0A                listOfMessages.toArray(new Message%5BlistOfMessages.size()%5D));%0A%0A        assertThat(sent.get(1, TimeUnit.MINUTES), is(msgsCount));%0A        assertThat(receivedGroupA.get(1, TimeUnit.MINUTES).size(), is(msgCountGroupA));%0A        assertThat(receivedGroupB.get(1, TimeUnit.MINUTES).size(), is(msgCountGroupB));%0A%0A        for (Message m : receivedGroupA.get()) %7B%0A            assertEquals(m.getGroupId(), %22group A%22);%0A        %7D%0A%0A        for (Message m : receivedGroupB.get()) %7B%0A            assertEquals(m.getGroupId(), %22group B%22);%0A        %7D%0A    %7D%0A%7D%0A

Test for message grouping