jbertram commented on code in PR #5390:
URL: https://github.com/apache/activemq-artemis/pull/5390#discussion_r1890570664


##########
tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/multiprotocol/JMSMessageExpiryTest.java:
##########
@@ -0,0 +1,197 @@
+/*
+ * 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.artemis.tests.integration.jms.multiprotocol;
+
+import javax.jms.Connection;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import java.lang.invoke.MethodHandles;
+
+import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class JMSMessageExpiryTest extends MultiprotocolJMSClientTestSupport {
+
+   protected static final Logger logger = 
LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+
+   private final long EXPIRY_DELAY = 9999999L;
+   private final long WINDOW = 20L;
+
+   @Test
+   @Timeout(30)
+   public void testCoreMessageExpiryDelay() throws Exception {
+      testExpiry(createCoreConnection(), DelayType.NORMAL, false);
+   }
+
+   @Test
+   @Timeout(30)
+   public void testAmqpMessageExpiryDelay() throws Exception {
+      testExpiry(createConnection(), DelayType.NORMAL, false);
+   }
+
+   @Test
+   @Timeout(30)
+   public void testOpenWireMessageExpiryDelay() throws Exception {
+      testExpiry(createOpenWireConnection(), DelayType.NORMAL, false);
+   }
+
+   @Test
+   @Timeout(30)
+   public void testCoreMaxExpiryDelayNoExpiration() throws Exception {
+      testExpiry(createCoreConnection(), DelayType.MAX, false);
+   }
+
+   @Test
+   @Timeout(30)
+   public void testAmqpMaxExpiryDelayNoExpiration() throws Exception {
+      testExpiry(createConnection(), DelayType.MAX, false);
+   }
+
+   @Test
+   @Timeout(30)
+   public void testOpenWireMaxExpiryDelayNoExpiration() throws Exception {
+      testExpiry(createOpenWireConnection(), DelayType.MAX, false);
+   }
+
+   @Test
+   @Timeout(30)
+   public void testCoreMinExpiryDelayNoExpiration() throws Exception {
+      testExpiry(createCoreConnection(), DelayType.MIN, false);
+   }
+
+   @Test
+   @Timeout(30)
+   public void testAmqpMinExpiryDelayNoExpiration() throws Exception {
+      testExpiry(createConnection(), DelayType.MIN, false);
+   }
+
+   @Test
+   @Timeout(30)
+   public void testOpenWireMinExpiryDelayNoExpiration() throws Exception {
+      testExpiry(createOpenWireConnection(), DelayType.MIN, false);
+   }
+
+   @Test
+   @Timeout(30)
+   public void testCoreMaxExpiryDelayWithExpiration() throws Exception {
+      testExpiry(createCoreConnection(), DelayType.MAX, true);
+   }
+
+   @Test
+   @Timeout(30)
+   public void testAmqpMaxExpiryDelayWithExpiration() throws Exception {
+      testExpiry(createConnection(), DelayType.MAX, true);
+   }
+
+   @Test
+   @Timeout(30)
+   public void testOpenWireMaxExpiryDelayWithExpiration() throws Exception {
+      testExpiry(createOpenWireConnection(), DelayType.MAX, true);
+   }
+
+   @Test
+   @Timeout(30)
+   public void testCoreMinExpiryDelayWithExpiration() throws Exception {
+      testExpiry(createCoreConnection(), DelayType.MIN, true);
+   }
+
+   @Test
+   @Timeout(30)
+   public void testAmqpMinExpiryDelayWithExpiration() throws Exception {
+      testExpiry(createConnection(), DelayType.MIN, true);
+   }
+
+   @Test
+   @Timeout(30)
+   public void testOpenWireMinExpiryDelayWithExpiration() throws Exception {
+      testExpiry(createOpenWireConnection(), DelayType.MIN, true);
+   }
+
+   @Test
+   @Timeout(30)
+   public void testCoreMessageNeverExpire() throws Exception {
+      testExpiry(createCoreConnection(), DelayType.NEVER, true);
+   }
+
+   @Test
+   @Timeout(30)
+   public void testAmqpMessageNeverExpire() throws Exception {
+      testExpiry(createConnection(), DelayType.NEVER, true);
+   }
+
+   @Test
+   @Timeout(30)
+   public void testOpenWireMessageNeverExpire() throws Exception {
+      testExpiry(createOpenWireConnection(), DelayType.NEVER, true);
+   }
+
+   private void testExpiry(Connection connection, DelayType delayType, boolean 
setTimeToLive) throws Exception {
+      AddressSettings addressSettings = new AddressSettings();
+      if (delayType == DelayType.NORMAL) {
+         addressSettings.setExpiryDelay(EXPIRY_DELAY);
+      } else if (delayType == DelayType.MIN) {
+         addressSettings.setMinExpiryDelay(EXPIRY_DELAY);
+      } else if (delayType == DelayType.MAX) {
+         addressSettings.setMaxExpiryDelay(EXPIRY_DELAY);
+      } else if (delayType == DelayType.NEVER) {
+         addressSettings.setNeverExpire(true);
+      }
+      server.getAddressSettingsRepository().addMatch(getQueueName(), 
addressSettings);
+
+      Session s = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+      Queue q = s.createQueue(getQueueName());
+      MessageProducer p = s.createProducer(q);
+      if (setTimeToLive) {
+         if (delayType == DelayType.MIN) {
+            p.setTimeToLive(EXPIRY_DELAY / 2);
+         } else if (delayType == DelayType.MAX) {
+            p.setTimeToLive(EXPIRY_DELAY * 2);
+         } else if (delayType == DelayType.NEVER) {
+            p.setTimeToLive(EXPIRY_DELAY);
+         }
+      }
+      long start = System.currentTimeMillis();
+      p.send(s.createMessage());
+      p.close();
+      MessageConsumer c = s.createConsumer(q);
+      connection.start();
+      Message m = c.receive(100);

Review Comment:
   Test is using `1500` now.



-- 
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: gitbox-unsubscr...@activemq.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscr...@activemq.apache.org
For additional commands, e-mail: gitbox-h...@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact


Reply via email to