You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@activemq.apache.org by "asaxena14 (via GitHub)" <gi...@apache.org> on 2026/02/25 10:54:55 UTC
[PR] AMQP: added transport factory unit tests for mutex stripping and monitor wiring. [activemq]
asaxena14 opened a new pull request, #1725:
URL: https://github.com/apache/activemq/pull/1725
This PR adds focused unit coverage for AMQP transport factories to validate configuration behaviour.
Added test:
AmqpTransportFactoryConfigurationTest.java
Factories covered:
- AmqpTransportFactory
- AmqpSslTransportFactory
- AmqpNioTransportFactory
- AmqpNioSslTransportFactory
What is verified:
- serverConfigure(...) strips broker-side MutexTransport
- compositeConfigure(...) applies AMQP and wireFormat.* properties (transformer, producerCredit, maxFrameSize, connectAttemptTimeout)
- inactivity monitor wiring is correct (AmqpInactivityMonitor is present in the transport chain and the same monitor instance is set on AmqpTransportFilter)
--
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-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org
For additional commands, e-mail: gitbox-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact
Re: [PR] AMQP: added transport factory unit tests for mutex stripping and monitor wiring. [activemq]
Posted by "asaxena14 (via GitHub)" <gi...@apache.org>.
asaxena14 commented on PR #1725:
URL: https://github.com/apache/activemq/pull/1725#issuecomment-3961945070
CI Quick is blocked as workflow is awaiting approval from a maintainer. Can someone Please provide an approval for this. Thanks
--
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-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org
For additional commands, e-mail: gitbox-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact
Re: [PR] AMQP: added transport factory unit tests for mutex stripping and monitor wiring. [activemq]
Posted by "jbonofre (via GitHub)" <gi...@apache.org>.
jbonofre merged PR #1725:
URL: https://github.com/apache/activemq/pull/1725
--
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-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org
For additional commands, e-mail: gitbox-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact
Re: [PR] AMQP: added transport factory unit tests for mutex stripping and monitor wiring. [activemq]
Posted by "asaxena14 (via GitHub)" <gi...@apache.org>.
asaxena14 commented on code in PR #1725:
URL: https://github.com/apache/activemq/pull/1725#discussion_r2853735485
##########
activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/AmqpTransportFactoryConfigurationTest.java:
##########
@@ -0,0 +1,146 @@
+/**
+ * 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.transport.amqp;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+
+import java.net.URI;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.net.SocketFactory;
+import javax.net.ssl.SSLSocket;
+import javax.net.ssl.SSLSocketFactory;
+
+import org.apache.activemq.transport.MutexTransport;
+import org.apache.activemq.transport.Transport;
+import org.apache.activemq.transport.TransportFactory;
+import org.apache.activemq.transport.TransportFilter;
+import org.apache.activemq.transport.tcp.SslTransport;
+import org.apache.activemq.transport.tcp.TcpTransport;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+@Category(ParallelTest.class)
+public class AmqpTransportFactoryConfigurationTest {
+
+ @Test
+ public void testServerConfigureStripsMutexTransportForAllAmqpFactories() throws Exception {
+ assertServerConfigureStripsMutex(new AmqpTransportFactory());
+ assertServerConfigureStripsMutex(new AmqpSslTransportFactory());
+ assertServerConfigureStripsMutex(new AmqpNioTransportFactory());
+ assertServerConfigureStripsMutex(new AmqpNioSslTransportFactory());
+ }
+
+ @Test
+ public void testCompositeConfigureAppliesAmqpAndWireFormatPropertiesForAllAmqpFactories() throws Exception {
+ assertCompositeConfigureAppliesProperties(new AmqpTransportFactory());
+ assertCompositeConfigureAppliesProperties(new AmqpSslTransportFactory());
+ assertCompositeConfigureAppliesProperties(new AmqpNioTransportFactory());
+ assertCompositeConfigureAppliesProperties(new AmqpNioSslTransportFactory());
+ }
+
+ @Test
+ public void testAllAmqpFactoriesWireAmqpInactivityMonitor() throws Exception {
+ assertAmqpFactoriesWireAmqpInactivityMonitor(new AmqpTransportFactory());
+ assertAmqpFactoriesWireAmqpInactivityMonitor(new AmqpSslTransportFactory());
+ assertAmqpFactoriesWireAmqpInactivityMonitor(new AmqpNioTransportFactory());
+ assertAmqpFactoriesWireAmqpInactivityMonitor(new AmqpNioSslTransportFactory());
+ }
+
+ private void assertServerConfigureStripsMutex(TransportFactory factory) throws Exception {
+ Transport configured = factory.serverConfigure(
+ createTransportForFactory(factory, new AmqpWireFormat()),
+ new AmqpWireFormat(),
+ new HashMap<String, Object>());
+
+ assertFalse("AMQP serverConfigure should strip the broker-side MutexTransport",
+ configured instanceof MutexTransport);
+ }
+
+ private void assertCompositeConfigureAppliesProperties(TransportFactory factory) throws Exception {
+ Map<String, String> options = new HashMap<>();
+ options.put("transformer", "raw");
+ options.put("producerCredit", "17");
+ options.put("wireFormat.maxFrameSize", "4096");
+ options.put("wireFormat.connectAttemptTimeout", "1234");
+
+ Transport configured = factory.compositeConfigure(
+ createTransportForFactory(factory, new AmqpWireFormat()),
+ new AmqpWireFormat(),
+ options);
+
+ AmqpTransportFilter filter = findInChain(configured, AmqpTransportFilter.class);
+ assertNotNull("Expected AmqpTransportFilter in configured transport chain", filter);
+ assertEquals("raw", filter.getTransformer());
+ assertEquals(17, filter.getProducerCredit());
+ assertEquals(4096L, filter.getMaxFrameSize());
+ assertEquals(1234, filter.getConnectAttemptTimeout());
+ }
+
+ private void assertAmqpFactoriesWireAmqpInactivityMonitor(TransportFactory factory) throws Exception {
+ Transport configured = factory.compositeConfigure(
+ createTransportForFactory(factory, new AmqpWireFormat()),
+ new AmqpWireFormat(),
+ new HashMap<String, String>());
+
+ AmqpInactivityMonitor monitor = findInChain(configured, AmqpInactivityMonitor.class);
+ AmqpTransportFilter filter = findInChain(configured, AmqpTransportFilter.class);
+
+ assertNotNull("Expected AmqpInactivityMonitor in configured transport chain", monitor);
+ assertNotNull("Expected AmqpTransportFilter in configured transport chain", filter);
+ assertTrue("Filter should report inactivity monitor as enabled", filter.isUseInactivityMonitor());
+ assertSame("Factory should wire the same monitor instance into the AMQP filter",
+ monitor, filter.getInactivityMonitor());
+ }
+
+ private TcpTransport createTcpTransport(AmqpWireFormat wireFormat) throws Exception {
+ return new TcpTransport(
+ wireFormat,
+ SocketFactory.getDefault(),
+ new URI("tcp://localhost:61616"),
Review Comment:
Updated the code to use dynamic ports.
--
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-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org
For additional commands, e-mail: gitbox-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact
Re: [PR] AMQP: added transport factory unit tests for mutex stripping and monitor wiring. [activemq]
Posted by "jbonofre (via GitHub)" <gi...@apache.org>.
jbonofre commented on code in PR #1725:
URL: https://github.com/apache/activemq/pull/1725#discussion_r2852335654
##########
activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/AmqpTransportFactoryConfigurationTest.java:
##########
@@ -0,0 +1,146 @@
+/**
+ * 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.transport.amqp;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+
+import java.net.URI;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.net.SocketFactory;
+import javax.net.ssl.SSLSocket;
+import javax.net.ssl.SSLSocketFactory;
+
+import org.apache.activemq.transport.MutexTransport;
+import org.apache.activemq.transport.Transport;
+import org.apache.activemq.transport.TransportFactory;
+import org.apache.activemq.transport.TransportFilter;
+import org.apache.activemq.transport.tcp.SslTransport;
+import org.apache.activemq.transport.tcp.TcpTransport;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+@Category(ParallelTest.class)
+public class AmqpTransportFactoryConfigurationTest {
+
+ @Test
+ public void testServerConfigureStripsMutexTransportForAllAmqpFactories() throws Exception {
+ assertServerConfigureStripsMutex(new AmqpTransportFactory());
+ assertServerConfigureStripsMutex(new AmqpSslTransportFactory());
+ assertServerConfigureStripsMutex(new AmqpNioTransportFactory());
+ assertServerConfigureStripsMutex(new AmqpNioSslTransportFactory());
+ }
+
+ @Test
+ public void testCompositeConfigureAppliesAmqpAndWireFormatPropertiesForAllAmqpFactories() throws Exception {
+ assertCompositeConfigureAppliesProperties(new AmqpTransportFactory());
+ assertCompositeConfigureAppliesProperties(new AmqpSslTransportFactory());
+ assertCompositeConfigureAppliesProperties(new AmqpNioTransportFactory());
+ assertCompositeConfigureAppliesProperties(new AmqpNioSslTransportFactory());
+ }
+
+ @Test
+ public void testAllAmqpFactoriesWireAmqpInactivityMonitor() throws Exception {
+ assertAmqpFactoriesWireAmqpInactivityMonitor(new AmqpTransportFactory());
+ assertAmqpFactoriesWireAmqpInactivityMonitor(new AmqpSslTransportFactory());
+ assertAmqpFactoriesWireAmqpInactivityMonitor(new AmqpNioTransportFactory());
+ assertAmqpFactoriesWireAmqpInactivityMonitor(new AmqpNioSslTransportFactory());
+ }
+
+ private void assertServerConfigureStripsMutex(TransportFactory factory) throws Exception {
+ Transport configured = factory.serverConfigure(
+ createTransportForFactory(factory, new AmqpWireFormat()),
+ new AmqpWireFormat(),
+ new HashMap<String, Object>());
+
+ assertFalse("AMQP serverConfigure should strip the broker-side MutexTransport",
+ configured instanceof MutexTransport);
+ }
+
+ private void assertCompositeConfigureAppliesProperties(TransportFactory factory) throws Exception {
+ Map<String, String> options = new HashMap<>();
+ options.put("transformer", "raw");
+ options.put("producerCredit", "17");
+ options.put("wireFormat.maxFrameSize", "4096");
+ options.put("wireFormat.connectAttemptTimeout", "1234");
+
+ Transport configured = factory.compositeConfigure(
+ createTransportForFactory(factory, new AmqpWireFormat()),
+ new AmqpWireFormat(),
+ options);
+
+ AmqpTransportFilter filter = findInChain(configured, AmqpTransportFilter.class);
+ assertNotNull("Expected AmqpTransportFilter in configured transport chain", filter);
+ assertEquals("raw", filter.getTransformer());
+ assertEquals(17, filter.getProducerCredit());
+ assertEquals(4096L, filter.getMaxFrameSize());
+ assertEquals(1234, filter.getConnectAttemptTimeout());
+ }
+
+ private void assertAmqpFactoriesWireAmqpInactivityMonitor(TransportFactory factory) throws Exception {
+ Transport configured = factory.compositeConfigure(
+ createTransportForFactory(factory, new AmqpWireFormat()),
+ new AmqpWireFormat(),
+ new HashMap<String, String>());
+
+ AmqpInactivityMonitor monitor = findInChain(configured, AmqpInactivityMonitor.class);
+ AmqpTransportFilter filter = findInChain(configured, AmqpTransportFilter.class);
+
+ assertNotNull("Expected AmqpInactivityMonitor in configured transport chain", monitor);
+ assertNotNull("Expected AmqpTransportFilter in configured transport chain", filter);
+ assertTrue("Filter should report inactivity monitor as enabled", filter.isUseInactivityMonitor());
+ assertSame("Factory should wire the same monitor instance into the AMQP filter",
+ monitor, filter.getInactivityMonitor());
+ }
+
+ private TcpTransport createTcpTransport(AmqpWireFormat wireFormat) throws Exception {
+ return new TcpTransport(
+ wireFormat,
+ SocketFactory.getDefault(),
+ new URI("tcp://localhost:61616"),
Review Comment:
We should use a dynamic port here to avoid tests conflicts.
--
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-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org
For additional commands, e-mail: gitbox-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact