ferocia-rubywmq 2.0.2 → 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +10 -0
  3. data/Gemfile.lock +36 -0
  4. data/LICENSE.txt +1 -1
  5. data/README.md +36 -47
  6. data/Rakefile +12 -76
  7. data/examples/each_a.rb +2 -3
  8. data/examples/each_b.rb +4 -5
  9. data/examples/each_header.rb +5 -6
  10. data/examples/files_to_q.rb +7 -8
  11. data/examples/get_a.rb +3 -5
  12. data/examples/get_client.rb +9 -10
  13. data/examples/put1_a.rb +2 -3
  14. data/examples/put1_b.rb +4 -7
  15. data/examples/put1_c.rb +6 -6
  16. data/examples/put_a.rb +0 -2
  17. data/examples/put_b.rb +5 -7
  18. data/examples/put_dlh.rb +11 -12
  19. data/examples/put_dynamic_q.rb +7 -7
  20. data/examples/put_group_a.rb +3 -4
  21. data/examples/put_group_b.rb +7 -7
  22. data/examples/put_rfh.rb +13 -11
  23. data/examples/put_rfh2_a.rb +9 -10
  24. data/examples/put_rfh2_b.rb +9 -9
  25. data/examples/put_xmit_q.rb +63 -8
  26. data/examples/q_to_files.rb +6 -7
  27. data/examples/request.rb +20 -18
  28. data/examples/server.rb +19 -16
  29. data/ext/extconf.rb +36 -26
  30. data/ext/extconf_client.rb +3 -3
  31. data/ext/generate/generate_const.rb +30 -23
  32. data/ext/generate/generate_reason.rb +70 -72
  33. data/ext/generate/generate_structs.rb +20 -19
  34. data/ext/generate/wmq_structs.erb +67 -67
  35. data/ext/wmq.c +0 -16
  36. data/ext/wmq.h +0 -16
  37. data/ext/wmq_message.c +8 -24
  38. data/ext/wmq_mq_load.c +5 -17
  39. data/ext/wmq_queue.c +73 -90
  40. data/ext/wmq_queue_manager.c +78 -88
  41. data/lib/wmq.rb +17 -11
  42. data/lib/wmq/message.rb +36 -34
  43. data/lib/wmq/queue_manager.rb +30 -23
  44. data/lib/wmq/version.rb +1 -1
  45. data/rubywmq.gemspec +44 -0
  46. data/test/queue_manager_test.rb +334 -0
  47. data/test/test_helper.rb +14 -0
  48. metadata +23 -34
  49. data/tests/test.rb +0 -318
@@ -1,3 +1,3 @@
1
1
  module WMQ #:nodoc
2
- VERSION = "2.0.2"
2
+ VERSION = '2.1.1'
3
3
  end
@@ -0,0 +1,44 @@
1
+ $:.push File.expand_path('../lib', __FILE__)
2
+
3
+ # Maintain your gem's version:
4
+ require 'wmq/version'
5
+
6
+ # Describe your gem and declare its dependencies:
7
+ Gem::Specification.new do |s|
8
+ # Exclude locally compiled files since they are platform specific
9
+ excludes = [
10
+ /lib.wmq.constants\.rb/,
11
+ /lib.wmq.constants_admin\.rb/,
12
+ /ext.wmq_structs\.c/,
13
+ /ext.wmq_reason\.c/,
14
+ /ext.Makefile/,
15
+ /ext.*\.o/,
16
+ /ext.wmq\.so/,
17
+ /\.gem$/,
18
+ /\.log$/,
19
+ /nbproject/
20
+ ]
21
+ s.name = 'ferocia-rubywmq'
22
+ s.version = WMQ::VERSION
23
+ s.platform = Gem::Platform::RUBY
24
+ s.authors = ['Reid Morrison']
25
+ s.email = ['reidmo@gmail.com']
26
+ s.homepage = 'https://github.com/reidmorrison/rubywmq'
27
+ s.summary = 'Native Ruby interface into WebSphere MQ'
28
+ s.description = 'RubyWMQ is a high performance native Ruby interface into WebSphere MQ.'
29
+ s.files = Dir.glob("./**/*").reject {|p| excludes.any? {|e| p[e] } }.map {|f| f.sub(/^\.\//, '')} + ['.document']
30
+ s.test_files = Dir['test/**/*']
31
+ s.license = 'Apache-2.0'
32
+ s.extensions << 'ext/extconf.rb'
33
+ s.requirements << 'WebSphere MQ v5.3, v6 or v7 Client or Server with Development Kit'
34
+ s.required_ruby_version = '>= 1.9'
35
+
36
+
37
+ s.post_install_message = <<-MESSAGE
38
+ * ferocia-rubywmq builds against the WMQ libs, which aren't available for OS X.
39
+ * The gem will still install, but the build will be skipped, producing a
40
+ * non-functional gem, so you'll need stubs. (You can skip the build elsewhere by
41
+ * setting the DISABLE_RUBYWMQ environment variable.)
42
+ MESSAGE
43
+ end
44
+
@@ -0,0 +1,334 @@
1
+ require_relative 'test_helper'
2
+
3
+ # Unit Test for RocketJob::Job
4
+ class WMQTest < Minitest::Test
5
+ context WMQ do
6
+ setup do
7
+ @queue_manager = WMQ::QueueManager.new(q_mgr_name: 'TEST') #, connection_name: 'localhost(1414)')
8
+ @queue_manager.connect
9
+
10
+ # Create Queue and clear any messages from the queue
11
+ @in_queue = WMQ::Queue.new(
12
+ queue_manager: @queue_manager,
13
+ mode: :input,
14
+ dynamic_q_name: 'UNIT.TEST.*',
15
+ q_name: 'SYSTEM.DEFAULT.MODEL.QUEUE',
16
+ fail_if_exists: false
17
+ )
18
+ @in_queue.open
19
+ @in_queue.each { |message|}
20
+
21
+ # Open same queue for Output. Queue should be created by now
22
+ @out_queue = WMQ::Queue.new(
23
+ queue_manager: @queue_manager,
24
+ mode: :output,
25
+ q_name: @in_queue.name
26
+ )
27
+ @out_queue.open
28
+ end
29
+
30
+ teardown do
31
+ @out_queue.close if @out_queue
32
+ @in_queue.close if @in_queue
33
+ @queue_manager.disconnect if @queue_manager
34
+ end
35
+
36
+ context 'exceptions' do
37
+ should 'raise exceptions' do
38
+ assert_raises(TypeError) do
39
+ WMQ::QueueManager.new(1)
40
+ end
41
+ WMQ::QueueManager.new(exception_on_error: nil)
42
+ assert_raises(TypeError) do
43
+ WMQ::QueueManager.new(exception_on_error: 1)
44
+ end
45
+ assert_raises(TypeError) do
46
+ WMQ::QueueManager.new(q_mgr_name: 2).connect
47
+ end
48
+ assert_raises(WMQ::WMQException) do
49
+ WMQ::QueueManager.new(q_mgr_name: 'bad').connect
50
+ end
51
+ end
52
+ end
53
+
54
+ context 'queue manager' do
55
+ should 'exist' do
56
+ assert_equal Object, WMQ::QueueManager.superclass
57
+ assert_equal WMQ::QueueManager, @queue_manager.class
58
+ end
59
+
60
+ should 'open_queue' do
61
+ @queue_manager.open_queue(
62
+ mode: :output,
63
+ q_name: {
64
+ q_name: @in_queue.name,
65
+ q_mgr_name: @queue_manager.name
66
+ }
67
+ ) do |test_queue|
68
+ assert_equal(true, test_queue.put(data: 'Hello World'))
69
+ message = WMQ::Message.new
70
+ assert_equal(true, @in_queue.get(message: message))
71
+ assert_equal('Hello World', message.data)
72
+ end
73
+ end
74
+
75
+ should 'execute' do
76
+ array = @queue_manager.inquire_q(
77
+ q_name: @in_queue.name,
78
+ q_type: WMQ::MQQT_LOCAL,
79
+ current_q_depth: nil
80
+ )
81
+ assert_equal 1, array.size
82
+ assert_equal @in_queue.name, array[0][:q_name]
83
+
84
+ assert_equal true, @queue_manager.inquire_process(process_name: '*').size > 0
85
+ assert_raises WMQ::WMQException do
86
+ @queue_manager.inquire_q(q_name: 'BADQUEUENAME*')
87
+ end
88
+ assert_equal 1, @queue_manager.ping_q_mgr.size
89
+ end
90
+
91
+ should 'mqsc' do
92
+ array = @queue_manager.mqsc("dis ql(#{@in_queue.name})")
93
+ assert_equal 1, array.size
94
+ assert_equal true, array[0].include?("QUEUE(#{@in_queue.name})")
95
+ end
96
+
97
+ should 'put1' do
98
+ data = 'Some Test Data'
99
+ assert_equal true, @queue_manager.put(q_name: @in_queue.name, data: data)
100
+
101
+ message = WMQ::Message.new
102
+ assert_equal true, @in_queue.get(message: message)
103
+ assert_equal data, message.data
104
+ end
105
+
106
+ end
107
+
108
+ context 'Queue' do
109
+ should 'send and receive message' do
110
+ assert_equal @out_queue.put(data: 'Hello World'), true
111
+ message = WMQ::Message.new
112
+ assert_equal @in_queue.get(message: message), true
113
+ assert_equal message.data, 'Hello World'
114
+ end
115
+
116
+ should 'group messages' do
117
+ # Clear out queue of any messages
118
+ @in_queue.each { |message|}
119
+
120
+ msg = WMQ::Message.new
121
+ msg.data = 'First'
122
+ msg.descriptor[:msg_flags] = WMQ::MQMF_MSG_IN_GROUP
123
+ assert_equal(@out_queue.put(message: msg, options: WMQ::MQPMO_LOGICAL_ORDER), true)
124
+
125
+ msg.data = 'Second'
126
+ assert_equal(@out_queue.put(message: msg, options: WMQ::MQPMO_LOGICAL_ORDER), true)
127
+
128
+ msg.data = 'Last'
129
+ msg.descriptor[:msg_flags] = WMQ::MQMF_LAST_MSG_IN_GROUP
130
+ assert_equal(@out_queue.put(message: msg, options: WMQ::MQPMO_LOGICAL_ORDER), true)
131
+ end
132
+ end
133
+
134
+ context 'Message' do
135
+ should 'dynamic_buffer' do
136
+ test_sizes = [0, 1, 100, 101, 102, 500, 65534, 65535, 65536, 65537, 1*1024*1024, 4*1024*1024]
137
+ test_sizes.each do |size|
138
+ str = '0123456789ABCDEF' * (size/16) + '0123456789ABCDEF'[0, size%16]
139
+ assert_equal str.length, size
140
+ assert_equal @out_queue.put(data: str), true
141
+ end
142
+
143
+ # First test the browse mechanism
144
+ counter = 0
145
+ @queue_manager.open_queue(mode: :browse, q_name: @in_queue.name) do |browse_queue|
146
+ browse_queue.each do |message|
147
+ size = test_sizes[counter]
148
+ assert_equal(size, message.data.length)
149
+ str = '0123456789ABCDEF' * (size/16) + '0123456789ABCDEF'[0, size%16]
150
+ assert_equal(str, message.data)
151
+ counter = counter + 1
152
+ end
153
+ end
154
+ assert_equal(test_sizes.size, counter)
155
+
156
+ # Now retrieve the messages destructively
157
+ message = WMQ::Message.new
158
+ test_sizes.each do |size|
159
+ assert_equal(true, @in_queue.get(message: message, match: WMQ::MQMO_NONE))
160
+ assert_equal(size, message.data.length)
161
+ str = '0123456789ABCDEF' * (size/16) + '0123456789ABCDEF'[0, size%16]
162
+ assert_equal(str, message.data)
163
+ end
164
+ end
165
+
166
+ should 'dead letter header' do
167
+ # TODO: Something has changed with DLH since MQ V6
168
+ skip
169
+ dlh = {
170
+ header_type: :dead_letter_header,
171
+ reason: WMQ::MQRC_UNKNOWN_REMOTE_Q_MGR,
172
+ dest_q_name: 'ORIGINAL_QUEUE_NAME',
173
+ dest_q_mgr_name: 'BAD_Q_MGR',
174
+ put_appl_name: 'TestApp.exe',
175
+ }
176
+
177
+ verify_header(dlh, WMQ::MQFMT_DEAD_LETTER_HEADER)
178
+ end
179
+
180
+ should 'cics' do
181
+ cics = {
182
+ header_type: :cics,
183
+ reason: WMQ::MQRC_UNKNOWN_REMOTE_Q_MGR,
184
+ facility: 'TOKEN123',
185
+ reply_to_format: WMQ::MQFMT_STRING
186
+ }
187
+ verify_header(cics, WMQ::MQFMT_NONE)
188
+ end
189
+
190
+ should 'ims' do
191
+ ims = {
192
+ header_type: :ims,
193
+ l_term_override: 'LTERM',
194
+ reply_to_format: WMQ::MQFMT_STRING
195
+ }
196
+ verify_header(ims, WMQ::MQFMT_STRING)
197
+ end
198
+
199
+ should 'transmission_header' do
200
+ xqh = {
201
+ header_type: :xmit_q_header,
202
+ remote_q_name: 'SOME_REMOTE_QUEUE',
203
+ remote_q_mgr_name: 'SOME_REMOTE_Q_MGR',
204
+ msg_type: WMQ::MQMT_REQUEST,
205
+ msg_id: 'my message Id'
206
+ }
207
+ verify_header(xqh, WMQ::MQFMT_STRING)
208
+ end
209
+
210
+ should 'rf_header' do
211
+ rfh = {
212
+ header_type: :rf_header,
213
+ name_value: {
214
+ ' name s' => ' v a "l" u e 1 ',
215
+ 'n a m e 2 ' => 'v a l u e 2',
216
+ '' => ['"', '""', '"""', '""""', ''],
217
+ 'name3' => ['"value3"', '', '"', ' value 43"']
218
+ }
219
+ }
220
+ verify_header(rfh, WMQ::MQFMT_STRING)
221
+ end
222
+
223
+ should 'rf_header_2' do
224
+ rfh2 = {
225
+ header_type: :rf_header_2,
226
+ xml: [
227
+ '<hello>to the world</hello>',
228
+ '<another>xml like string</another>'
229
+ ],
230
+ }
231
+ verify_header(rfh2, WMQ::MQFMT_STRING)
232
+ end
233
+
234
+ should 'multiple_headers' do
235
+ headers = [
236
+ {header_type: :rf_header_2,
237
+ xml: [
238
+ '<hello>to the world</hello>',
239
+ '<another>xml like string</another>'],
240
+ },
241
+
242
+ {
243
+ header_type: :rf_header,
244
+ name_value: {
245
+ ' name s' => ' v a l u e 1 ',
246
+ 'n a m e 2 ' => 'v a l u e 2',
247
+ 'name3' => ['value3', '', 'value 43']
248
+ }
249
+ },
250
+
251
+ {
252
+ header_type: :ims,
253
+ l_term_override: 'LTERM',
254
+ reply_to_format: WMQ::MQFMT_STRING
255
+ },
256
+
257
+ {
258
+ header_type: :rf_header,
259
+ name_value: {
260
+ ' name s' => ' v a l u e 1 ',
261
+ 'n a m e 2 ' => 'v a l u e 2',
262
+ 'name3' => ['value3', '', 'value 43']
263
+ }
264
+ },
265
+
266
+ {
267
+ header_type: :cics,
268
+ reason: WMQ::MQRC_UNKNOWN_REMOTE_Q_MGR,
269
+ facility: 'TOKEN123',
270
+ reply_to_format: WMQ::MQFMT_STRING
271
+ },
272
+
273
+ {
274
+ header_type: :rf_header_2,
275
+ xml: ['<hello>to the world</hello>', '<another>xml like string</another>'],
276
+ },
277
+
278
+ {
279
+ header_type: :xmit_q_header,
280
+ remote_q_name: 'SOME_REMOTE_QUEUE',
281
+ remote_q_mgr_name: 'SOME_REMOTE_Q_MGR',
282
+ msg_type: WMQ::MQMT_REQUEST,
283
+ msg_id: 'my message Id'
284
+ },
285
+ ]
286
+ verify_multiple_headers(headers, WMQ::MQFMT_STRING)
287
+ end
288
+
289
+ should 'xmit_q_header' do
290
+ headers = [
291
+ {
292
+ header_type: :xmit_q_header,
293
+ remote_q_name: 'SOME_REMOTE_QUEUE',
294
+ remote_q_mgr_name: 'SOME_REMOTE_Q_MGR',
295
+ msg_type: WMQ::MQMT_REQUEST,
296
+ msg_id: 'my message Id'},
297
+
298
+ {
299
+ header_type: :ims,
300
+ l_term_override: 'LTERM',
301
+ reply_to_format: WMQ::MQFMT_STRING
302
+ },
303
+ ]
304
+ verify_multiple_headers(headers, WMQ::MQFMT_STRING)
305
+ end
306
+ end
307
+ end
308
+
309
+ def verify_header(header, format)
310
+ verify_multiple_headers([header], format)
311
+ end
312
+
313
+ def verify_multiple_headers(headers, format)
314
+ data = 'Some Test Data'
315
+ message = WMQ::Message.new
316
+ message.data = data
317
+ message.descriptor[:format] = format
318
+ message.headers = headers
319
+ #assert_equal(true,@queue_manager.put(q_name: @in_queue.name, message: message))
320
+ assert_equal(true, @out_queue.put(message: message))
321
+
322
+ message = WMQ::Message.new
323
+ assert_equal true, @in_queue.get(message: message)
324
+ assert_equal data, message.data
325
+ assert_equal headers.size, message.headers.size
326
+ count = 0
327
+ headers.each do |header|
328
+ reply_header = message.headers[count]
329
+ header.each_pair { |key, value| assert_equal(value, reply_header[key]) }
330
+ count = count + 1
331
+ end
332
+ end
333
+
334
+ end
@@ -0,0 +1,14 @@
1
+ $LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
2
+
3
+ require 'yaml'
4
+ require 'minitest/autorun'
5
+ require 'minitest/reporters'
6
+ require 'minitest/stub_any_instance'
7
+ require 'shoulda/context'
8
+ require 'wmq'
9
+ require 'awesome_print'
10
+
11
+ Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new
12
+
13
+ # SemanticLogger.add_appender('test.log', &SemanticLogger::Appender::Base.colorized_formatter)
14
+ # SemanticLogger.default_level = :debug
metadata CHANGED
@@ -1,33 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ferocia-rubywmq
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
5
- prerelease:
4
+ version: 2.1.1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Reid Morrison
9
- - Edwin Fine
10
8
  autorequire:
11
9
  bindir: bin
12
10
  cert_chain: []
13
- date: 2013-06-06 00:00:00.000000000 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
16
- name: shoulda
17
- requirement: !ruby/object:Gem::Requirement
18
- none: false
19
- requirements:
20
- - - ! '>='
21
- - !ruby/object:Gem::Version
22
- version: '0'
23
- type: :development
24
- prerelease: false
25
- version_requirements: !ruby/object:Gem::Requirement
26
- none: false
27
- requirements:
28
- - - ! '>='
29
- - !ruby/object:Gem::Version
30
- version: '0'
11
+ date: 2020-09-08 00:00:00.000000000 Z
12
+ dependencies: []
31
13
  description: RubyWMQ is a high performance native Ruby interface into WebSphere MQ.
32
14
  email:
33
15
  - reidmo@gmail.com
@@ -36,6 +18,9 @@ extensions:
36
18
  - ext/extconf.rb
37
19
  extra_rdoc_files: []
38
20
  files:
21
+ - ".document"
22
+ - Gemfile
23
+ - Gemfile.lock
39
24
  - LICENSE.txt
40
25
  - README.md
41
26
  - Rakefile
@@ -82,33 +67,37 @@ files:
82
67
  - lib/wmq/message.rb
83
68
  - lib/wmq/queue_manager.rb
84
69
  - lib/wmq/version.rb
85
- - tests/test.rb
86
- - .document
70
+ - rubywmq.gemspec
71
+ - test/queue_manager_test.rb
72
+ - test/test_helper.rb
87
73
  homepage: https://github.com/reidmorrison/rubywmq
88
74
  licenses:
89
- - Apache License V2.0
90
- post_install_message:
75
+ - Apache-2.0
76
+ metadata: {}
77
+ post_install_message: |
78
+ * ferocia-rubywmq builds against the WMQ libs, which aren't available for OS X.
79
+ * The gem will still install, but the build will be skipped, producing a
80
+ * non-functional gem, so you'll need stubs. (You can skip the build elsewhere by
81
+ * setting the DISABLE_RUBYWMQ environment variable.)
91
82
  rdoc_options: []
92
83
  require_paths:
93
84
  - lib
94
85
  required_ruby_version: !ruby/object:Gem::Requirement
95
- none: false
96
86
  requirements:
97
- - - ! '>='
87
+ - - ">="
98
88
  - !ruby/object:Gem::Version
99
- version: 1.8.4
89
+ version: '1.9'
100
90
  required_rubygems_version: !ruby/object:Gem::Requirement
101
- none: false
102
91
  requirements:
103
- - - ! '>='
92
+ - - ">="
104
93
  - !ruby/object:Gem::Version
105
94
  version: '0'
106
95
  requirements:
107
96
  - WebSphere MQ v5.3, v6 or v7 Client or Server with Development Kit
108
- rubyforge_project: rubywmq
109
- rubygems_version: 1.8.23
97
+ rubygems_version: 3.1.4
110
98
  signing_key:
111
- specification_version: 3
99
+ specification_version: 4
112
100
  summary: Native Ruby interface into WebSphere MQ
113
101
  test_files:
114
- - tests/test.rb
102
+ - test/queue_manager_test.rb
103
+ - test/test_helper.rb