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
This commit is contained in:
Bosanac Dejan 2012-08-31 10:46:49 +00:00
parent eea9fca04d
commit 1e57750dd6
2 changed files with 41 additions and 14 deletions

View File

@ -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());
}
}
}

View File

@ -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());
}
}