NikitaShupletsov commented on code in PR #848:
URL: https://github.com/apache/activemq/pull/848#discussion_r1080646856


##########
activemq-broker/src/test/java/org/apache/activemq/replica/ReplicaCompactorTest.java:
##########
@@ -0,0 +1,166 @@
+/**
+ * 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.replica;
+
+import org.apache.activemq.broker.Broker;
+import org.apache.activemq.broker.ConnectionContext;
+import org.apache.activemq.broker.region.MessageReference;
+import org.apache.activemq.broker.region.PrefetchSubscription;
+import org.apache.activemq.broker.region.Queue;
+import org.apache.activemq.command.ActiveMQMessage;
+import org.apache.activemq.command.ActiveMQQueue;
+import org.apache.activemq.command.ConsumerInfo;
+import org.apache.activemq.command.MessageAck;
+import org.apache.activemq.command.MessageId;
+import org.apache.activemq.store.MessageStore;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+
+import java.util.List;
+import java.util.Set;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+public class ReplicaCompactorTest {
+
+    private final ConnectionContext connectionContext = 
mock(ConnectionContext.class);
+    private final Broker broker = mock(Broker.class);
+    private final ReplicaReplicationQueueSupplier queueProvider = 
mock(ReplicaReplicationQueueSupplier.class);
+    private final MessageStore messageStore = mock(MessageStore.class);
+
+    private final ActiveMQQueue intermediateQueueDestination = new 
ActiveMQQueue(ReplicaSupport.INTERMEDIATE_REPLICATION_QUEUE_NAME);
+    private final Queue intermediateQueue = mock(Queue.class);
+
+    private ReplicaCompactor replicaCompactor;
+
+    @Before
+    public void setUp() throws Exception {
+        ConnectionContext adminConnectionContext = 
mock(ConnectionContext.class);
+        when(adminConnectionContext.copy()).thenReturn(connectionContext);
+        
when(broker.getAdminConnectionContext()).thenReturn(adminConnectionContext);
+
+        
when(queueProvider.getIntermediateQueue()).thenReturn(intermediateQueueDestination);
+        
when(broker.getDestinations(intermediateQueueDestination)).thenReturn(Set.of(intermediateQueue));
+        when(intermediateQueue.getMessageStore()).thenReturn(messageStore);
+
+        ConsumerInfo consumerInfo = new ConsumerInfo();
+        PrefetchSubscription originalSubscription = 
mock(PrefetchSubscription.class);
+        when(originalSubscription.getConsumerInfo()).thenReturn(consumerInfo);
+
+        replicaCompactor = new ReplicaCompactor(broker, connectionContext, 
queueProvider, originalSubscription);
+    }
+
+    @Test
+    public void compactWhenSendAndAck() throws Exception {
+        MessageId messageId1 = new MessageId("1:0:0:1");
+        MessageId messageId2 = new MessageId("1:0:0:2");
+        MessageId messageId3 = new MessageId("1:0:0:3");
+
+        String messageIdToAck = "2:1";
+
+        ActiveMQMessage message1 = new ActiveMQMessage();
+        message1.setMessageId(messageId1);
+        
message1.setBooleanProperty(ReplicaSupport.IS_ORIGINAL_MESSAGE_SENT_TO_QUEUE_PROPERTY,
 true);
+        message1.setStringProperty(ReplicaEventType.EVENT_TYPE_PROPERTY, 
ReplicaEventType.MESSAGE_SEND.toString());
+        message1.setStringProperty(ReplicaSupport.MESSAGE_ID_PROPERTY, 
messageIdToAck);

Review Comment:
   `ReplicaSupport.MESSAGE_ID_PROPERTY` is used for the selector 
https://github.com/apache/activemq/pull/848/files/ec191dae604c3e51230ac88da8fb383dcd27d168#diff-eb08a6397c7e082f3d1aab53880eeb062d837f235dc870f910819a5b2d63c30aR102



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to