Skip to content

Commit

Permalink
minor tidy up, fix problem with ipv6 unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonrbriggs committed Sep 8, 2015
1 parent f452746 commit 8bf83a7
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 27 deletions.
43 changes: 21 additions & 22 deletions stomp/test/basic_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,30 +193,29 @@ def test_connect_nowait_error(self):
self.fail("Shouldn't happen")


if sys.hexversion >= 0x03000000:
class TestIPV6Send(unittest.TestCase):
def setUp(self):
conn = stomp.Connection(get_ipv6_host())
listener = TestListener('123')
conn.set_listener('', listener)
conn.start()
conn.connect('admin', 'password', wait=True)
self.conn = conn
self.listener = listener
self.timestamp = time.strftime('%Y%m%d%H%M%S')
class TestIPV6Send(unittest.TestCase):
def setUp(self):
conn = stomp.Connection(get_ipv6_host())
listener = TestListener('123')
conn.set_listener('', listener)
conn.start()
conn.connect('admin', 'password', wait=True)
self.conn = conn
self.listener = listener
self.timestamp = time.strftime('%Y%m%d%H%M%S')

def tearDown(self):
if self.conn:
self.conn.disconnect(receipt=None)
def tearDown(self):
if self.conn:
self.conn.disconnect(receipt=None)

def test_ipv6(self):
queuename = '/queue/testipv6-%s' % self.timestamp
self.conn.subscribe(destination=queuename, id=1, ack='auto')
def test_ipv6(self):
queuename = '/queue/testipv6-%s' % self.timestamp
self.conn.subscribe(destination=queuename, id=1, ack='auto')

self.conn.send(body='this is a test', destination=queuename, receipt='123')
self.conn.send(body='this is a test', destination=queuename, receipt='123')

self.listener.wait_on_receipt()
self.listener.wait_on_receipt()

self.assert_(self.listener.connections == 1, 'should have received 1 connection acknowledgement')
self.assert_(self.listener.messages == 1, 'should have received 1 message')
self.assert_(self.listener.errors == 0, 'should not have received any errors')
self.assert_(self.listener.connections == 1, 'should have received 1 connection acknowledgement')
self.assert_(self.listener.messages == 1, 'should have received 1 message')
self.assert_(self.listener.errors == 0, 'should not have received any errors')
2 changes: 1 addition & 1 deletion stomp/test/setup.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ port = 62613
ssl_port = 62614

[ipv6]
host = fe80::a00:27ff:fe90:3f1a%%en1
host = fe80::a00:27ff:fe90:3f1a%en1
port = 62613

[rabbitmq]
Expand Down
6 changes: 3 additions & 3 deletions stomp/test/testutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
log = logging.getLogger('testutils.py')

try:
from configparser import ConfigParser
from configparser import RawConfigParser
except ImportError:
from ConfigParser import ConfigParser
from ConfigParser import RawConfigParser


from stomp import StatsListener, WaitingListener
from stomp.backward import *


config = ConfigParser()
config = RawConfigParser()
config.read(os.path.join(os.path.dirname(__file__), 'setup.ini'))


Expand Down
1 change: 0 additions & 1 deletion stomp/transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,6 @@ def attempt_connection(self):
for host_and_port in self.__host_and_ports:
try:
log.info("Attempting connection to host %s, port %s", host_and_port[0], host_and_port[1])
#self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.socket = get_socket(host_and_port[0], host_and_port[1], self.__timeout)
self.__enable_keepalive()
need_ssl = self.__need_ssl(host_and_port)
Expand Down

0 comments on commit 8bf83a7

Please sign in to comment.