You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ac...@apache.org on 2019/03/05 21:59:14 UTC
[qpid-proton] branch master updated: PROTON-1643: [ruby] remove
outdated old-example-tests
This is an automated email from the ASF dual-hosted git repository.
aconway pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/qpid-proton.git
The following commit(s) were added to refs/heads/master by this push:
new 34cc8bf PROTON-1643: [ruby] remove outdated old-example-tests
34cc8bf is described below
commit 34cc8bf85979187721223dbce579fc36eda29e6f
Author: Alan Conway <ac...@redhat.com>
AuthorDate: Tue Mar 5 16:57:04 2019 -0500
PROTON-1643: [ruby] remove outdated old-example-tests
---
ruby/CMakeLists.txt | 9 --
ruby/tests/old-examples/README.md | 8 -
ruby/tests/old-examples/broker.rb | 200 ------------------------
ruby/tests/old-examples/client.rb | 81 ----------
ruby/tests/old-examples/direct_recv.rb | 64 --------
ruby/tests/old-examples/direct_send.rb | 63 --------
ruby/tests/old-examples/helloworld.rb | 72 ---------
ruby/tests/old-examples/helloworld_direct.rb | 73 ---------
ruby/tests/old-examples/lib/debugging.rb | 25 ---
ruby/tests/old-examples/lib/driver.rb | 68 --------
ruby/tests/old-examples/lib/qpid_examples.rb | 26 ---
ruby/tests/old-examples/lib/selectable.rb | 119 --------------
ruby/tests/old-examples/lib/send_and_receive.rb | 89 -----------
ruby/tests/old-examples/old_example_test.rb | 99 ------------
ruby/tests/old-examples/server.rb | 75 ---------
ruby/tests/old-examples/simple_recv.rb | 57 -------
ruby/tests/old-examples/simple_send.rb | 54 -------
17 files changed, 1182 deletions(-)
diff --git a/ruby/CMakeLists.txt b/ruby/CMakeLists.txt
index 9d4bd7a..c17550d 100644
--- a/ruby/CMakeLists.txt
+++ b/ruby/CMakeLists.txt
@@ -141,20 +141,11 @@ if (result EQUAL 0) # Have minitest
COMMAND ${test_env} ${RUBY_EXECUTABLE} testme -v
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/examples)
- add_test(
- NAME ruby-old-example-test
- COMMAND ${test_env} ${RUBY_EXECUTABLE} old_example_test.rb -v
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tests/old-examples)
-
file(GLOB TESTS tests/test_*.rb)
file(GLOB SPECS spec/*_spec.rb)
foreach(t ${TESTS} ${SPECS})
add_ruby_test(${t})
endforeach()
- # Suppress deprecation warnings from backward-compatibility tests
- set_tests_properties(
- ruby-old-example-test ruby-test-old-adapter
- PROPERTIES ENVIRONMENT "RUBYOPT=-W0")
else()
# No minitest
message(STATUS "Ruby tests will not run, minitest is not installed")
diff --git a/ruby/tests/old-examples/README.md b/ruby/tests/old-examples/README.md
deleted file mode 100644
index 1516e86..0000000
--- a/ruby/tests/old-examples/README.md
+++ /dev/null
@@ -1,8 +0,0 @@
-# OLD EXAMPLES FOR BACKWARDS COMPATIBILITY TESTING
-
-These examples are from 0.18.1, before the ruby IO refactoring.
-
-They are run as part of the regression test suite to catch breaks in backwards
-compatibility.
-
-They will be removed when all deprecated features have been removed.
diff --git a/ruby/tests/old-examples/broker.rb b/ruby/tests/old-examples/broker.rb
deleted file mode 100644
index d76dfba..0000000
--- a/ruby/tests/old-examples/broker.rb
+++ /dev/null
@@ -1,200 +0,0 @@
-# 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.
-
-
-require 'qpid_proton'
-require 'optparse'
-require 'pathname'
-
-require_relative 'lib/debugging'
-
-class Exchange
-
- include Debugging
-
- def initialize(dynamic = false)
- @dynamic = dynamic
- @queue = Queue.new
- @consumers = []
- end
-
- def subscribe(consumer)
- debug("subscribing #{consumer}") if $options[:debug]
- @consumers << (consumer)
- debug(" there are #{@consumers.size} consumers") if $options[:debug]
- end
-
- def unsubscribe(consumer)
- debug("unsubscribing #{consumer}") if $options[:debug]
- if @consumers.include?(consumer)
- @consumers.delete(consumer)
- else
- debug(" consumer doesn't exist") if $options[:debug]
- end
- debug(" there are #{@consumers.size} consumers") if $options[:debug]
- @consumers.empty? && (@dynamic || @queue.empty?)
- end
-
- def publish(message)
- debug("queueing message: #{message.body}") if $options[:debug]
- @queue << message
- self.dispatch
- end
-
- def dispatch(consumer = nil)
- debug("dispatching: consumer=#{consumer}") if $options[:debug]
- if consumer
- c = [consumer]
- else
- c = @consumers
- end
-
- while self.deliver_to(c) do
- end
- end
-
- def deliver_to(consumers)
- debug("delivering to #{consumers.size} consumer(s)") if $options[:debug]
- result = false
- consumers.each do |consumer|
- debug(" current consumer=#{consumer} credit=#{consumer.credit}") if $options[:debug]
- if consumer.credit > 0 && !@queue.empty?
- consumer.send(@queue.pop(true))
- result = true
- end
- end
- return result
- end
-
-end
-
-class Broker < Qpid::Proton::Handler::MessagingHandler
-
- include Debugging
-
- def initialize(url)
- super()
- @url = url
- @queues = {}
- end
-
- def on_start(event)
- debug("on_start event") if $options[:debug]
- @acceptor = event.container.listen(@url)
- print "Listening on #{@url}\n"
- STDOUT.flush
- end
-
- def queue(address)
- debug("fetching queue for #{address}: (there are #{@queues.size} queues)") if $options[:debug]
- unless @queues.has_key?(address)
- debug(" creating new queue") if $options[:debug]
- @queues[address] = Exchange.new
- else
- debug(" using existing queue") if $options[:debug]
- end
- result = @queues[address]
- debug(" returning #{result}") if $options[:debug]
- return result
- end
-
- def on_link_opening(event)
- debug("processing on_link_opening") if $options[:debug]
- debug("link is#{event.link.sender? ? '' : ' not'} a sender") if $options[:debug]
- if event.link.sender?
- if event.link.remote_source.dynamic?
- address = SecureRandom.uuid
- event.link.source.address = address
- q = Exchange.new(true)
- @queues[address] = q
- q.subscribe(event.link)
- elsif event.link.remote_source.address
- event.link.source.address = event.link.remote_source.address
- self.queue(event.link.source.address).subscribe(event.link)
- end
- elsif event.link.remote_target.address
- event.link.target.address = event.link.remote_target.address
- end
- end
-
- def unsubscribe(link)
- debug("unsubscribing #{link.address}") if $options[:debug]
- if @queues.has_key?(link.source.address)
- if @queues[link.source.address].unsubscribe(link)
- @queues.delete(link.source.address)
- end
- end
- end
-
- def on_link_closing(event)
- self.unsubscribe(event.link) if event.link.sender?
- end
-
- def on_connection_closing(event)
- self.remove_stale_consumers(event.connection)
- end
-
- def on_disconnected(event)
- self.remove_stale_consumers(event.connection)
- end
-
- def remove_stale_consumers(connection)
- l = connection.link_head(Qpid::Proton::Endpoint::REMOTE_ACTIVE)
- while !l.nil?
- self.unsubscribe(l) if l.sender?
- l = l.next(Qpid::Proton::Endpoint::REMOTE_ACTIVE)
- end
- end
-
- def on_sendable(event)
- debug("on_sendable event") if $options[:debug]
- q = self.queue(event.link.source.address)
- debug(" dispatching #{event.message} to #{q}") if $options[:debug]
- q.dispatch(event.link)
- end
-
- def on_message(event)
- debug("on_message event") if $options[:debug]
- q = self.queue(event.link.target.address)
- debug(" dispatching #{event.message} to #{q}") if $options[:debug]
- q.publish(event.message)
- end
-
-end
-
-$options = {
- :address => "localhost:5672",
- :debug => false
-}
-
-OptionParser.new do |opts|
- opts.banner = "Usage: #{Pathname.new(__FILE__).basename} [$options]"
-
- opts.on("-a", "--address=ADDRESS", "Send messages to ADDRESS (def. #{$options[:address]}).") do |address|
- $options[:address] = address
- end
-
- opts.on("-d", "--debug", "Enable debugging output (def. #{$options[:debug]})") do
- $options[:debug] = true
- end
-
-end.parse!
-
-begin
- Qpid::Proton::Reactor::Container.new(Broker.new($options[:address])).run
-rescue Interrupt
-end
diff --git a/ruby/tests/old-examples/client.rb b/ruby/tests/old-examples/client.rb
deleted file mode 100644
index ff22e6b..0000000
--- a/ruby/tests/old-examples/client.rb
+++ /dev/null
@@ -1,81 +0,0 @@
-# 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.
-
-
-require 'qpid_proton'
-require 'optparse'
-
-class Client < Qpid::Proton::Handler::MessagingHandler
-
- def initialize(url, requests)
- super()
- @url = url
- @requests = requests
- end
-
- def on_start(event)
- @sender = event.container.create_sender(@url)
- @receiver = event.container.create_receiver(@sender.connection, :dynamic => true)
- end
-
- def next_request
- if @receiver.remote_source.address
- req = Qpid::Proton::Message.new
- req.reply_to = @receiver.remote_source.address
- req.body = @requests.first
- puts "-> #{req.body}"
- @sender.send(req)
- end
- end
-
- def on_link_opened(event)
- if event.receiver == @receiver
- next_request
- end
- end
-
- def on_message(event)
- puts "<- #{event.message.body}"
- @requests.delete_at(0)
- if !@requests.empty?
- next_request
- else
- event.connection.close
- end
- end
-
- def on_transport_error(event)
- raise "Connection error: #{event.transport.condition}"
- end
-
-end
-
-REQUESTS = ["Twas brillig, and the slithy toves",
- "Did gire and gymble in the wabe.",
- "All mimsy were the borogroves,",
- "And the mome raths outgrabe."]
-
-options = {
- :address => "localhost:5672/examples",
-}
-
-OptionParser.new do |opts|
- opts.banner = "Usage: client.rb [options]"
- opts.on("-a", "--address=ADDRESS", "Send messages to ADDRESS (def. #{options[:address]}).") { |address| options[:address] = address }
-end.parse!
-
-Qpid::Proton::Reactor::Container.new(Client.new(options[:address], REQUESTS)).run
diff --git a/ruby/tests/old-examples/direct_recv.rb b/ruby/tests/old-examples/direct_recv.rb
deleted file mode 100644
index 7281845..0000000
--- a/ruby/tests/old-examples/direct_recv.rb
+++ /dev/null
@@ -1,64 +0,0 @@
-# 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.
-
-
-require 'qpid_proton'
-require 'optparse'
-
-require_relative 'lib/send_and_receive'
-
-class DirectReceive < ExampleReceive
-
- def initialize(url, expected)
- super
- end
-
- def on_start(event)
- @acceptor = event.container.listen(self.url)
- puts "Listening"; STDOUT.flush
- end
-
- def on_connection_opening(event)
- @acceptor.close
- end
-
- def on_message(event)
- super(event)
- @acceptor.close if self.finished?
- end
-
-end
-
-options = {
- :address => "localhost:5672/examples",
- :messages => 10,
-}
-
-OptionParser.new do |opts|
- opts.banner = "Usage: simple_send.rb [options]"
-
- opts.on("-a", "--address=ADDRESS", "Send messages to ADDRESS (def. #{options[:address]}).") do |address|
- options[:address] = address
- end
-
- opts.on("-m", "--messages=COUNT", "The number of messages to send (def. #{options[:messages]}",
- OptionParser::DecimalInteger) do |messages|
- options[:messages] = messages
- end
-end.parse!
-
-Qpid::Proton::Reactor::Container.new(DirectReceive.new(options[:address], options[:messages])).run
diff --git a/ruby/tests/old-examples/direct_send.rb b/ruby/tests/old-examples/direct_send.rb
deleted file mode 100644
index 1a7a71a..0000000
--- a/ruby/tests/old-examples/direct_send.rb
+++ /dev/null
@@ -1,63 +0,0 @@
-# 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.
-
-
-require 'qpid_proton'
-require 'optparse'
-
-require_relative 'lib/send_and_receive'
-
-options = {
- :address => "localhost:5672/examples",
- :messages => 10,
-}
-
-class SimpleSend < ExampleSend
-
- def initialize(url, messages)
- super(url, messages)
- end
-
- def on_start(event)
- @acceptor = event.container.listen(url)
- puts "Listening"; STDOUT.flush
- end
-
- def on_connection_opening(event)
- @acceptor.close
- end
-end
-
-OptionParser.new do |opts|
- opts.banner = "Usage: simple_send.rb [options]"
-
- opts.on("-a", "--address=ADDRESS", "Send messages to ADDRESS (def. #{options[:address]}).") do |address|
- options[:address] = address
- end
-
- opts.on("-m", "--messages=COUNT", "The number of messages to send (def. #{options[:messages]}",
- OptionParser::DecimalInteger) do |messages|
- options[:messages] = messages
- end
-end.parse!
-
-begin
- Qpid::Proton::Reactor::Container.new(SimpleSend.new(options[:address], options[:messages]), {:container_id=> "direct_send"}).run
-
-rescue Interrupt => error
- puts "ERROR: #{error}"
-end
diff --git a/ruby/tests/old-examples/helloworld.rb b/ruby/tests/old-examples/helloworld.rb
deleted file mode 100644
index 65b9ccc..0000000
--- a/ruby/tests/old-examples/helloworld.rb
+++ /dev/null
@@ -1,72 +0,0 @@
-# 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.
-
-
-require 'qpid_proton'
-require 'optparse'
-
-class HelloWorld < Qpid::Proton::Handler::MessagingHandler
-
- def initialize(server, address)
- super()
- @server = server
- @address = address
- end
-
- def on_start(event)
- conn = event.container.connect(:address => @server)
- event.container.create_sender(conn, :target => @address)
- event.container.create_receiver(conn, :source => @address)
- end
-
- def on_sendable(event)
- msg = Qpid::Proton::Message.new
- msg.body = "Hello world!"
- event.sender.send(msg)
- event.sender.close
- end
-
- def on_message(event)
- puts event.message.body
- event.connection.close
- end
-
- def on_transport_error(event)
- raise "Connection error: #{event.transport.condition}"
- end
-end
-
-options = {
- :address => "localhost:5672",
- :queue => "examples"
-}
-
-OptionParser.new do |opts|
- opts.banner = "Usage: helloworld_direct.rb [options]"
-
- opts.on("-a", "--address=ADDRESS", "Send messages to ADDRESS (def. #{options[:address]}).") do |address|
- options[:address] = address
- end
-
- opts.on("-q", "--queue=QUEUE", "Send messages to QUEUE (def. #{options[:queue]})") do |queue|
- options[:queue] = queue
- end
-
-end.parse!
-
-hw = HelloWorld.new(options[:address], "examples")
-Qpid::Proton::Reactor::Container.new(hw).run
diff --git a/ruby/tests/old-examples/helloworld_direct.rb b/ruby/tests/old-examples/helloworld_direct.rb
deleted file mode 100644
index f329723..0000000
--- a/ruby/tests/old-examples/helloworld_direct.rb
+++ /dev/null
@@ -1,73 +0,0 @@
-# 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.
-
-
-require 'qpid_proton'
-require 'optparse'
-
-options = {
- :address => "localhost:5672/examples",
-}
-
-class HelloWorldDirect < Qpid::Proton::Handler::MessagingHandler
-
- include Qpid::Proton::Util::Wrapper
-
- def initialize(url)
- super()
- @url = url
- end
-
- def on_start(event)
- @acceptor = event.container.listen(@url)
- event.container.create_sender(@url)
- end
-
- def on_sendable(event)
- msg = Qpid::Proton::Message.new
- msg.body = "Hello world!"
- event.sender.send(msg)
- event.sender.close
- end
-
- def on_message(event)
- puts "#{event.message.body}"
- end
-
- def on_accepted(event)
- event.connection.close
- end
-
- def on_connection_closed(event)
- @acceptor.close
- end
-
-end
-
-OptionParser.new do |opts|
- opts.banner = "Usage: helloworld_direct.rb [options]"
-
- opts.on("-a", "--address=ADDRESS", "Send messages to ADDRESS (def. #{options[:address]}).") do |address|
- options[:address] = address
- end
-
-end.parse!
-
-begin
- Qpid::Proton::Reactor::Container.new(HelloWorldDirect.new(options[:address])).run
-rescue Interrupt => error
-end
diff --git a/ruby/tests/old-examples/lib/debugging.rb b/ruby/tests/old-examples/lib/debugging.rb
deleted file mode 100644
index 4f7414e..0000000
--- a/ruby/tests/old-examples/lib/debugging.rb
+++ /dev/null
@@ -1,25 +0,0 @@
-# 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.
-
-
-module Debugging
-
- def debug(text)
- print "[#{Time.now.strftime('%s')}] #{text}\n"
- end
-
-end
diff --git a/ruby/tests/old-examples/lib/driver.rb b/ruby/tests/old-examples/lib/driver.rb
deleted file mode 100644
index 129f499..0000000
--- a/ruby/tests/old-examples/lib/driver.rb
+++ /dev/null
@@ -1,68 +0,0 @@
-# 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.
-
-
-class Driver
-
- def initialize
- @selectables = {}
- end
-
- def add(selectable)
- @selectables[selectable.fileno] = selectable
- end
-
- def process
- reading = []
- writing = []
-
- @selectables.each_value do |sel|
- if sel.closed? || sel.fileno.nil?
- @selectables.delete(sel.fileno)
- else
- begin
- reading << sel.to_io if sel.reading?
- writing << sel.to_io if sel.writing?
- rescue Exception => error
- puts "Error: #{error}"
- puts error.backtrace.join("\n");
- # @selectables.delete(sel.fileno)
- end
- end
- end
-
- read_from, write_to = IO.select(reading, writing, [], 0)
-
- unless read_from.nil?
- read_from.each do |r|
- sel = @selectables[r.fileno]
- sel.readable unless sel.nil? || sel.closed?
- end
- end
-
- begin
- unless write_to.nil?
- write_to.each do |w|
- sel = @selectables[w.fileno]
- sel.writable unless sel.nil? || sel.closed?
- end
- end
-
- end
- end
-
-end
diff --git a/ruby/tests/old-examples/lib/qpid_examples.rb b/ruby/tests/old-examples/lib/qpid_examples.rb
deleted file mode 100644
index 0a369a6..0000000
--- a/ruby/tests/old-examples/lib/qpid_examples.rb
+++ /dev/null
@@ -1,26 +0,0 @@
-# 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.
-
-
-require "qpid_proton"
-
-require "selectable"
-require "driver"
-require "socket"
-require "monitor"
-
-include Socket::Constants
diff --git a/ruby/tests/old-examples/lib/selectable.rb b/ruby/tests/old-examples/lib/selectable.rb
deleted file mode 100644
index 4634743..0000000
--- a/ruby/tests/old-examples/lib/selectable.rb
+++ /dev/null
@@ -1,119 +0,0 @@
-# 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.
-
-
-class Selectable
-
- attr_reader :transport
-
- def initialize(transport, socket)
- @transport = transport
- @socket = socket
- @socket.autoclose = true
- @write_done = false
- @read_done = false
- end
-
- def closed?
- return true if @socket.closed?
- return false if !@read_done && !@write_done
- @socket.close
- true
- end
-
- def fileno
- @socket.fileno unless @socket.closed?
- end
-
- def to_io
- @socket
- end
-
- def reading?
- return false if @read_done
- c = @transport.capacity
- if c > 0
- return true
- elsif c < 0
- @read_done = true
- return false
- else
- return false
- end
- end
-
- def writing?
- return false if @write_done
- begin
- p = @transport.pending
- if p > 0
- return true
- elsif p < 0
- @write_done = true
- return false
- else
- return false
- end
- rescue Qpid::Proton::TransportError => error
- @write_done = true
- return false
- end
- end
-
- def readable
- c = @transport.capacity
- if c > 0
- begin
- data = @socket.recv(c)
- if data
- @transport.push(data)
- else
- @transport.close_tail
- end
- rescue Exception => error
- puts "read error; #{error}"
- @transport.close_tail
- @read_done = true
- end
- elsif c < 0
- @read_done = true
- end
- end
-
- def writable
- begin
- p = @transport.pending
- if p > 0
- data = @transport.peek(p)
- n = @socket.send(data, 0)
- @transport.pop(n)
- elsif p < 0
- @write_done = true
- end
- rescue Exception => error
- puts "write error: #{error}"
- puts error.backtrace.join("\n")
- @transport.close_head
- @write_done = true
- end
- end
-
- def tick(now)
- @transport.tick(now)
- end
-
-end
diff --git a/ruby/tests/old-examples/lib/send_and_receive.rb b/ruby/tests/old-examples/lib/send_and_receive.rb
deleted file mode 100644
index 3b1cf4f..0000000
--- a/ruby/tests/old-examples/lib/send_and_receive.rb
+++ /dev/null
@@ -1,89 +0,0 @@
-# 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.
-
-
-class ExampleSend < Qpid::Proton::Handler::MessagingHandler
-
- attr_reader :url
-
- def initialize(url, expected)
- super()
- @url = url
- @sent = 0
- @confirmed = 0
- @expected = expected
- end
-
- def on_sendable(event)
- while event.sender.credit > 0 && @sent < @expected
- msg = Qpid::Proton::Message.new
- msg.body = "sequence #{@sent}"
- msg.id = @sent
- event.sender.send(msg)
- @sent = @sent + 1
- end
- end
-
- def on_accepted(event)
- @confirmed = @confirmed + 1
- if self.finished?
- puts "#{@expected > 1 ? 'All ' : ''}#{@expected} message#{@expected > 1 ? 's' : ''} confirmed!"
- event.connection.close
- end
- end
-
- def on_disconnected(event)
- @sent = @confirmed
- end
-
- def finished?
- @confirmed == @expected
- end
-
-end
-
-class ExampleReceive < Qpid::Proton::Handler::MessagingHandler
-
- attr_reader :url
-
- def initialize(url, expected)
- super()
- @url = url
- @expected = expected
- @received = 0
- end
-
- def on_message(event)
- if event.message.id.nil? || event.message.id < @received
- puts "Missing or old message id: id=#{event.message.id}"
- return
- end
- if @expected.zero? || (@received < @expected)
- puts "Received: #{event.message.body}"
- @received = @received + 1
- if finished?
- event.receiver.close
- event.connection.close
- end
- end
- end
-
- def finished?
- @received == @expected
- end
-
-end
diff --git a/ruby/tests/old-examples/old_example_test.rb b/ruby/tests/old-examples/old_example_test.rb
deleted file mode 100755
index a3f6ad1..0000000
--- a/ruby/tests/old-examples/old_example_test.rb
+++ /dev/null
@@ -1,99 +0,0 @@
-#!/usr/bin/env ruby
-#
-# 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.
-#
-
-require 'minitest/autorun'
-require 'qpid_proton'
-require 'socket'
-require 'rbconfig'
-
-begin
- MiniTest::Test
-rescue NameError # For older versions of MiniTest
- MiniTest::Test = MiniTest::Unit::TestCase
-end
-
-def unused_port; TCPServer.open(0) { |s| s.addr[1] } end
-def make_url(port, path) "amqp://:#{port}/#{path}"; end
-
-class OldExampleTest < MiniTest::Test
-
- def run_script(*args)
- IO.popen [RbConfig.ruby, *args];
- end
-
- def assert_output(want, args)
- assert_equal want.strip, run_script(*args).read.strip
- end
-
- def test_helloworld
- assert_output "Hello world!", ["helloworld.rb", "-a", make_url($port, __method__)]
- end
-
- def test_send_recv
- assert_output "All 10 messages confirmed!", ["simple_send.rb", "-a", make_url($port, __method__)]
- want = (0..9).reduce("") { |x,y| x << "Received: sequence #{y}\n" }
- assert_output want, ["simple_recv.rb", "-a", make_url($port, __method__)]
- end
-
- def test_client_server
- want = <<EOS
--> Twas brillig, and the slithy toves
-<- TWAS BRILLIG, AND THE SLITHY TOVES
--> Did gire and gymble in the wabe.
-<- DID GIRE AND GYMBLE IN THE WABE.
--> All mimsy were the borogroves,
-<- ALL MIMSY WERE THE BOROGROVES,
--> And the mome raths outgrabe.
-<- AND THE MOME RATHS OUTGRABE.
-EOS
- srv = run_script("server.rb", "-a", make_url($port, __method__))
- assert_output(want, ["client.rb", "-a", make_url($port, __method__)])
- ensure
- Process.kill :TERM, srv.pid if srv
- end
-
- def test_direct_recv
- url = make_url unused_port, __method__
- p = run_script("direct_recv.rb", "-a", url)
- p.readline # Wait till ready
- assert_output("All 10 messages confirmed!", ["simple_send.rb", "-a", url])
- want = (0..9).reduce("") { |x,y| x << "Received: sequence #{y}\n" }
- assert_equal(want.strip, p.read.strip)
- end
-
- def test_direct_send
- url = make_url unused_port, __method__
- p = run_script("direct_send.rb", "-a", url)
- p.readline # Wait till ready
- want = (0..9).reduce("") { |x,y| x << "Received: sequence #{y}\n" }
- assert_output(want, ["simple_recv.rb", "-a", url])
- assert_equal("All 10 messages confirmed!", p.read.strip)
- end
-end
-
-# Start the broker before all tests.
-$port = unused_port
-$broker = IO.popen [RbConfig.ruby, "broker.rb", "-a", ":#{$port}"]
-$broker.readline # Wait for "Listening"
-
-# Kill the broker after all tests
-MiniTest.after_run do
- Process.kill(:TERM, $broker.pid) if $broker
-end
diff --git a/ruby/tests/old-examples/server.rb b/ruby/tests/old-examples/server.rb
deleted file mode 100644
index 1908c24..0000000
--- a/ruby/tests/old-examples/server.rb
+++ /dev/null
@@ -1,75 +0,0 @@
-# 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.
-
-
-require 'qpid_proton'
-require 'optparse'
-
-class Server < Qpid::Proton::Handler::MessagingHandler
-
- def initialize(url)
- super()
- @url = Qpid::Proton::URL.new url
- @address = @url.path
- @senders = {}
- end
-
- def on_start(event)
- @container = event.container
- @conn = @container.connect(:url => @url)
- @receiver = @container.create_receiver(@conn, :source => @address)
- @relay = nil
- end
-
- def on_connection_opened(event)
- if event.connection.offered_capabilities &&
- event.connection.offered_capabilities.contain?("ANONYMOUS-RELAY")
- @relay = @container.create_sender(@conn, nil)
- end
- end
-
- def on_message(event)
- msg = event.message
- puts "<- #{msg.body}"
- sender = @relay || @senders[msg.reply_to]
- if sender.nil?
- sender = @container.create_sender(@conn, :target => msg.reply_to)
- @senders[msg.reply_to] = sender
- end
- reply = Qpid::Proton::Message.new
- reply.address = msg.reply_to
- reply.body = msg.body.upcase
- puts "-> #{reply.body}"
- reply.correlation_id = msg.correlation_id
- sender.send(reply)
- end
-
- def on_transport_error(event)
- raise "Connection error: #{event.transport.condition}"
- end
-end
-
-options = {
- :address => "localhost:5672/examples",
-}
-
-OptionParser.new do |opts|
- opts.banner = "Usage: server.rb [options]"
- opts.on("-a", "--address=ADDRESS", "Send messages to ADDRESS (def. #{options[:address]}).") { |address| options[:address] = address }
-end.parse!
-
-Qpid::Proton::Reactor::Container.new(Server.new(options[:address])).run()
diff --git a/ruby/tests/old-examples/simple_recv.rb b/ruby/tests/old-examples/simple_recv.rb
deleted file mode 100644
index 21feedd..0000000
--- a/ruby/tests/old-examples/simple_recv.rb
+++ /dev/null
@@ -1,57 +0,0 @@
-# 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.
-
-
-require 'qpid_proton'
-require 'optparse'
-
-require_relative 'lib/send_and_receive'
-
-class Receiver < ExampleReceive
-
- def initialize(url, count)
- super(url, count)
- end
-
- def on_start(event)
- event.container.create_receiver(@url)
- end
-
-end
-
-options = {
- :address => "localhost:5672/examples",
- :messages => 10,
-}
-
-OptionParser.new do |opts|
- opts.banner = "Usage: simple_send.rb [options]"
-
- opts.on("-a", "--address=ADDRESS", "Send messages to ADDRESS (def. #{options[:address]}).") do |address|
- options[:address] = address
- end
-
- opts.on("-m", "--messages=COUNT", "The number of messages to send (def. #{options[:messages]}",
- OptionParser::DecimalInteger) do |messages|
- options[:messages] = messages
- end
-end.parse!
-
-begin
- Qpid::Proton::Reactor::Container.new(Receiver.new(options[:address], options[:messages])).run
-rescue Interrupt
-end
diff --git a/ruby/tests/old-examples/simple_send.rb b/ruby/tests/old-examples/simple_send.rb
deleted file mode 100644
index 0b84c4c..0000000
--- a/ruby/tests/old-examples/simple_send.rb
+++ /dev/null
@@ -1,54 +0,0 @@
-# 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.
-
-
-require 'qpid_proton'
-require 'optparse'
-
-require_relative 'lib/send_and_receive'
-
-options = {
- :address => "localhost:5672/examples",
- :messages => 10,
-}
-
-class SimpleSend < ExampleSend
-
- def initialize(url, messages)
- super(url, messages)
- end
-
- def on_start(event)
- event.container.create_sender(url)
- end
-
-end
-
-OptionParser.new do |opts|
- opts.banner = "Usage: simple_send.rb [options]"
-
- opts.on("-a", "--address=ADDRESS", "Send messages to ADDRESS (def. #{options[:address]}).") do |address|
- options[:address] = address
- end
-
- opts.on("-m", "--messages=COUNT", "The number of messages to send (def. #{options[:messages]}",
- OptionParser::DecimalInteger) do |messages|
- options[:messages] = messages
- end
-end.parse!
-
-Qpid::Proton::Reactor::Container.new(SimpleSend.new(options[:address], options[:messages])).run
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org