From 1e57750dd6204434880a9000c5c3df5cf6f3cb44 Mon Sep 17 00:00:00 2001 From: Bosanac Dejan Date: Fri, 31 Aug 2012 10:46:49 +0000 Subject: [PATCH] https://issues.apache.org/jira/browse/AMQ-3986 - improve test, copy prefetch policies on managed connection factory git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1379414 13f79535-47bb-0310-9956-ffa450edef68 --- .../ra/ActiveMQManagedConnectionFactory.java | 31 +++++++++++++++---- .../ra/ActiveMQConnectionFactoryTest.java | 24 +++++++++----- 2 files changed, 41 insertions(+), 14 deletions(-) diff --git a/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQManagedConnectionFactory.java b/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQManagedConnectionFactory.java index d7cf3f7e5c..4c9216dac1 100755 --- a/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQManagedConnectionFactory.java +++ b/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQManagedConnectionFactory.java @@ -56,23 +56,42 @@ public class ActiveMQManagedConnectionFactory extends ActiveMQConnectionSupport { if ( log.isDebugEnabled() ) { log.debug("copying standard ResourceAdapter configuration properties"); - } + } + ActiveMQConnectionRequestInfo baseInfo = ((MessageResourceAdapter) adapter).getInfo().copy(); if (getClientid() == null) { setClientid(baseInfo.getClientid()); - } + } if (getPassword() == null) { setPassword(baseInfo.getPassword()); - } + } if (getServerUrl() == null) { setServerUrl(baseInfo.getServerUrl()); - } + } if (getUseInboundSession() == null) { setUseInboundSession(baseInfo.getUseInboundSession()); - } + } if (getUserName() == null) { setUserName(baseInfo.getUserName()); - } + } + if (getDurableTopicPrefetch() != null) { + setDurableTopicPrefetch(baseInfo.getDurableTopicPrefetch()); + } + if (getOptimizeDurableTopicPrefetch() != null) { + setOptimizeDurableTopicPrefetch(baseInfo.getOptimizeDurableTopicPrefetch()); + } + if (getQueuePrefetch() != null) { + setQueuePrefetch(baseInfo.getQueuePrefetch()); + } + if (getQueueBrowserPrefetch() != null) { + setQueueBrowserPrefetch(baseInfo.getQueueBrowserPrefetch()); + } + if (getTopicPrefetch() != null) { + setTopicPrefetch(baseInfo.getTopicPrefetch()); + } + if (getInputStreamPrefetch() != null) { + setInputStreamPrefetch(baseInfo.getInputStreamPrefetch()); + } } } diff --git a/activemq-ra/src/test/java/org/apache/activemq/ra/ActiveMQConnectionFactoryTest.java b/activemq-ra/src/test/java/org/apache/activemq/ra/ActiveMQConnectionFactoryTest.java index 00a733af42..3e15a4493d 100644 --- a/activemq-ra/src/test/java/org/apache/activemq/ra/ActiveMQConnectionFactoryTest.java +++ b/activemq-ra/src/test/java/org/apache/activemq/ra/ActiveMQConnectionFactoryTest.java @@ -21,9 +21,14 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; +import java.util.Timer; import javax.jms.Connection; import javax.jms.Session; import javax.jms.TopicSubscriber; +import javax.resource.spi.BootstrapContext; +import javax.resource.spi.UnavailableException; +import javax.resource.spi.XATerminator; +import javax.resource.spi.work.WorkManager; import junit.framework.TestCase; import org.apache.activemq.ActiveMQConnection; @@ -82,19 +87,22 @@ public class ActiveMQConnectionFactoryTest extends TestCase { } public void testOptimizeDurablePrefetch() throws Exception { - ActiveMQConnectionRequestInfo info = new ActiveMQConnectionRequestInfo(); - info.setServerUrl(url); - info.setUserName(user); - info.setPassword(pwd); - info.setOptimizeDurableTopicPrefetch(new Integer(500)); - ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(mcf, new ConnectionManagerAdapter(), info); - Connection con = factory.createConnection("defaultUser", "defaultPassword"); + ActiveMQResourceAdapter ra = new ActiveMQResourceAdapter(); + ra.setServerUrl(url); + ra.setUserName(user); + ra.setPassword(pwd); + + ra.setOptimizeDurableTopicPrefetch(0); + ra.setDurableTopicPrefetch(0); + + Connection con = ra.makeConnection(); + con.setClientID("x"); Session sess = con.createSession(false, Session.AUTO_ACKNOWLEDGE); TopicSubscriber sub = sess.createDurableSubscriber(sess.createTopic("TEST"), "x"); con.start(); - assertEquals(500, ((ActiveMQTopicSubscriber)sub).getPrefetchNumber()); + assertEquals(0, ((ActiveMQTopicSubscriber)sub).getPrefetchNumber()); } }