You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ai...@apache.org on 2009/09/17 18:21:21 UTC
svn commit: r816261 [5/8] - in /qpid/branches/java-network-refactor: ./
qpid/cpp/bindings/qmf/python/ qpid/cpp/bindings/qmf/ruby/
qpid/cpp/bindings/qmf/tests/ qpid/cpp/include/qpid/messaging/ qpid/cpp/src/
qpid/cpp/src/qmf/ qpid/cpp/src/qpid/acl/ qpid/...
Modified: qpid/branches/java-network-refactor/qpid/cpp/src/tests/acl.py
URL: http://svn.apache.org/viewvc/qpid/branches/java-network-refactor/qpid/cpp/src/tests/acl.py?rev=816261&r1=816260&r2=816261&view=diff
==============================================================================
--- qpid/branches/java-network-refactor/qpid/cpp/src/tests/acl.py (original)
+++ qpid/branches/java-network-refactor/qpid/cpp/src/tests/acl.py Thu Sep 17 16:21:13 2009
@@ -61,7 +61,7 @@
# ACL general tests
#=====================================
- def test_deny_all(self):
+ def test_deny_mode(self):
"""
Test the deny all mode
"""
@@ -71,7 +71,9 @@
aclf.write('acl deny all all')
aclf.close()
- self.reload_acl()
+ result = self.reload_acl()
+ if (result.text.find("format error",0,len(result.text)) != -1):
+ self.fail(result)
session = self.get_session('bob','bob')
try:
@@ -87,7 +89,7 @@
except qpid.session.SessionException, e:
self.assertEqual(530,e.args[0].error_code)
- def test_allow_all(self):
+ def test_allow_mode(self):
"""
Test the allow all mode
"""
@@ -96,7 +98,9 @@
aclf.write('acl allow all all')
aclf.close()
- self.reload_acl()
+ result = self.reload_acl()
+ if (result.text.find("format error",0,len(result.text)) != -1):
+ self.fail(result)
session = self.get_session('bob','bob')
try:
@@ -124,7 +128,9 @@
aclf.write('acl allow all all')
aclf.close()
- self.reload_acl()
+ result = self.reload_acl()
+ if (result.text.find("format error",0,len(result.text)) != -1):
+ self.fail(result)
session = self.get_session('bob','bob')
try:
@@ -208,9 +214,9 @@
# ACL queue tests
#=====================================
- def test_queue_acl(self):
+ def test_queue_allow_mode(self):
"""
- Test various modes for queue acl
+ Test cases for queue acl in allow mode
"""
aclf = ACLFile()
aclf.write('acl deny bob@QPID create queue name=q1 durable=true passive=true\n')
@@ -221,27 +227,35 @@
aclf.write('acl allow all all')
aclf.close()
- self.reload_acl()
+ result = self.reload_acl()
+ if (result.text.find("format error",0,len(result.text)) != -1):
+ self.fail(result)
session = self.get_session('bob','bob')
try:
- session.queue_declare(queue="q1", durable='true', passive='true')
+ session.queue_declare(queue="q1", durable=True, passive=True)
self.fail("ACL should deny queue create request with name=q1 durable=true passive=true");
except qpid.session.SessionException, e:
self.assertEqual(530,e.args[0].error_code)
session = self.get_session('bob','bob')
try:
- session.queue_declare(queue="q2", exclusive='true')
+ session.queue_declare(queue="q2", exclusive=True)
self.fail("ACL should deny queue create request with name=q2 exclusive=true");
except qpid.session.SessionException, e:
self.assertEqual(530,e.args[0].error_code)
session = self.get_session('bob','bob')
try:
- session.queue_declare(queue="q3", exclusive='true')
- session.queue_declare(queue="q4", durable='true')
+ session.queue_declare(queue="q2", durable=True)
+ except qpid.session.SessionException, e:
+ if (530 == e.args[0].error_code):
+ self.fail("ACL should allow queue create request for q2 with any parameter other than exclusive=true");
+
+ try:
+ session.queue_declare(queue="q3", exclusive=True)
+ session.queue_declare(queue="q4", durable=True)
except qpid.session.SessionException, e:
if (530 == e.args[0].error_code):
self.fail("ACL should allow queue create request for q3 and q4 with any parameter");
@@ -279,57 +293,185 @@
if (530 == e.args[0].error_code):
self.fail("ACL should allow queue delete request for q3");
+
+ def test_queue_deny_mode(self):
+ """
+ Test cases for queue acl in deny mode
+ """
+ aclf = ACLFile()
+ aclf.write('acl allow bob@QPID create queue name=q1 durable=true passive=true\n')
+ aclf.write('acl allow bob@QPID create queue name=q2 exclusive=true\n')
+ aclf.write('acl allow bob@QPID access queue name=q3\n')
+ aclf.write('acl allow bob@QPID purge queue name=q3\n')
+ aclf.write('acl allow bob@QPID create queue name=q3\n')
+ aclf.write('acl allow bob@QPID create queue name=q4\n')
+ aclf.write('acl allow bob@QPID delete queue name=q4\n')
+ aclf.write('acl allow guest@QPID all all\n')
+ aclf.write('acl deny all all')
+ aclf.close()
+
+ result = self.reload_acl()
+ if (result.text.find("format error",0,len(result.text)) != -1):
+ self.fail(result)
+
+ session = self.get_session('bob','bob')
+
+ try:
+ session.queue_declare(queue="q1", durable=True, passive=True)
+ except qpid.session.SessionException, e:
+ if (530 == e.args[0].error_code):
+ self.fail("ACL should allow queue create request with name=q1 durable=true passive=true");
+
+ try:
+ session.queue_declare(queue="q1", durable=False, passive=False)
+ self.fail("ACL should deny queue create request with name=q1 durable=true passive=false");
+ except qpid.session.SessionException, e:
+ self.assertEqual(530,e.args[0].error_code)
+ session = self.get_session('bob','bob')
+
+ try:
+ session.queue_declare(queue="q2", exclusive=False)
+ self.fail("ACL should deny queue create request with name=q2 exclusive=false");
+ except qpid.session.SessionException, e:
+ self.assertEqual(530,e.args[0].error_code)
+ session = self.get_session('bob','bob')
+
+ try:
+ session.queue_declare(queue="q2", exclusive=True)
+ except qpid.session.SessionException, e:
+ if (530 == e.args[0].error_code):
+ self.fail("ACL should allow queue create request for q2 with exclusive=true");
+
+ try:
+ session.queue_declare(queue="q3")
+ session.queue_declare(queue="q4")
+ except qpid.session.SessionException, e:
+ if (530 == e.args[0].error_code):
+ self.fail("ACL should allow queue create request for q3 and q4");
+
+ try:
+ session.queue_query(queue="q4")
+ self.fail("ACL should deny queue query request for q4");
+ except qpid.session.SessionException, e:
+ self.assertEqual(530,e.args[0].error_code)
+ session = self.get_session('bob','bob')
+
+ try:
+ session.queue_purge(queue="q4")
+ self.fail("ACL should deny queue purge request for q4");
+ except qpid.session.SessionException, e:
+ self.assertEqual(530,e.args[0].error_code)
+ session = self.get_session('bob','bob')
+
+ try:
+ session.queue_purge(queue="q3")
+ except qpid.session.SessionException, e:
+ if (530 == e.args[0].error_code):
+ self.fail("ACL should allow queue purge request for q3");
+
+ try:
+ session.queue_query(queue="q3")
+ except qpid.session.SessionException, e:
+ if (530 == e.args[0].error_code):
+ self.fail("ACL should allow queue query request for q3");
+
+ try:
+ session.queue_delete(queue="q3")
+ self.fail("ACL should deny queue delete request for q3");
+ except qpid.session.SessionException, e:
+ self.assertEqual(530,e.args[0].error_code)
+ session = self.get_session('bob','bob')
+
+ try:
+ session.queue_delete(queue="q4")
+ except qpid.session.SessionException, e:
+ if (530 == e.args[0].error_code):
+ self.fail("ACL should allow queue delete request for q4");
+
#=====================================
# ACL exchange tests
#=====================================
- def test_exchange_acl(self):
+ def test_exchange_acl_allow_mode(self):
+ session = self.get_session('bob','bob')
+ session.queue_declare(queue="baz")
+
"""
- Test various modes for exchange acl
+ Test cases for exchange acl in allow mode
"""
aclf = ACLFile()
aclf.write('acl deny bob@QPID create exchange name=testEx durable=true passive=true\n')
aclf.write('acl deny bob@QPID create exchange name=ex1 type=direct\n')
- aclf.write('acl deny bob@QPID access exchange name=myEx\n')
+ aclf.write('acl deny bob@QPID access exchange name=myEx queuename=q1 routingkey=rk1.*\n')
aclf.write('acl deny bob@QPID bind exchange name=myEx queuename=q1 routingkey=rk1\n')
aclf.write('acl deny bob@QPID unbind exchange name=myEx queuename=q1 routingkey=rk1\n')
- aclf.write('acl deny bob@QPID delete exchange name=myEx\n')
+ aclf.write('acl deny bob@QPID delete exchange name=myEx\n')
aclf.write('acl allow all all')
aclf.close()
- self.reload_acl()
+ result = self.reload_acl()
+ if (result.text.find("format error",0,len(result.text)) != -1):
+ self.fail(result)
session = self.get_session('bob','bob')
-
+ session.queue_declare(queue='q1')
+ session.queue_declare(queue='q2')
+ session.exchange_declare(exchange='myEx', type='direct')
+
try:
- session.exchange_declare(exchange='testEx', durable='true', passive='true')
+ session.exchange_declare(exchange='testEx', durable=True, passive=True)
self.fail("ACL should deny exchange create request with name=testEx durable=true passive=true");
except qpid.session.SessionException, e:
self.assertEqual(530,e.args[0].error_code)
session = self.get_session('bob','bob')
try:
+ session.exchange_declare(exchange='testEx', type='direct', durable=True, passive=False)
+ except qpid.session.SessionException, e:
+ print e
+ if (530 == e.args[0].error_code):
+ self.fail("ACL should allow exchange create request for testEx with any parameter other than durable=true and passive=true");
+
+ try:
session.exchange_declare(exchange='ex1', type='direct')
self.fail("ACL should deny exchange create request with name=ex1 type=direct");
- except qpid.session.SessionException, e:
+ except qpid.session.SessionException, e:
self.assertEqual(530,e.args[0].error_code)
session = self.get_session('bob','bob')
try:
session.exchange_declare(exchange='myXml', type='direct')
- session.queue_declare(queue='q1')
except qpid.session.SessionException, e:
if (530 == e.args[0].error_code):
self.fail("ACL should allow exchange create request for myXml with any parameter");
try:
session.exchange_query(name='myEx')
- self.fail("ACL should deny queue query request for q3");
+ self.fail("ACL should deny exchange query request for myEx");
except qpid.session.SessionException, e:
self.assertEqual(530,e.args[0].error_code)
session = self.get_session('bob','bob')
+
+ try:
+ session.exchange_bound(exchange='myEx', queue='q1', binding_key='rk1.*')
+ self.fail("ACL should deny exchange bound request for myEx with queuename=q1 and routing_key='rk1.*' ");
+ except qpid.session.SessionException, e:
+ self.assertEqual(530,e.args[0].error_code)
+ session = self.get_session('bob','bob')
+
+ try:
+ session.exchange_query(name='amq.topic')
+ except qpid.session.SessionException, e:
+ if (530 == e.args[0].error_code):
+ self.fail("ACL should allow exchange query request for exchange='amq.topic'");
try:
+ session.exchange_bound(exchange='myEx', queue='q1', binding_key='rk2.*')
+ except qpid.session.SessionException, e:
+ if (530 == e.args[0].error_code):
+ self.fail("ACL should allow exchange bound request for myEx with queuename=q1 and binding_key='rk2.*'");
+
+ try:
session.exchange_bind(exchange='myEx', queue='q1', binding_key='rk1')
self.fail("ACL should deny exchange bind request with exchange='myEx' queuename='q1' bindingkey='rk1'");
except qpid.session.SessionException, e:
@@ -337,10 +479,17 @@
session = self.get_session('bob','bob')
try:
- session.exchange_bind(exchange='myXml', queue='q1', binding_key='x')
+ session.exchange_bind(exchange='myEx', queue='q1', binding_key='x')
+ except qpid.session.SessionException, e:
+ if (530 == e.args[0].error_code):
+ self.fail("ACL should allow exchange bind request for exchange='myEx', queue='q1', binding_key='x'");
+
+ try:
+ session.exchange_bind(exchange='myEx', queue='q2', binding_key='rk1')
except qpid.session.SessionException, e:
if (530 == e.args[0].error_code):
- self.fail("ACL should allow exchange bind request for exchange='myXml', queue='q1', binding_key='x'");
+ self.fail("ACL should allow exchange bind request for exchange='myEx', queue='q2', binding_key='rk1'");
+
try:
session.exchange_unbind(exchange='myEx', queue='q1', binding_key='rk1')
self.fail("ACL should deny exchange unbind request with exchange='myEx' queuename='q1' bindingkey='rk1'");
@@ -349,10 +498,16 @@
session = self.get_session('bob','bob')
try:
- session.exchange_unbind(exchange='myXml', queue='q1', binding_key='x')
+ session.exchange_unbind(exchange='myEx', queue='q1', binding_key='x')
+ except qpid.session.SessionException, e:
+ if (530 == e.args[0].error_code):
+ self.fail("ACL should allow exchange unbind request for exchange='myEx', queue='q1', binding_key='x'");
+
+ try:
+ session.exchange_unbind(exchange='myEx', queue='q2', binding_key='rk1')
except qpid.session.SessionException, e:
if (530 == e.args[0].error_code):
- self.fail("ACL should allow exchange unbind request for exchange='myXml', queue='q1', binding_key='x'");
+ self.fail("ACL should allow exchange unbind request for exchange='myEx', queue='q2', binding_key='rk1'");
try:
session.exchange_delete(exchange='myEx')
@@ -366,45 +521,161 @@
except qpid.session.SessionException, e:
if (530 == e.args[0].error_code):
self.fail("ACL should allow exchange delete request for myXml");
-
+
+
+ def test_exchange_acl_deny_mode(self):
+ session = self.get_session('bob','bob')
+ session.queue_declare(queue='bar')
+
+ """
+ Test cases for exchange acl in deny mode
+ """
+ aclf = ACLFile()
+ aclf.write('acl allow bob@QPID create exchange name=myEx durable=true passive=false\n')
+ aclf.write('acl allow bob@QPID bind exchange name=amq.topic queuename=bar routingkey=foo.*\n')
+ aclf.write('acl allow bob@QPID unbind exchange name=amq.topic queuename=bar routingkey=foo.*\n')
+ aclf.write('acl allow bob@QPID access exchange name=myEx queuename=q1 routingkey=rk1.*\n')
+ aclf.write('acl allow bob@QPID delete exchange name=myEx\n')
+ aclf.write('acl allow guest@QPID all all\n')
+ aclf.write('acl deny all all')
+ aclf.close()
+
+ result = self.reload_acl()
+ if (result.text.find("format error",0,len(result.text)) != -1):
+ self.fail(result)
+
+ session = self.get_session('bob','bob')
+
+ try:
+ session.exchange_declare(exchange='myEx', type='direct', durable=True, passive=False)
+ except qpid.session.SessionException, e:
+ if (530 == e.args[0].error_code):
+ self.fail("ACL should allow exchange create request for myEx with durable=true and passive=false");
+ try:
+ session.exchange_declare(exchange='myEx', type='direct', durable=False)
+ self.fail("ACL should deny exchange create request with name=myEx durable=false");
+ except qpid.session.SessionException, e:
+ self.assertEqual(530,e.args[0].error_code)
+ session = self.get_session('bob','bob')
+
+ try:
+ session.exchange_bind(exchange='amq.topic', queue='bar', binding_key='foo.bar')
+ except qpid.session.SessionException, e:
+ if (530 == e.args[0].error_code):
+ self.fail("ACL should allow exchange bind request for exchange='amq.topic', queue='bar', binding_key='foor.bar'");
+
+ try:
+ session.exchange_bind(exchange='amq.topic', queue='baz', binding_key='foo.bar')
+ self.fail("ACL should deny exchange bind request for exchange='amq.topic', queue='baz', binding_key='foo.bar'");
+ except qpid.session.SessionException, e:
+ self.assertEqual(530,e.args[0].error_code)
+ session = self.get_session('bob','bob')
+
+ try:
+ session.exchange_bind(exchange='amq.topic', queue='bar', binding_key='fooz.bar')
+ self.fail("ACL should deny exchange bind request for exchange='amq.topic', queue='bar', binding_key='fooz.bar'");
+ except qpid.session.SessionException, e:
+ self.assertEqual(530,e.args[0].error_code)
+ session = self.get_session('bob','bob')
+
+ try:
+ session.exchange_unbind(exchange='amq.topic', queue='bar', binding_key='foo.bar')
+ except qpid.session.SessionException, e:
+ if (530 == e.args[0].error_code):
+ self.fail("ACL should allow exchange unbind request for exchange='amq.topic', queue='bar', binding_key='foor.bar'");
+ try:
+ session.exchange_unbind(exchange='amq.topic', queue='baz', binding_key='foo.bar')
+ self.fail("ACL should deny exchange unbind request for exchange='amq.topic', queue='baz', binding_key='foo.bar'");
+ except qpid.session.SessionException, e:
+ self.assertEqual(530,e.args[0].error_code)
+ session = self.get_session('bob','bob')
+
+ try:
+ session.exchange_unbind(exchange='amq.topic', queue='bar', binding_key='fooz.bar')
+ self.fail("ACL should deny exchange unbind request for exchange='amq.topic', queue='bar', binding_key='fooz.bar'");
+ except qpid.session.SessionException, e:
+ self.assertEqual(530,e.args[0].error_code)
+ session = self.get_session('bob','bob')
+
+ try:
+ session.exchange_query(name='amq.topic')
+ self.fail("ACL should deny exchange query request for amq.topic");
+ except qpid.session.SessionException, e:
+ self.assertEqual(530,e.args[0].error_code)
+ session = self.get_session('bob','bob')
+
+ try:
+ session.exchange_bound(exchange='myEx', queue='q1', binding_key='rk2.*')
+ self.fail("ACL should deny exchange bound request for amq.topic with queuename=q1 and routing_key='rk2.*' ");
+ except qpid.session.SessionException, e:
+ self.assertEqual(530,e.args[0].error_code)
+ session = self.get_session('bob','bob')
+
+ try:
+ session.exchange_query(name='myEx')
+ except qpid.session.SessionException, e:
+ if (530 == e.args[0].error_code):
+ self.fail("ACL should allow exchange query request for exchange='myEx'");
+
+ try:
+ session.exchange_bound(exchange='myEx', queue='q1', binding_key='rk1.*')
+ except qpid.session.SessionException, e:
+ if (530 == e.args[0].error_code):
+ self.fail("ACL should allow exchange bound request for myEx with queuename=q1 and binding_key='rk1.*'");
+
+ try:
+ session.exchange_delete(exchange='myXml')
+ self.fail("ACL should deny exchange delete request for myXml");
+ except qpid.session.SessionException, e:
+ self.assertEqual(530,e.args[0].error_code)
+ session = self.get_session('bob','bob')
+
+ try:
+ session.exchange_delete(exchange='myEx')
+ except qpid.session.SessionException, e:
+ if (530 == e.args[0].error_code):
+ self.fail("ACL should allow exchange delete request for myEx");
+
#=====================================
# ACL consume tests
#=====================================
- def test_consume_acl(self):
+ def test_consume_allow_mode(self):
"""
- Test various consume acl
+ Test cases for consume in allow mode
"""
aclf = ACLFile()
- aclf.write('acl deny bob@QPID consume queue name=q1 durable=true\n')
- aclf.write('acl deny bob@QPID consume queue name=q2 exclusive=true\n')
+ aclf.write('acl deny bob@QPID consume queue name=q1\n')
+ aclf.write('acl deny bob@QPID consume queue name=q2\n')
aclf.write('acl allow all all')
aclf.close()
- self.reload_acl()
+ result = self.reload_acl()
+ if (result.text.find("format error",0,len(result.text)) != -1):
+ self.fail(result)
session = self.get_session('bob','bob')
try:
- session.queue_declare(queue='q1', durable='true')
- session.queue_declare(queue='q2', exclusive='true')
- session.queue_declare(queue='q3', durable='true')
+ session.queue_declare(queue='q1')
+ session.queue_declare(queue='q2')
+ session.queue_declare(queue='q3')
except qpid.session.SessionException, e:
if (530 == e.args[0].error_code):
self.fail("ACL should allow create queue request");
try:
session.message_subscribe(queue='q1', destination='myq1')
- self.fail("ACL should deny message subscriber request for queue='q1'");
+ self.fail("ACL should deny subscription for queue='q1'");
except qpid.session.SessionException, e:
self.assertEqual(530,e.args[0].error_code)
session = self.get_session('bob','bob')
try:
session.message_subscribe(queue='q2', destination='myq1')
- self.fail("ACL should deny message subscriber request for queue='q2'");
+ self.fail("ACL should deny subscription for queue='q2'");
except qpid.session.SessionException, e:
self.assertEqual(530,e.args[0].error_code)
session = self.get_session('bob','bob')
@@ -413,9 +684,51 @@
session.message_subscribe(queue='q3', destination='myq1')
except qpid.session.SessionException, e:
if (530 == e.args[0].error_code):
- self.fail("ACL should allow create message subscribe");
+ self.fail("ACL should allow subscription for q3");
+ def test_consume_deny_mode(self):
+ """
+ Test cases for consume in allow mode
+ """
+ aclf = ACLFile()
+ aclf.write('acl allow bob@QPID consume queue name=q1\n')
+ aclf.write('acl allow bob@QPID consume queue name=q2\n')
+ aclf.write('acl allow bob@QPID create queue\n')
+ aclf.write('acl allow guest@QPID all\n')
+ aclf.write('acl deny all all')
+ aclf.close()
+
+ result = self.reload_acl()
+ if (result.text.find("format error",0,len(result.text)) != -1):
+ self.fail(result)
+
+ session = self.get_session('bob','bob')
+
+
+ try:
+ session.queue_declare(queue='q1')
+ session.queue_declare(queue='q2')
+ session.queue_declare(queue='q3')
+ except qpid.session.SessionException, e:
+ if (530 == e.args[0].error_code):
+ self.fail("ACL should allow create queue request");
+
+ try:
+ session.message_subscribe(queue='q1', destination='myq1')
+ session.message_subscribe(queue='q2', destination='myq2')
+ except qpid.session.SessionException, e:
+ if (530 == e.args[0].error_code):
+ self.fail("ACL should allow subscription for q1 and q2");
+
+ try:
+ session.message_subscribe(queue='q3', destination='myq3')
+ self.fail("ACL should deny subscription for queue='q3'");
+ except qpid.session.SessionException, e:
+ self.assertEqual(530,e.args[0].error_code)
+ session = self.get_session('bob','bob')
+
+
#=====================================
# ACL publish tests
#=====================================
@@ -431,15 +744,11 @@
aclf.write('acl allow all all')
aclf.close()
- self.reload_acl()
+ result = self.reload_acl()
+ if (result.text.find("format error",0,len(result.text)) != -1):
+ self.fail(result)
session = self.get_session('bob','bob')
-
- try:
- session.exchange_declare(exchange='myEx', type='topic')
- except qpid.session.SessionException, e:
- if (530 == e.args[0].error_code):
- self.fail("ACL should allow exchange create request for myEx with any parameter");
props = session.delivery_properties(routing_key="rk1")
@@ -458,6 +767,7 @@
session = self.get_session('bob','bob')
try:
+ session.exchange_declare(exchange='myEx', type='direct', durable=False)
session.message_transfer(destination="myEx", message=Message(props,"Test"))
except qpid.session.SessionException, e:
if (530 == e.args[0].error_code):
Modified: qpid/branches/java-network-refactor/qpid/cpp/src/tests/client_test.cpp
URL: http://svn.apache.org/viewvc/qpid/branches/java-network-refactor/qpid/cpp/src/tests/client_test.cpp?rev=816261&r1=816260&r2=816261&view=diff
==============================================================================
--- qpid/branches/java-network-refactor/qpid/cpp/src/tests/client_test.cpp (original)
+++ qpid/branches/java-network-refactor/qpid/cpp/src/tests/client_test.cpp Thu Sep 17 16:21:13 2009
@@ -7,9 +7,9 @@
* 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
@@ -40,13 +40,16 @@
using namespace qpid::framing;
using std::string;
+namespace qpid {
+namespace tests {
+
struct Args : public TestOptions {
uint msgSize;
bool verbose;
Args() : TestOptions("Simple test of Qpid c++ client; sends and receives a single message."), msgSize(26)
{
- addOptions()
+ addOptions()
("size", optValue(msgSize, "N"), "message size")
("verbose", optValue(verbose), "print out some status messages");
}
@@ -58,7 +61,7 @@
{
if (size < chars.length()) {
return chars.substr(0, size);
- }
+ }
std::string data;
for (uint i = 0; i < (size / chars.length()); i++) {
data += chars;
@@ -78,6 +81,10 @@
std::cout << std::endl;
}
+}} // namespace qpid::tests
+
+using namespace qpid::tests;
+
int main(int argc, char** argv)
{
try {
@@ -92,7 +99,7 @@
//Create and open a session on the connection through which
//most functionality is exposed:
Session session = connection.newSession();
- if (opts.verbose) std::cout << "Opened session." << std::endl;
+ if (opts.verbose) std::cout << "Opened session." << std::endl;
//'declare' the exchange and the queue, which will create them
@@ -116,13 +123,13 @@
// Using the SubscriptionManager, get the message from the queue.
SubscriptionManager subs(session);
Message msgIn = subs.get("MyQueue");
- if (msgIn.getData() == msgOut.getData())
+ if (msgIn.getData() == msgOut.getData())
if (opts.verbose) std::cout << "Received the exepected message." << std::endl;
//close the session & connection
session.close();
if (opts.verbose) std::cout << "Closed session." << std::endl;
- connection.close();
+ connection.close();
if (opts.verbose) std::cout << "Closed connection." << std::endl;
return 0;
} catch(const std::exception& e) {
Modified: qpid/branches/java-network-refactor/qpid/cpp/src/tests/cluster_test.cpp
URL: http://svn.apache.org/viewvc/qpid/branches/java-network-refactor/qpid/cpp/src/tests/cluster_test.cpp?rev=816261&r1=816260&r2=816261&view=diff
==============================================================================
--- qpid/branches/java-network-refactor/qpid/cpp/src/tests/cluster_test.cpp (original)
+++ qpid/branches/java-network-refactor/qpid/cpp/src/tests/cluster_test.cpp Thu Sep 17 16:21:13 2009
@@ -59,8 +59,6 @@
ostream& operator<<(ostream& o, const std::set<T>& s) { return seqPrint(o, s); }
}
-QPID_AUTO_TEST_SUITE(cluster_test)
-
using namespace std;
using namespace qpid;
using namespace qpid::cluster;
@@ -70,6 +68,11 @@
using broker::Broker;
using boost::shared_ptr;
+namespace qpid {
+namespace tests {
+
+QPID_AUTO_TEST_SUITE(cluster_test)
+
bool durableFlag = std::getenv("STORE_LIB") != 0;
void prepareArgs(ClusterFixture::Args& args, const bool durableFlag = false) {
@@ -1098,3 +1101,5 @@
}
QPID_AUTO_TEST_SUITE_END()
+
+}} // namespace qpid::tests
Propchange: qpid/branches/java-network-refactor/qpid/cpp/src/tests/cluster_tests.py
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Sep 17 16:21:13 2009
@@ -1 +1 @@
-/incubator/qpid/trunk/qpid/cpp/src/tests/cluster_tests.py:520691-726139
+/incubator/qpid/trunk/qpid/cpp/src/tests/cluster_tests.py:443187-726139
Modified: qpid/branches/java-network-refactor/qpid/cpp/src/tests/consume.cpp
URL: http://svn.apache.org/viewvc/qpid/branches/java-network-refactor/qpid/cpp/src/tests/consume.cpp?rev=816261&r1=816260&r2=816261&view=diff
==============================================================================
--- qpid/branches/java-network-refactor/qpid/cpp/src/tests/consume.cpp (original)
+++ qpid/branches/java-network-refactor/qpid/cpp/src/tests/consume.cpp Thu Sep 17 16:21:13 2009
@@ -7,9 +7,9 @@
* 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
@@ -36,6 +36,9 @@
using namespace qpid::sys;
using namespace std;
+namespace qpid {
+namespace tests {
+
typedef vector<string> StringSet;
struct Args : public qpid::TestOptions {
@@ -46,7 +49,7 @@
bool summary;
bool print;
bool durable;
-
+
Args() : count(1000), ack(0), queue("publish-consume"),
declare(false), summary(false), print(false)
{
@@ -63,12 +66,12 @@
Args opts;
-struct Client
+struct Client
{
Connection connection;
Session session;
- Client()
+ Client()
{
opts.open(connection);
session = connection.newSession();
@@ -85,7 +88,7 @@
settings.flowControl = FlowControl(opts.count, SubscriptionManager::UNLIMITED,false);
Subscription sub = subs.subscribe(lq, opts.queue, settings);
Message msg;
- AbsTime begin=now();
+ AbsTime begin=now();
for (size_t i = 0; i < opts.count; ++i) {
msg=lq.pop();
QPID_LOG(info, "Received: " << msg.getMessageProperties().getCorrelationId());
@@ -99,7 +102,7 @@
else cout << "Time: " << secs << "s Rate: " << opts.count/secs << endl;
}
- ~Client()
+ ~Client()
{
try{
session.close();
@@ -110,6 +113,10 @@
}
};
+}} // namespace qpid::tests
+
+using namespace qpid::tests;
+
int main(int argc, char** argv)
{
try {
Modified: qpid/branches/java-network-refactor/qpid/cpp/src/tests/datagen.cpp
URL: http://svn.apache.org/viewvc/qpid/branches/java-network-refactor/qpid/cpp/src/tests/datagen.cpp?rev=816261&r1=816260&r2=816261&view=diff
==============================================================================
--- qpid/branches/java-network-refactor/qpid/cpp/src/tests/datagen.cpp (original)
+++ qpid/branches/java-network-refactor/qpid/cpp/src/tests/datagen.cpp Thu Sep 17 16:21:13 2009
@@ -7,9 +7,9 @@
* 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
@@ -25,7 +25,10 @@
#include <time.h>
#include "qpid/Options.h"
-struct Args : public qpid::Options
+namespace qpid {
+namespace tests {
+
+struct Args : public qpid::Options
{
uint count;
uint minSize;
@@ -34,12 +37,12 @@
uint maxChar;
bool help;
- Args() : qpid::Options("Random data generator"),
- count(1), minSize(8), maxSize(4096),
+ Args() : qpid::Options("Random data generator"),
+ count(1), minSize(8), maxSize(4096),
minChar(32), maxChar(126),//safely printable ascii chars
help(false)
{
- addOptions()
+ addOptions()
("count", qpid::optValue(count, "N"), "number of data strings to generate")
("min-size", qpid::optValue(minSize, "N"), "minimum size of data string")
("max-size", qpid::optValue(maxSize, "N"), "maximum size of data string")
@@ -81,6 +84,10 @@
return data;
}
+}} // namespace qpid::tests
+
+using namespace qpid::tests;
+
int main(int argc, char** argv)
{
Args opts;
Modified: qpid/branches/java-network-refactor/qpid/cpp/src/tests/echotest.cpp
URL: http://svn.apache.org/viewvc/qpid/branches/java-network-refactor/qpid/cpp/src/tests/echotest.cpp?rev=816261&r1=816260&r2=816261&view=diff
==============================================================================
--- qpid/branches/java-network-refactor/qpid/cpp/src/tests/echotest.cpp (original)
+++ qpid/branches/java-network-refactor/qpid/cpp/src/tests/echotest.cpp Thu Sep 17 16:21:13 2009
@@ -7,9 +7,9 @@
* 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
@@ -33,6 +33,9 @@
using namespace qpid::sys;
using namespace std;
+namespace qpid {
+namespace tests {
+
struct Args : public qpid::Options,
public qpid::client::ConnectionSettings
{
@@ -48,7 +51,7 @@
("help", optValue(help), "Print this usage statement")
("count", optValue(count, "N"), "Number of messages to send")
("size", optValue(count, "N"), "Size of messages")
- ("broker,b", optValue(host, "HOST"), "Broker host to connect to")
+ ("broker,b", optValue(host, "HOST"), "Broker host to connect to")
("port,p", optValue(port, "PORT"), "Broker port to connect to")
("username", optValue(username, "USER"), "user name for broker log in.")
("password", optValue(password, "PASSWORD"), "password for broker log in.")
@@ -75,7 +78,7 @@
Message request;
double total, min, max;
bool summary;
-
+
public:
Listener(Session& session, uint limit, bool summary);
void start(uint size);
@@ -92,7 +95,7 @@
{
session.queueDeclare(arg::queue=queue, arg::exclusive=true, arg::autoDelete=true);
request.getDeliveryProperties().setRoutingKey(queue);
- subscriptions.subscribe(*this, queue, SubscriptionSettings(FlowControl::unlimited(), ACCEPT_MODE_NONE));
+ subscriptions.subscribe(*this, queue, SubscriptionSettings(FlowControl::unlimited(), ACCEPT_MODE_NONE));
request.getDeliveryProperties().setTimestamp(current_time());
if (size) request.setData(std::string(size, 'X'));
@@ -100,7 +103,7 @@
subscriptions.run();
}
-void Listener::received(Message& response)
+void Listener::received(Message& response)
{
//extract timestamp and compute latency:
uint64_t sentAt = response.getDeliveryProperties().getTimestamp();
@@ -122,7 +125,11 @@
}
}
-int main(int argc, char** argv)
+}} // namespace qpid::tests
+
+using namespace qpid::tests;
+
+int main(int argc, char** argv)
{
Args opts;
opts.parse(argc, argv);
Modified: qpid/branches/java-network-refactor/qpid/cpp/src/tests/exception_test.cpp
URL: http://svn.apache.org/viewvc/qpid/branches/java-network-refactor/qpid/cpp/src/tests/exception_test.cpp?rev=816261&r1=816260&r2=816261&view=diff
==============================================================================
--- qpid/branches/java-network-refactor/qpid/cpp/src/tests/exception_test.cpp (original)
+++ qpid/branches/java-network-refactor/qpid/cpp/src/tests/exception_test.cpp Thu Sep 17 16:21:13 2009
@@ -7,9 +7,9 @@
* 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
@@ -28,6 +28,9 @@
#include "qpid/sys/Thread.h"
#include "qpid/framing/reply_exceptions.h"
+namespace qpid {
+namespace tests {
+
QPID_AUTO_TEST_SUITE(exception_test)
// FIXME aconway 2008-06-12: need to update our exception handling to
@@ -49,12 +52,12 @@
function<void ()> f;
bool caught;
Thread thread;
-
+
Catcher(function<void ()> f_) : f(f_), caught(false), thread(this) {}
~Catcher() { join(); }
-
+
void run() {
- try {
+ try {
ScopedSuppressLogging sl; // Suppress messages for expected errors.
f();
}
@@ -110,7 +113,7 @@
Catcher<TransportFailure> runner(bind(&SubscriptionManager::run, boost::ref(fix.subs)));
fix.connection.proxy.close();
runner.join();
- BOOST_CHECK_THROW(fix.session.close(), TransportFailure);
+ BOOST_CHECK_THROW(fix.session.close(), TransportFailure);
}
QPID_AUTO_TEST_CASE(NoSuchQueueTest) {
@@ -120,3 +123,5 @@
}
QPID_AUTO_TEST_SUITE_END()
+
+}} // namespace qpid::tests
Modified: qpid/branches/java-network-refactor/qpid/cpp/src/tests/failover_soak.cpp
URL: http://svn.apache.org/viewvc/qpid/branches/java-network-refactor/qpid/cpp/src/tests/failover_soak.cpp?rev=816261&r1=816260&r2=816261&view=diff
==============================================================================
--- qpid/branches/java-network-refactor/qpid/cpp/src/tests/failover_soak.cpp (original)
+++ qpid/branches/java-network-refactor/qpid/cpp/src/tests/failover_soak.cpp Thu Sep 17 16:21:13 2009
@@ -7,9 +7,9 @@
* 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
@@ -51,7 +51,8 @@
using namespace qpid::client;
-
+namespace qpid {
+namespace tests {
typedef vector<ForkedBroker *> brokerVector;
@@ -90,9 +91,9 @@
struct child
{
- child ( string & name, pid_t pid, childType type )
+ child ( string & name, pid_t pid, childType type )
: name(name), pid(pid), retval(-999), status(RUNNING), type(type)
- {
+ {
gettimeofday ( & startTime, 0 );
}
@@ -107,7 +108,7 @@
void
- setType ( childType t )
+ setType ( childType t )
{
type = t;
}
@@ -126,7 +127,7 @@
struct children : public vector<child *>
-{
+{
void
add ( string & name, pid_t pid, childType type )
@@ -135,7 +136,7 @@
}
- child *
+ child *
get ( pid_t pid )
{
vector<child *>::iterator i;
@@ -155,7 +156,7 @@
{
if ( verbosity > 1 )
{
- cerr << "children::exited warning: Can't find child with pid "
+ cerr << "children::exited warning: Can't find child with pid "
<< pid
<< endl;
}
@@ -192,7 +193,7 @@
<< endl;
return (*i)->retval;
}
-
+
return 0;
}
@@ -226,11 +227,11 @@
children allMyChildren;
-void
-childExit ( int )
+void
+childExit ( int )
{
- int childReturnCode;
- pid_t pid = waitpid ( 0, & childReturnCode, WNOHANG);
+ int childReturnCode;
+ pid_t pid = waitpid ( 0, & childReturnCode, WNOHANG);
if ( pid > 0 )
allMyChildren.exited ( pid, childReturnCode );
@@ -270,10 +271,10 @@
{
cout << "Broker List ------------ size: " << brokers.size() << "\n";
for ( brokerVector::iterator i = brokers.begin(); i != brokers.end(); ++ i) {
- cout << "pid: "
- << (*i)->getPID()
- << " port: "
- << (*i)->getPort()
+ cout << "pid: "
+ << (*i)->getPID()
+ << " port: "
+ << (*i)->getPort()
<< endl;
}
cout << "end Broker List ------------\n";
@@ -293,7 +294,7 @@
if ( ! newbie )
return true;
- try
+ try
{
Connection connection;
connection.open ( "127.0.0.1", newbie_port );
@@ -303,8 +304,8 @@
}
catch ( const std::exception& error )
{
- std::cerr << "wait_for_newbie error: "
- << error.what()
+ std::cerr << "wait_for_newbie error: "
+ << error.what()
<< endl;
return false;
}
@@ -320,7 +321,7 @@
char const * moduleOrDir,
string const clusterName,
int verbosity,
- int durable )
+ int durable )
{
static int brokerId = 0;
stringstream path, prefix;
@@ -353,8 +354,8 @@
ForkedBroker * broker = newbie;
if ( verbosity > 0 )
- std::cerr << "new broker created: pid == "
- << broker->getPID()
+ std::cerr << "new broker created: pid == "
+ << broker->getPID()
<< " log-prefix == "
<< "soak-" << brokerId
<< endl;
@@ -381,8 +382,8 @@
catch ( const exception& error ) {
if ( verbosity > 0 )
{
- cout << "error killing broker: "
- << error.what()
+ cout << "error killing broker: "
+ << error.what()
<< endl;
}
@@ -398,14 +399,14 @@
/*
- * The optional delay is to avoid killing newbie brokers that have just
+ * The optional delay is to avoid killing newbie brokers that have just
* been added and are still in the process of updating. This causes
* spurious, test-generated errors that scare everybody.
*/
void
killAllBrokers ( brokerVector & brokers, int delay )
{
- if ( delay > 0 )
+ if ( delay > 0 )
{
std::cerr << "Killing all brokers after delay of " << delay << endl;
sleep ( delay );
@@ -413,8 +414,8 @@
for ( uint i = 0; i < brokers.size(); ++ i )
try { brokers[i]->kill(9); }
- catch ( const exception& error )
- {
+ catch ( const exception& error )
+ {
std::cerr << "killAllBrokers Warning: exception during kill on broker "
<< i
<< " "
@@ -428,21 +429,21 @@
pid_t
-runDeclareQueuesClient ( brokerVector brokers,
+runDeclareQueuesClient ( brokerVector brokers,
char const * host,
char const * path,
int verbosity,
int durable
- )
+ )
{
string name("declareQueues");
int port = brokers[0]->getPort ( );
if ( verbosity > 1 )
- cout << "startDeclareQueuesClient: host: "
- << host
- << " port: "
- << port
+ cout << "startDeclareQueuesClient: host: "
+ << host
+ << " port: "
+ << port
<< endl;
stringstream portSs;
portSs << port;
@@ -473,12 +474,12 @@
pid_t
-startReceivingClient ( brokerVector brokers,
+startReceivingClient ( brokerVector brokers,
char const * host,
char const * receiverPath,
char const * reportFrequency,
int verbosity
- )
+ )
{
string name("receiver");
int port = brokers[0]->getPort ( );
@@ -520,14 +521,14 @@
pid_t
-startSendingClient ( brokerVector brokers,
+startSendingClient ( brokerVector brokers,
char const * host,
char const * senderPath,
char const * nMessages,
char const * reportFrequency,
int verbosity,
int durability
- )
+ )
{
string name("sender");
int port = brokers[0]->getPort ( );
@@ -580,13 +581,14 @@
#define HANGING 7
#define ERROR_KILLING_BROKER 8
+}} // namespace qpid::tests
-// If you want durability, use the "dir" option of "moduleOrDir" .
-
+using namespace qpid::tests;
+// If you want durability, use the "dir" option of "moduleOrDir" .
int
-main ( int argc, char const ** argv )
-{
+main ( int argc, char const ** argv )
+{
if ( argc != 9 ) {
cerr << "Usage: "
<< argv[0]
@@ -626,10 +628,10 @@
int nBrokers = 3;
for ( int i = 0; i < nBrokers; ++ i ) {
startNewBroker ( brokers,
- moduleOrDir,
+ moduleOrDir,
clusterName,
verbosity,
- durable );
+ durable );
}
@@ -638,7 +640,7 @@
// Run the declareQueues child.
int childStatus;
- pid_t dqClientPid =
+ pid_t dqClientPid =
runDeclareQueuesClient ( brokers, host, declareQueuesPath, verbosity, durable );
if ( -1 == dqClientPid ) {
cerr << "END_OF_TEST ERROR_START_DECLARE_1\n";
@@ -657,8 +659,8 @@
// Start the receiving client.
pid_t receivingClientPid =
- startReceivingClient ( brokers,
- host,
+ startReceivingClient ( brokers,
+ host,
receiverPath,
reportFrequency,
verbosity );
@@ -669,10 +671,10 @@
// Start the sending client.
- pid_t sendingClientPid =
- startSendingClient ( brokers,
- host,
- senderPath,
+ pid_t sendingClientPid =
+ startSendingClient ( brokers,
+ host,
+ senderPath,
nMessages,
reportFrequency,
verbosity,
@@ -687,10 +689,10 @@
maxSleep = 4;
- for ( int totalBrokers = 3;
- totalBrokers < maxBrokers;
- ++ totalBrokers
- )
+ for ( int totalBrokers = 3;
+ totalBrokers < maxBrokers;
+ ++ totalBrokers
+ )
{
if ( verbosity > 0 )
cout << totalBrokers << " brokers have been added to the cluster.\n\n\n";
@@ -721,14 +723,14 @@
cout << "Starting new broker.\n\n";
startNewBroker ( brokers,
- moduleOrDir,
+ moduleOrDir,
clusterName,
verbosity,
- durable );
-
+ durable );
+
if ( verbosity > 1 )
printBrokers ( brokers );
-
+
// If all children have exited, quit.
int unfinished = allMyChildren.unfinished();
if ( ! unfinished ) {
Modified: qpid/branches/java-network-refactor/qpid/cpp/src/tests/latencytest.cpp
URL: http://svn.apache.org/viewvc/qpid/branches/java-network-refactor/qpid/cpp/src/tests/latencytest.cpp?rev=816261&r1=816260&r2=816261&view=diff
==============================================================================
--- qpid/branches/java-network-refactor/qpid/cpp/src/tests/latencytest.cpp (original)
+++ qpid/branches/java-network-refactor/qpid/cpp/src/tests/latencytest.cpp Thu Sep 17 16:21:13 2009
@@ -7,9 +7,9 @@
* 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
@@ -40,6 +40,9 @@
using namespace qpid::sys;
using std::string;
+namespace qpid {
+namespace tests {
+
typedef std::vector<std::string> StringSet;
struct Args : public qpid::TestOptions {
@@ -64,7 +67,7 @@
durable(false), base("latency-test"), singleConnect(false)
{
- addOptions()
+ addOptions()
("size", optValue(size, "N"), "message size")
("concurrentTests", optValue(concurrentConnections, "N"), "number of concurrent test setups, will create another publisher,\
@@ -73,9 +76,9 @@
("count", optValue(count, "N"), "number of messages to send")
("rate", optValue(rate, "N"), "target message rate (causes count to be ignored)")
("sync", optValue(sync), "send messages synchronously")
- ("report-frequency", optValue(reportFrequency, "N"),
+ ("report-frequency", optValue(reportFrequency, "N"),
"number of milliseconds to wait between reports (ignored unless rate specified)")
- ("time-limit", optValue(timeLimit, "N"),
+ ("time-limit", optValue(timeLimit, "N"),
"test duration, in seconds")
("prefetch", optValue(prefetch, "N"), "prefetch count (0 implies no flow control, and no acking)")
("ack", optValue(ack, "N"), "Ack frequency in messages (defaults to half the prefetch value)")
@@ -98,7 +101,7 @@
return t;
}
-struct Stats
+struct Stats
{
Mutex lock;
uint count;
@@ -132,7 +135,7 @@
};
class Receiver : public Client, public MessageListener
-{
+{
SubscriptionManager mgr;
uint count;
Stats& stats;
@@ -168,7 +171,7 @@
Receiver receiver;
Sender sender;
AbsTime begin;
-
+
public:
Test(const string& q) : queue(q), receiver(queue, stats), sender(queue, receiver), begin(now()) {}
void start();
@@ -186,7 +189,7 @@
connection = &localConnection;
opts.open(localConnection);
}
- session = connection->newSession();
+ session = connection->newSession();
}
void Client::start()
@@ -235,7 +238,7 @@
settings.acceptMode = ACCEPT_MODE_NONE;
settings.flowControl = FlowControl::unlimited();
}
- mgr.subscribe(*this, queue, settings);
+ mgr.subscribe(*this, queue, settings);
}
void Receiver::test()
@@ -283,7 +286,7 @@
if (!opts.csv) {
if (count) {
std::cout << "Latency(ms): min=" << minLatency << ", max=" <<
- maxLatency << ", avg=" << aux_avg;
+ maxLatency << ", avg=" << aux_avg;
} else {
std::cout << "Stalled: no samples for interval";
}
@@ -368,7 +371,7 @@
Duration delay(sentAt, waitTill);
if (delay < 0)
++missedRate;
- else
+ else
sys::usleep(delay / TIME_USEC);
if (timeLimit != 0 && Duration(start, now()) > timeLimit) {
session.sync();
@@ -382,7 +385,7 @@
{
if (size < chars.length()) {
return chars.substr(0, size);
- }
+ }
std::string data;
for (uint i = 0; i < (size / chars.length()); i++) {
data += chars;
@@ -392,35 +395,39 @@
}
-void Test::start()
-{
- receiver.start();
+void Test::start()
+{
+ receiver.start();
begin = AbsTime(now());
- sender.start();
+ sender.start();
}
-void Test::join()
-{
- sender.join();
- receiver.join();
+void Test::join()
+{
+ sender.join();
+ receiver.join();
AbsTime end = now();
Duration time(begin, end);
double msecs(time / TIME_MSEC);
if (!opts.csv) {
- std::cout << "Sent " << receiver.getCount() << " msgs through " << queue
+ std::cout << "Sent " << receiver.getCount() << " msgs through " << queue
<< " in " << msecs << "ms (" << (receiver.getCount() * 1000 / msecs) << " msgs/s) ";
}
stats.print();
std::cout << std::endl;
}
-void Test::report()
-{
+void Test::report()
+{
stats.print();
std::cout << std::endl;
stats.reset();
}
+}} // namespace qpid::tests
+
+using namespace qpid::tests;
+
int main(int argc, char** argv)
{
try {
Modified: qpid/branches/java-network-refactor/qpid/cpp/src/tests/logging.cpp
URL: http://svn.apache.org/viewvc/qpid/branches/java-network-refactor/qpid/cpp/src/tests/logging.cpp?rev=816261&r1=816260&r2=816261&view=diff
==============================================================================
--- qpid/branches/java-network-refactor/qpid/cpp/src/tests/logging.cpp (original)
+++ qpid/branches/java-network-refactor/qpid/cpp/src/tests/logging.cpp Thu Sep 17 16:21:13 2009
@@ -37,6 +37,9 @@
#include <time.h>
+namespace qpid {
+namespace tests {
+
QPID_AUTO_TEST_SUITE(loggingTestSuite)
using namespace std;
@@ -106,7 +109,7 @@
TestOutput(Logger& l) {
l.output(std::auto_ptr<Logger::Output>(this));
}
-
+
void log(const Statement& s, const string& m) {
msg.push_back(m);
stmt.push_back(s);
@@ -117,7 +120,7 @@
using boost::assign::list_of;
QPID_AUTO_TEST_CASE(testLoggerOutput) {
- Logger l;
+ Logger l;
l.clear();
l.select(Selector(debug));
Statement s=QPID_LOG_STATEMENT_INIT(debug);
@@ -174,7 +177,7 @@
l.format(Logger::FUNCTION);
QPID_LOG(critical, "foo");
BOOST_CHECK_EQUAL(string(BOOST_CURRENT_FUNCTION) + ": foo\n", out->last());
-
+
l.format(Logger::LEVEL);
QPID_LOG(critical, "foo");
BOOST_CHECK_EQUAL("critical foo\n", out->last());
@@ -228,12 +231,12 @@
// Overhead test disabled because it consumes a ton of CPU and takes
// forever under valgrind. Not friendly for regular test runs.
-//
+//
#if 0
QPID_AUTO_TEST_CASE(testOverhead) {
// Ensure that the ratio of CPU time for an incrementing loop
// with and without disabled log statements is in acceptable limits.
- //
+ //
int times=100000000;
clock_t noLog=timeLoop(times, count);
clock_t withLog=timeLoop(times, loggedCount);
@@ -242,9 +245,9 @@
// NB: in initial tests the ratio was consistently below 1.5,
// 2.5 is reasonable and should avoid spurios failures
// due to machine load.
- //
- BOOST_CHECK_SMALL(ratio, 2.5);
-}
+ //
+ BOOST_CHECK_SMALL(ratio, 2.5);
+}
#endif // 0
Statement statement(
@@ -290,7 +293,7 @@
}
QPID_AUTO_TEST_CASE(testOptionsDefault) {
- Options opts("");
+ qpid::log::Options opts("");
#ifdef _WIN32
qpid::log::windows::SinkOptions sinks("test");
#else
@@ -328,10 +331,10 @@
QPID_AUTO_TEST_CASE(testLoggerStateure) {
Logger& l=Logger::instance();
ScopedSuppressLogging ls(l);
- Options opts("test");
+ qpid::log::Options opts("test");
const char* argv[]={
0,
- "--log-time", "no",
+ "--log-time", "no",
"--log-source", "yes",
"--log-to-stderr", "no",
"--log-to-file", "logging.tmp",
@@ -352,7 +355,7 @@
QPID_AUTO_TEST_CASE(testQuoteNonPrintable) {
Logger& l=Logger::instance();
ScopedSuppressLogging ls(l);
- Options opts("test");
+ qpid::log::Options opts("test");
opts.time=false;
#ifdef _WIN32
qpid::log::windows::SinkOptions *sinks =
@@ -367,7 +370,7 @@
char s[] = "null\0tab\tspace newline\nret\r\x80\x99\xff";
string str(s, sizeof(s));
- QPID_LOG(critical, str);
+ QPID_LOG(critical, str);
ifstream log("logging.tmp");
string line;
getline(log, line, '\0');
@@ -378,3 +381,5 @@
}
QPID_AUTO_TEST_SUITE_END()
+
+}} // namespace qpid::tests
Modified: qpid/branches/java-network-refactor/qpid/cpp/src/tests/perftest.cpp
URL: http://svn.apache.org/viewvc/qpid/branches/java-network-refactor/qpid/cpp/src/tests/perftest.cpp?rev=816261&r1=816260&r2=816261&view=diff
==============================================================================
--- qpid/branches/java-network-refactor/qpid/cpp/src/tests/perftest.cpp (original)
+++ qpid/branches/java-network-refactor/qpid/cpp/src/tests/perftest.cpp Thu Sep 17 16:21:13 2009
@@ -7,9 +7,9 @@
* 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
@@ -49,6 +49,9 @@
using boost::lexical_cast;
using boost::bind;
+namespace qpid {
+namespace tests {
+
enum Mode { SHARED, FANOUT, TOPIC };
const char* modeNames[] = { "shared", "fanout", "topic" };
@@ -105,9 +108,9 @@
bool commitAsync;
static const std::string helpText;
-
+
Opts() :
- TestOptions(helpText),
+ TestOptions(helpText),
setup(false), control(false), publish(false), subscribe(false), baseName("perftest"),
pubs(1), count(500000), size(1024), confirm(true), durable(false), uniqueData(false), syncPub(false),
subs(1), ack(0),
@@ -136,16 +139,16 @@
("nsubs", optValue(subs, "N"), "Create N subscribers.")
("sub-ack", optValue(ack, "N"), "N>0: Subscriber acks batches of N.\n"
"N==0: Subscriber uses unconfirmed mode")
-
+
("qt", optValue(qt, "N"), "Create N queues or topics.")
("single-connection", optValue(singleConnect, "yes|no"), "Use one connection for multiple sessions.")
-
+
("iterations", optValue(iterations, "N"), "Desired number of iterations of the test.")
("summary,s", optValue(summary), "Summary output: pubs/sec subs/sec transfers/sec Mbytes/sec")
("queue-max-count", optValue(queueMaxCount, "N"), "queue policy: count to trigger 'flow to disk'")
("queue-max-size", optValue(queueMaxSize, "N"), "queue policy: accumulated size to trigger 'flow to disk'")
- ("base-name", optValue(baseName, "NAME"), "base name used for queues or topics")
+ ("base-name", optValue(baseName, "NAME"), "base name used for queues or topics")
("queue-durable", optValue(queueDurable, "N"), "Make queue durable (implied if durable set)")
("interval_sub", optValue(intervalSub, "ms"), ">=0 delay between msg consume")
@@ -171,7 +174,7 @@
count += subs - (count % subs);
cout << "WARNING: Adjusted --count to " << count
<< " the nearest multiple of --nsubs" << endl;
- }
+ }
totalPubs = pubs*qt;
totalSubs = subs*qt;
subQuota = (pubs*count)/subs;
@@ -258,7 +261,7 @@
};
struct Setup : public Client {
-
+
void queueInit(string name, bool durable=false, const framing::FieldTable& settings=framing::FieldTable()) {
session.queueDeclare(arg::queue=name, arg::durable=durable, arg::arguments=settings);
session.queuePurge(arg::queue=name);
@@ -278,7 +281,7 @@
for (size_t i = 0; i < opts.qt; ++i) {
ostringstream qname;
qname << opts.baseName << i;
- queueInit(qname.str(), opts.durable || opts.queueDurable, settings);
+ queueInit(qname.str(), opts.durable || opts.queueDurable, settings);
}
}
}
@@ -303,7 +306,7 @@
public:
Stats() : sum(0) {}
-
+
// Functor to collect rates.
void operator()(const string& data) {
try {
@@ -314,7 +317,7 @@
throw Exception("Bad report: "+data);
}
}
-
+
double mean() const {
return sum/values.size();
}
@@ -331,7 +334,7 @@
}
return sqrt(ssq/(values.size()-1));
}
-
+
ostream& print(ostream& out) {
ostream_iterator<double> o(out, "\n");
copy(values.begin(), values.end(), o);
@@ -341,11 +344,11 @@
return out << endl;
}
};
-
+
// Manage control queues, collect and print reports.
struct Controller : public Client {
-
+
SubscriptionManager subs;
Controller() : subs(session) {}
@@ -354,7 +357,7 @@
void process(size_t n, string queue,
boost::function<void (const string&)> msgFn)
{
- if (!opts.summary)
+ if (!opts.summary)
cout << "Processing " << n << " messages from "
<< queue << " " << flush;
LocalQueue lq;
@@ -370,8 +373,8 @@
void process(size_t n, LocalQueue lq, string queue,
boost::function<void (const string&)> msgFn)
{
- session.messageFlow(queue, 0, n);
- if (!opts.summary)
+ session.messageFlow(queue, 0, n);
+ if (!opts.summary)
cout << "Processing " << n << " messages from "
<< queue << " " << flush;
for (size_t i = 0; i < n; ++i) {
@@ -386,7 +389,7 @@
cout << "Sending " << data << " " << n << " times to " << queue
<< endl;
Message msg(data, queue);
- for (size_t i = 0; i < n; ++i)
+ for (size_t i = 0; i < n; ++i)
session.messageTransfer(arg::content=msg, arg::acceptMode=1);
}
@@ -419,7 +422,7 @@
process(opts.totalPubs, pubDone, fqn("pub_done"), boost::ref(pubRates));
process(opts.totalSubs, subDone, fqn("sub_done"), boost::ref(subRates));
- AbsTime end=now();
+ AbsTime end=now();
double time=secs(start, end);
double txrate=opts.transfers/time;
@@ -469,12 +472,12 @@
string routingKey;
PublishThread() {};
-
+
PublishThread(string key, string dest=string()) {
destination=dest;
routingKey=key;
}
-
+
void run() { // Publisher
try {
string data;
@@ -492,7 +495,7 @@
}
} else {
size_t msgSize=max(opts.size, sizeof(size_t));
- data = string(msgSize, 'X');
+ data = string(msgSize, 'X');
}
Message msg(data, routingKey);
@@ -500,21 +503,21 @@
msg.getDeliveryProperties().setDeliveryMode(framing::PERSISTENT);
- if (opts.txPub){
+ if (opts.txPub){
session.txSelect();
}
SubscriptionManager subs(session);
LocalQueue lq;
- subs.setFlowControl(1, SubscriptionManager::UNLIMITED, true);
- subs.subscribe(lq, fqn("pub_start"));
-
+ subs.setFlowControl(1, SubscriptionManager::UNLIMITED, true);
+ subs.subscribe(lq, fqn("pub_start"));
+
for (size_t j = 0; j < opts.iterations; ++j) {
expect(lq.pop().getData(), "start");
AbsTime start=now();
for (size_t i=0; i<opts.count; i++) {
// Stamp the iteration into the message data, avoid
// any heap allocation.
- const_cast<std::string&>(msg.getData()).replace(offset, sizeof(size_t),
+ const_cast<std::string&>(msg.getData()).replace(offset, sizeof(size_t),
reinterpret_cast<const char*>(&i), sizeof(size_t));
if (opts.syncPub) {
sync(session).messageTransfer(
@@ -540,7 +543,7 @@
if (opts.confirm) session.sync();
AbsTime end=now();
double time=secs(start,end);
-
+
// Send result to controller.
Message report(lexical_cast<string>(opts.count/time), fqn("pub_done"));
session.messageTransfer(arg::content=report, arg::acceptMode=1);
@@ -561,7 +564,7 @@
string queue;
SubscribeThread() {}
-
+
SubscribeThread(string q) { queue = q; }
SubscribeThread(string key, string ex) {
@@ -586,7 +589,7 @@
}
void run() { // Subscribe
- try {
+ try {
if (opts.txSub) sync(session).txSelect();
SubscriptionManager subs(session);
SubscriptionSettings settings;
@@ -606,15 +609,15 @@
if (opts.iterations > 1) {
subs.subscribe(iterationControl, fqn("sub_iteration"), SubscriptionSettings(FlowControl::messageCredit(0)));
}
-
+
for (size_t j = 0; j < opts.iterations; ++j) {
if (j > 0) {
//need to wait here until all subs are done
- session.messageFlow(fqn("sub_iteration"), 0, 1);
+ session.messageFlow(fqn("sub_iteration"), 0, 1);
iterationControl.pop();
//need to allocate some more credit for subscription
- session.messageFlow(queue, 0, opts.subQuota);
+ session.messageFlow(queue, 0, opts.subQuota);
}
Message msg;
AbsTime start=now();
@@ -627,7 +630,7 @@
}
if (opts.intervalSub)
qpid::sys::usleep(opts.intervalSub*1000);
- // TODO aconway 2007-11-23: check message order for.
+ // TODO aconway 2007-11-23: check message order for.
// multiple publishers. Need an array of counters,
// one per publisher and a publisher ID in the
// message. Careful not to introduce a lot of overhead
@@ -664,6 +667,10 @@
}
};
+}} // namespace qpid::tests
+
+using namespace qpid::tests;
+
int main(int argc, char** argv) {
int exitCode = 0;
boost::ptr_vector<Client> subs(opts.subs);
Modified: qpid/branches/java-network-refactor/qpid/cpp/src/tests/publish.cpp
URL: http://svn.apache.org/viewvc/qpid/branches/java-network-refactor/qpid/cpp/src/tests/publish.cpp?rev=816261&r1=816260&r2=816261&view=diff
==============================================================================
--- qpid/branches/java-network-refactor/qpid/cpp/src/tests/publish.cpp (original)
+++ qpid/branches/java-network-refactor/qpid/cpp/src/tests/publish.cpp Thu Sep 17 16:21:13 2009
@@ -7,9 +7,9 @@
* 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
@@ -36,6 +36,9 @@
using namespace qpid::sys;
using namespace std;
+namespace qpid {
+namespace tests {
+
typedef vector<string> StringSet;
struct Args : public qpid::TestOptions {
@@ -61,12 +64,12 @@
Args opts;
-struct Client
+struct Client
{
Connection connection;
AsyncSession session;
- Client()
+ Client()
{
opts.open(connection);
session = connection.newSession();
@@ -75,7 +78,7 @@
// Cheap hex calculation, avoid expensive ostrstream and string
// creation to generate correlation ids in message loop.
char hex(char i) { return i<10 ? '0'+i : 'A'+i-10; }
- void hex(char i, string& s) {
+ void hex(char i, string& s) {
s[0]=hex(i>>24); s[1]=hex(i>>16); s[2]=hex(i>>8); s[3]=i;
}
@@ -86,7 +89,7 @@
string correlationId = "0000";
if (opts.durable)
msg.getDeliveryProperties().setDeliveryMode(framing::PERSISTENT);
-
+
for (uint i = 0; i < opts.count; i++) {
if (opts.id) {
hex(i+1, correlationId);
@@ -103,7 +106,7 @@
else cout << "Time: " << secs << "s Rate: " << opts.count/secs << endl;
}
- ~Client()
+ ~Client()
{
try{
session.close();
@@ -114,6 +117,10 @@
}
};
+}} // namespace qpid::tests
+
+using namespace qpid::tests;
+
int main(int argc, char** argv)
{
try {
Modified: qpid/branches/java-network-refactor/qpid/cpp/src/tests/qpid_ping.cpp
URL: http://svn.apache.org/viewvc/qpid/branches/java-network-refactor/qpid/cpp/src/tests/qpid_ping.cpp?rev=816261&r1=816260&r2=816261&view=diff
==============================================================================
--- qpid/branches/java-network-refactor/qpid/cpp/src/tests/qpid_ping.cpp (original)
+++ qpid/branches/java-network-refactor/qpid/cpp/src/tests/qpid_ping.cpp Thu Sep 17 16:21:13 2009
@@ -7,9 +7,9 @@
* 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
@@ -38,6 +38,9 @@
using namespace qpid::client;
using namespace qpid;
+namespace qpid {
+namespace tests {
+
struct PingOptions : public qpid::TestOptions {
int timeout; // Timeout in seconds.
bool quiet; // No output
@@ -58,7 +61,7 @@
public:
Ping() : status(WAITING) {}
-
+
void run() {
try {
opts.open(connection);
@@ -100,6 +103,9 @@
}
};
+}} // namespace qpid::tests
+
+using namespace qpid::tests;
int main(int argc, char** argv) {
try {
Modified: qpid/branches/java-network-refactor/qpid/cpp/src/tests/qrsh.cpp
URL: http://svn.apache.org/viewvc/qpid/branches/java-network-refactor/qpid/cpp/src/tests/qrsh.cpp?rev=816261&r1=816260&r2=816261&view=diff
==============================================================================
--- qpid/branches/java-network-refactor/qpid/cpp/src/tests/qrsh.cpp (original)
+++ qpid/branches/java-network-refactor/qpid/cpp/src/tests/qrsh.cpp Thu Sep 17 16:21:13 2009
@@ -7,9 +7,9 @@
* 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
@@ -37,11 +37,13 @@
using namespace std;
+namespace qpid {
+namespace tests {
class ResponseListener : public MessageListener
{
public :
-
+
int exitCode;
ResponseListener ( SubscriptionManager & subscriptions )
@@ -50,7 +52,7 @@
{
}
- virtual void
+ virtual void
received ( Message & message )
{
char first_word[1000];
@@ -66,9 +68,9 @@
if ( ! strcmp ( first_word, "get_response" ) )
{
// The remainder of the message is the file we requested.
- fprintf ( stdout,
- "%s",
- message.getData().c_str() + strlen("get_response" )
+ fprintf ( stdout,
+ "%s",
+ message.getData().c_str() + strlen("get_response" )
);
subscriptions.cancel(message.getDestination());
}
@@ -76,12 +78,13 @@
private :
-
+
SubscriptionManager & subscriptions;
};
+}} // namespace qpid::tests
-
+using namespace qpid::tests;
/*
* argv[1] host
@@ -90,8 +93,8 @@
* argv[4] command name
* argv[5..N] args to the command
*/
-int
-main ( int argc, char ** argv )
+int
+main ( int argc, char ** argv )
{
const char* host = argv[1];
int port = atoi(argv[2]);
@@ -99,14 +102,14 @@
Connection connection;
- try
+ try
{
connection.open ( host, port );
Session session = connection.newSession ( );
// Make a queue and bind it to fanout.
string myQueue = session.getId().getName();
-
+
session.queueDeclare ( arg::queue=myQueue,
arg::exclusive=true,
arg::autoDelete=true
@@ -136,7 +139,7 @@
response_command = true;
// Send the payload message.
- // Skip "qrsh host_name port"
+ // Skip "qrsh host_name port"
Message message;
stringstream ss;
for ( int i = 3; i < argc; ++ i )
@@ -144,7 +147,7 @@
message.setData ( ss.str() );
- session.messageTransfer(arg::content=message,
+ session.messageTransfer(arg::content=message,
arg::destination="amq.fanout");
if ( response_command )
@@ -153,8 +156,8 @@
session.close();
connection.close();
return responseListener.exitCode;
- }
- catch ( exception const & e)
+ }
+ catch ( exception const & e)
{
cerr << e.what() << endl;
}
Modified: qpid/branches/java-network-refactor/qpid/cpp/src/tests/qrsh_server.cpp
URL: http://svn.apache.org/viewvc/qpid/branches/java-network-refactor/qpid/cpp/src/tests/qrsh_server.cpp?rev=816261&r1=816260&r2=816261&view=diff
==============================================================================
--- qpid/branches/java-network-refactor/qpid/cpp/src/tests/qrsh_server.cpp (original)
+++ qpid/branches/java-network-refactor/qpid/cpp/src/tests/qrsh_server.cpp Thu Sep 17 16:21:13 2009
@@ -7,9 +7,9 @@
* 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
@@ -43,7 +43,8 @@
using namespace std;
-
+namespace qpid {
+namespace tests {
int
mrand ( int max_desired_val )
@@ -54,7 +55,7 @@
-char *
+char *
file2str ( char const * file_name )
{
FILE * fp = fopen ( file_name, "r" );
@@ -71,9 +72,9 @@
if ( ! content )
{
- fprintf ( stderr,
- "file2str error: can't malloc %d bytes.\n",
- (int)file_len
+ fprintf ( stderr,
+ "file2str error: can't malloc %d bytes.\n",
+ (int)file_len
);
return 0;
}
@@ -123,9 +124,9 @@
bool myMessage ( Message const & message );
/* ----------------------------------------------
- * Special Commands
+ * Special Commands
* These are commands that the qrsh_server executes
- * directly, rather than through a child process
+ * directly, rather than through a child process
* instance of qrsh_run.
*/
void runCommand ( Message const & message );
@@ -157,9 +158,9 @@
char const * skipWord ( char const * s );
- void string_replaceAll ( string & str,
- string & target,
- string & replacement
+ void string_replaceAll ( string & str,
+ string & target,
+ string & replacement
);
@@ -186,12 +187,12 @@
-QrshServer::QrshServer ( SubscriptionManager & subs,
+QrshServer::QrshServer ( SubscriptionManager & subs,
char const * name,
char const * qrsh_run_path,
char const * host,
int port
- )
+ )
: subscriptions ( subs ),
name ( name ),
qrsh_run_path ( qrsh_run_path ),
@@ -202,11 +203,11 @@
{
data_dir << "/tmp/qrsh_"
<< getpid();
-
+
if(mkdir ( data_dir.str().c_str(), 0777 ) )
{
- fprintf ( stderr,
- "QrshServer::QrshServer error: can't mkdir |%s|\n",
+ fprintf ( stderr,
+ "QrshServer::QrshServer error: can't mkdir |%s|\n",
data_dir.str().c_str()
);
exit ( 1 );
@@ -239,21 +240,21 @@
<< name;
send ( announcement_data.str() );
-
+
saidHello = true;
}
-void
+void
QrshServer::send ( string const & content )
{
try
{
Message message;
message.setData ( content );
-
+
Connection connection;
connection.open ( host, port );
Session session = connection.newSession ( );
@@ -289,7 +290,7 @@
-void
+void
QrshServer::sayName ( )
{
fprintf ( stderr, "My name is: |%s|\n", name.c_str() );
@@ -343,7 +344,7 @@
break;
}
}
-
+
if ( i_win && (ties <= 0) )
{
myStraw = 0;
@@ -364,10 +365,10 @@
/*
* "APB" command (all-points-bullitens (commands that are not addressed
* specifically to any server)) are handled directly, here.
- * Because if I return simply "true", the normal command processing code
+ * Because if I return simply "true", the normal command processing code
* will misinterpret the command.
*/
-bool
+bool
QrshServer::myMessage ( Message const & message )
{
int const maxlen = 100;
@@ -414,7 +415,7 @@
{
return true;
}
- else
+ else
if ( ! strcmp ( first_word, "any" ) )
{
straws.clear();
@@ -443,7 +444,7 @@
-void
+void
QrshServer::addAlias ( Message const & message )
{
char alias[1000];
@@ -463,8 +464,8 @@
if ( ! dir )
{
- fprintf ( stderr,
- "QrshServer::getNames error: could not open dir |%s|.\n",
+ fprintf ( stderr,
+ "QrshServer::getNames error: could not open dir |%s|.\n",
data_dir.str().c_str()
);
return;
@@ -491,8 +492,8 @@
}
else
{
- /*
- * Fail silently. The non-existence of this file
+ /*
+ * Fail silently. The non-existence of this file
* is not necessarily an error.
*/
}
@@ -504,9 +505,9 @@
void
-QrshServer::string_replaceAll ( string & str,
- string & target,
- string & replacement
+QrshServer::string_replaceAll ( string & str,
+ string & target,
+ string & replacement
)
{
int target_size = target.size();
@@ -519,7 +520,7 @@
-bool
+bool
QrshServer::isProcessName ( char const * str )
{
getNames();
@@ -537,12 +538,12 @@
-int
+int
QrshServer::string_countWords ( char const * s1 )
{
int count = 0;
char const * s2 = s1 + 1;
-
+
if ( ! isspace(* s1) )
{
++ count;
@@ -603,7 +604,7 @@
*/
char file_or_process_name[1000];
sscanf ( request_message.getData().c_str(), "%*s%*s%s", file_or_process_name );
-
+
if ( isProcessName ( file_or_process_name ) )
{
stringstream desired_file_name;
@@ -612,13 +613,13 @@
<< file_or_process_name
<< '/';
char requested_output_stream[1000];
- if(1 != sscanf ( request_message.getData().c_str(),
- "%*s%*s%*s%s",
- requested_output_stream
+ if(1 != sscanf ( request_message.getData().c_str(),
+ "%*s%*s%*s%s",
+ requested_output_stream
)
)
{
- fprintf ( stderr,
+ fprintf ( stderr,
"QrshServer::get error: Can't read requested data file name from this message: |%s|\n",
request_message.getData().c_str()
);
@@ -674,7 +675,7 @@
if ( truncated_command )
{
stringstream ss;
- ss << qrsh_run_path
+ ss << qrsh_run_path
<< ' '
<< data_dir.str()
<< ' '
@@ -706,9 +707,9 @@
fprintf ( stderr, "qrsh_server error awaiting child!\n" );
exit ( 1 );
}
-
+
exit_code >>= 8;
-
+
stringstream data;
data << "wait_response "
<< exit_code;
@@ -731,7 +732,7 @@
// The second word is "exec_wait".
// The third word is the symbolic name of the command to wait for.
// The fact that there are exactly three words means that this
- // must be a command that has already been named and started --
+ // must be a command that has already been named and started --
// we just need to find its pid and wait on it.
pre_existing = true;
}
@@ -762,7 +763,7 @@
if ( truncated_command )
{
stringstream ss;
- ss << qrsh_run_path
+ ss << qrsh_run_path
<< ' '
<< data_dir.str()
<< ' '
@@ -795,7 +796,7 @@
exit ( 1 );
}
}
-
+
exit_code >>= 8;
stringstream data;
@@ -810,7 +811,7 @@
-char const *
+char const *
QrshServer::skipWord ( char const * s )
{
if(! (s && *s) )
@@ -884,7 +885,7 @@
arg_len = 0;
}
- done:
+ done:
if ( arg_len > 0 )
lengths.push_back ( arg_len );
@@ -896,8 +897,8 @@
for ( int i = 0; i < n_args; ++ i )
{
argv[i] = ( char *) malloc ( lengths[i] + 1 );
- strncpy ( argv[i],
- str + start_positions[i],
+ strncpy ( argv[i],
+ str + start_positions[i],
lengths[i]
);
argv[i][lengths[i]] = 0;
@@ -971,12 +972,12 @@
* qrsh_run, which will save all its data in the qrsh dir.
*/
stringstream ss;
- ss << qrsh_run_path
+ ss << qrsh_run_path
<< ' '
<< data_dir.str()
<< ' '
<< s;
-
+
if ( ! fork() )
{
char ** argv = getArgs ( ss.str().c_str() );
@@ -988,8 +989,8 @@
-void
-QrshServer::received ( Message & message )
+void
+QrshServer::received ( Message & message )
{
if ( myMessage ( message ) )
runCommand ( message );
@@ -997,7 +998,9 @@
+}} // namespace qpid::tests
+using namespace qpid::tests;
/*
* fixme mick Mon Aug 3 10:29:26 EDT 2009
@@ -1024,23 +1027,23 @@
// Declare queues.
string myQueue = session.getId().getName();
- session.queueDeclare ( arg::queue=myQueue,
+ session.queueDeclare ( arg::queue=myQueue,
arg::exclusive=true,
arg::autoDelete=true);
- session.exchangeBind ( arg::exchange="amq.fanout",
- arg::queue=myQueue,
+ session.exchangeBind ( arg::exchange="amq.fanout",
+ arg::queue=myQueue,
arg::bindingKey="my-key");
-
+
// Create a server and subscribe it to my queue.
SubscriptionManager subscriptions ( session );
- QrshServer server ( subscriptions,
+ QrshServer server ( subscriptions,
argv[1], // server name
argv[2], // qrsh exe path
host,
port
);
- subscriptions.subscribe ( server, myQueue );
+ subscriptions.subscribe ( server, myQueue );
// Receive messages until the subscription is cancelled
// by QrshServer::received()
@@ -1048,7 +1051,7 @@
connection.close();
}
- catch(const exception& error)
+ catch(const exception& error)
{
cout << error.what() << endl;
return 1;
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org