summaryrefslogtreecommitdiff
path: root/qpid/tests/src/py
diff options
context:
space:
mode:
authorGordon Sim <gsim@apache.org>2013-07-16 10:50:43 +0000
committerGordon Sim <gsim@apache.org>2013-07-16 10:50:43 +0000
commit156e666579700160b56331c89c8216e278fed90f (patch)
tree5fd77e11c9165f2c619501d5274ec2b379f106b8 /qpid/tests/src/py
parent42b37635a7b0252c7cdaae11b431d8d3c67cbae9 (diff)
downloadqpid-python-156e666579700160b56331c89c8216e278fed90f.tar.gz
QPID-4988: Add test runs using swigged python client
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1503652 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/tests/src/py')
-rw-r--r--qpid/tests/src/py/qpid_tests/broker_0_10/lvq.py5
-rw-r--r--qpid/tests/src/py/qpid_tests/broker_0_10/new_api.py3
-rw-r--r--qpid/tests/src/py/qpid_tests/broker_0_10/priority.py2
-rw-r--r--qpid/tests/src/py/qpid_tests/broker_0_10/stats.py3
-rw-r--r--qpid/tests/src/py/qpid_tests/broker_1_0/__init__.py24
-rw-r--r--qpid/tests/src/py/qpid_tests/broker_1_0/general.py52
-rw-r--r--qpid/tests/src/py/qpid_tests/broker_1_0/legacy_exchanges.py101
-rw-r--r--qpid/tests/src/py/qpid_tests/broker_1_0/selector.py79
8 files changed, 261 insertions, 8 deletions
diff --git a/qpid/tests/src/py/qpid_tests/broker_0_10/lvq.py b/qpid/tests/src/py/qpid_tests/broker_0_10/lvq.py
index 8fd6b88d78..476b6ee052 100644
--- a/qpid/tests/src/py/qpid_tests/broker_0_10/lvq.py
+++ b/qpid/tests/src/py/qpid_tests/broker_0_10/lvq.py
@@ -17,7 +17,7 @@
# under the License.
#
-from qpid.messaging import *
+from qpid.tests.messaging.implementation import *
from qpid.tests.messaging import Base
import math
@@ -61,8 +61,7 @@ class LVQTests (Base):
def create_message(key, content):
- msg = Message(content=content)
- msg.properties["lvq-key"] = key
+ msg = Message(content=content, properties={"lvq-key":key})
return msg
def fetch_all(rcv):
diff --git a/qpid/tests/src/py/qpid_tests/broker_0_10/new_api.py b/qpid/tests/src/py/qpid_tests/broker_0_10/new_api.py
index c4a47029b9..ad0c32dac7 100644
--- a/qpid/tests/src/py/qpid_tests/broker_0_10/new_api.py
+++ b/qpid/tests/src/py/qpid_tests/broker_0_10/new_api.py
@@ -17,9 +17,8 @@
# under the License.
#
-from qpid.messaging import *
+from qpid.tests.messaging.implementation import *
from qpid.tests.messaging import Base
-import qmf.console
from time import sleep
#
diff --git a/qpid/tests/src/py/qpid_tests/broker_0_10/priority.py b/qpid/tests/src/py/qpid_tests/broker_0_10/priority.py
index bf4f1209b1..47aae6dfd6 100644
--- a/qpid/tests/src/py/qpid_tests/broker_0_10/priority.py
+++ b/qpid/tests/src/py/qpid_tests/broker_0_10/priority.py
@@ -17,7 +17,7 @@
# under the License.
#
-from qpid.messaging import *
+from qpid.tests.messaging.implementation import *
from qpid.tests.messaging import Base
from qpid.compat import set
import math
diff --git a/qpid/tests/src/py/qpid_tests/broker_0_10/stats.py b/qpid/tests/src/py/qpid_tests/broker_0_10/stats.py
index d36cc79acc..353f3631eb 100644
--- a/qpid/tests/src/py/qpid_tests/broker_0_10/stats.py
+++ b/qpid/tests/src/py/qpid_tests/broker_0_10/stats.py
@@ -17,9 +17,8 @@
# under the License.
#
-from qpid.messaging import *
+from qpid.tests.messaging.implementation import *
from qpid.tests.messaging import Base
-import qmf.console
from time import sleep
from qpidtoollibs.broker import BrokerAgent
diff --git a/qpid/tests/src/py/qpid_tests/broker_1_0/__init__.py b/qpid/tests/src/py/qpid_tests/broker_1_0/__init__.py
new file mode 100644
index 0000000000..8088ddd95f
--- /dev/null
+++ b/qpid/tests/src/py/qpid_tests/broker_1_0/__init__.py
@@ -0,0 +1,24 @@
+# Do not delete - marks this directory as a python package.
+
+#
+# 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 legacy_exchanges import *
+from selector import *
+from general import *
diff --git a/qpid/tests/src/py/qpid_tests/broker_1_0/general.py b/qpid/tests/src/py/qpid_tests/broker_1_0/general.py
new file mode 100644
index 0000000000..085acf8405
--- /dev/null
+++ b/qpid/tests/src/py/qpid_tests/broker_1_0/general.py
@@ -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.
+#
+
+from qpid.tests.messaging.implementation import *
+from qpid.tests.messaging import Base
+
+class GeneralTests (Base):
+ """
+ Miscellaneous tests for core AMQP 1.0 messaging behaviour.
+ """
+ def setup_connection(self):
+ return Connection.establish(self.broker, **self.connection_options())
+
+ def setup_session(self):
+ return self.conn.session()
+
+ def test_request_response(self):
+ snd_request = self.ssn.sender("#")
+ rcv_response = self.ssn.receiver("#")
+
+ #send request
+ snd_request.send(Message(reply_to=rcv_response.source, id="a1", content="request"))
+
+ #receive request
+ rcv_request = self.ssn.receiver(snd_request.target)
+ request = rcv_request.fetch(5)
+ assert request.content == "request" and request.id == "a1", request
+ #send response
+ snd_response = self.ssn.sender(request.reply_to)
+ snd_response.send(Message(correlation_id=request.id, content="response"))
+
+ #receive response
+ response = rcv_response.fetch(5)
+ assert response.content == "response" and response.correlation_id == "a1", response
+
+ self.ssn.acknowledge()
diff --git a/qpid/tests/src/py/qpid_tests/broker_1_0/legacy_exchanges.py b/qpid/tests/src/py/qpid_tests/broker_1_0/legacy_exchanges.py
new file mode 100644
index 0000000000..d2b8c643bd
--- /dev/null
+++ b/qpid/tests/src/py/qpid_tests/broker_1_0/legacy_exchanges.py
@@ -0,0 +1,101 @@
+#
+# 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.tests.messaging.implementation import *
+from qpid.tests.messaging import Base
+
+class LegacyExchangeTests (Base):
+ """
+ Tests for the legacy (i.e. pre 1.0) AMQP exchanges and the filters
+ defined for them and registered for AMQP 1.0.
+ """
+ def setup_connection(self):
+ return Connection.establish(self.broker, **self.connection_options())
+
+ def setup_session(self):
+ return self.conn.session()
+
+ def test_fanout(self):
+ msgs = [Message(content=s, subject = s) for s in ['a','b','c','d']]
+
+ snd = self.ssn.sender("amq.fanout")
+ rcv = self.ssn.receiver("amq.fanout")
+
+ for m in msgs: snd.send(m)
+
+ for expected in msgs:
+ msg = rcv.fetch(0)
+ assert msg.content == expected.content
+ self.ssn.acknowledge(msg)
+
+ def test_direct(self):
+ msgs = [Message(content=c, subject=s) for s, c in [('a', 'one'), ('b', 'two'),('a', 'three'),('b', 'four')]]
+
+ snd = self.ssn.sender("amq.direct")
+ rcv_a = self.ssn.receiver("amq.direct/a")
+ rcv_b = self.ssn.receiver("amq.direct/b")
+
+ for m in msgs: snd.send(m)
+
+ for expected in ['one', 'three']:
+ msg = rcv_a.fetch(0)
+ assert msg.content == expected, (msg, expected)
+ self.ssn.acknowledge(msg)
+
+ for expected in ['two', 'four']:
+ msg = rcv_b.fetch(0)
+ assert msg.content == expected
+ self.ssn.acknowledge(msg), (msg, expected)
+
+ def test_topic(self):
+ msgs = [Message(content=s, subject=s) for s in ['red.dog', 'black.cat', 'red.squirrel', 'grey.squirrel']]
+
+ snd = self.ssn.sender("amq.topic")
+ rcv_a = self.ssn.receiver("amq.topic/red.*")
+ rcv_b = self.ssn.receiver("amq.topic/*.squirrel")
+
+ for m in msgs: snd.send(m)
+
+ for expected in ['red.dog', 'red.squirrel']:
+ msg = rcv_a.fetch(0)
+ assert msg.content == expected, (msg, expected)
+ self.ssn.acknowledge(msg)
+
+ for expected in ['red.squirrel', 'grey.squirrel']:
+ msg = rcv_b.fetch(0)
+ assert msg.content == expected
+ self.ssn.acknowledge(msg), (msg, expected)
+
+ def test_headers(self):
+ msgs = [Message(content="%s.%s" % (colour, creature), properties={'creature':creature,'colour':colour}) for colour, creature in [('red','dog'), ('black', 'cat'), ('red', 'squirrel'), ('grey', 'squirrel')]]
+
+ snd = self.ssn.sender("amq.match")
+ rcv_a = self.ssn.receiver("amq.match; {link:{filter:{descriptor:'apache.org:legacy-amqp-headers-binding:map',name:'red-things',value:{'colour':'red','x-match':'all'}}}}")
+ rcv_b = self.ssn.receiver("amq.match; {link:{filter:{descriptor:'apache.org:legacy-amqp-headers-binding:map',name:'cats-and-squirrels',value:{'creature':'squirrel','colour':'black','x-match':'any'}}}}")
+ for m in msgs: snd.send(m)
+
+ for expected in ['red.dog', 'red.squirrel']:
+ msg = rcv_a.fetch(0)
+ assert msg.content == expected, (msg, expected)
+ self.ssn.acknowledge(msg)
+
+ for expected in ['black.cat', 'red.squirrel', 'grey.squirrel']:
+ msg = rcv_b.fetch(0)
+ assert msg.content == expected
+ self.ssn.acknowledge(msg), (msg, expected)
diff --git a/qpid/tests/src/py/qpid_tests/broker_1_0/selector.py b/qpid/tests/src/py/qpid_tests/broker_1_0/selector.py
new file mode 100644
index 0000000000..2e956cecb6
--- /dev/null
+++ b/qpid/tests/src/py/qpid_tests/broker_1_0/selector.py
@@ -0,0 +1,79 @@
+#
+# 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.tests.messaging.implementation import *
+from qpid.tests.messaging import Base
+
+class SelectorTests (Base):
+ """
+ Tests for the selector filter registered for AMQP 1.0 under the
+ apache namespace.
+ """
+ def setup_connection(self):
+ return Connection.establish(self.broker, **self.connection_options())
+
+ def setup_session(self):
+ return self.conn.session()
+
+ def basic_selection_test(self, node):
+ properties = [(1, 'red','dog'), (2, 'black', 'cat'), (3, 'red', 'squirrel'), (4, 'grey', 'squirrel')]
+ msgs = [Message(content="%s.%s" % (colour, creature), properties={'sequence':sequence,'colour':colour}) for sequence, colour, creature in properties]
+
+ snd = self.ssn.sender(node)
+ rcv = self.ssn.receiver("%s; {link:{selector:\"colour IN ('red', 'grey') AND (sequence > 3 OR sequence = 1)\"}}" % snd.target)
+
+ for m in msgs: snd.send(m)
+
+ for expected in ["red.dog", "grey.squirrel"]:
+ msg = rcv.fetch(0)
+ assert msg.content == expected
+ self.ssn.acknowledge(msg)
+
+ def test_topic(self):
+ self.basic_selection_test(self.config.defines.get("topic_name", "amq.fanout"))
+
+ def test_queue(self):
+ self.basic_selection_test("#")
+
+ def test_special_fields(self):
+ msgs = [Message(content=i, id=i, correlation_id=i, priority=p) for p, i in enumerate(['a', 'b', 'c', 'd'], 1)]
+
+ snd = self.ssn.sender("#")
+ rcv_1 = self.ssn.receiver("%s; {link:{selector:\"amqp.message_id = 'c'\"}}" % snd.target)
+ rcv_2 = self.ssn.receiver("%s; {link:{selector:\"amqp.correlation_id = 'b'\"}}" % snd.target)
+ rcv_3 = self.ssn.receiver("%s; {link:{selector:\"amqp.priority = 1\"}}" % snd.target)
+
+ for m in msgs: snd.send(m)
+
+ msg = rcv_1.fetch(0)
+ assert msg.content == 'c', msg
+ self.ssn.acknowledge(msg)
+
+ msg = rcv_2.fetch(0)
+ assert msg.content == 'b', msg
+ self.ssn.acknowledge(msg)
+
+ msg = rcv_3.fetch(0)
+ assert msg.content == 'a', msg
+ self.ssn.acknowledge(msg)
+
+ rcv_4 = self.ssn.receiver(snd.target)
+ msg = rcv_4.fetch(0)
+ assert msg.content == 'd'
+ self.ssn.acknowledge(msg)