summaryrefslogtreecommitdiff
path: root/java/broker/src/test/java/org/apache/qpid/server/protocol/MaxChannelsTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/broker/src/test/java/org/apache/qpid/server/protocol/MaxChannelsTest.java')
-rw-r--r--java/broker/src/test/java/org/apache/qpid/server/protocol/MaxChannelsTest.java42
1 files changed, 24 insertions, 18 deletions
diff --git a/java/broker/src/test/java/org/apache/qpid/server/protocol/MaxChannelsTest.java b/java/broker/src/test/java/org/apache/qpid/server/protocol/MaxChannelsTest.java
index e8ee2c4d0b..99dd42e179 100644
--- a/java/broker/src/test/java/org/apache/qpid/server/protocol/MaxChannelsTest.java
+++ b/java/broker/src/test/java/org/apache/qpid/server/protocol/MaxChannelsTest.java
@@ -23,20 +23,24 @@ package org.apache.qpid.server.protocol;
import org.apache.qpid.AMQException;
import org.apache.qpid.protocol.AMQConstant;
import org.apache.qpid.server.AMQChannel;
-import org.apache.qpid.server.registry.ApplicationRegistry;
-import org.apache.qpid.server.util.InternalBrokerBaseCase;
-import org.apache.qpid.server.virtualhost.VirtualHost;
+import org.apache.qpid.server.util.BrokerTestHelper;
+import org.apache.qpid.test.utils.QpidTestCase;
/** Test class to test MBean operations for AMQMinaProtocolSession. */
-public class MaxChannelsTest extends InternalBrokerBaseCase
+public class MaxChannelsTest extends QpidTestCase
{
- private AMQProtocolEngine _session;
+ private AMQProtocolEngine _session;
- public void testChannels() throws Exception
+ @Override
+ public void setUp() throws Exception
{
- VirtualHost vhost = ApplicationRegistry.getInstance().getVirtualHostRegistry().getVirtualHost("test");
- _session = new InternalTestProtocolSession(vhost);
+ super.setUp();
+ BrokerTestHelper.setUp();
+ _session = BrokerTestHelper.createSession();
+ }
+ public void testChannels() throws Exception
+ {
// check the channel count is correct
int channelCount = _session.getChannels().size();
assertEquals("Initial channel count wrong", 0, channelCount);
@@ -45,13 +49,15 @@ public class MaxChannelsTest extends InternalBrokerBaseCase
_session.setMaximumNumberOfChannels(maxChannels);
assertEquals("Number of channels not correctly set.", new Long(maxChannels), _session.getMaximumNumberOfChannels());
+ for (long currentChannel = 0L; currentChannel < maxChannels; currentChannel++)
+ {
+ _session.addChannel(new AMQChannel(_session, (int) currentChannel, null));
+ }
try
{
- for (long currentChannel = 0L; currentChannel < maxChannels; currentChannel++)
- {
- _session.addChannel(new AMQChannel(_session, (int) currentChannel, null));
- }
+ _session.addChannel(new AMQChannel(_session, (int) maxChannels, null));
+ fail("Cannot create more channels then maximum");
}
catch (AMQException e)
{
@@ -63,14 +69,14 @@ public class MaxChannelsTest extends InternalBrokerBaseCase
@Override
public void tearDown() throws Exception
{
- try {
- _session.closeSession();
- } catch (AMQException e) {
- // Yikes
- fail(e.getMessage());
- }
+ try
+ {
+ _session.getVirtualHost().close();
+ _session.closeSession();
+ }
finally
{
+ BrokerTestHelper.tearDown();
super.tearDown();
}
}