summaryrefslogtreecommitdiff
path: root/qpid/java/broker/src/test
diff options
context:
space:
mode:
authorKeith Wall <kwall@apache.org>2012-03-19 14:00:37 +0000
committerKeith Wall <kwall@apache.org>2012-03-19 14:00:37 +0000
commite9a23033bb075f50b0a46c9366012e30538a4e54 (patch)
treeca952b4b7109cea8ff7ca7896f708c525ec3410a /qpid/java/broker/src/test
parent617810d8db1359d81688be587908cebe77d3f559 (diff)
downloadqpid-python-e9a23033bb075f50b0a46c9366012e30538a4e54.tar.gz
QPID-3895: Remove blocked channel/session from the list of blocked channels on channel/session close
This patch adds the fllowing: - fixes AMQChannel to stop sending flow commands if channel is closing - fixes AMQChannel#compareTo ServerSession#compareTo - removes AMQSessionModel#getID() method from AMQChannel and Server session in order to avoid confusions Applied patch from Oleksandr Rudyy <orudyy@gmail.com>. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1302455 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/broker/src/test')
-rw-r--r--qpid/java/broker/src/test/java/org/apache/qpid/server/AMQChannelTest.java52
-rw-r--r--qpid/java/broker/src/test/java/org/apache/qpid/server/transport/ServerSessionTest.java67
2 files changed, 119 insertions, 0 deletions
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/AMQChannelTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/AMQChannelTest.java
new file mode 100644
index 0000000000..fc6cbcb248
--- /dev/null
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/AMQChannelTest.java
@@ -0,0 +1,52 @@
+/*
+ *
+ * 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.qpid.server;
+
+import org.apache.qpid.server.protocol.AMQProtocolSession;
+import org.apache.qpid.server.protocol.InternalTestProtocolSession;
+import org.apache.qpid.server.registry.ApplicationRegistry;
+import org.apache.qpid.server.util.InternalBrokerBaseCase;
+import org.apache.qpid.server.virtualhost.VirtualHost;
+
+public class AMQChannelTest extends InternalBrokerBaseCase
+{
+ private VirtualHost _virtualHost;
+ private AMQProtocolSession _protocolSession;
+
+ @Override
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ _virtualHost = ApplicationRegistry.getInstance().getVirtualHostRegistry().getVirtualHosts().iterator().next();
+ _protocolSession = new InternalTestProtocolSession(_virtualHost);
+ }
+
+ public void testCompareTo() throws Exception
+ {
+ AMQChannel channel1 = new AMQChannel(_protocolSession, 1, _virtualHost.getMessageStore());
+
+ // create a channel with the same channelId but on a different session
+ AMQChannel channel2 = new AMQChannel(new InternalTestProtocolSession(_virtualHost), 1, _virtualHost.getMessageStore());
+ assertFalse("Unexpected compare result", channel1.compareTo(channel2) == 0);
+ assertEquals("Unexpected compare result", 0, channel1.compareTo(channel1));
+ }
+
+}
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/transport/ServerSessionTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/transport/ServerSessionTest.java
new file mode 100644
index 0000000000..d775b0f2f8
--- /dev/null
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/transport/ServerSessionTest.java
@@ -0,0 +1,67 @@
+/*
+ *
+ * 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.qpid.server.transport;
+
+import java.util.UUID;
+
+import org.apache.qpid.server.configuration.MockConnectionConfig;
+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.transport.Binary;
+
+public class ServerSessionTest extends InternalBrokerBaseCase
+{
+
+ private VirtualHost _virtualHost;
+
+ @Override
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ _virtualHost = ApplicationRegistry.getInstance().getVirtualHostRegistry().getVirtualHosts().iterator().next();
+ }
+
+ public void testCompareTo() throws Exception
+ {
+ ServerConnection connection = new ServerConnection(1);
+ connection.setConnectionConfig(createConnectionConfig());
+ ServerSession session1 = new ServerSession(connection, new ServerSessionDelegate(),
+ new Binary(getName().getBytes()), 0 , connection.getConfig());
+
+ // create a session with the same name but on a different connection
+ ServerConnection connection2 = new ServerConnection(2);
+ connection2.setConnectionConfig(createConnectionConfig());
+ ServerSession session2 = new ServerSession(connection2, new ServerSessionDelegate(),
+ new Binary(getName().getBytes()), 0 , connection2.getConfig());
+
+ assertFalse("Unexpected compare result", session1.compareTo(session2) == 0);
+ assertEquals("Unexpected compare result", 0, session1.compareTo(session1));
+ }
+
+ private MockConnectionConfig createConnectionConfig()
+ {
+ return new MockConnectionConfig(UUID.randomUUID(), null, null,
+ false, 1, _virtualHost, "address", Boolean.TRUE, Boolean.TRUE, Boolean.TRUE,
+ "authid", "remoteProcessName", new Integer(1967), new Integer(1970), _virtualHost.getConfigStore(), Boolean.FALSE);
+ }
+
+}