diff --git a/.document b/.document index 803ebe4..f5bb871 100644 --- a/.document +++ b/.document @@ -1,8 +1,4 @@ -ext/lib/wmq_const.rb ext/wmq.c ext/wmq_queue_manager.c ext/wmq_message.c ext/wmq_queue.c -ext/lib/wmq_const_admin.rb -ext/lib/wmq_temp.rb -README diff --git a/.gitignore b/.gitignore index f771518..008c426 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,12 @@ +lib/wmq/constants.rb +lib/wmq/constants_admin.rb ext/wmq_structs.c -ext/Makefile -ext/lib/wmq_const.rb -ext/lib/wmq_const_admin.rb ext/wmq_reason.c +ext/Makefile ext/*.o ext/wmq.so nbproject/private/* -rubywmq*.gem +.DS_Store +*.gem +.idea/* +Gemfile.lock diff --git a/.project b/.project deleted file mode 100644 index 2063fc2..0000000 --- a/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - rubywmq - - - - - - org.rubypeople.rdt.core.rubybuilder - - - - - - org.rubypeople.rdt.core.rubynature - - diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 180302b..0000000 --- a/LICENSE +++ /dev/null @@ -1,13 +0,0 @@ -Copyright 2006 J. Reid Morrison. Dimension Solutions, Inc. - -Licensed 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. diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..7634f65 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2006 - 2012 J. Reid Morrison + + Licensed 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. diff --git a/Manifest.txt b/Manifest.txt deleted file mode 100644 index b3ab56f..0000000 --- a/Manifest.txt +++ /dev/null @@ -1,20 +0,0 @@ -.document -lib/wmq.rb -ext/lib/wmq_temp.rb -ext/decode_rfh.h -ext/decode_rfh.c -ext/wmq.h -ext/wmq.c -ext/wmq_message.c -ext/wmq_mq_load.c -ext/wmq_queue.c -ext/wmq_queue_manager.c -ext/extconf.rb -ext/extconf_client.rb -ext/build.bat -ext/build.sh -ext/generate/generate_const.rb -ext/generate/generate_reason.rb -ext/generate/generate_structs.rb -ext/generate/wmq_structs.erb -examples/files_to_q.cfg \ No newline at end of file diff --git a/README b/README deleted file mode 100644 index b4e9f96..0000000 --- a/README +++ /dev/null @@ -1,73 +0,0 @@ -== Description - rubywmq - RubyWMQ is a Ruby interface into WebSphere MQ, previously called MQSeries - -== Synopsis - require 'wmq' - - WMQ::QueueManager.connect(:q_mgr_name=>'REID') do |qmgr| - qmgr.put(:q_name=>'TEST.QUEUE', :data => 'Hello World') - end - -== Building Ruby WMQ - Building Ruby WMQ on UNIX/Linux - ------------------------------- - The following is required to build from source code - * A 'C' compiler - * The WebSphere MQ Software development toolkit - - Extracting the source code package: - * unzip package.zip - * tar -xvf package.tar - - cd ext/wmq - Edit the file build.sh and edit the location of WebSphere MQ (if not in /opt/mqm) - Also edit extconf.rb and extconf_client.rb with the location of WebSphere MQ (if not in /opt/mqm) - - Run build.sh - - For any questions, or to report build errors, submit a new Support Request: - http://rubywmq.rubyforge.org - - Building Ruby WMQ on Windows - ---------------------------- - The following is required to build from source code - * The Visual C++ 6.0 compiler - * The WebSphere MQ Software development toolkit - - cd ext\wmq - Edit the file build.bat and edit the location of WebSphere MQ - (if not in C:\Program Files\IBM\WebSphere MQ) - and the location of Visual C++ 6 (if not C:\Program Files\Microsoft Visual Studio\VC98) - Also edit extconf.rb and extconf_client.rb with the location of WebSphere MQ (if not in C:\Program Files\IBM\WebSphere MQ) - - Run build.bat - -== Support - For any questions, or to report build errors, submit a new Support Request: - http://rubywmq.rubyforge.org - -== Future Plans - Add more formatting option contants and related methods. - -== License - Copyright 2006 J. Reid Morrison. Dimension Solutions, Inc. - - Licensed 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. - -== Copyright - (C) 2006 J. Reid Morrison. Dimension Solutions, Inc. - All Rights Reserved - -== Author - Reid Morrison - rubywmq at gmail dot com diff --git a/README.md b/README.md new file mode 100644 index 0000000..01a7a5b --- /dev/null +++ b/README.md @@ -0,0 +1,192 @@ +## rubywmq + +* http://github.com/reidmorrison/rubywmq + +### Description + +RubyWMQ is a high performance native Ruby interface into WebSphere MQ. + +### Compatibility + +Ruby + +* RubyWMQ only works on Ruby MRI on with Ruby 1.8.7, Ruby 1.9.3, or greater +* For JRuby, see http://github.com/reidmorrison/jruby-jms + +WebSphere MQ + +* RubyWMQ parses the header files that come with WebSphere MQ so always + stays up to date with the latest structures and return codes +* RubyWMQ has been tested against WebSphere MQ 5, 6, and 7.5 + +## Example + + require 'rubygems' + require 'wmq' + + # Connect to a local queue manager called 'TEST' and put a single message + # on the queue 'TEST.QUEUE' + WMQ::QueueManager.connect(:q_mgr_name=>'TEST') do |qmgr| + qmgr.put(:q_name=>'TEST.QUEUE', :data => 'Hello World') + end + +## Installation + +### Installing on UNIX/Linux + +* Install a 'C' Compiler, GNU C++ is recommended +* Install Ruby using the package manager for your platform +* Also install RubyGems and ruby-dev or ruby-sdk packages if not already installed +* Install the [WebSphere MQ Client and/or Server](http://www.ibm.com/developerworks/downloads/ws/wmq/) + + Note: Install the Development Toolkit (SDK) and Client + +* Install RubyWMQ Gem + + gem install rubywmq + +If no errors appear RubyWMQ is ready for use + +#### Installation Errors + +Use this command to find the directory in which the gem was installed + + gem which rubywmq + +When WebSphere MQ is not installed in the default location, call the build +command directly and supply the location explicitly: + + ruby extconf.rb --with-mqm-include=/opt/mqm/inc --with-mqm-lib=/opt/mqm/lib + make + +For platforms such as AIX and HP-UX it may be necessary to statically link in +the WebSphere MQ client library when the auto-detection build above does not work. +This build option is a last resort since it will only work using a client connection + + ruby extconf_client.rb --with-mqm-include=/opt/mqm/inc --with-mqm-lib=/opt/mqm/lib + make + +### Installing on Windows + +#### Install Ruby and DevKit + +* Download and install the Ruby installer from http://rubyinstaller.org/downloads/ + + Select "Add Ruby executables to your PATH" during the installation + +* Download and install the Development Kit from the same site + + Extract files into c:\DevKit + +* Open a command prompt and run the commands below: + + cd c:\DevKit + ruby dk.rb init + +If you experience any difficulties, see https://github.com/oneclick/rubyinstaller/wiki/Development-Kit + +#### Install WebSphereMQ + +* Install the [WebSphere MQ Client and/or Server](http://www.ibm.com/developerworks/downloads/ws/wmq/) + + Note: Install the Development Toolkit (SDK) and Client + +#### Install the RubyWMQ Gem + + call "c:\DevKit\devkitvars.bat" +  gem install rubywmq --platform=ruby + +#### Installation Errors + +Use this command to find the directory in which the gems are installed + + gem env + +The path to the rubywmq gem will be something like + + C:\Ruby193\lib\ruby\gems\1.9.1\gems\rubywmq-2.0.0\ext + +When WebSphere MQ is not installed in the default location, change to the directory +above and call the build command directly while supplying the location explicitly: + + call "C:\DevKit\devkitvars.bat" + ruby extconf.rb --with-mqm-include="C:\Program Files\IBM\WebSphere MQ\Tools\c\include" + nmake + +## Verifying the build + +### Verifying a local WebSphere MQ Server installation + +* Create a local Queue Manager called TEST. Select the option to create the server +side channels. +* Create a local queue called TEST.QUEUE +* Run the following Ruby Code in an irb session: + + require 'rubygems' + require 'wmq' + WMQ::QueueManager.connect(:q_mgr_name=>'TEST') do |qmgr| + qmgr.put(:q_name=>'TEST.QUEUE', :data => 'Hello World') + end + +## Rails Installation + +After following the steps above to compile the source code, add the following +line to Gemfile + + gem 'rubywmq', :require => 'wmq' + +## Architecture + +RubyWMQ uses an automatic detection library to figure out whether a Client or Server +is installed locally. This prevents issues with having to statically link with +both the client and server libraries and then having to select the "correct" +one on startup. + +Additionally, this approach allows RubyWMQ to be simultaneously connect to both a local +Queue Manager via server bindings and to a remote Queue Manager using Client bindings. + +Instead of hard coding all the MQ C Structures and return codes into RubyWMQ, it +parses the MQ 'C' header files at compile time to take advantage of all the latest +features in new releases. + +## Contributing + +Once you've made your great commits: + +1. [Fork](http://help.github.com/forking/) rubywmq +2. Create a topic branch - `git checkout -b my_branch` +3. Push to your branch - `git push origin my_branch` +4. Create an [Issue](http://github.com/reidmorrison/rubywmq/issues) with a link to your branch +5. That's it! + +## Meta + +* Code: `git clone git://github.com/reidmorrison/rubywmq.git` +* Home: +* Bugs: +* Gems: + +This project uses [Semantic Versioning](http://semver.org/). + +## Author + +Reid Morrison :: reidmo@gmail.com :: @reidmorrison + +Special thanks to Edwin Fine for the RFH parsing code and for introducing me to +the wonderful world of Ruby + +## License + +Copyright 2006 - 2012 J. Reid Morrison + +Licensed 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. diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..2da03a8 --- /dev/null +++ b/Rakefile @@ -0,0 +1,87 @@ +lib = File.expand_path('../lib/', __FILE__) +$:.unshift lib unless $:.include?(lib) + +require 'rubygems' +require 'rake/clean' +require 'rake/testtask' +require 'date' +require 'wmq/version' + +desc "Build Ruby Source gem" +task :gem do |t| + excludes = [ + 'lib/wmq/constants.rb', + 'lib/wmq/constants_admin.rb', + 'ext/wmq_structs.c', + 'ext/wmq_reason.c', + 'ext/Makefile', + 'ext/*.o', + 'ext/wmq.so', + '*.gem', + 'nbproject' + ] + + gemspec = Gem::Specification.new do |spec| + spec.name = 'rubywmq' + spec.version = WMQ::VERSION + spec.platform = Gem::Platform::RUBY + spec.authors = ['Reid Morrison', 'Edwin Fine'] + spec.email = ['reidmo@gmail.com'] + spec.homepage = 'https://github.com/reidmorrison/rubywmq' + spec.date = Date.today.to_s + spec.summary = "Native Ruby interface into WebSphere MQ" + spec.description = "RubyWMQ is a high performance native Ruby interface into WebSphere MQ." + spec.files = FileList["./**/*"].exclude(*excludes).map{|f| f.sub(/^\.\//, '')} + + ['.document'] + spec.extensions << 'ext/extconf.rb' + spec.rubyforge_project = 'rubywmq' + spec.test_file = 'tests/test.rb' + spec.has_rdoc = true + spec.required_ruby_version = '>= 1.8.4' + spec.add_development_dependency 'shoulda' + spec.requirements << 'WebSphere MQ v5.3, v6 or v7 Client or Server with Development Kit' + end + Gem::Builder.new(gemspec).build +end + +desc "Build a binary gem including pre-compiled binary files for re-distribution" +task :binary do |t| + # Move compiled files into locations for repackaging as a binary gem + FileUtils.mkdir_p('lib/wmq') + Dir['ext/lib/*.rb'].each{|file| FileUtils.copy(file, File.join('lib/wmq', File.basename(file)))} + FileUtils.copy('ext/wmq.so', 'lib/wmq/wmq.so') + + gemspec = Gem::Specification.new do |spec| + spec.name = 'rubywmq' + spec.version = WMQ::VERSION + spec.platform = Gem::Platform::CURRENT + spec.authors = ['Reid Morrison', 'Edwin Fine'] + spec.email = ['reidmo@gmail.com'] + spec.homepage = 'https://github.com/reidmorrison/rubywmq' + spec.date = Date.today.to_s + spec.summary = "Native Ruby interface into WebSphere MQ" + spec.description = "RubyWMQ is a high performance native Ruby interface into WebSphere MQ." + spec.files = Dir['examples/**/*.rb'] + + Dir['examples/**/*.cfg'] + + Dir['doc/**/*.*'] + + Dir['lib/**/*.rb'] + + ['lib/wmq/wmq.so', 'tests/test.rb', 'README', 'LICENSE'] + spec.rubyforge_project = 'rubywmq' + spec.test_file = 'tests/test.rb' + spec.has_rdoc = false + spec.required_ruby_version = '>= 1.8.4' + spec.add_development_dependency 'shoulda' + spec.requirements << 'WebSphere MQ v5.3, v6 or v7 Client or Server with Development Kit' + end + Gem::Builder.new(gemspec).build +end + +desc "Run Test Suite" +task :test do + Rake::TestTask.new(:functional) do |t| + t.test_files = FileList['test/*_test.rb'] + t.verbose = true + end + + Rake::Task['functional'].invoke +end diff --git a/ext/build.bat b/ext/build.bat deleted file mode 100644 index 5af34e6..0000000 --- a/ext/build.bat +++ /dev/null @@ -1,3 +0,0 @@ -call "C:\Program Files\Microsoft Visual Studio\VC98\Bin\VCVARS32.BAT" -ruby extconf.rb --with-mqm-include="C:\Program Files\IBM\WebSphere MQ\Tools\c\include" -nmake diff --git a/ext/build.sh b/ext/build.sh deleted file mode 100644 index fe1e9ea..0000000 --- a/ext/build.sh +++ /dev/null @@ -1,6 +0,0 @@ -ruby extconf.rb --with-mqm-include=/opt/mqm/inc --with-mqm-lib=/opt/mqm/lib -make -# Uncomment the following lines for platforms other than Solaris, Windows and Linux -#ruby extconf_client.rb --with-mqm-include=/opt/mqm/inc --with-mqm-lib=/opt/mqm/lib -#make - diff --git a/ext/extconf.rb b/ext/extconf.rb index 312a5b0..5d65702 100644 --- a/ext/extconf.rb +++ b/ext/extconf.rb @@ -1,27 +1,11 @@ -################################################################################ -# Copyright 2006 J. Reid Morrison. Dimension Solutions, Inc. -# -# Licensed 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 'mkmf' -require 'generate/generate_reason' -require 'generate/generate_const' -require 'generate/generate_structs' +require File.join(File.dirname(__FILE__), 'generate', 'generate_reason') +require File.join(File.dirname(__FILE__), 'generate', 'generate_const') +require File.join(File.dirname(__FILE__), 'generate', 'generate_structs') include_path = '' -if RUBY_PLATFORM =~ /mswin32/ - include_path = 'C:\Program Files\IBM\WebSphere MQ\Tools\c\include' +if RUBY_PLATFORM =~ /win|mingw/i + include_path = 'C:\Program Files\IBM\WebSphere MQ\tools\c\include' dir_config('mqm', include_path, '.') else include_path = '/opt/mqm/inc' @@ -37,7 +21,7 @@ # Generate Source Files GenerateReason.generate(include_path+'/') -GenerateConst.generate(include_path+'/', 'lib') +GenerateConst.generate(include_path+'/', File.dirname(__FILE__) + '/../lib/wmq') GenerateStructs.new(include_path+'/', 'generate').generate # Generate Makefile diff --git a/ext/extconf_client.rb b/ext/extconf_client.rb index bfedc7b..ba6172c 100644 --- a/ext/extconf_client.rb +++ b/ext/extconf_client.rb @@ -1,21 +1,5 @@ -################################################################################ -# Copyright 2006 J. Reid Morrison. Dimension Solutions, Inc. # -# Licensed 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. -################################################################################ - -# -# NOTE: Do NOT use this file unless the platform being requested is not supported +# NOTE: Do NOT use this file unless the platform being used is not supported # directly by Ruby WMQ. Ruby WMQ already supports automatic dynamic loading on # Windows, Solaris and Linux # @@ -29,12 +13,12 @@ include_path = '/opt/mqm/inc' dir_config('mqm', include_path, '/opt/mqm/lib') have_library('mqic') - + # Generate Source Files # Could check if not already present GenerateReason.generate(include_path+'/') GenerateConst.generate(include_path+'/', '../../lib/wmq') GenerateStructs.new(include_path+'/', '../../generate').generate - + have_header('cmqc.h') create_makefile('wmq_client') end diff --git a/ext/generate/generate_const.rb b/ext/generate/generate_const.rb index f38483e..ca73bce 100644 --- a/ext/generate/generate_const.rb +++ b/ext/generate/generate_const.rb @@ -1,6 +1,7 @@ +# Extract Constants from the WebSphere MQ header files class GenerateConst - - #Extract Constants from Header files + + # Extract Constants from Header files def GenerateConst.extract_const(filename, const_prefix, start_exp=nil, end_exp=nil) @constants = [] active = if start_exp then false else true end # Sure there is a better way @@ -23,8 +24,8 @@ def GenerateConst.extract_const(filename, const_prefix, start_exp=nil, end_exp=n end @constants end - - #Extract MQ Constants from Header files + + # Extract MQ Constants from Header files def GenerateConst.rb_const(filename, const_prefix, exclude_exp=nil) str = '' GenerateConst.extract_const(filename, const_prefix).each do |item| @@ -42,7 +43,7 @@ def GenerateConst.rb_const(filename, const_prefix, exclude_exp=nil) end str end - + def GenerateConst.config(filename, prefix) str = "# WMQ::QueueManager execute commands\n" str << "execute_commands:\n" @@ -55,24 +56,10 @@ def GenerateConst.config(filename, prefix) end str end - + def GenerateConst.wmq_const(path) str = <'MQXQH', :header=>'xmit_q_header', :format=>'MsgDesc.Format'}, ] - + wmq_structs.each do |struct| # Parse WebSphere MQ 'C' Header file and extract elements elements = extract_struct(@path+'/'+struct[:file], struct[:struct]) @@ -84,20 +68,6 @@ end %> /* -------------------------------------------------------------------------- - * Copyright 2006 J. Reid Morrison. Dimension Solutions, Inc. - * - * Licensed 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. - * -------------------------------------------------------------------------- * * WARNING: DO NOT MODIFY THIS FILE * @@ -110,16 +80,16 @@ /* -------------------------------------------------------------------------- * Static's to hold Symbols * --------------------------------------------------------------------------*/ -<% +<% header_file = 'cmqc.h' struct = 'MQMD' # Define static variables to hold Ruby symbols key_list = symbols.keys.sort - key_list.each do |key, value| + key_list.each do |key, value| %><%="static ID ID_#{key.sub('=', '_set')};\n" %><% end - + # initialize symbols %> /* -------------------------------------------------------------------------- @@ -127,7 +97,7 @@ * --------------------------------------------------------------------------*/ void wmq_structs_id_init() { -<% key_list.each do |key, value| +<% key_list.each do |key, value| %><%=" ID_%-20s = rb_intern(\"%s\");\n"% [key.sub('=', '_set'), key] %><% end %>} @@ -145,18 +115,18 @@ void Message_from_<%=struct_name.downcase%>(VALUE hash, <%=struct_name%>* <%=var { VALUE str; size_t size; - size_t length; + size_t length; size_t i; char* pChar; - + <% elements.each do |item| type = item[0] name = item[1] - + next if @@field_ignore_list.include?(name) || (name=='Format' && struct[:header]) - + match = /(MQ\D+)/.match(type) type = "#{match[1]}S" if match[1] != type %><%= if type == 'MQMDS' @@ -164,25 +134,25 @@ void Message_from_<%=struct_name.downcase%>(VALUE hash, <%=struct_name%>* <%=var else " %-16s(hash, %-30s #{variable}->%s)\n" % ["WMQ_#{type}2HASH", rubyize_name(name)+',',name] end %><% - end + end %>} static int Message_to_<%=struct_name.downcase%>_each (VALUE key, VALUE value, <%=struct_name%>* p<%=struct_name.downcase%>) { VALUE str; size_t size; - size_t length; + size_t length; VALUE val; ID id = rb_to_id(key); - + <% contains = nil elements.each do |item| type = item[0] name = item[1] - + next if @@field_ignore_list.include?(name) || (name=='Format' && struct[:header]) - + match = /(MQ\D+)/.match(type) type = "#{match[1]}S" if match[1] != type %><%= if type == 'MQMDS' @@ -198,9 +168,9 @@ static int Message_to_<%=struct_name.downcase%>_each (VALUE key, VALUE value, <% else<% end end %><%=struct[:header]?" if(id != ID_header_type)":""%><% - if contains + if contains %> { - Message_to_<%= contains%>_each(key, value, &pmqxqh->MsgDesc); + Message_to_<%= contains%>_each(key, value, &pmqxqh->MsgDesc); }<% else%> { @@ -215,7 +185,7 @@ void Message_to_<%=struct_name.downcase%>(VALUE hash, <%=struct_name%>* p<%=stru { rb_hash_foreach(hash, Message_to_<%=struct_name.downcase%>_each, (VALUE)p<%=struct_name.downcase%>); } -<% end # wmq_structs.each +<% end # wmq_structs.each %> /* -------------------------------------------------------------------------- @@ -240,10 +210,10 @@ void Message_deblock(VALUE self, PMQMD pmqmd, PMQBYTE p_buffer, MQLONG total_len { VALUE hash = rb_hash_new(); P<%=struct[:struct]%> p_header = (P<%=struct[:struct]%>)p_data; - + if(trace_level>2) printf("WMQ::Message#deblock Found <%=struct[:header]%>\n"); - + if(memcmp(p_header->StrucId, <%=struct[:struct_id] || "#{struct[:struct].upcase}_STRUC_ID"%>, sizeof(p_header->StrucId)) != 0) { if(trace_level>1) @@ -277,7 +247,7 @@ void Message_deblock(VALUE self, PMQMD pmqmd, PMQBYTE p_buffer, MQLONG total_len else <% end - end # wmq_structs.each + end # wmq_structs.each %> { break; } @@ -287,7 +257,7 @@ void Message_deblock(VALUE self, PMQMD pmqmd, PMQBYTE p_buffer, MQLONG total_len { strncpy(pmqmd->Format, p_format, MQ_FORMAT_LENGTH); } - + Message_from_mqmd(descriptor, pmqmd); rb_funcall(self, ID_descriptor_set, 1, descriptor); rb_funcall(self, ID_headers_set, 1, headers); @@ -302,8 +272,8 @@ void Message_build_set_format(ID header_type, PMQBYTE p_format) %> if(header_type == ID_<%=struct[:header]%>) { memcpy(p_format, MQFMT_<%=struct[:header].upcase%>, MQ_FORMAT_LENGTH); return;} <% end - end # wmq_structs.each - + end # wmq_structs.each + %> rb_raise(rb_eArgError, "Invalid/Unknown header_type supplied in WMQ::Message#headers array"); } @@ -332,7 +302,7 @@ int Message_build_header (VALUE hash, struct Message_build_header_arg* parg) if(parg->trace_level>2) printf ("WMQ::Message#build_header Found <%=struct[:header]%>\n"); - + p_data = Message_autogrow_data_buffer(parg, sizeof(<%=struct[:struct]%>)); memcpy(p_data, &<%=struct[:struct]%>_DEF, sizeof(<%=struct[:struct]%>)); @@ -351,13 +321,13 @@ int Message_build_header (VALUE hash, struct Message_build_header_arg* parg) if(parg->trace_level>2) printf ("WMQ::Message#build_header data offset:%ld\n", (long)(*(parg->p_data_offset))); -<% end +<% end %> } else <% end - end # wmq_structs.each - + end # wmq_structs.each + %> { rb_raise(rb_eArgError, "Unknown :header_type supplied in WMQ::Message#headers array"); } diff --git a/ext/wmq.c b/ext/wmq.c index 812c399..225c640 100644 --- a/ext/wmq.c +++ b/ext/wmq.c @@ -1,5 +1,5 @@ /* - * Copyright 2006 J. Reid Morrison. Dimension Solutions, Inc. + * Copyright 2006 J. Reid Morrison * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -80,9 +80,6 @@ void Init_wmq() { QueueManager_selector_id_init(); QueueManager_command_id_init(); wmq_structs_id_init(); - - rb_require("wmq/wmq_temp"); - rb_require("wmq/wmq_const"); } /* diff --git a/ext/wmq.h b/ext/wmq.h index 5261048..e435eec 100644 --- a/ext/wmq.h +++ b/ext/wmq.h @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- - * Copyright 2006 J. Reid Morrison. Dimension Solutions, Inc. + * Copyright 2006 J. Reid Morrison * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,6 +33,10 @@ #define rb_str_set_len(str, length) (RSTRING_LEN(str) = (length)) #endif +#ifndef _int64 + #define _int64 long long +#endif + #include #include diff --git a/ext/wmq_message.c b/ext/wmq_message.c index ec85dfc..a901d72 100644 --- a/ext/wmq_message.c +++ b/ext/wmq_message.c @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- - * Copyright 2006 J. Reid Morrison. Dimension Solutions, Inc. + * Copyright 2006 J. Reid Morrison * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/ext/wmq_mq_load.c b/ext/wmq_mq_load.c index 447d9b8..6415a7d 100644 --- a/ext/wmq_mq_load.c +++ b/ext/wmq_mq_load.c @@ -1,5 +1,5 @@ /* - * Copyright 2006 J. Reid Morrison. Dimension Solutions, Inc. + * Copyright 2006 J. Reid Morrison * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/ext/wmq_queue.c b/ext/wmq_queue.c index 3a3f58e..f90ee2b 100644 --- a/ext/wmq_queue.c +++ b/ext/wmq_queue.c @@ -1,5 +1,5 @@ /* -------------------------------------------------------------------------- - * Copyright 2006 J. Reid Morrison. Dimension Solutions, Inc. + * Copyright 2006 J. Reid Morrison * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/ext/wmq_queue_manager.c b/ext/wmq_queue_manager.c index 7613eaa..bc1a96d 100644 --- a/ext/wmq_queue_manager.c +++ b/ext/wmq_queue_manager.c @@ -1,5 +1,5 @@ /* - * Copyright 2006 J. Reid Morrison. Dimension Solutions, Inc. + * Copyright 2006 J. Reid Morrison * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/wmq.rb b/lib/wmq.rb index 9cd0560..ee4eb38 100644 --- a/lib/wmq.rb +++ b/lib/wmq.rb @@ -1,23 +1,14 @@ -################################################################################ -# Copyright 2006 J. Reid Morrison. Dimension Solutions, Inc. -# -# Licensed 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 'wmq/version' +require 'wmq/constants' +require 'wmq/constants_admin' +require 'wmq/queue_manager' +require 'wmq/message' -# Load wmq that uses auto-load library. -# -# If it fails, then it is likely due to this platform not being supported -# by auto load facility in Ruby WMQ, so try to load client linked library +# Load wmq using the auto-load library. +# +# If it fails, then it is most likely since this platform is not supported +# by the auto load facility in Ruby WMQ, so try to load client linked library +# For Example AIX does not support Autoload whereas Windows and Linux are supported begin require 'wmq/wmq' rescue LoadError diff --git a/lib/wmq/message.rb b/lib/wmq/message.rb new file mode 100644 index 0000000..61de710 --- /dev/null +++ b/lib/wmq/message.rb @@ -0,0 +1,70 @@ +# Message Ruby methods +module WMQ + # Message contains the message descriptor (MQMD), data + # and any headers. + # + # Note: + # * The format in the descriptor applies only to the format of the data portion, + # not the format of any included headers + # * The message format can ONLY be supplied in the descriptor. + # * I.e. It is the format of the data, Not the headers. + # * On the wire formats are determined automatically by the :header_type key for + # each header + # * Other WebSphere MQ interfaces require that the formats be "daisy-chained" + # * I.e. The MQMD.Format is actually the format of the first header + # * Ruby WMQ removes this tedious requirement and performs this + # requirement automatically under the covers + # * The format of any header should not be supplied in the descriptor or any header + # + # Message has the following attributes: + # * descriptor = { + # # WebSphere MQ Equivalent + # :format => WMQ::MQFMT_STRING, # MQMD.Format - Format of data only + # WMQ::MQFMT_NONE # Do not supply header formats here + # :original_length => Number # MQMD.OriginalLength + # :priority => 0 .. 9 # MQMD.Priority + # :put_time => String # MQMD.PutTime + # :msg_id => String ... + # :expiry => Number + # :persistence => Number + # :reply_to_q => String + # :correl_id => String + # :feedback => Number + # :offset => Number + # :report => Number + # :msg_flags => Number + # :reply_to_q_mgr => String + # :appl_identity_data => String + # :put_appl_name => String + # :user_identifier => String + # :msg_seq_number => Number + # :appl_origin_data => String + # :accounting_token => String + # :backout_count => Number + # :coded_char_set_id => Number + # :put_appl_type => Number + # :msg_type => Number + # :group_id => String + # :put_date => String + # :encoding => Number + # } + # * data => String + # * headers => Array of Hashes + # * Note: Do not supply the format of any header. Ruby WMQ does this for you. + # + # The following headers are supported: + # * Rules And Formatting Header (RFH) + # :header_type => :rf_header + # :.... + # * Rules and Formatting V2 Header (RFH2) + # .... + # * Dead Letter Header + # * CICS Header + # * IMS Header + # * Transmission Queue Header + # * ... + class Message + attr_accessor :data, :descriptor, :headers + end + +end diff --git a/ext/lib/wmq_temp.rb b/lib/wmq/queue_manager.rb similarity index 53% rename from ext/lib/wmq_temp.rb rename to lib/wmq/queue_manager.rb index 1e283d6..c4413bb 100644 --- a/ext/lib/wmq_temp.rb +++ b/lib/wmq/queue_manager.rb @@ -1,35 +1,6 @@ -################################################################################ -# Copyright 2006 J. Reid Morrison. Dimension Solutions, Inc. -# -# Licensed 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. -################################################################################ - +# QueueManager ruby methods module WMQ - - # Temporary placeholder until the following code is moved to 'C' - - # class QueueManager - def method_missing(name, *args) - if args.size == 1 - self.execute({:command=>name}.merge(args[0])) - elsif args.size == 0 - self.execute({:command=>name}) - else - raise("Invalid arguments supplied to QueueManager#:#{name}, args:#{args}") - end - end - # Execute any MQSC command against the queue manager # # Example @@ -124,74 +95,16 @@ def put_to_dead_letter_q(parms) return self.put(parms) end - end + # Expose Commands directly as Queue Manager methods + def method_missing(name, *args) + if args.size == 1 + self.execute({:command=>name}.merge(args[0])) + elsif args.size == 0 + self.execute({:command=>name}) + else + raise("Invalid arguments supplied to QueueManager#:#{name}, args:#{args}") + end + end - # Message contains the message descriptor (MQMD), data - # and any headers. - # - # Note: - # * The format in the descriptor applies only to the format of the data portion, - # not the format of any included headers - # * The message format can ONLY be supplied in the descriptor. - # * I.e. It is the format of the data, Not the headers. - # * On the wire formats are determined automatically by the :header_type key for - # each header - # * Other WebSphere MQ interfaces require that the formats be "daisy-chained" - # * I.e. The MQMD.Format is actually the format of the first header - # * Ruby WMQ removes this tedious requirement and performs this - # requirement automatically under the covers - # * The format of any header should not be supplied in the descriptor or any header - # - # Message has the following attributes: - # * descriptor = { - # # WebSphere MQ Equivalent - # :format => WMQ::MQFMT_STRING, # MQMD.Format - Format of data only - # WMQ::MQFMT_NONE # Do not supply header formats here - # :original_length => Number # MQMD.OriginalLength - # :priority => 0 .. 9 # MQMD.Priority - # :put_time => String # MQMD.PutTime - # :msg_id => String ... - # :expiry => Number - # :persistence => Number - # :reply_to_q => String - # :correl_id => String - # :feedback => Number - # :offset => Number - # :report => Number - # :msg_flags => Number - # :reply_to_q_mgr => String - # :appl_identity_data => String - # :put_appl_name => String - # :user_identifier => String - # :msg_seq_number => Number - # :appl_origin_data => String - # :accounting_token => String - # :backout_count => Number - # :coded_char_set_id => Number - # :put_appl_type => Number - # :msg_type => Number - # :group_id => String - # :put_date => String - # :encoding => Number - # } - # * data => String - # * headers => Array of Hashes - # * Note: Do not supply the format of any header. Ruby WMQ does this for you. - # - # The following headers are supported: - # * Rules And Formatting Header (RFH) - # :header_type => :rf_header - # :.... - # * Rules and Formatting V2 Header (RFH2) - # .... - # * Dead Letter Header - # * CICS Header - # * IMS Header - # * Transmission Queue Header - # * ... - class Message - attr_reader :data, :descriptor, :headers - attr_writer :data, :descriptor, :headers end - end diff --git a/lib/wmq/version.rb b/lib/wmq/version.rb new file mode 100644 index 0000000..a0b8c36 --- /dev/null +++ b/lib/wmq/version.rb @@ -0,0 +1,3 @@ +module WMQ #:nodoc + VERSION = "1.9.0" +end diff --git a/nbproject/project.properties b/nbproject/project.properties index 234b628..9fd93e4 100644 --- a/nbproject/project.properties +++ b/nbproject/project.properties @@ -3,6 +3,7 @@ file.reference.trunk-examples=examples file.reference.trunk-ext=ext file.reference.trunk-lib=lib file.reference.trunk-tests=tests +javac.classpath= lib.dir=${file.reference.trunk-lib} main.file= source.encoding=UTF-8 diff --git a/nbproject/project.xml b/nbproject/project.xml index 5adb2cf..48371f1 100644 --- a/nbproject/project.xml +++ b/nbproject/project.xml @@ -5,9 +5,9 @@ rubywmq - + - + diff --git a/rubywmq.binary.gemspec b/rubywmq.binary.gemspec deleted file mode 100644 index 33b0cc0..0000000 --- a/rubywmq.binary.gemspec +++ /dev/null @@ -1,32 +0,0 @@ -require 'fileutils' -require 'rubygems' - -if $0 == __FILE__ - FileUtils.mkdir_p('lib/wmq') - Dir['ext/lib/*.rb'].each{|file| FileUtils.copy(file, File.join('lib/wmq', File.basename(file)))} - FileUtils.copy('ext/wmq.so', 'lib/wmq/wmq.so') -end - -spec = Gem::Specification.new do |s| - s.name = 'rubywmq' - s.version = '1.1.0' - s.author = 'Reid Morrison' - s.email = 'rubywmq@gmail.com' - s.homepage = 'http://www.reidmorrison.com/rubywmq' - s.platform = Gem::Platform::CURRENT - s.summary = 'Ruby interface into WebSphere MQ (MQSeries)' - s.description = 'RubyWMQ is a Ruby interface into WebSphere MQ, previously called MQSeries' - s.files = Dir['examples/**/*.rb'] + - Dir['examples/**/*.cfg'] + - Dir['doc/**/*.*'] + - Dir['lib/**/*.rb'] + - ['lib/wmq/wmq.so', 'tests/test.rb', 'README', 'LICENSE'] - s.rubyforge_project = 'rubywmq' - s.test_file = 'tests/test.rb' - s.has_rdoc = false - s.required_ruby_version = '>= 1.8.3' - s.requirements << 'WebSphere MQ v5.3, v6 or v7 Client or Server' -end -if $0 == __FILE__ - Gem::Builder.new(spec).build -end \ No newline at end of file diff --git a/rubywmq.gemspec b/rubywmq.gemspec deleted file mode 100644 index 2efe477..0000000 --- a/rubywmq.gemspec +++ /dev/null @@ -1,23 +0,0 @@ -require 'rubygems' -require 'date' -spec = Gem::Specification.new do |s| - s.name = 'rubywmq' - s.version = '1.1.0' - s.author = 'Reid Morrison' - s.email = 'rubywmq@gmail.com' - s.homepage = 'http://www.reidmorrison.com/rubywmq' - s.platform = Gem::Platform::RUBY - s.summary = 'Ruby interface into WebSphere MQ (MQSeries)' - s.description = 'RubyWMQ is a Ruby interface into WebSphere MQ, previously called MQSeries' - s.files = Dir['examples/**/*.rb'] + File.readlines('Manifest.txt').map { |l| l.chomp } - s.rubyforge_project = 'rubywmq' - s.extensions << 'ext/extconf.rb' - s.test_file = 'tests/test.rb' - s.has_rdoc = true - s.required_ruby_version = '>= 1.8.3' - s.extra_rdoc_files = ['README', 'LICENSE'] - s.requirements << 'WebSphere MQ v5.3, v6 or v7 Client or Server with MQ and Ruby SDK' -end -if $0 == __FILE__ - Gem::Builder.new(spec).build -end diff --git a/tests/test.rb b/tests/test.rb index 84182bb..a6542ad 100644 --- a/tests/test.rb +++ b/tests/test.rb @@ -1,15 +1,14 @@ -# Shift include path to use locally built copy of rubywmq - For testing dev builds only -#$:.unshift '../lib' +# Allow test to be run in-place without requiring a gem install +$LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib' require 'rubygems' -require 'wmq/wmq' -require 'wmq/wmq_const_admin' +require 'wmq' require 'test/unit' class TestTest < Test::Unit::TestCase def setup puts '****** setup: start ******' - @queue_manager = WMQ::QueueManager.new(:q_mgr_name => 'REID') #, :connection_name=>'localhost(1414)') + @queue_manager = WMQ::QueueManager.new(:q_mgr_name => 'TEST') #, :connection_name=>'localhost(1414)') @queue_manager.connect # Create Queue and clear any messages from the queue @@ -161,7 +160,7 @@ def verify_multiple_headers(headers, format) count = count + 1 end end - + def test_dlh puts '****** test_dlh ******' dlh = {:header_type =>:dead_letter_header, @@ -205,7 +204,7 @@ def test_cics } verify_header(cics, WMQ::MQFMT_NONE) end - + def test_ims puts '****** test_ims ******' ims = {:header_type =>:ims, @@ -214,7 +213,7 @@ def test_ims } verify_header(ims, WMQ::MQFMT_STRING) end - + def test_transmission_header puts '****** test_transmission_header ******' xqh = {:header_type =>:xmit_q_header, @@ -225,45 +224,45 @@ def test_transmission_header } verify_header(xqh, WMQ::MQFMT_STRING) end - + def test_rf_header puts '****** test_rf_header ******' rfh = {:header_type =>:rf_header, - :name_value => {' name s' => ' v a "l" u e 1 ', - 'n a m e 2 ' => 'v a l u e 2', + :name_value => {' name s' => ' v a "l" u e 1 ', + 'n a m e 2 ' => 'v a l u e 2', '' => ['"', '""', '"""', '""""', ''], 'name3'=>['"value3"', '', '"',' value 43"']}, } verify_header(rfh, WMQ::MQFMT_STRING) end - + def test_rf_header_2 puts '****** test_rf_header_2 ******' rfh2 = {:header_type =>:rf_header_2, - :xml => ['to the world', + :xml => ['to the world', 'xml like string'], } verify_header(rfh2, WMQ::MQFMT_STRING) end - + def test_multiple_headers puts '****** test_multiple_headers ******' headers = [{:header_type => :rf_header_2, - :xml => ['to the world', + :xml => ['to the world', 'xml like string'],}, - + {:header_type => :rf_header, - :name_value => {' name s' => ' v a l u e 1 ', - 'n a m e 2 ' => 'v a l u e 2', + :name_value => {' name s' => ' v a l u e 1 ', + 'n a m e 2 ' => 'v a l u e 2', 'name3'=>['value3', '', 'value 43']} }, - + {:header_type => :ims, :l_term_override => 'LTERM', :reply_to_format => WMQ::MQFMT_STRING}, - + {:header_type => :rf_header, - :name_value => {' name s' => ' v a l u e 1 ', - 'n a m e 2 ' => 'v a l u e 2', + :name_value => {' name s' => ' v a l u e 1 ', + 'n a m e 2 ' => 'v a l u e 2', 'name3'=>['value3', '', 'value 43']} }, {:header_type => :cics, @@ -273,16 +272,16 @@ def test_multiple_headers {:header_type => :rf_header_2, :xml => ['to the world', 'xml like string'],}, - + {:header_type => :xmit_q_header, :remote_q_name => 'SOME_REMOTE_QUEUE', :remote_q_mgr_name=> 'SOME_REMOTE_Q_MGR', :msg_type => WMQ::MQMT_REQUEST, :msg_id => 'my message Id'}, - ] + ] verify_multiple_headers(headers, WMQ::MQFMT_STRING) end - + def test_xmit_multiple_headers puts '****** test_xmit_q_header with ims header ******' headers = [{:header_type => :xmit_q_header, @@ -290,27 +289,27 @@ def test_xmit_multiple_headers :remote_q_mgr_name=> 'SOME_REMOTE_Q_MGR', :msg_type => WMQ::MQMT_REQUEST, :msg_id => 'my message Id'}, - + {:header_type => :ims, :l_term_override => 'LTERM', :reply_to_format => WMQ::MQFMT_STRING}, ] verify_multiple_headers(headers, WMQ::MQFMT_STRING) end - + def test_message_grouping puts '****** test_message_grouping ******' # Clear out queue of any messages @in_queue.each { |message| } - + msg = WMQ::Message.new msg.data = 'First' msg.descriptor[:msg_flags] = WMQ::MQMF_MSG_IN_GROUP assert_equal(@out_queue.put(:message=>msg, :options => WMQ::MQPMO_LOGICAL_ORDER), true) - + msg.data = 'Second' assert_equal(@out_queue.put(:message=>msg, :options => WMQ::MQPMO_LOGICAL_ORDER), true) - + msg.data = 'Last' msg.descriptor[:msg_flags] = WMQ::MQMF_LAST_MSG_IN_GROUP assert_equal(@out_queue.put(:message=>msg, :options => WMQ::MQPMO_LOGICAL_ORDER), true) @@ -324,5 +323,5 @@ def test_message_grouping assert_equal(str, message.data) end end - + end