qpid_proton 0.19.0 → 0.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/examples/README.md +76 -0
  3. data/examples/broker.rb +167 -0
  4. data/examples/client.rb +79 -0
  5. data/examples/direct_recv.rb +61 -0
  6. data/examples/direct_send.rb +67 -0
  7. data/examples/example_test.rb +109 -0
  8. data/examples/helloworld.rb +57 -0
  9. data/examples/server.rb +70 -0
  10. data/examples/simple_recv.rb +57 -0
  11. data/examples/simple_send.rb +63 -0
  12. data/examples/ssl_certs/README.txt +24 -0
  13. data/examples/ssl_certs/tclient-certificate.p12 +0 -0
  14. data/examples/ssl_certs/tclient-certificate.pem +19 -0
  15. data/examples/ssl_certs/tclient-full.p12 +0 -0
  16. data/examples/ssl_certs/tclient-private-key.pem +30 -0
  17. data/examples/ssl_certs/tserver-certificate.p12 +0 -0
  18. data/examples/ssl_certs/tserver-certificate.pem +19 -0
  19. data/examples/ssl_certs/tserver-full.p12 +0 -0
  20. data/examples/ssl_certs/tserver-private-key.pem +30 -0
  21. data/examples/ssl_send.rb +70 -0
  22. data/ext/cproton/cproton.c +105 -74
  23. data/lib/core/container.rb +2 -1
  24. data/lib/core/ssl_domain.rb +1 -1
  25. data/lib/core/uri.rb +15 -9
  26. data/lib/handler/messaging_adapter.rb +20 -5
  27. data/tests/old_examples/broker.rb +200 -0
  28. data/tests/old_examples/client.rb +81 -0
  29. data/tests/old_examples/direct_recv.rb +64 -0
  30. data/tests/old_examples/direct_send.rb +63 -0
  31. data/tests/old_examples/helloworld.rb +72 -0
  32. data/tests/old_examples/helloworld_direct.rb +73 -0
  33. data/tests/old_examples/lib/debugging.rb +25 -0
  34. data/tests/old_examples/lib/driver.rb +68 -0
  35. data/tests/old_examples/lib/qpid_examples.rb +26 -0
  36. data/tests/old_examples/lib/selectable.rb +119 -0
  37. data/tests/old_examples/lib/send_and_receive.rb +89 -0
  38. data/tests/old_examples/old_example_test.rb +107 -0
  39. data/tests/old_examples/recv.rb +23 -0
  40. data/tests/old_examples/send.rb +21 -0
  41. data/tests/old_examples/server.rb +75 -0
  42. data/tests/old_examples/simple_recv.rb +57 -0
  43. data/tests/old_examples/simple_send.rb +54 -0
  44. data/tests/test_connection_driver.rb +134 -0
  45. data/tests/test_container.rb +319 -0
  46. data/tests/test_data.rb +66 -0
  47. data/tests/test_delivery.rb +110 -0
  48. data/tests/test_interop.rb +131 -0
  49. data/tests/test_messaging_adapter.rb +223 -0
  50. data/tests/test_old_adapter.rb +228 -0
  51. data/tests/test_tools.rb +147 -0
  52. data/tests/test_uri.rb +83 -0
  53. metadata +49 -3
@@ -0,0 +1,147 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one
2
+ # or more contributor license agreements. See the NOTICE file
3
+ # distributed with this work for additional information
4
+ # regarding copyright ownership. The ASF licenses this file
5
+ # to you under the Apache License, Version 2.0 (the
6
+ # "License"); you may not use this file except in compliance
7
+ # with the License. You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+
18
+
19
+ # Tools for tests. Only minitest is used.
20
+
21
+ require 'minitest/autorun'
22
+ require 'qpid_proton'
23
+ require 'socket'
24
+
25
+ begin
26
+ MiniTest::Test
27
+ rescue NameError # For older versions of MiniTest
28
+ MiniTest::Test = MiniTest::Unit::TestCase
29
+ end
30
+
31
+ class TestError < Exception; end
32
+
33
+ def wait_port(port, timeout=5)
34
+ deadline = Time.now + timeout
35
+ begin # Wait for the port to be connectible
36
+ TCPSocket.open("", $port).close
37
+ rescue Errno::ECONNREFUSED
38
+ if Time.now > deadline then
39
+ raise TestError, "timed out waiting for port #{port}"
40
+ end
41
+ sleep(0.1)
42
+ retry
43
+ end
44
+ end
45
+
46
+ # Handler that records some common events that are checked by tests
47
+ class TestHandler < Qpid::Proton::MessagingHandler
48
+ attr_reader :errors, :connections, :sessions, :links, :messages
49
+
50
+ # Pass optional extra handlers and options to the Container
51
+ # @param raise_errors if true raise an exception for error events, if false, store them in #errors
52
+ def initialize(raise_errors=true)
53
+ super()
54
+ @raise_errors = raise_errors
55
+ @errors, @connections, @sessions, @links, @messages = 5.times.collect { [] }
56
+ end
57
+
58
+ # If the handler has errors, raise a TestError with all the error text
59
+ def raise_errors()
60
+ return if @errors.empty?
61
+ text = ""
62
+ while @errors.size > 0
63
+ text << @errors.pop + "\n"
64
+ end
65
+ raise TestError.new("TestHandler has errors:\n #{text}")
66
+ end
67
+
68
+ def on_error(condition)
69
+ @errors.push "#{condition}"
70
+ raise_errors if @raise_errors
71
+ end
72
+
73
+ def endpoint_open(queue, endpoint)
74
+ queue.push(endpoint)
75
+ end
76
+
77
+ def on_connection_open(c)
78
+ endpoint_open(@connections, c)
79
+ end
80
+
81
+ def on_session_open(s)
82
+ endpoint_open(@sessions, s)
83
+ end
84
+
85
+ def on_receiver_open(l)
86
+ endpoint_open(@links, l)
87
+ end
88
+
89
+ def on_sender_open(l)
90
+ endpoint_open(@links, l)
91
+ end
92
+
93
+ def on_message(d, m)
94
+ @messages.push(m)
95
+ end
96
+ end
97
+
98
+ # ListenHandler that closes the Listener after first accept
99
+ class ListenOnceHandler < Qpid::Proton::Listener::Handler
100
+ def on_error(l, e) raise TestError, e.inspect; end
101
+ def on_accept(l) l.close; super; end
102
+ end
103
+
104
+ # Add port/url to Listener, assuming a TCP socket
105
+ class Qpid::Proton::Listener
106
+ def port() to_io.addr[1]; end
107
+ def url() "amqp://:#{port}"; end
108
+ end
109
+
110
+ # A client/server pair of ConnectionDrivers linked by a socket pair
111
+ DriverPair = Struct.new(:client, :server) do
112
+
113
+ def initialize(client_handler, server_handler)
114
+ s = Socket.pair(:LOCAL, :STREAM, 0)
115
+ self.client = HandlerDriver.new(s[0], client_handler)
116
+ self.server = HandlerDriver.new(s[1], server_handler)
117
+ server.transport.set_server
118
+ end
119
+
120
+ # Process each driver once, return time of next timed event
121
+ def process(now = Time.now, max_time=nil)
122
+ t = collect { |d| d.process(now) }.compact.min
123
+ t = max_time if max_time && t > max_time
124
+ t
125
+ end
126
+
127
+ def active()
128
+ can_read = self.select { |d| d.can_read? }
129
+ can_write = self.select {|d| d.can_write? }
130
+ IO.select(can_read, can_write, [], 0)
131
+ end
132
+
133
+ def names() collect { |x| x.handler.names }; end
134
+
135
+ def clear() each { |x| x.handler.clear; } end
136
+
137
+ # Run till there is nothing else to do - not handle waiting for timed events
138
+ # but does pass +now+ to process and returns the min returned timed event time
139
+ def run(now=Time.now)
140
+ t = nil
141
+ begin
142
+ t = process(now, t)
143
+ end while active
144
+ t
145
+ end
146
+ end
147
+
data/tests/test_uri.rb ADDED
@@ -0,0 +1,83 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one
2
+ # or more contributor license agreements. See the NOTICE file
3
+ # distributed with this work for additional information
4
+ # regarding copyright ownership. The ASF licenses this file
5
+ # to you under the Apache License, Version 2.0 (the
6
+ # "License"); you may not use this file except in compliance
7
+ # with the License. You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+
18
+
19
+ require 'test_tools'
20
+ require 'qpid_proton'
21
+
22
+ class TestURI < MiniTest::Test
23
+
24
+ PARTS=[:scheme, :userinfo, :host, :port, :path] # Interesting URI components
25
+ def uri(u) Qpid::Proton::uri(u); end
26
+ def uri_parts(u) uri(u).select(*PARTS); end
27
+
28
+ # Extension to standard URI parser
29
+ def test_standard
30
+ u = URI("amqp://u:p@h/x")
31
+ assert_equal URI::AMQP, u.class
32
+ assert_equal ['amqp', 'u:p', 'h', 5672, '/x'], u.select(*PARTS)
33
+
34
+ u = URI("amqps://u:p@h/x")
35
+ assert_equal URI::AMQPS, u.class
36
+ assert_equal ['amqps', 'u:p', 'h', 5671, '/x'], u.select(*PARTS)
37
+
38
+ assert_equal ['amqp', nil, '[::1:2:3]', 5672, ""], URI('amqp://[::1:2:3]').select(*PARTS)
39
+ end
40
+
41
+ # Proton::uri on valid URIs
42
+ def test_valid
43
+ u = uri("amqp://u:p@h:1/x")
44
+ assert_equal URI::AMQP, u.class
45
+ assert_equal ['amqp', 'u:p', 'h', 1, '/x'], u.select(*PARTS)
46
+
47
+ u = uri("amqps://u:p@h:1/x")
48
+ assert_equal URI::AMQPS, u.class
49
+ assert_equal ['amqps', 'u:p', 'h', 1, '/x'], u.select(*PARTS)
50
+
51
+ # Schemeless string -> amqp
52
+ assert_equal ["amqp", nil, "h", 1, "/x"], uri_parts("//h:1/x")
53
+ assert_equal ["amqp", nil, "", 5672, "/x"], uri_parts("/x")
54
+ assert_equal ["amqp", nil, "[::1]", 5672, ""], uri_parts("//[::1]")
55
+
56
+ # Schemeless URI gets amqp: scheme
57
+ assert_equal ["amqp", nil, nil, 5672, "/x"], uri_parts(URI("/x"))
58
+
59
+ # Pass-through
60
+ u = uri('')
61
+ assert_same u, uri(u)
62
+ end
63
+
64
+ # Proton::uri non-standard shortcuts
65
+ def test_shortcut
66
+ assert_equal URI("amqp://u:p@h:1/x"), uri("u:p@h:1/x")
67
+ assert_equal URI("amqp://h:1"), uri("h:1")
68
+ assert_equal URI("amqp://h"), uri("h")
69
+ assert_equal URI("amqp://h"), uri("h:")
70
+ assert_equal ["amqp", nil, "", 1, ""], uri_parts(":1")
71
+ assert_equal ["amqp", nil, "", 1, ""], uri_parts("amqp://:1")
72
+ assert_equal URI("amqp://[::1:2]:1"), uri("[::1:2]:1")
73
+ assert_equal URI("amqp://[::1:2]"), uri("[::1:2]")
74
+ end
75
+
76
+ def test_error
77
+ assert_raises(::ArgumentError) { uri(nil) }
78
+ assert_raises(URI::BadURIError) { uri(URI("http://x")) } # Don't re-parse a URI with wrong scheme
79
+ assert_raises(URI::InvalidURIError) { uri("x:y:z") } # Nonsense
80
+ assert_raises(URI::InvalidURIError) { uri("amqp://[foobar]") } # Bad host
81
+ end
82
+
83
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qpid_proton
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.19.0
4
+ version: 0.21.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Darryl L. Pierce
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-01-02 00:00:00.000000000 Z
12
+ date: 2018-03-06 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: |
15
15
  Proton is a high performance, lightweight messaging library. It can be used in
@@ -26,6 +26,26 @@ files:
26
26
  - ChangeLog
27
27
  - LICENSE
28
28
  - TODO
29
+ - examples/README.md
30
+ - examples/broker.rb
31
+ - examples/client.rb
32
+ - examples/direct_recv.rb
33
+ - examples/direct_send.rb
34
+ - examples/example_test.rb
35
+ - examples/helloworld.rb
36
+ - examples/server.rb
37
+ - examples/simple_recv.rb
38
+ - examples/simple_send.rb
39
+ - examples/ssl_certs/README.txt
40
+ - examples/ssl_certs/tclient-certificate.p12
41
+ - examples/ssl_certs/tclient-certificate.pem
42
+ - examples/ssl_certs/tclient-full.p12
43
+ - examples/ssl_certs/tclient-private-key.pem
44
+ - examples/ssl_certs/tserver-certificate.p12
45
+ - examples/ssl_certs/tserver-certificate.pem
46
+ - examples/ssl_certs/tserver-full.p12
47
+ - examples/ssl_certs/tserver-private-key.pem
48
+ - examples/ssl_send.rb
29
49
  - ext/cproton/cproton.c
30
50
  - ext/cproton/extconf.rb
31
51
  - lib/codec/data.rb
@@ -76,6 +96,32 @@ files:
76
96
  - lib/util/timeout.rb
77
97
  - lib/util/version.rb
78
98
  - lib/util/wrapper.rb
99
+ - tests/old_examples/broker.rb
100
+ - tests/old_examples/client.rb
101
+ - tests/old_examples/direct_recv.rb
102
+ - tests/old_examples/direct_send.rb
103
+ - tests/old_examples/helloworld.rb
104
+ - tests/old_examples/helloworld_direct.rb
105
+ - tests/old_examples/lib/debugging.rb
106
+ - tests/old_examples/lib/driver.rb
107
+ - tests/old_examples/lib/qpid_examples.rb
108
+ - tests/old_examples/lib/selectable.rb
109
+ - tests/old_examples/lib/send_and_receive.rb
110
+ - tests/old_examples/old_example_test.rb
111
+ - tests/old_examples/recv.rb
112
+ - tests/old_examples/send.rb
113
+ - tests/old_examples/server.rb
114
+ - tests/old_examples/simple_recv.rb
115
+ - tests/old_examples/simple_send.rb
116
+ - tests/test_connection_driver.rb
117
+ - tests/test_container.rb
118
+ - tests/test_data.rb
119
+ - tests/test_delivery.rb
120
+ - tests/test_interop.rb
121
+ - tests/test_messaging_adapter.rb
122
+ - tests/test_old_adapter.rb
123
+ - tests/test_tools.rb
124
+ - tests/test_uri.rb
79
125
  homepage: http://qpid.apache.org/proton
80
126
  licenses:
81
127
  - Apache-2.0
@@ -88,7 +134,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
88
134
  requirements:
89
135
  - - ">="
90
136
  - !ruby/object:Gem::Version
91
- version: '0'
137
+ version: 1.9.3
92
138
  required_rubygems_version: !ruby/object:Gem::Requirement
93
139
  requirements:
94
140
  - - ">="