qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acon...@apache.org
Subject [61/89] [abbrv] qpid-proton git commit: NO-JIRA: [ruby] use ":0" in example test to get a random port
Date Tue, 03 Jul 2018 22:13:50 GMT
NO-JIRA: [ruby] use ":0" in example test to get a random port


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/df467c4c
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/df467c4c
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/df467c4c

Branch: refs/heads/go1
Commit: df467c4c461c7deb8f0fd042ff0826fac4217dbb
Parents: be20a51
Author: Alan Conway <aconway@redhat.com>
Authored: Wed Apr 11 18:19:50 2018 -0400
Committer: Alan Conway <aconway@redhat.com>
Committed: Wed Apr 11 18:19:50 2018 -0400

----------------------------------------------------------------------
 ruby/examples/broker.rb       |  2 +-
 ruby/examples/direct_recv.rb  |  2 +-
 ruby/examples/direct_send.rb  |  2 +-
 ruby/examples/example_test.rb | 30 +++++++++++++++---------------
 4 files changed, 18 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/df467c4c/ruby/examples/broker.rb
----------------------------------------------------------------------
diff --git a/ruby/examples/broker.rb b/ruby/examples/broker.rb
index 8de7d84..65e7142 100644
--- a/ruby/examples/broker.rb
+++ b/ruby/examples/broker.rb
@@ -146,7 +146,7 @@ class Broker < Qpid::Proton::Listener::Handler
   end
 
   def on_open(l)
-    STDOUT.puts "Listening on #{l}\n"; STDOUT.flush
+    STDOUT.puts "Listening on #{l.port}\n"; STDOUT.flush
   end
 
   # Create a new BrokerHandler instance for each connection we accept

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/df467c4c/ruby/examples/direct_recv.rb
----------------------------------------------------------------------
diff --git a/ruby/examples/direct_recv.rb b/ruby/examples/direct_recv.rb
index 327d8d0..2bc97b7 100644
--- a/ruby/examples/direct_recv.rb
+++ b/ruby/examples/direct_recv.rb
@@ -31,7 +31,7 @@ class DirectReceive < Qpid::Proton::MessagingHandler
   end
 
   class ListenOnce < Qpid::Proton::Listener::Handler
-    def on_open(l) STDOUT.puts "Listening\n"; STDOUT.flush; end
+    def on_open(l) STDOUT.puts "Listening on #{l.port}\n"; STDOUT.flush; end
     def on_accept(l) l.close; end
   end
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/df467c4c/ruby/examples/direct_send.rb
----------------------------------------------------------------------
diff --git a/ruby/examples/direct_send.rb b/ruby/examples/direct_send.rb
index 6ea5fd3..ea7a581 100644
--- a/ruby/examples/direct_send.rb
+++ b/ruby/examples/direct_send.rb
@@ -32,7 +32,7 @@ class DirectSend < Qpid::Proton::MessagingHandler
   end
 
   class ListenOnce < Qpid::Proton::Listener::Handler
-    def on_open(l) STDOUT.puts "Listening\n"; STDOUT.flush; end
+    def on_open(l) STDOUT.puts "Listening on #{l.port}\n"; STDOUT.flush; end
     def on_accept(l) l.close; end
   end
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/df467c4c/ruby/examples/example_test.rb
----------------------------------------------------------------------
diff --git a/ruby/examples/example_test.rb b/ruby/examples/example_test.rb
index 7008dd1..c050da2 100755
--- a/ruby/examples/example_test.rb
+++ b/ruby/examples/example_test.rb
@@ -29,11 +29,13 @@ rescue NameError                # For older versions of MiniTest
   MiniTest::Test = MiniTest::Unit::TestCase
 end
 
-# URL with an unused port
-def test_url()
-  "amqp://:#{TCPServer.open(0) { |s| s.addr[1] }}"
+def listening_port(s)
+  /Listening on ([0-9]+)/.match(s)[1]
 end
 
+def listening_url(s)
+  ":#{listening_port s}"
+end
 
 class ExampleTest < MiniTest::Test
 
@@ -80,18 +82,16 @@ EOS
   end
 
   def test_direct_recv
-    url = test_url
-      p = run_script("direct_recv.rb", url, "examples")
-      p.readline                # Wait till ready
-      assert_output("All 10 messages confirmed!", "simple_send.rb", url, "examples")
-      want = (0..9).reduce("") { |x,y| x << "Received: sequence #{y}\n" }
-      assert_equal(want.strip, p.read.strip)
+    p = run_script("direct_recv.rb", ":0", "examples")
+    url = listening_url(p.readline) # Wait till ready
+    assert_output("All 10 messages confirmed!", "simple_send.rb", url, "examples")
+    want = (0..9).reduce("") { |x,y| x << "Received: sequence #{y}\n" }
+    assert_equal(want.strip, p.read.strip)
   end
 
   def test_direct_send
-    url = test_url
-    p = run_script("direct_send.rb", url, "examples")
-    p.readline                # Wait till ready
+    p = run_script("direct_send.rb", ":0", "examples")
+    url = listening_url(p.readline) # Wait till ready
     want = (0..9).reduce("") { |x,y| x << "Received: sequence #{y}\n" }
     assert_output(want.strip, "simple_recv.rb", url, "examples")
     assert_equal("All 10 messages confirmed!", p.read.strip)
@@ -99,9 +99,9 @@ EOS
 end
 
 # Start the broker before all tests.
-$url = test_url
-$broker = IO.popen([RbConfig.ruby, 'broker.rb', $url])
-$broker.readline
+$broker = IO.popen([RbConfig.ruby, 'broker.rb', ":0"])
+l = $broker.readline
+$url = listening_url(l)
 
 # Kill the broker after all tests
 MiniTest.after_run do


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message