You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by gs...@apache.org on 2008/02/19 17:02:28 UTC
svn commit: r629137 [1/3] - in /incubator/qpid/branches/M2.1:
cpp/gen/Makefile.am cpp/lib/broker/SessionHandlerImpl.cpp
cpp/lib/broker/SessionHandlerImpl.h cpp/tests/run-python-tests
python/tests/unbind.py specs/amqp.0-9.no-wip.xml
Author: gsim
Date: Tue Feb 19 08:02:25 2008
New Revision: 629137
URL: http://svn.apache.org/viewvc?rev=629137&view=rev
Log:
Moved c++ to 0-9, based on a spec file with all the WIP stuff removed manually to avoid having to tinker with generator to exclude it.
Added:
incubator/qpid/branches/M2.1/python/tests/unbind.py (with props)
incubator/qpid/branches/M2.1/specs/amqp.0-9.no-wip.xml (with props)
Modified:
incubator/qpid/branches/M2.1/cpp/gen/Makefile.am
incubator/qpid/branches/M2.1/cpp/lib/broker/SessionHandlerImpl.cpp
incubator/qpid/branches/M2.1/cpp/lib/broker/SessionHandlerImpl.h
incubator/qpid/branches/M2.1/cpp/tests/run-python-tests
Modified: incubator/qpid/branches/M2.1/cpp/gen/Makefile.am
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2.1/cpp/gen/Makefile.am?rev=629137&r1=629136&r2=629137&view=diff
==============================================================================
--- incubator/qpid/branches/M2.1/cpp/gen/Makefile.am (original)
+++ incubator/qpid/branches/M2.1/cpp/gen/Makefile.am Tue Feb 19 08:02:25 2008
@@ -35,7 +35,7 @@
gentools_dir = $(srcdir)/../../gentools
spec_dir = $(srcdir)/../../specs
-spec = $(spec_dir)/amqp.0-8.xml
+spec = $(spec_dir)/amqp.0-9.no-wip.xml
gentools_srcdir = $(gentools_dir)/src/org/apache/qpid/gentools
gentools_libs = $(gentools_dir)/lib/velocity-1.4.jar:$(gentools_dir)/lib/velocity-dep-1.4.jar
@@ -45,8 +45,6 @@
$(JAVAC) -cp $(gentools_libs) -sourcepath $(gentools_srcdir) -d $(gentools_dir)/src $(gentools_srcdir)/*.java
$(JAVA) -cp $(gentools_dir)/src:$(gentools_libs) org.apache.qpid.gentools.Main \
-c -o . -t $(gentools_dir)/templ.cpp $(spec)
- echo $(JAVA) -cp $(gentools_dir)/src:$(gentools_libs) org.apache.qpid.gentools.Main \
- -c -o . -t $(gentools_dir)/templ.cpp $(spec) >> debug
touch timestamp
gen-src.mk: timestamp
Modified: incubator/qpid/branches/M2.1/cpp/lib/broker/SessionHandlerImpl.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2.1/cpp/lib/broker/SessionHandlerImpl.cpp?rev=629137&r1=629136&r2=629137&view=diff
==============================================================================
--- incubator/qpid/branches/M2.1/cpp/lib/broker/SessionHandlerImpl.cpp (original)
+++ incubator/qpid/branches/M2.1/cpp/lib/broker/SessionHandlerImpl.cpp Tue Feb 19 08:02:25 2008
@@ -223,7 +223,7 @@
if (parent->channels[channel] == 0) {
parent->channels[channel] = new Channel(parent->client->getProtocolVersion() , parent->context, channel, parent->framemax,
parent->queues->getStore(), parent->settings.stagingThreshold);
- parent->client->getChannel().openOk(channel);
+ parent->client->getChannel().openOk(channel, "");
} else {
std::stringstream out;
out << "Channel already open: " << channel;
@@ -337,6 +337,25 @@
}
}
+
+void SessionHandlerImpl::QueueHandlerImpl::unbind(u_int16_t channel,
+ u_int16_t /*ticket*/,
+ const string& queueName,
+ const string& exchangeName,
+ const string& routingKey,
+ const FieldTable& arguments)
+{
+ Queue::shared_ptr queue = parent->getQueue(queueName, channel);
+ Exchange::shared_ptr exchange = parent->exchanges->get(exchangeName);
+ if(exchange){
+ exchange->unbind(queue, routingKey, &arguments);
+ }else{
+ throw ChannelException(404, "Unbind failed. No such exchange: " + exchangeName);
+ }
+
+ parent->client->getQueue().unbindOk(channel);
+}
+
void SessionHandlerImpl::QueueHandlerImpl::purge(u_int16_t channel, u_int16_t /*ticket*/, const string& queueName, bool nowait){
Queue::shared_ptr queue = parent->getQueue(queueName, channel);
@@ -446,7 +465,11 @@
void SessionHandlerImpl::BasicHandlerImpl::recover(u_int16_t channel, bool requeue){
parent->getChannel(channel)->recover(requeue);
- parent->client->getBasic().recoverOk(channel);
+}
+
+void SessionHandlerImpl::BasicHandlerImpl::recoverSync(u_int16_t channel, bool requeue){
+ parent->getChannel(channel)->recover(requeue);
+ parent->client->getBasic().recoverSyncOk(channel);
}
void SessionHandlerImpl::TxHandlerImpl::select(u_int16_t channel){
Modified: incubator/qpid/branches/M2.1/cpp/lib/broker/SessionHandlerImpl.h
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2.1/cpp/lib/broker/SessionHandlerImpl.h?rev=629137&r1=629136&r2=629137&view=diff
==============================================================================
--- incubator/qpid/branches/M2.1/cpp/lib/broker/SessionHandlerImpl.h (original)
+++ incubator/qpid/branches/M2.1/cpp/lib/broker/SessionHandlerImpl.h Tue Feb 19 08:02:25 2008
@@ -162,7 +162,7 @@
u_int16_t classId, u_int16_t methodId);
virtual void closeOk(u_int16_t channel);
-
+
virtual ~ChannelHandlerImpl(){}
};
@@ -200,6 +200,13 @@
const string& exchange, const string& routingKey, bool nowait,
const qpid::framing::FieldTable& arguments);
+ virtual void unbind(u_int16_t channel,
+ u_int16_t ticket,
+ const string& queue,
+ const string& exchange,
+ const string& routingKey,
+ const framing::FieldTable& arguments);
+
virtual void purge(u_int16_t channel, u_int16_t ticket, const string& queue,
bool nowait);
@@ -235,6 +242,8 @@
virtual void reject(u_int16_t channel, u_int64_t deliveryTag, bool requeue);
virtual void recover(u_int16_t channel, bool requeue);
+
+ virtual void recoverSync(u_int16_t channel, bool requeue);
virtual ~BasicHandlerImpl(){}
};
@@ -262,10 +271,6 @@
inline virtual StreamHandler* getStreamHandler(){ throw ConnectionException(540, "Stream class not implemented"); }
inline virtual DtxHandler* getDtxHandler(){ throw ConnectionException(540, "Dtx class not implemented"); }
inline virtual TunnelHandler* getTunnelHandler(){ throw ConnectionException(540, "Tunnel class not implemented"); }
-
- // Temporary add-in to resolve version conflicts: AMQP v8.0 still defines class Test;
- // however v0.9 will not - kpvdr 2006-11-17
- inline virtual TestHandler* getTestHandler(){ throw ConnectionException(540, "Test class not implemented"); }
};
}
Modified: incubator/qpid/branches/M2.1/cpp/tests/run-python-tests
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2.1/cpp/tests/run-python-tests?rev=629137&r1=629136&r2=629137&view=diff
==============================================================================
--- incubator/qpid/branches/M2.1/cpp/tests/run-python-tests (original)
+++ incubator/qpid/branches/M2.1/cpp/tests/run-python-tests Tue Feb 19 08:02:25 2008
@@ -41,7 +41,7 @@
# Run the tests.
( cd $abs_srcdir/../../python \
- && python ./run-tests -v -I cpp_failing.txt ) || fail=1
+ && python ./run-tests -v -I cpp_failing.txt -s ../specs/amqp.0-9.no-wip.xml ) || fail=1
kill $pid || { echo FAIL: process already died; cat log; fail=1; }
Added: incubator/qpid/branches/M2.1/python/tests/unbind.py
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2.1/python/tests/unbind.py?rev=629137&view=auto
==============================================================================
--- incubator/qpid/branches/M2.1/python/tests/unbind.py (added)
+++ incubator/qpid/branches/M2.1/python/tests/unbind.py Tue Feb 19 08:02:25 2008
@@ -0,0 +1,76 @@
+#
+# 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.
+#
+from qpid.client import Client, Closed
+from qpid.queue import Empty
+from qpid.content import Content
+from qpid.testlib import testrunner, TestBase
+
+class UnbindTests(TestBase):
+ """Tests for the unbind method introduced in 0-9"""
+ def test_unbind_direct(self):
+ self.unbind_test(exchange="amq.direct", routing_key="key")
+
+ def test_unbind_topic(self):
+ self.unbind_test(exchange="amq.topic", routing_key="key")
+
+ def test_unbind_fanout(self):
+ self.unbind_test(exchange="amq.fanout")
+
+ def test_unbind_headers(self):
+ self.unbind_test(exchange="amq.match", args={ "x-match":"all", "a":"b"}, headers={"a":"b"})
+
+ def unbind_test(self, exchange, routing_key="", args={}, headers={}):
+ #bind two queues and consume from them
+ channel = self.channel
+
+ self.queue_declare(queue="queue-1")
+ self.queue_declare(queue="queue-2")
+
+ channel.basic_consume(queue="queue-1", consumer_tag="queue-1", no_ack=True)
+ channel.basic_consume(queue="queue-2", consumer_tag="queue-2", no_ack=True)
+
+ queue1 = self.client.queue("queue-1")
+ queue2 = self.client.queue("queue-2")
+
+ channel.queue_bind(exchange=exchange, queue="queue-1", routing_key=routing_key, arguments=args)
+ channel.queue_bind(exchange=exchange, queue="queue-2", routing_key=routing_key, arguments=args)
+
+ #send a message that will match both bindings
+ channel.basic_publish(exchange=exchange, routing_key=routing_key, content=Content("one", properties={'headers':headers}))
+
+ #unbind first queue
+ channel.queue_unbind(exchange=exchange, queue="queue-1", routing_key=routing_key, arguments=args)
+
+ #send another message
+ channel.basic_publish(exchange=exchange, routing_key=routing_key, content=Content("two", properties={'headers':headers}))
+
+ #check one queue has both messages and the other has only one
+ self.assertEquals("one", queue1.get(timeout=1).content.body)
+ try:
+ msg = queue1.get(timeout=1)
+ self.fail("Got extra message: %s" % msg.content.body)
+ except Empty: pass
+
+ self.assertEquals("one", queue2.get(timeout=1).content.body)
+ self.assertEquals("two", queue2.get(timeout=1).content.body)
+ try:
+ msg = queue2.get(timeout=1)
+ self.fail("Got extra message: " + msg)
+ except Empty: pass
+
Propchange: incubator/qpid/branches/M2.1/python/tests/unbind.py
------------------------------------------------------------------------------
svn:eol-style = native