summaryrefslogtreecommitdiff
path: root/qpid
diff options
context:
space:
mode:
authorLahiru Gunathilake <lahiru@apache.org>2008-10-07 09:07:34 +0000
committerLahiru Gunathilake <lahiru@apache.org>2008-10-07 09:07:34 +0000
commit72b302e7c6ce04f700dfc8f52a17599dd2268eb8 (patch)
tree478c74e63dc35eb81a6e6bf31ed851ab935268ae /qpid
parent6498fc705816a435f8a9a5f2fdd60816b19beb90 (diff)
downloadqpid-python-72b302e7c6ce04f700dfc8f52a17599dd2268eb8.tar.gz
committing qpid-cli for the first time.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@702402 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid')
-rw-r--r--qpid/java/management/tools/qpid-cli/Guide.txt143
-rw-r--r--qpid/java/management/tools/qpid-cli/LICENSE225
-rw-r--r--qpid/java/management/tools/qpid-cli/NOTICE12
-rw-r--r--qpid/java/management/tools/qpid-cli/README64
-rwxr-xr-xqpid/java/management/tools/qpid-cli/bin/qpid-cli34
-rwxr-xr-xqpid/java/management/tools/qpid-cli/bin/qpid-cli.bat27
-rw-r--r--qpid/java/management/tools/qpid-cli/build.xml73
-rw-r--r--qpid/java/management/tools/qpid-cli/lib/jline-0.9.94.jarbin0 -> 87325 bytes
-rw-r--r--qpid/java/management/tools/qpid-cli/lib/junit-4.4.jarbin0 -> 161477 bytes
-rw-r--r--qpid/java/management/tools/qpid-cli/report.property7
-rw-r--r--qpid/java/management/tools/qpid-cli/src/org/apache/qpid/Command.java62
-rw-r--r--qpid/java/management/tools/qpid-cli/src/org/apache/qpid/CommandConstants.java50
-rw-r--r--qpid/java/management/tools/qpid-cli/src/org/apache/qpid/CommandExecusionEngine.java88
-rw-r--r--qpid/java/management/tools/qpid-cli/src/org/apache/qpid/CommandLineInterpreter.java194
-rw-r--r--qpid/java/management/tools/qpid-cli/src/org/apache/qpid/Connector.java76
-rw-r--r--qpid/java/management/tools/qpid-cli/src/org/apache/qpid/ConnectorFactory.java72
-rw-r--r--qpid/java/management/tools/qpid-cli/src/org/apache/qpid/ReportGenerator.java180
-rw-r--r--qpid/java/management/tools/qpid-cli/src/org/apache/qpid/commands/Command.java113
-rw-r--r--qpid/java/management/tools/qpid-cli/src/org/apache/qpid/commands/Commanddelete.java228
-rw-r--r--qpid/java/management/tools/qpid-cli/src/org/apache/qpid/commands/Commandhelp.java73
-rw-r--r--qpid/java/management/tools/qpid-cli/src/org/apache/qpid/commands/Commandinfo.java259
-rw-r--r--qpid/java/management/tools/qpid-cli/src/org/apache/qpid/commands/Commandlist.java296
-rw-r--r--qpid/java/management/tools/qpid-cli/src/org/apache/qpid/commands/Commandmove.java294
-rw-r--r--qpid/java/management/tools/qpid-cli/src/org/apache/qpid/commands/Commandview.java276
-rw-r--r--qpid/java/management/tools/qpid-cli/src/org/apache/qpid/commands/Commandviewcontent.java284
-rw-r--r--qpid/java/management/tools/qpid-cli/src/org/apache/qpid/commands/objects/AllObjects.java44
-rw-r--r--qpid/java/management/tools/qpid-cli/src/org/apache/qpid/commands/objects/ConnectionObject.java54
-rw-r--r--qpid/java/management/tools/qpid-cli/src/org/apache/qpid/commands/objects/ExchangeObject.java53
-rw-r--r--qpid/java/management/tools/qpid-cli/src/org/apache/qpid/commands/objects/ObjectNames.java477
-rw-r--r--qpid/java/management/tools/qpid-cli/src/org/apache/qpid/commands/objects/QueueObject.java86
-rw-r--r--qpid/java/management/tools/qpid-cli/src/org/apache/qpid/commands/objects/UserManagementObject.java45
-rw-r--r--qpid/java/management/tools/qpid-cli/src/org/apache/qpid/commands/objects/VirtualHostObject.java53
-rw-r--r--qpid/java/management/tools/qpid-cli/src/org/apache/qpid/utils/CommandLineOption.java112
-rw-r--r--qpid/java/management/tools/qpid-cli/src/org/apache/qpid/utils/CommandLineOptionConstants.java53
-rw-r--r--qpid/java/management/tools/qpid-cli/src/org/apache/qpid/utils/CommandLineOptionParser.java218
-rw-r--r--qpid/java/management/tools/qpid-cli/src/org/apache/qpid/utils/JMXConfigProperty.java47
-rw-r--r--qpid/java/management/tools/qpid-cli/src/org/apache/qpid/utils/JMXConfiguration.java148
-rw-r--r--qpid/java/management/tools/qpid-cli/src/org/apache/qpid/utils/JMXinfo.java72
-rw-r--r--qpid/java/management/tools/qpid-cli/test/org/apache/qpid/AllTest.java80
-rw-r--r--qpid/java/management/tools/qpid-cli/test/org/apache/qpid/ConnectionConstants.java51
-rw-r--r--qpid/java/management/tools/qpid-cli/test/org/apache/qpid/TestCommandExecusionEngine.java90
-rw-r--r--qpid/java/management/tools/qpid-cli/test/org/apache/qpid/TestCommandLineInterpreter.java101
-rw-r--r--qpid/java/management/tools/qpid-cli/test/org/apache/qpid/TestConnector.java106
-rw-r--r--qpid/java/management/tools/qpid-cli/test/org/apache/qpid/TestReportGenerator.java50
-rw-r--r--qpid/java/management/tools/qpid-cli/test/org/apache/qpid/commands/TestCommand.java99
-rw-r--r--qpid/java/management/tools/qpid-cli/test/org/apache/qpid/commands/TestCommanddelete.java99
-rw-r--r--qpid/java/management/tools/qpid-cli/test/org/apache/qpid/commands/TestCommandinfo.java95
-rw-r--r--qpid/java/management/tools/qpid-cli/test/org/apache/qpid/commands/TestCommandlist.java100
-rw-r--r--qpid/java/management/tools/qpid-cli/test/org/apache/qpid/commands/TestCommandmove.java100
-rw-r--r--qpid/java/management/tools/qpid-cli/test/org/apache/qpid/commands/TestCommandview.java96
-rw-r--r--qpid/java/management/tools/qpid-cli/test/org/apache/qpid/commands/TestCommandviewcontent.java99
-rw-r--r--qpid/java/management/tools/qpid-cli/test/org/apache/qpid/commands/objects/TestAllObject.java93
-rw-r--r--qpid/java/management/tools/qpid-cli/test/org/apache/qpid/commands/objects/TestConnectionObject.java105
-rw-r--r--qpid/java/management/tools/qpid-cli/test/org/apache/qpid/commands/objects/TestExchangeObject.java103
-rw-r--r--qpid/java/management/tools/qpid-cli/test/org/apache/qpid/commands/objects/TestObjectNames.java51
-rw-r--r--qpid/java/management/tools/qpid-cli/test/org/apache/qpid/commands/objects/TestQueueObject.java106
-rw-r--r--qpid/java/management/tools/qpid-cli/test/org/apache/qpid/commands/objects/TestUserManagementObject.java102
-rw-r--r--qpid/java/management/tools/qpid-cli/test/org/apache/qpid/commands/objects/TestVirtualHostObject.java88
-rw-r--r--qpid/java/management/tools/qpid-cli/test/org/apache/qpid/utils/TestCommandLineOption.java85
-rw-r--r--qpid/java/management/tools/qpid-cli/test/org/apache/qpid/utils/TestCommandLineOptionParser.java100
-rw-r--r--qpid/java/management/tools/qpid-cli/test/org/apache/qpid/utils/TestJMXConfigProperty.java51
-rw-r--r--qpid/java/management/tools/qpid-cli/test/org/apache/qpid/utils/TestJMXConfiguration.java85
-rw-r--r--qpid/java/management/tools/qpid-cli/test/org/apache/qpid/utils/TestJMXinfo.java53
63 files changed, 6780 insertions, 0 deletions
diff --git a/qpid/java/management/tools/qpid-cli/Guide.txt b/qpid/java/management/tools/qpid-cli/Guide.txt
new file mode 100644
index 0000000000..db841ebaa1
--- /dev/null
+++ b/qpid/java/management/tools/qpid-cli/Guide.txt
@@ -0,0 +1,143 @@
+
+ * How to connect with the Broker *
+ ---------------------------------
+
+Before you come in to this state you have to build the source or you
+can get the binary and extract then set the QPID_CLI environment
+variable to the main directory of the source or binary,then only you
+are in a position to start working with management console. First
+check whether the broker is up and running. In order to simply connect
+with the broker you can run the qpid-cli script which required
+arguments.
+
+${QPID_CLI}/bin/qpid-cli -h [HostName of IP of the broker ] -p [Port
+of the broker]
+
+Default values for arguments -h [localhost] -p [8999]
+
+ * One Shot mode *
+ -----------------
+
+With one shot mode you can run interactive mode commands for one time
+and disconnect with the broker.This feature is useful when you want to
+run particular command in the management console using a script which
+is running in the normal console.What you have to do is you have to
+give the command you want to run with the qpid-cli script running
+command.
+
+Ex 1: $QPID_CLI/bin/qpid-cli queue list -- This will list the queue
+objects and disconnect.
+
+Ex 2: $QPID_CLI/bin/qpid-cli queue view -n ping - This will display
+information about all the message in the queue with the name of ping
+
+Likewise you can run any command in one shot mode and get the output
+for one time.
+
+ * Report Generation Mode *
+ -------------------------
+
+If you want to generate reports you can do it by defining your
+required information using a property file. There's a sample property
+file in the parent directory and you can have a look and get an idea
+about that.You can generate reports by giving a time interval in the
+property file. In order to start the daemon mode you have to run the
+qpid-cli script with the option : -r by giving the path for your
+property file.
+
+Ex: $QPID_CLI/bin/qpid-cli -r ../report.property
+
+You should specify a property file in order to run the daemon mode and
+get information repeatedly.
+
+ * Interactive mode with number of command *
+ -------------------------------------------
+
+This is the mode you get when you run the qpid-cli script without the
+one shot mode and without the daemon mode with [-r] option.Once you
+connect with the broker it display you a prompt [qpid-admin-$], then
+you can run several commands to can perform following tasks.
+
+For all the commands object type is command and most important command
+so you can use this option value without giving the option letter by
+giving that option value at the beginning of the command.
+
+Ex: [list -o queue ] can use this command like this dropping -o option
+[queue list]
+Ex: [list -o queue -n ping] = [queue list -n ping]
+
+ * Data displaying commands *
+ ----------------------------
+
+This is the set of commands which display the information about
+broker.
+
+list :
+------
+list information about the given object type with limited
+number of attributes and you can use number of command options to get
+different useful behaviors with the list command.You can get the
+complete description about the command by running the command like
+this.[list -h].
+
+info :
+------
+list all the attributes of a given object type. This command
+works very similar way to list command. You can use -h option for help
+and get complete description of the info command.
+
+view :
+------
+view information about the content of the message in the queue
+object. In order to run this command you have to specify the object
+type at the beginning.You can give how many message informations you
+want to view from the top of the queue by using -t option.
+
+Ex : queue view -n message_queue -t 5
+[list the message info for top 5 messages in queue message_queue]
+
+viewcontent :
+-------------
+view the content of the a given message in the
+queue. You have to give the messageId as a parameter with -id option
+letters.
+
+Ex: queue viewcontent -n message_queue -id 12
+[list the content encoding and Mimetype of the message with the
+messageId for the give message which is in the queue message_queue]
+
+ * Data modification commands *
+ ------------------------------
+
+This is a set of commands which allow users to deal with messages in
+queues.Users can delete messages from a give queue and user's can move
+one message from one queue to another queue.
+
+delete :
+--------
+Using this command user can delete a give message from a given
+queue you can specify how many messages you want to delete from the
+queue from the top of the queue by using -t option.If user does not
+give how many messages to delete from the top of the queue program is
+going to delete all the messages from the queue after giving a prompt
+to confirm the deletion.
+
+Ex: queue delete -n message_queue -t 3
+[Delete top three messages in the queue message_queue ]
+
+move :
+------
+This command allow user to move number of messages from one
+queue to another queue. First you have to specify from which queue you
+want to move messages by using -n1 and -v1 option letters(-n1 queue
+name/ -v1 virtual host).Then you have to use -n2 option to give the
+target queue name and then you have to give From messageId and To
+messageId using -fmid and -tmid option letters to specify the messages
+range you want to do the move operation.
+
+Ex: queue move -n1 message_queue -n2 ping -fmid 13 -tmid 15
+[This will move messages with the messageId range of 13-15 from queue
+message_queue to queue ping.
+
+
+
diff --git a/qpid/java/management/tools/qpid-cli/LICENSE b/qpid/java/management/tools/qpid-cli/LICENSE
new file mode 100644
index 0000000000..c6432e459f
--- /dev/null
+++ b/qpid/java/management/tools/qpid-cli/LICENSE
@@ -0,0 +1,225 @@
+=========================================================================
+== Apache License ==
+=========================================================================
+
+ 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 [yyyy] [name of copyright owner]
+
+ 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.
+
+
+=============================================================================
+== JLine (BSD) License
+=============================================================================
+Copyright (c) 2008, Apache Software Foundation
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
+ * Neither the name of the <ORGANIZATION> nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+
+
+
+
diff --git a/qpid/java/management/tools/qpid-cli/NOTICE b/qpid/java/management/tools/qpid-cli/NOTICE
new file mode 100644
index 0000000000..f1d9e54095
--- /dev/null
+++ b/qpid/java/management/tools/qpid-cli/NOTICE
@@ -0,0 +1,12 @@
+Apache Qpid
+Copyright 2006-2008 Apache Software Foundation
+This product includes software developed at
+Apache Software Foundation (http://www.apache.org/)
+
+Handling console input is provided bye the Jline library package,
+JLine is a Java library for handling console input. It is similar
+in functionality to BSD editline and GNU readline.Original software is
+available from
+
+http://jline.sourceforge.net/index.html
+
diff --git a/qpid/java/management/tools/qpid-cli/README b/qpid/java/management/tools/qpid-cli/README
new file mode 100644
index 0000000000..9432d76b69
--- /dev/null
+++ b/qpid/java/management/tools/qpid-cli/README
@@ -0,0 +1,64 @@
+README
+======
+
+INSTALL
+=======
+ source
+ ======
+ 1.Set the environment variable QPID_CLI to the root directory of the repository or the release.
+
+ 2.Run these command to build the source
+
+ ant init compile
+
+ 3.To launch the CLI run the script in bin folder with appropriate parameters.
+
+ ex:
+
+ Linux $QPID_CLI/bin/qpid-cli -h 10.8.100.122 -p 8334
+ Windows %QPID_CLI%/bin/qpid-cli.bat -h 10.8.100.122 -p 8334
+
+ -h hostname (default localhost)
+ -p broker port (default 8999)
+
+ binary
+ ======
+ 1.Set the environment variable QPID_CLI to the root directory of the repository or the release.
+
+ 2.To launch the CLI run the script in bin folder with appropriate parameters.
+
+ ex:
+
+ Linux $QPID_CLI/bin/qpid-cli -h 10.8.100.122 -p 8334
+ Windows %QPID_CLI%/bin/qpid-cli.bat -h 10.8.100.122 -p 8334
+
+ -h hostname (default localhost)
+ -p broker port (default 8999)
+
+ 3. No test cases are included in the binary version.
+
+TESTING
+=======
+
+1.Test source is located in the test directory.If you want to run the tests please start the
+Qpid java broker and run following ant targets.
+
+ ant compile-tests This compile all the test sources
+ ant test This runs all the test cases
+2.If you want to test with a remote broker please use the source release and change the constants in ConnectionConstants.java
+class.(Default values are BROKER_HOSTNAME="localhost" BROKER_PORT="8999")
+
+For more informations please visit the project home page.Please feel free to report bugs and that will
+be really useful to have a good product at the end.
+ http://code.google.com/p/lahirugsoc2008/
+
+
+
+
+
+
+
+
+
+
+
diff --git a/qpid/java/management/tools/qpid-cli/bin/qpid-cli b/qpid/java/management/tools/qpid-cli/bin/qpid-cli
new file mode 100755
index 0000000000..ca1d55c696
--- /dev/null
+++ b/qpid/java/management/tools/qpid-cli/bin/qpid-cli
@@ -0,0 +1,34 @@
+#!/bin/bash
+#
+# 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.
+#
+# set classpath to using jar files
+for f in $QPID_CLI/lib/*.jar
+do
+ CLASSPATH=$CLASSPATH:$f
+done
+export CLASSPATH
+
+
+
+export CLASSPATH=$CLASSPATH:$QPID_CLI/build/main/classes/
+echo $CLASSPATH
+
+
+
+java -classpath $CLASSPATH org.apache.qpid.CommandLineInterpreter $@
diff --git a/qpid/java/management/tools/qpid-cli/bin/qpid-cli.bat b/qpid/java/management/tools/qpid-cli/bin/qpid-cli.bat
new file mode 100755
index 0000000000..fe83b01184
--- /dev/null
+++ b/qpid/java/management/tools/qpid-cli/bin/qpid-cli.bat
@@ -0,0 +1,27 @@
+@REM
+@REM Licensed to the Apache Software Foundation (ASF) under one
+@REM or more contributor license agreements. See the NOTICE file
+@REM distributed with this work for additional information
+@REM regarding copyright ownership. The ASF licenses this file
+@REM to you under the Apache License, Version 2.0 (the
+@REM "License"); you may not use this file except in compliance
+@REM with the License. You may obtain a copy of the License at
+@REM
+@REM http://www.apache.org/licenses/LICENSE-2.0
+@REM
+@REM Unless required by applicable law or agreed to in writing,
+@REM software distributed under the License is distributed on an
+@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+@REM KIND, either express or implied. See the License for the
+@REM specific language governing permissions and limitations
+@REM under the License.
+@REM
+set CLASSPATH=%CLASSPATH%;%QPID_CLI%/lib/jline-0.9.94.jar
+set CLASSPATH=%CLASSPATH%;%QPID_CLI%/lib/junit-4.4.jar
+set CLASSPATH=%CLASSPATH%;%QPID_CLI%/lib/qpid-cli-1.0.jar
+set CLASSPATH=%CLASSPATH%;%QPID_CLI%/build/main/classes/
+java -classpath %CLASSPATH% org.apache.qpid.CommandLineInterpreter %1
+
+
+
+
diff --git a/qpid/java/management/tools/qpid-cli/build.xml b/qpid/java/management/tools/qpid-cli/build.xml
new file mode 100644
index 0000000000..e1dc06b4be
--- /dev/null
+++ b/qpid/java/management/tools/qpid-cli/build.xml
@@ -0,0 +1,73 @@
+<?xml version="1.0" ?>
+<project name="lahirugsoc2008">
+ <property name="src.dir" value="src"/>
+ <property name="build.dir" value="build"/>
+ <property name="build.src.dir" value="${build.dir}/main/"/>
+ <property name="build.test.dir" value="${build.dir}/test/"/>
+ <property name="build.src.classes.dir" value="${build.src.dir}/classes"/>
+ <property name="build.test.classes.dir" value="${build.test.dir}/classes"/>
+ <property name="jar.dir" value="${build.dir}/jar"/>
+ <property name="lib.dir" value="lib"/>
+ <property name="test.dir" value="test"/>
+ <property name="dependency1" value="jline-0.9.94.jar"/>
+ <property name="dependency2" value="junit-4.4.jar"/>
+ <property name="project.name" value="qpid-cli"/>
+ <property name="project.version" value="1.0"/>
+ <property name="target.name" value="${project.name}-${project.version}.jar"/>
+ <property name="target.jar" location="${jar.dir}/${target.name}"/>
+ <property name="build.failed" location="${build.test.dir}/results/FAILED"/>
+ <property name="test.suite" value="org.apache.qpid.AllTest"/>
+ <property name="test.report.dir" value="${build.test.dir}/reports"/>
+ <target name="init">
+ <mkdir dir="${build.src.classes.dir}" />
+ <mkdir dir="${build.test.classes.dir}"/>
+ <mkdir dir="${jar.dir}"/>
+ </target>
+ <target name="clean">
+ <delete dir="${build.src.dir}"/>
+ <delete dir="${build.test.dir}"/>
+ <delete dir="${jar.dir}"/>
+ </target>
+ <target name="compile" depends="init">
+ <javac srcdir="${src.dir}"
+ destdir="${build.src.classes.dir}">
+ <classpath>
+ <pathelement path="${lib.dir}/${dependency1}"/>
+ </classpath>
+ </javac>
+ </target>
+ <target name="compile-tests" depends="compile">
+ <javac srcdir="${test.dir}"
+ destdir="${build.test.classes.dir}"
+ debug="true"
+ includeAntRuntime="true">
+ <classpath>
+ <pathelement path="${lib.dir}/${dependency2}"/>
+ <pathelement path="${build.src.classes.dir}"/>
+ </classpath>
+ </javac>
+ </target>
+ <target name="jar" depends="compile">
+ <jar destfile="${target.jar}" duplicate="preserve"
+ compress="true">
+ <fileset dir="${build.src.classes.dir}"/>
+ </jar>
+ </target>
+ <target name="test" depends="compile-tests">
+ <junit printsummary="true">
+ <classpath>
+ <pathelement path="${build.test.classes.dir}"/>
+ <pathelement path="${build.src.classes.dir}"/>
+ <pathelement path="${lib.dir}/${dependency2}"/>
+ </classpath>
+ <formatter type="brief" usefile="false"/>
+ <test name="${test.suite}"/>
+ </junit>
+ </target>
+</project>
+
+
+
+
+
+
diff --git a/qpid/java/management/tools/qpid-cli/lib/jline-0.9.94.jar b/qpid/java/management/tools/qpid-cli/lib/jline-0.9.94.jar
new file mode 100644
index 0000000000..dafca7c46e
--- /dev/null
+++ b/qpid/java/management/tools/qpid-cli/lib/jline-0.9.94.jar
Binary files differ
diff --git a/qpid/java/management/tools/qpid-cli/lib/junit-4.4.jar b/qpid/java/management/tools/qpid-cli/lib/junit-4.4.jar
new file mode 100644
index 0000000000..649b0b327f
--- /dev/null
+++ b/qpid/java/management/tools/qpid-cli/lib/junit-4.4.jar
Binary files differ
diff --git a/qpid/java/management/tools/qpid-cli/report.property b/qpid/java/management/tools/qpid-cli/report.property
new file mode 100644
index 0000000000..720fdac899
--- /dev/null
+++ b/qpid/java/management/tools/qpid-cli/report.property
@@ -0,0 +1,7 @@
+object=queue
+column=Name,MessageCount,ActiveConsumerCount,Durable
+filter.name=ping
+filter.virtualhost=test
+output=csv
+seperator=|
+interval=1
diff --git a/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/Command.java b/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/Command.java
new file mode 100644
index 0000000000..6845361192
--- /dev/null
+++ b/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/Command.java
@@ -0,0 +1,62 @@
+/*
+ *
+ * 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.
+ *
+ */
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * 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.
+ *
+ */
+package org.apache.qpid;
+
+import org.apache.qpid.utils.CommandLineOption;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: lahiru
+ * Date: May 29, 2008
+ * Time: 9:21:46 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public interface
+ Command {
+
+ public static String commandname = null;
+ public static CommandLineOption options = null;
+
+ void execute();
+
+ void printusage();
+
+ void optionchecker();
+
+ void optionvaluechecker();
+}
diff --git a/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/CommandConstants.java b/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/CommandConstants.java
new file mode 100644
index 0000000000..9285501693
--- /dev/null
+++ b/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/CommandConstants.java
@@ -0,0 +1,50 @@
+/*
+ *
+ * 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.
+ *
+ */
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * 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.
+ *
+ */
+package org.apache.qpid;
+
+public interface CommandConstants {
+
+ String LIST_COMMAND = "list";
+ String INFO_COMMAND = "info";
+ String HELP_COMMAND = "help";
+ String DELETE_COMMAND = "delete";
+ String MOVE_COMMAND = "move";
+ String VIEW_COMMAND = "view";
+ String VIEWCONTENT_COMMAND = "viewcontent";
+
+}
diff --git a/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/CommandExecusionEngine.java b/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/CommandExecusionEngine.java
new file mode 100644
index 0000000000..ed54883759
--- /dev/null
+++ b/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/CommandExecusionEngine.java
@@ -0,0 +1,88 @@
+/*
+ *
+ * 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.
+ *
+ */
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * 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.
+ *
+ */
+package org.apache.qpid;
+
+import org.apache.qpid.utils.CommandLineOptionParser;
+import org.apache.qpid.utils.JMXinfo;
+import org.apache.qpid.commands.*;
+import org.apache.qpid.commands.Command;
+
+
+public class CommandExecusionEngine {
+ private Command currentcommand = null;
+ private String commandname = null;
+ private JMXinfo info = null;
+
+ public CommandExecusionEngine(JMXinfo info) {
+ this.info = info;
+ this.commandname = info.getCommandLineOptionParser().getcommandname();
+ }
+
+ public boolean CommandSelector() {
+
+ if (CommandConstants.INFO_COMMAND.equalsIgnoreCase(this.commandname))
+ currentcommand = new Commandinfo(info, this.commandname);
+ else if (CommandConstants.LIST_COMMAND.equalsIgnoreCase(this.commandname))
+ currentcommand = new Commandlist(info, this.commandname);
+ else if (CommandConstants.HELP_COMMAND.equalsIgnoreCase(this.commandname))
+ currentcommand = new Commandhelp(info, this.commandname);
+ else if (CommandConstants.DELETE_COMMAND.equalsIgnoreCase(this.commandname))
+ currentcommand = new Commanddelete(info, this.commandname);
+ else if (CommandConstants.MOVE_COMMAND.equalsIgnoreCase(this.commandname))
+ currentcommand = new Commandmove(info, this.commandname);
+ else if (CommandConstants.VIEW_COMMAND.equalsIgnoreCase(this.commandname))
+ currentcommand = new Commandview(info, this.commandname);
+ else if (CommandConstants.VIEWCONTENT_COMMAND.equalsIgnoreCase(this.commandname))
+ currentcommand = new Commandviewcontent(info, this.commandname);
+ else {
+ usage();
+ return false;
+ }
+ return true;
+
+
+ }
+
+ public void runcommand() {
+ currentcommand.execute();
+ }
+
+ public void usage() {
+ System.out.println(commandname + ":Command not found");
+ }
+}
diff --git a/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/CommandLineInterpreter.java b/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/CommandLineInterpreter.java
new file mode 100644
index 0000000000..e9073c79ce
--- /dev/null
+++ b/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/CommandLineInterpreter.java
@@ -0,0 +1,194 @@
+/*
+ *
+ * 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.
+ *
+ */
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * 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.
+ *
+ */
+
+package org.apache.qpid;
+
+import org.apache.qpid.utils.CommandLineOptionParser;
+import org.apache.qpid.utils.JMXConfiguration;
+import org.apache.qpid.utils.JMXinfo;
+
+import javax.management.MBeanServerConnection;
+import javax.management.remote.JMXConnector;
+import javax.naming.ServiceUnavailableException;
+import java.io.PrintWriter;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.FileInputStream;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.StringTokenizer;
+import java.util.Properties;
+import java.rmi.ConnectException;
+
+import jline.ConsoleReader;
+import jline.ArgumentCompletor;
+import jline.SimpleCompletor;
+
+
+public class CommandLineInterpreter {
+ public static void main(String[] args) {
+ Connector conn = null;
+ try {
+ // Create an RMI connector client and
+ // connect it to the RMI connector server
+
+ /*checking the commandline options and
+ parse them in to config method */
+ JMXConnector jmxc = null;
+ MBeanServerConnection mbsc = null;
+ ConsoleReader reader = new ConsoleReader();
+ reader.setBellEnabled(false);
+ CommandLineOptionParser commandlineoptionparser = null;
+
+ if ((args == null) || (args.length) == 0) {
+ Usage();
+ }
+ /* here special constructor is calling, when parsing options,in here first option value is starting from minus sign
+ so this is handle by a special constructor */
+ else {
+ if (args[0].startsWith("-")) {
+ commandlineoptionparser = new CommandLineOptionParser(args, args[0]); // if user specify any argument with the qpid-cli script
+ }
+ }
+
+ /* Connecting with the broker */
+// commandlineoptionparser = new CommandLineOptionParser(args);
+// JMXConfiguration config = new JMXConfiguration(commandlineoptionparser.getAlloptions());
+ try {
+ if (commandlineoptionparser == null)
+ commandlineoptionparser = new CommandLineOptionParser(args);
+
+ JMXConfiguration config = new JMXConfiguration(commandlineoptionparser.getAlloptions());
+ conn = ConnectorFactory.getConnector(config.gethostname(), config.getport());
+ jmxc = conn.getConnector();
+ mbsc = conn.getMBeanServerConnection();
+ if (config.checkoptionsetting("r", commandlineoptionparser.getAlloptions())) {
+ JMXinfo info = new JMXinfo(jmxc, commandlineoptionparser, mbsc);
+ ReportGenerator reportgen = new ReportGenerator(config.optionchecker("r", commandlineoptionparser.getAlloptions()), info);
+ reportgen.loadproperties();
+ reportgen.run();
+ }
+ /* This implementation is for the people who are using the interactive
+ mode for one shot this run the user given command and exit */
+ for (int i = 0; i < args.length; i++) {
+ if (args[i].compareTo("list") == 0 || args[i].compareTo("info") == 0 || args[i].compareTo("view") == 0 || args[i].compareTo("viewcontent") == 0
+ || args[i].compareTo("delete") == 0 || args[i].compareTo("move") == 0) {
+ oneshotmode(args,commandlineoptionparser,jmxc,mbsc);
+
+ return;
+ }
+ }
+ } catch (Exception ex) {
+ connectionrefuse();
+ return;
+ }
+ /* In this point connection has been established */
+ String line;
+ String[] command;
+
+ /* prividing GNU readline features using Jline library */
+ //String list = "list";
+ PrintWriter out = new PrintWriter(System.out);
+ reader.addCompletor(new ArgumentCompletor(
+ new SimpleCompletor(new String[]{"list", "info", "exit", "quit", "delete", "move", "view", "viewcontent", "queue", "exchange", "connection", "usermanagement", "virtualhost"})));
+ while ((line = reader.readLine("qpid-admin-$ ")) != null) {
+ out.flush();
+ if (removeSpaces(line).equalsIgnoreCase("quit") || removeSpaces(line).equalsIgnoreCase("exit"))
+ break;
+ else if (line.length() == 0)
+ continue;
+ else {
+ command = line.split("\\s+");
+ commandlineoptionparser = new CommandLineOptionParser(command);
+ JMXinfo info = new JMXinfo(jmxc, commandlineoptionparser, mbsc);
+ CommandExecusionEngine engine = new CommandExecusionEngine(info);
+ if (engine.CommandSelector())
+ engine.runcommand();
+ }
+ }
+ conn.getConnector().close();
+ }
+ catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+
+ private static void Usage() {
+ System.out.println("Connecting to localhost Qpid java broker...");
+ }
+
+ private static String removeSpaces(String s) {
+ StringTokenizer st = new StringTokenizer(s, " ", false);
+ String t = "";
+ while (st.hasMoreElements()) t += st.nextElement();
+ return t;
+ }
+
+ private static void connectionrefuse() {
+ System.out.println("Cannot connect with the broker in given host with given port");
+ System.out.println("Please check the host name and the port given");
+ }
+
+ private static void commandlineerror() {
+ System.out.println("Please run the script again and try to connect to broker again");
+ }
+ public static String[] oneshotmode(String[] args,CommandLineOptionParser commandlineoptionparser,JMXConnector jmxc,MBeanServerConnection mbsc)
+ {
+ int check = 0;
+ String [] temp;
+ for (int i = 0; i < args.length; i++) {
+
+ if (args[i].compareTo("-h") == 0)
+ check++;
+ else if (args[i].compareTo("-p") == 0)
+ check++;
+ }
+ for (int i = 0; i < (args.length - 2 * check); i++) { // mulitply by 2 because have to remove the option letter with the option value//
+ args[i] = args[i + check * 2];
+ }
+
+ commandlineoptionparser = new CommandLineOptionParser(args); //change the args string array which works as interactive mode//
+ JMXinfo info = new JMXinfo(jmxc, commandlineoptionparser, mbsc);
+ CommandExecusionEngine engine = new CommandExecusionEngine(info);
+ if (engine.CommandSelector())
+ engine.runcommand();
+ return args;
+
+ }
+}
+
diff --git a/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/Connector.java b/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/Connector.java
new file mode 100644
index 0000000000..d3357e31b7
--- /dev/null
+++ b/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/Connector.java
@@ -0,0 +1,76 @@
+/*
+ *
+ * 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.
+ *
+ */
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * 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.
+ *
+ */
+package org.apache.qpid;
+
+import javax.management.MBeanServerConnection;
+import javax.management.remote.JMXConnector;
+import javax.management.remote.JMXServiceURL;
+import javax.management.remote.JMXConnectorFactory;
+import java.io.IOException;
+
+
+public class Connector {
+ private JMXServiceURL url = null;
+ private JMXConnector jmxc = null;
+ private MBeanServerConnection mbsc = null;
+
+
+ public Connector(JMXServiceURL url, JMXConnector jmxc, MBeanServerConnection mbsc) {
+
+
+ this.url = url;
+ this.jmxc = jmxc;
+ this.mbsc = mbsc;
+
+
+ }
+
+ public JMXServiceURL getURL() {
+ return url;
+ }
+
+ public JMXConnector getConnector() {
+ return jmxc;
+ }
+
+ public MBeanServerConnection getMBeanServerConnection() {
+ return mbsc;
+ }
+
+
+}
diff --git a/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/ConnectorFactory.java b/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/ConnectorFactory.java
new file mode 100644
index 0000000000..6c0bacf3ac
--- /dev/null
+++ b/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/ConnectorFactory.java
@@ -0,0 +1,72 @@
+/*
+ *
+ * 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.
+ *
+ */
+ /*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * 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.
+ *
+ */
+package org.apache.qpid;
+
+import javax.management.remote.JMXConnectorFactory;
+import javax.management.remote.JMXServiceURL;
+import javax.management.remote.JMXConnector;
+import javax.management.MBeanServerConnection;
+import java.io.IOException;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: lahiru
+ * Date: Jul 3, 2008
+ * Time: 10:51:28 AM
+ * To change this template use File | Settings | File Templates.
+ */
+public class ConnectorFactory {
+
+ public static Connector getConnector(String host, String port) {
+
+ String url_string = "service:jmx:rmi:///jndi/rmi://" + host + ":" + port + "/jmxrmi";
+ JMXServiceURL url;
+ JMXConnector jmxc;
+ MBeanServerConnection mbsc;
+ try {
+ url = new JMXServiceURL(url_string);
+ jmxc = JMXConnectorFactory.connect(url, null);
+ mbsc = jmxc.getMBeanServerConnection();
+
+ } catch (IOException e) {
+ e.printStackTrace();
+ return null; //To change body of catch statement use File | Settings | File Templates.
+ }
+ return new Connector(url, jmxc, mbsc);
+ }
+}
diff --git a/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/ReportGenerator.java b/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/ReportGenerator.java
new file mode 100644
index 0000000000..0a63d73a98
--- /dev/null
+++ b/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/ReportGenerator.java
@@ -0,0 +1,180 @@
+/*
+ *
+ * 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.
+ *
+ */
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * 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.
+ *
+ */
+package org.apache.qpid;
+
+import org.apache.qpid.commands.objects.*;
+import org.apache.qpid.utils.JMXinfo;
+
+import javax.management.MBeanServerConnection;
+import java.util.*;
+import java.io.FileInputStream;
+import java.io.IOException;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: lahiru
+ * Date: Aug 12, 2008
+ * Time: 4:03:21 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class ReportGenerator implements Runnable {
+
+ String[] propertyname = {"object", "column", "filter.name", "filter.virtualhost", "output", "seperator", "interval"};
+ String[] propertyvalue = null;
+ String propertyfilepath = null;
+ String[] columnvalue = null;
+ List<String> columns = null;
+ Properties props = null;
+ JMXinfo info = null;
+ int interval = 10;
+
+ public void run() {
+ for (; ;) // creating infinite loop
+ {
+ generatereport();
+ try {
+ Thread.sleep(this.interval * 60000);
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+ }
+
+ public ReportGenerator(String propfile, JMXinfo info) {
+ this.propertyfilepath = propfile;
+ props = new Properties();
+ propertyvalue = new String[propertyname.length];
+ this.info = info;
+ columns = new ArrayList<String>();
+ }
+
+ public void loadproperties() // get all the property file values and set the columen values//
+ {
+ try {
+
+ props.load(new FileInputStream(this.propertyfilepath));
+ for (int i = 0; i < propertyname.length; i++) {
+ propertyvalue[i] = props.getProperty(propertyname[i]);
+ }
+ this.setcolumnvalues();
+ this.setinterval();
+ }
+
+ //catch exception in case properties file does not exist
+
+ catch (IOException e) {
+ System.out.println("Oooops Give property file is not exist");
+ }
+ }
+
+ public void generatereport() {
+ this.listobjects(propertyvalue[0]);
+ }
+
+ private void setcolumnvalues() {
+ columnvalue = propertyvalue[1].split(",");
+ for (int i = 0; i < columnvalue.length; i++) {
+ columns.add(columnvalue[i]);
+ }
+ }
+
+ private void setinterval() {
+ this.interval = (new Integer(propertyvalue[6])).intValue();
+ }
+
+ private void listobjects(String option_value) {
+ /*pring usage if use is not give the correct option letter or no options */
+ if (option_value == null) {
+// System.out.println("testing");
+ return;
+ }
+ MBeanServerConnection mbsc = info.getmbserverconnector();
+ Set set = null;
+ ObjectNames objname = null;
+
+ try {
+ if (option_value.compareToIgnoreCase("queue") == 0 || option_value.compareToIgnoreCase("queues") == 0) {
+ objname = new QueueObject(mbsc);
+
+ } else
+ if (option_value.compareToIgnoreCase("Virtualhosts") == 0 || option_value.compareToIgnoreCase("Virtualhost") == 0) {
+ objname = new VirtualHostObject(mbsc);
+// this.name = option_value;
+ } else
+ if (option_value.compareToIgnoreCase("Exchange") == 0 || option_value.compareToIgnoreCase("Exchanges") == 0) {
+ objname = new ExchangeObject(mbsc);
+// this.name = option_value;
+ } else
+ if (option_value.compareToIgnoreCase("Connection") == 0 || option_value.compareToIgnoreCase("Connections") == 0) {
+ objname = new ConnectionObject(mbsc);
+// this.name = option_value;
+ } else if (option_value.compareToIgnoreCase("all") == 0) {
+ objname = new AllObjects(mbsc);
+// this.name = option_value;
+ } else
+ if (option_value.compareToIgnoreCase("Usermanagement") == 0 || option_value.compareToIgnoreCase("Usermanagmenets") == 0) {
+ objname = new UserManagementObject(mbsc);
+// this.name = option_value;
+ } else {
+ printusage();
+ echo("Wrong objectName");
+ return;
+ }
+ objname.setQueryString(this.propertyvalue[0], this.propertyvalue[2], this.propertyvalue[3]);
+ objname.returnObjects();
+ if (objname.getSet().size() != 0) {
+ objname.reportgenerator(this.propertyvalue[4], this.propertyvalue[5], columns);
+ } else {
+ printusage();
+ }
+ }
+ catch (Exception ex) {
+ ex.printStackTrace();
+ }
+
+
+ }
+
+ public void echo(String str) {
+ System.out.println(str);
+ }
+
+ public void printusage() {
+ System.out.println("Wrong option or wrong option value");
+ }
+}
diff --git a/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/commands/Command.java b/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/commands/Command.java
new file mode 100644
index 0000000000..02c50e37e4
--- /dev/null
+++ b/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/commands/Command.java
@@ -0,0 +1,113 @@
+/*
+ *
+ * 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.
+ *
+ */
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * 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.
+ *
+ */
+
+package org.apache.qpid.commands;
+
+
+import org.apache.qpid.utils.CommandLineOptionParser;
+import org.apache.qpid.utils.JMXinfo;
+import org.apache.qpid.utils.CommandLineOption;
+
+import javax.management.remote.JMXConnector;
+import javax.management.MBeanServerConnection;
+import java.util.Map;
+
+
+public class Command {
+ public JMXinfo info = null;
+ public String commandname = null;
+
+
+ public Command(JMXinfo info, String name) {
+ this.info = info;
+ this.commandname = name;
+ }
+
+ public Command() {
+
+ }
+
+ public void execute() {
+
+
+ }
+
+ public void printusage() {
+ }
+
+
+ public String optionchecker(String option_letter) {
+ Map map = info.getCommandLineOptionParser().getAlloptions();
+ if (map == null)
+ return null;
+ CommandLineOption option = (CommandLineOption) map.get(option_letter);
+ if (option == null)
+ return null;
+ String value = option.getOptionValue();
+ return value;
+ }
+
+ public boolean checkoptionsetting(String option_letter) {
+ Map map = info.getCommandLineOptionParser().getAlloptions();
+ if (map == null)
+ return false;
+ CommandLineOption option = (CommandLineOption) map.get(option_letter);
+ if (option == null)
+ return false;
+ String value = option.getOptionType();
+
+ if (value != null)
+ return true;
+ else
+ return false;
+ }
+
+ public void optionvaluechecker() {
+
+ }
+
+ public void echo(String str) {
+ System.out.println(str);
+ }
+
+ public void unrecognizeoption() {
+ echo("list: Unrecognized option");
+ echo("Try `" + this.commandname + " --help` for more information");
+ }
+
+}
diff --git a/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/commands/Commanddelete.java b/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/commands/Commanddelete.java
new file mode 100644
index 0000000000..eb24012405
--- /dev/null
+++ b/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/commands/Commanddelete.java
@@ -0,0 +1,228 @@
+/*
+ *
+ * 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.
+ *
+ */
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * 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.
+ *
+ */
+
+
+package org.apache.qpid.commands;
+
+import org.apache.qpid.utils.JMXinfo;
+import org.apache.qpid.commands.objects.*;
+
+import javax.management.MBeanServerConnection;
+import javax.management.ObjectName;
+import javax.management.MBeanAttributeInfo;
+import javax.management.MBeanInfo;
+import java.util.Set;
+import java.util.Iterator;
+import java.util.StringTokenizer;
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: lahiru
+ * Date: Aug 6, 2008
+ * Time: 5:34:51 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class Commanddelete extends Command {
+ private String object;
+ private String name;
+ private String vhost;
+ private int number = 0;
+ private QueueObject objname;
+ private MBeanServerConnection mbsc;
+ private String method1, method2;
+ private ObjectName queue;
+
+ public Commanddelete(JMXinfo info, String name) {
+ super(info, name);
+ this.mbsc = info.getmbserverconnector();
+ this.objname = new QueueObject(mbsc);
+ this.method1 = "deleteMessageFromTop";
+ this.method2 = "clearQueue";
+
+ }
+
+ public void deletemessages() {
+ Set set = null;
+ objname.setQueryString(this.object, this.name, this.vhost);
+ set = objname.returnObjects();
+
+ if (objname.getSet().size() != 0) {
+ Iterator it = set.iterator();
+ this.queue = (ObjectName) it.next();
+ try {
+ if (this.number == 0) {
+ echo("");
+ System.out.print("Do you want to delete all the messages from the Queue [Y/N] :");
+ InputStreamReader isr = new InputStreamReader(System.in);
+ BufferedReader br = new BufferedReader(isr);
+ String s = br.readLine();
+ echo(s);
+ if (s.compareToIgnoreCase("y") == 0)
+ this.mbsc.invoke(queue, this.method2, null, null);
+ else
+ return;
+ } else if (objname.getmessagecount(this.queue) < this.number) {
+ echo("Given number is Greater than the Queue Depth");
+ return;
+ } else {
+ for (int i = 0; i < this.number; i++) {
+ this.mbsc.invoke(queue, this.method1, null, null);
+ }
+ }
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+
+ } else {
+ if (isname()) {
+
+ echo("The Queue you have specified is not in the current broker");
+ echo("");
+ } else {
+ printusage();
+ }
+ }
+ }
+
+ public void execute() {
+ /* In here you it's easy to handle any number of otpions which are going to add with the list command which works
+ with main option object or o
+ */
+
+ if (checkoptionsetting("object") || checkoptionsetting("o")) {
+ String object = optionchecker("object");
+ if (object == null) {
+ object = optionchecker("o");
+ }
+ if (object.compareToIgnoreCase("queue") == 0)
+ setobject(object);
+ else {
+ unrecognizeoption();
+ echo("This command is only applicable for delete command so please start with queue");
+ }
+ if (checkoptionsetting("name") || checkoptionsetting("n")) {
+ String name = optionchecker("name");
+ if (name == null)
+ name = optionchecker("n");
+
+ setname(name);
+ }
+ if (checkoptionsetting("virtualhost") || checkoptionsetting("v")) {
+ String vhost = optionchecker("virtualhost");
+ if (vhost == null)
+ vhost = optionchecker("v");
+ setvhost(vhost);
+ }
+ if (checkoptionsetting("top") || checkoptionsetting("t")) {
+ String number = optionchecker("top");
+ if (number == null)
+ number = optionchecker("t");
+
+ setnumber(removeSpaces(number));
+ }
+ this.deletemessages();
+ } else if (checkoptionsetting("h") || checkoptionsetting("help"))
+ printusage();
+ else
+ unrecognizeoption();
+ }
+
+ public void printusage() {
+ echo("");
+ echo("Usage:delete [OPTION] ... [OBJECT TYPE]...\n");
+ echo("Delete the top most messages from the given queue object\n");
+ echo("To specify the desired queue you have to give the virtualhost name and the queue name with following commands\n");
+ echo("Where possible options include:\n");
+ echo(" -v --virtualhost Give the virtuallhost name of the desired queue");
+ echo(" -n --name Give the queue name of the desired queue you want to do the delete operation");
+ echo(" -t --top Give how many number of messages you want to delete from the top (Default = all the messages will be deleted");
+ echo(" -h --help Display the help and back to the qpid-cli prompt\n");
+
+ }
+
+ private void setobject(String object) {
+ this.object = object;
+ }
+
+ public String getobject() {
+ return this.object;
+ }
+
+ private void setname(String name) {
+ this.name = name;
+ }
+
+ private boolean isname() {
+ if (this.name == null)
+ return false;
+
+ else
+ return true;
+ }
+
+ private void setvhost(String vhost) {
+ this.vhost = vhost;
+ }
+
+ public String getvhost() {
+ return this.vhost;
+ }
+
+ public String getname() {
+ return this.name;
+ }
+
+ private void setnumber(String number) {
+ Integer i = new Integer(number);
+ this.number = i.intValue();
+ }
+
+ public int getnumber() {
+ return this.number;
+ }
+
+ private static String removeSpaces(String s) {
+ StringTokenizer st = new StringTokenizer(s, " ", false);
+ String t = "";
+ while (st.hasMoreElements()) t += st.nextElement();
+ return t;
+ }
+
+}
diff --git a/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/commands/Commandhelp.java b/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/commands/Commandhelp.java
new file mode 100644
index 0000000000..962b606c12
--- /dev/null
+++ b/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/commands/Commandhelp.java
@@ -0,0 +1,73 @@
+/*
+ *
+ * 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.
+ *
+ */
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * 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.
+ *
+ */
+
+package org.apache.qpid.commands;
+
+import org.apache.qpid.utils.JMXinfo;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: lahiru
+ * Date: Jul 6, 2008
+ * Time: 5:55:28 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class Commandhelp extends Command {
+ public Commandhelp(JMXinfo info, String name) {
+ super(info, name);
+ }
+
+ public void execute() {
+ displayhelp();
+ }
+
+ private void displayhelp() {
+ echo("");
+ echo("Current version of qpid CLI is supporting following commands");
+ echo("");
+ echo("[list] This command is listing limited information about a given type of object");
+ echo(" For more information about list command run `list --help`");
+ echo("[info] This command is listing All the information about a given type of object");
+ echo(" For more information about list command run `info --help`");
+
+ echo("");
+ echo("[exit] This command is disconnect the connection with the Qpid Java broker and go back to normal propmt");
+ echo("[quit] This command is disconnect the connection with the Qpid Java broker and go back to normal propmt");
+ echo("");
+ }
+}
diff --git a/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/commands/Commandinfo.java b/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/commands/Commandinfo.java
new file mode 100644
index 0000000000..51cbb2b929
--- /dev/null
+++ b/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/commands/Commandinfo.java
@@ -0,0 +1,259 @@
+/*
+ *
+ * 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.
+ *
+ */
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * 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.
+ *
+ */
+
+package org.apache.qpid.commands;
+
+
+import org.apache.qpid.utils.CommandLineOptionParser;
+import org.apache.qpid.utils.JMXinfo;
+import org.apache.qpid.commands.objects.*;
+
+import javax.management.MBeanServerConnection;
+import java.util.Set;
+
+
+public class Commandinfo extends Command {
+ private String object = null;
+ private String name = null;
+ private String virtualhost = null;
+ private String outputformat = null;
+ private String seperator = ",";
+
+ public Commandinfo(JMXinfo info, String name) {
+
+ super(info, name);
+
+ }
+
+ private void listobjects(String option_value) {
+ /*pring usage if use is not give the correct option letter or no options */
+ if (option_value == null) {
+// System.out.println("testing");
+ printusage();
+ return;
+ }
+ MBeanServerConnection mbsc = info.getmbserverconnector();
+ Set set = null;
+ ObjectNames objname = null;
+
+ try {
+ if (option_value.compareToIgnoreCase("queue") == 0 || option_value.compareToIgnoreCase("queues") == 0) {
+ objname = new QueueObject(mbsc);
+
+ } else
+ if (option_value.compareToIgnoreCase("Virtualhosts") == 0 || option_value.compareToIgnoreCase("Virtualhost") == 0) {
+ objname = new VirtualHostObject(mbsc);
+// this.name = option_value;
+ } else
+ if (option_value.compareToIgnoreCase("Exchange") == 0 || option_value.compareToIgnoreCase("Exchanges") == 0) {
+ objname = new ExchangeObject(mbsc);
+// this.name = option_value;
+ } else
+ if (option_value.compareToIgnoreCase("Connection") == 0 || option_value.compareToIgnoreCase("Connections") == 0) {
+ objname = new ConnectionObject(mbsc);
+// this.name = option_value;
+ } else if (option_value.compareToIgnoreCase("all") == 0) {
+ objname = new AllObjects(mbsc);
+// this.name = option_value;
+ } else
+ if (option_value.compareToIgnoreCase("Usermanagement") == 0 || option_value.compareToIgnoreCase("Usermanagmenets") == 0) {
+ objname = new UserManagementObject(mbsc);
+// this.name = option_value;
+ } else {
+ printusage();
+ echo("Wrong objectName");
+ return;
+ }
+ objname.setQueryString(this.object, this.name, this.virtualhost);
+ objname.returnObjects();
+ if (objname.getSet().size() != 0) {
+ objname.displayinfo(this.outputformat, this.seperator);
+
+ } else {
+ if (isname()) {
+
+ echo("You might quering wrong " + this.object + " name with --name or -n option ");
+ echo("");
+ echo(this.object + "Type Objects might not in the broker currently");
+ echo("");
+ } else {
+ printusage();
+ }
+ }
+
+
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+
+
+ }
+
+ public void execute() {
+ /* In here you it's easy to handle any number of otpions which are going to add with the list command which works
+ with main option object or o
+ */
+ if (checkoptionsetting("output")) {
+ setoutputformat(optionchecker("output"));
+ if (checkoptionsetting("separator"))
+ setseperator(optionchecker("separator"));
+ }
+ if (checkoptionsetting("object") || checkoptionsetting("o")) {
+ String object = optionchecker("object");
+ if (object == null) {
+ object = optionchecker("o");
+ }
+ setobject(object);
+ if (checkoptionsetting("name") || checkoptionsetting("n")) {
+ String name = optionchecker("name");
+ if (name == null)
+ name = optionchecker("n");
+
+ setname(name);
+ }
+ if (checkoptionsetting("virtualhost") || checkoptionsetting("v")) {
+ String vhost = optionchecker("virtualhost");
+ if (vhost == null)
+ vhost = optionchecker("v");
+ setvirtualhost(vhost);
+ }
+ listobjects(this.object);
+ } else if (checkoptionsetting("h") || checkoptionsetting("help"))
+ printusage();
+ else
+ unrecognizeoption();
+ }
+
+ public void printusage() {
+ echo("");
+ echo("Usage:info [OPTION] ... [OBJECT TYPE]...\n");
+ echo("Give ALL the information about the given object\n");
+ echo("Where possible options include:\n");
+ echo(" -o --object type of objects which you want to list\n");
+ echo(" ex: < list -o queue > : lists all the queues created in the java broker\n");
+ echo(" For now list command is supporting following object typse \n");
+ echo(" Queue Connection VirtualHost UserMangement Exchange");
+ echo(" Or You can specify object type by giving it at the beginning rather giving ");
+ echo(" it as a argument");
+ echo(" Ex:< queue info > this command is equal to <info -o queue> command \n");
+ echo(" -v --virtualhost After specifying the object type you can filter output with this option");
+ echo(" list objects with the given virtualhost which will help to find identical");
+ echo(" queue objects with -n option");
+ echo(" ex: queue info -v developement");
+ echo(" -output Specify which output format you want to get the ouput");
+ echo(" Although the option is there current version supports only for CSV output format");
+ echo(" -separator This option use with output option to specify which separator you want to get the CSV output (default seperator is comma");
+ echo(" -h --help Display the help and back to the qpid-cli prompt\n");
+ echo(" -n --name After specifying what type of objects you want to monitor you can filter");
+ echo(" the output using -n option by specifying the name of the object you want");
+ echo(" to monitor exactly");
+ echo(" ex: <queue info -n ping> : Give all the information about queue objects ");
+ echo(" having queue name of ping\n");
+ }
+
+ private void setobject(String object) {
+ this.object = object;
+ }
+
+ private void setname(String name) {
+ this.name = name;
+ }
+
+ private boolean isname() {
+ if (this.name == null)
+ return false;
+
+ else
+ return true;
+ }
+
+ private void setvirtualhost(String vhost) {
+ this.virtualhost = vhost;
+ }
+
+ public String getvirtualhost() {
+ return this.virtualhost;
+ }
+
+ private void setoutputformat(String outputformat) {
+ this.outputformat = outputformat;
+ }
+
+ private void setseperator(String seperator) {
+ this.seperator = seperator;
+ }
+
+ private boolean isseperator() {
+ if (this.seperator == null)
+ return false;
+
+ else
+ return true;
+ }
+
+ private boolean isoutputformat() {
+ if (this.outputformat == null)
+ return false;
+
+ else
+ return true;
+ }
+
+ public String getname() {
+ return this.name;
+ }
+
+ public String getobject() {
+ return this.object;
+ }
+
+ /*
+ public String optionchecker(String option_letter) {
+ Map map = info.getCommandLineOptionParser().getAlloptions();
+ if(map == null)
+ return null;
+ CommandLineOption option = (CommandLineOption) map.get(option_letter);
+ if(option == null)
+ return null;
+ String value = option.getOptionValue();
+ return value;
+
+
+ }
+ */
+}
diff --git a/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/commands/Commandlist.java b/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/commands/Commandlist.java
new file mode 100644
index 0000000000..856dfcf0f2
--- /dev/null
+++ b/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/commands/Commandlist.java
@@ -0,0 +1,296 @@
+/*
+ *
+ * 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.
+ *
+ */
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * 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.
+ *
+ */
+
+package org.apache.qpid.commands;
+
+import org.apache.qpid.utils.JMXinfo;
+import org.apache.qpid.utils.CommandLineOptionParser;
+import org.apache.qpid.utils.CommandLineOptionConstants;
+import org.apache.qpid.utils.CommandLineOption;
+import org.apache.qpid.commands.objects.*;
+
+import javax.management.ObjectName;
+import javax.management.MBeanAttributeInfo;
+import javax.management.MBeanInfo;
+import javax.management.MBeanServerConnection;
+import java.util.Set;
+import java.util.Iterator;
+import java.util.Map;
+
+
+public class Commandlist extends Command {
+
+ private String object;
+ private String name;
+ private String vhost;
+ private String outputformat = null;
+ private String seperator = ","; //this variable is assigning if -n option is used otherwise this is null
+
+ public Commandlist(JMXinfo info, String name) {
+ super(info, name);
+
+ }
+
+ private void listobjects(String option_value) {
+ /*pring usage if use is not give the correct option letter or no options */
+ if (option_value == null) {
+// System.out.println("testing");
+ printusage();
+ return;
+ }
+ MBeanServerConnection mbsc = info.getmbserverconnector();
+ Set set = null;
+ ObjectNames objname = null;
+
+ try {
+ if (option_value.compareToIgnoreCase("queue") == 0 || option_value.compareToIgnoreCase("queues") == 0) {
+ objname = new QueueObject(mbsc);
+
+ } else
+ if (option_value.compareToIgnoreCase("Virtualhosts") == 0 || option_value.compareToIgnoreCase("Virtualhost") == 0) {
+ objname = new VirtualHostObject(mbsc);
+// this.name = option_value;
+ } else
+ if (option_value.compareToIgnoreCase("Exchange") == 0 || option_value.compareToIgnoreCase("Exchanges") == 0) {
+ objname = new ExchangeObject(mbsc);
+// this.name = option_value;
+ } else
+ if (option_value.compareToIgnoreCase("Connection") == 0 || option_value.compareToIgnoreCase("Connections") == 0) {
+ objname = new ConnectionObject(mbsc);
+// this.name = option_value;
+ } else if (option_value.compareToIgnoreCase("all") == 0) {
+ objname = new AllObjects(mbsc);
+// this.name = option_value;
+ } else
+ if (option_value.compareToIgnoreCase("Usermanagement") == 0 || option_value.compareToIgnoreCase("Usermanagmenets") == 0) {
+ objname = new UserManagementObject(mbsc);
+// this.name = option_value;
+ } else {
+ printusage();
+ echo("Wrong objectName");
+ return;
+ }
+ objname.setQueryString(this.object, this.name, this.vhost);
+ objname.returnObjects();
+ if (objname.getSet().size() != 0) {
+ if (this.object.compareToIgnoreCase("queue") == 0 || this.object.compareToIgnoreCase("queues") == 0)
+ objname.displayqueues(this.outputformat, this.seperator);
+ else
+ objname.displayobjects(this.outputformat, this.seperator);
+ } else {
+ if (isname()) {
+
+ echo("You might quering wrong " + this.object + " name with --name or -n option ");
+ echo("");
+ echo(this.object + "Type Objects might not in the broker currently");
+ echo("");
+ } else {
+ printusage();
+ }
+ }
+
+
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+
+
+ }
+
+ public void listdomains() {
+ MBeanServerConnection mbsc = info.getmbserverconnector();
+ try {
+ String[] domains = mbsc.getDomains();
+ echo("DOMAINS");
+ for (int i = 0; i < domains.length; i++)
+ echo("\tDomain[" + i + "] = " + domains[i]);
+
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+
+ public void execute() {
+ /* In here you it's easy to handle any number of otpions which are going to add with the list command which works
+ with main option object or o
+ */
+ if (checkoptionsetting("output")) {
+ setoutputformat(optionchecker("output"));
+ if (checkoptionsetting("separator"))
+ setseperator(optionchecker("separator"));
+ }
+ if (checkoptionsetting("object") || checkoptionsetting("o")) {
+ String object = optionchecker("object");
+ if (object == null) {
+ object = optionchecker("o");
+ }
+ setobject(object);
+ if (checkoptionsetting("name") || checkoptionsetting("n")) {
+ String name = optionchecker("name");
+ if (name == null)
+ name = optionchecker("n");
+
+ setname(name);
+ }
+ if (checkoptionsetting("virtualhost") || checkoptionsetting("v")) {
+ String vhost = optionchecker("virtualhost");
+ if (vhost == null)
+ vhost = optionchecker("v");
+ setvhost(vhost);
+ }
+ listobjects(this.object);
+ } else if (checkoptionsetting("domain") || checkoptionsetting("d"))
+ listdomains();
+ else if (checkoptionsetting("h") || checkoptionsetting("help"))
+ printusage();
+ else
+ unrecognizeoption();
+ }
+
+ public void printusage() {
+ echo("");
+ echo("Usage:list [OPTION] ... [OBJECT TYPE]...\n");
+ echo("List the information about the given object\n");
+ echo("Where possible options include:\n");
+ echo(" -o --object type of objects which you want to list\n");
+ echo(" ex: < list -o queue > : lists all the queues created in the java broker\n");
+ echo(" For now list command is supporting following object typse \n");
+ echo(" Queue Connection VirtualHost UserMangement Exchange");
+ echo(" Or You can specify object type by giving it at the beginning");
+ echo(" rather giving it as a argument");
+ echo(" Ex:< queue list > this command is equal to list -o queue \n");
+ echo(" -d --domain list all the domains of objects available for remote monitoring\n");
+ echo(" -v --virtualhost After specifying the object type you can filter output with this option");
+ echo(" list objects with the given virtualhost which will help to find ");
+ echo(" identical queue objects with -n option");
+ echo(" ex: queue list -v develop ment");
+ echo(" -output Specify which output format you want to get the ouput");
+ echo(" Although the option is there current version supports only for CSV output format");
+ echo(" -separator This option use with output option to specify which separator you want to get the CSV output (default seperator is comma");
+ echo(" -h --help Display the help and back to the qpid-cli prompt\n");
+ echo(" -n --name After specifying what type of objects you want to monitor you can filter");
+ echo(" the output using -n option by specifying the name of the object you want ");
+ echo(" to monitor exactly");
+ echo(" ex: <list -o queue -n ping> : list all the queue objects having queue name");
+ echo(" of ping");
+ echo(" ex: <queue list -n ping -v development> list all the queue objects with name ");
+ echo(" of ping and virtualhost of developement \n");
+
+
+ }
+
+ private void setobject(String object) {
+ this.object = object;
+ }
+
+ private void setname(String name) {
+ this.name = name;
+ }
+
+ private boolean isname() {
+ if (this.name == null)
+ return false;
+
+ else
+ return true;
+ }
+
+ private void setvhost(String vhost) {
+ this.vhost = vhost;
+ }
+
+ public String getvhost() {
+ return this.vhost;
+ }
+
+ public String getname() {
+ return this.name;
+ }
+
+ public String getobject() {
+ return this.object;
+ }
+
+ private void setoutputformat(String outputformat) {
+ this.outputformat = outputformat;
+ }
+
+ private void setseperator(String seperator) {
+ this.seperator = seperator;
+ }
+
+ private boolean isseperator() {
+ if (this.seperator == null)
+ return false;
+
+ else
+ return true;
+ }
+
+ private boolean isoutputformat() {
+ if (this.outputformat == null)
+ return false;
+
+ else
+ return true;
+ }
+
+
+ /*
+ public String optionchecker(String option_letter) {
+ Map map = info.getCommandLineOptionParser().getAlloptions();
+ if(map == null)
+ return null;
+ CommandLineOption option = (CommandLineOption) map.get(option_letter);
+ if(option == null)
+ return null;
+ String value = option.getOptionValue();
+ return value;
+
+
+ }
+ */
+ public void optionvaluechecker() {
+
+ }
+}
+
+
+
+
+
diff --git a/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/commands/Commandmove.java b/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/commands/Commandmove.java
new file mode 100644
index 0000000000..a4deb19315
--- /dev/null
+++ b/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/commands/Commandmove.java
@@ -0,0 +1,294 @@
+/*
+ *
+ * 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.
+ *
+ */
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * 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.
+ *
+ */
+
+
+package org.apache.qpid.commands;
+
+
+import org.apache.qpid.commands.objects.QueueObject;
+import org.apache.qpid.commands.objects.ObjectNames;
+import org.apache.qpid.utils.JMXinfo;
+
+import javax.management.ObjectName;
+import javax.management.MBeanInfo;
+import javax.management.MBeanServerConnection;
+import javax.management.MBeanAttributeInfo;
+import java.util.StringTokenizer;
+import java.util.Set;
+import java.util.Iterator;
+import java.util.List;
+import java.io.InputStreamReader;
+import java.io.BufferedReader;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: lahiru
+ * Date: Aug 6, 2008
+ * Time: 5:35:05 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class Commandmove extends Command {
+ private String object;
+ private String name1 = null, name2 = null, vhost1 = null, vhost2 = null, method1 = null, method2 = null; //target and starting queue specifications happen with these options
+ private int number = 0;
+ private QueueObject queue1, queue2;
+ private MBeanServerConnection mbsc;
+ private ObjectName queue;
+ private int fmid = 0, tmid = 0;
+
+ public Commandmove(JMXinfo info, String name) {
+ super(info, name);
+ this.mbsc = info.getmbserverconnector();
+ this.queue1 = new QueueObject(mbsc);
+// this.queue2 = new QueueObject(mbsc);
+ this.method1 = "moveMessages";
+ this.method2 = "getMessagesOnTheQueue";
+
+ }
+
+ public void movemessages() {
+ Set set = null;
+ queue1.setQueryString(this.object, this.name1, this.vhost1);
+// queue2.setQueryString(this.object, this.name2, this.vhost2);
+ set = queue1.returnObjects();
+ List messageidlist = null;
+ Long frommessageid = null, tomessageid, middle;
+ int temp = 0;
+ if (queue1.getSet().size() != 0) { // find the queue
+ Iterator it = set.iterator();
+ this.queue = (ObjectName) it.next();
+ } else {
+ if (isname1() || isname2()) { // if the specified queue is not there in the broker
+
+ echo("The Queue you have specified is not in the current broker");
+ echo("");
+ } else {
+ printusage();
+ }
+ }
+// if(this.tmid == 0 || this.fmid == 0)
+// {
+// this.number = queue1.getmessagecount(this.queue);
+// echo("");
+// System.out.print("Do you want to delete all the messages from the Queue[Y/N] :");
+// InputStreamReader isr = new InputStreamReader(System.in);
+// BufferedReader br = new BufferedReader(isr);
+// try{
+// String s = br.readLine();
+// echo(s);
+// if(s.compareToIgnoreCase("y") != 0)
+// return;
+// }catch(Exception ex)
+// {
+// ex.printStackTrace();
+// }
+//
+// }
+// if(this.number > queue1.getmessagecount(this.queue))
+// {
+// System.out.println("Given number is Greater than the Queue Depth");
+// return;
+// }//if user doesn't specify -t option all the messages will be moved
+// Object[] params = {new Integer(this.number)};
+// String[] signature = {new String("java.lang.Integer")};
+// try{
+// messageidlist = (List)this.mbsc.invoke(queue,this.method2,params,signature);
+// Iterator it1 = messageidlist.iterator();
+// temp++;
+// do
+// {
+// middle = (Long)it1.next();
+// if(temp == 1)
+// frommessageid = middle; // get the messageid of first message
+//
+// }while(it1.hasNext());
+// tomessageid = middle; // get the messageid of the last message
+ try {
+ Object[] params1 = {getfmid(), gettmid(), this.name2};
+ String[] signature1 = {new String("long"), new String("long"), new String("java.lang.String")};
+ this.mbsc.invoke(this.queue, this.method1, params1, signature1);
+
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ echo("Given messageId's might be wrong please run the view command and check messageId's you have given\n");
+ echo("From MessageId should be greater than 0 and should less than To messageId");
+ }
+
+
+ }
+
+ public void execute() {
+ /* In here you it's easy to handle any number of otpions which are going to add with the list command which works
+ with main option object or o
+ */
+
+ if (checkoptionsetting("object") || checkoptionsetting("o")) {
+ String object = optionchecker("object");
+ if (object == null) {
+ object = optionchecker("o");
+ }
+ if (object.compareToIgnoreCase("queue") == 0)
+ setobject(object);
+ else {
+ unrecognizeoption();
+ echo("This command is only applicable for queue command so please start with queue");
+ }
+ if (checkoptionsetting("n2") && checkoptionsetting("n1")) {
+ setname1(optionchecker("n1"));
+ setname2(optionchecker("n2"));
+ } else {
+ echo("You have to specify both n1 and n2 option value to move a message"); /* when user forget to specify target or starting queue name */
+ return;
+ }
+
+ if (checkoptionsetting("v1")) {
+
+ setvhost1(optionchecker("v1"));
+ }
+ if (checkoptionsetting("tmid") && checkoptionsetting("fmid")) {
+ String tmid = optionchecker("tmid");
+ String fmid = optionchecker("fmid");
+
+
+ settomessageIdandfrommessageId(removeSpaces(tmid), removeSpaces(fmid));
+ } else {
+ echo("You have to set from MessageId and to MessageId in order to move messages between queues");
+ echo("To view MessageId's use <view> command with -n and -v options");
+ return;
+ }
+ this.movemessages();
+
+ } else if (checkoptionsetting("h") || checkoptionsetting("help"))
+ printusage();
+ else
+ unrecognizeoption();
+ }
+
+ public void printusage() {
+ echo("");
+ echo("Usage:move [OPTION] ... [OBJECT TYPE]...\n");
+ echo("Move the top most messages from the given queue object to the given destination object\n");
+ echo("To specify the desired queues you have to give the virtualhost name and the queue name with following commands\n");
+ echo("Where possible options include:\n");
+ echo(" -v1 Give the virtuallhost name from which queue you want to move messages");
+ echo(" -n1 Give the queue name which you want to move messages from");
+ echo(" -n2 Give the queue name of the destination queue");
+ echo(" -tmid Give From MessageId you want to move from the Queue");
+ echo(" -fmid Give To MessageId you want to move from the Queue");
+ echo(" -h --help Display the help and back to the qpid-cli prompt\n");
+
+ }
+
+ private void setobject(String object) {
+ this.object = object;
+ }
+
+ private void setname1(String name) {
+ this.name1 = name;
+ }
+
+ private void setname2(String name) {
+ this.name2 = name;
+ }
+
+ private boolean isname1() {
+ if (this.name1 == null)
+ return false;
+
+ else
+ return true;
+ }
+
+ private boolean isname2() {
+ if (this.name2 == null)
+ return false;
+
+ else
+ return true;
+ }
+
+ private void setvhost1(String vhost) {
+ this.vhost1 = vhost;
+ }
+// private void setvhost2(String vhost) {
+// this.vhost2 = vhost;
+// }
+
+ private void setnumber(String number) {
+ Integer i = new Integer(number);
+ this.number = i.intValue();
+ }
+
+ private static String removeSpaces(String s) {
+ StringTokenizer st = new StringTokenizer(s, " ", false);
+ String t = "";
+ while (st.hasMoreElements()) t += st.nextElement();
+ return t;
+ }
+
+ private void settomessageIdandfrommessageId(String tmid, String fmid) {
+ Integer i = new Integer(tmid);
+ Integer j = new Integer(fmid);
+ this.tmid = i.intValue();
+ this.fmid = j.intValue();
+ }
+
+ public int gettmid() {
+ return this.tmid;
+ }
+
+ public int getfmid() {
+ return this.fmid;
+ }
+
+ public String getname1() {
+ return this.name1;
+ }
+
+ public String getname2() {
+ return this.name2;
+ }
+
+ public String getvhost() {
+ return this.vhost1;
+ }
+
+ public String getobject() {
+ return this.object;
+ }
+}
diff --git a/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/commands/Commandview.java b/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/commands/Commandview.java
new file mode 100644
index 0000000000..a4c6394589
--- /dev/null
+++ b/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/commands/Commandview.java
@@ -0,0 +1,276 @@
+/*
+ *
+ * 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.
+ *
+ */
+ /*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * 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.
+ *
+ */
+
+package org.apache.qpid.commands;
+
+import org.apache.qpid.commands.objects.ObjectNames;
+import org.apache.qpid.commands.objects.QueueObject;
+import org.apache.qpid.utils.JMXinfo;
+
+import javax.management.MBeanServerConnection;
+import javax.management.ObjectName;
+import javax.management.MBeanAttributeInfo;
+import javax.management.MBeanInfo;
+import javax.management.openmbean.*;
+import java.util.*;
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.awt.font.OpenType;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: lahiru
+ * Date: Aug 8, 2008
+ * Time: 11:33:05 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class Commandview extends Command {
+ private String object;
+ private String name;
+ private String vhost;
+ private int number = 0;
+ private QueueObject objname;
+ private MBeanServerConnection mbsc;
+ private String method1, method2;
+ private ObjectName queue;
+
+ public Commandview(JMXinfo info, String name) {
+ super(info, name);
+ this.mbsc = info.getmbserverconnector();
+ this.objname = new QueueObject(mbsc);
+ this.method1 = "viewMessages";
+ this.method2 = "viewMessaegContent";
+
+ }
+
+ public void viewmessages() {
+ Set set = null;
+ Object temp[] = {null};
+ objname.setQueryString(this.object, this.name, this.vhost);
+ set = objname.returnObjects();
+ String header = "", temp_header = "", message_data = "", outline = "";
+
+
+ if (objname.getSet().size() != 0) {
+ Iterator it = set.iterator();
+ this.queue = (ObjectName) it.next();
+ try {
+ if (objname.getmessagecount(this.queue) == 0) {
+ echo("Selected Queue doesn't contain any messages");
+ return;
+ }
+ if (this.number == 0)
+ this.number = objname.getmessagecount(this.queue);
+
+
+ if (objname.getmessagecount(this.queue) < this.number) {
+ echo("Given number is Greater than the Queue Depth");
+ return;
+ } else {
+ Object[] params = {1, this.number};
+ String[] signature = {new String("int"), new String("int")};
+ TabularDataSupport data = (TabularDataSupport) this.mbsc.invoke(queue, this.method1, params, signature);
+
+ Set entrySet = data.entrySet();
+ ArrayList<Map.Entry> list = new ArrayList<Map.Entry>(entrySet);
+ if (list.size() != 0) {// no data}
+ for (int i = 0; i < list.size(); i++) {
+ CompositeData compositedata =
+ (CompositeData) (list.get(i)).getValue();
+ List<String> itemNames = new
+ ArrayList<String>(compositedata.getCompositeType().keySet());
+ if (i == 0) // display the table headers
+ {
+ for (int j = 0; j < itemNames.size(); j++) {
+ temp_header = "";
+ if (j != 1) //skipping header information
+ {
+ temp_header = itemNames.get(j);
+ while (temp_header.length() < 15)
+ temp_header = " " + temp_header;
+
+ header = header + temp_header + "|";
+ } else
+ continue;
+ }
+ echo(header);
+ while (outline.length() < header.length())
+ outline = outline + "-";
+ echo(outline);
+ }
+
+ for (int j = 0; j < itemNames.size(); j++) {
+ temp_header = "";
+ if (j != 1) {
+ temp_header = String.valueOf(compositedata.get(itemNames.get(j)));
+ while (temp_header.length() < 15)
+ temp_header = " " + temp_header;
+ message_data = message_data + temp_header + "|";
+ } else // header information is not displaying unless user specify header information is needed
+ continue;
+
+
+ }
+ echo(message_data);
+ header = "";
+ message_data = "";
+ }
+ } else {
+ System.out.println("No Data to Display");
+ }
+ }
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+
+ } else {
+ if (isname()) {
+
+ echo("The Queue you have specified is not in the current broker");
+ echo("");
+ } else {
+ printusage();
+ }
+ }
+ }
+
+ public void execute() {
+ /* In here you it's easy to handle any number of otpions which are going to add with the list command which works
+ with main option object or o
+ */
+
+ if (checkoptionsetting("object") || checkoptionsetting("o")) {
+ String object = optionchecker("object");
+ if (object == null) {
+ object = optionchecker("o");
+ }
+ if (object.compareToIgnoreCase("queue") == 0)
+ setobject(object);
+ else {
+ unrecognizeoption();
+ echo("This command is only applicable for delete command so please start with queue");
+ }
+ if (checkoptionsetting("name") || checkoptionsetting("n")) {
+ String name = optionchecker("name");
+ if (name == null)
+ name = optionchecker("n");
+
+ setname(name);
+ }
+ if (checkoptionsetting("virtualhost") || checkoptionsetting("v")) {
+ String vhost = optionchecker("virtualhost");
+ if (vhost == null)
+ vhost = optionchecker("v");
+ setvhost(vhost);
+ }
+ if (checkoptionsetting("top") || checkoptionsetting("t")) {
+ String number = optionchecker("top");
+ if (number == null)
+ number = optionchecker("t");
+
+ setnumber(removeSpaces(number));
+ }
+ this.viewmessages();
+ } else if (checkoptionsetting("h") || checkoptionsetting("help"))
+ printusage();
+ else
+ unrecognizeoption();
+ }
+
+ public void printusage() {
+ echo("");
+ echo("Usage:view [OPTION] ... [OBJECT TYPE]...\n");
+ echo("view the information about given number of messages from the given queue object\n");
+ echo("To specify the desired queue you have to give the virtualhost name and the queue name with following commands\n");
+ echo("Where possible options include:\n");
+ echo(" -v --virtualhost Give the virtuallhost name of the desired queue");
+ echo(" -n --name Give the queue name of the desired queue you want to view messages");
+ echo(" -t --top Give how many number of messages you want to delete from the top (Default = all the messages will be deleted");
+ echo(" -h --help Display the help and back to the qpid-cli prompt\n");
+
+ }
+
+ private void setobject(String object) {
+ this.object = object;
+ }
+
+ private void setname(String name) {
+ this.name = name;
+ }
+
+ private boolean isname() {
+ if (this.name == null)
+ return false;
+
+ else
+ return true;
+ }
+
+ private void setvhost(String vhost) {
+ this.vhost = vhost;
+ }
+
+ public String getvhost() {
+ return this.vhost;
+ }
+
+ private void setnumber(String number) {
+ Integer i = new Integer(number);
+ this.number = i.intValue();
+ }
+
+ private static String removeSpaces(String s) {
+ StringTokenizer st = new StringTokenizer(s, " ", false);
+ String t = "";
+ while (st.hasMoreElements()) t += st.nextElement();
+ return t;
+ }
+
+ public String getname() {
+ return this.name;
+ }
+
+ public String getobject() {
+ return this.object;
+ }
+
+ public int getnumber() {
+ return this.number;
+ }
+
+}
diff --git a/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/commands/Commandviewcontent.java b/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/commands/Commandviewcontent.java
new file mode 100644
index 0000000000..f24fd08a99
--- /dev/null
+++ b/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/commands/Commandviewcontent.java
@@ -0,0 +1,284 @@
+/*
+ *
+ * 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.
+ *
+ */
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * 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.
+ *
+ */
+
+package org.apache.qpid.commands;
+
+import org.apache.qpid.commands.objects.QueueObject;
+import org.apache.qpid.utils.JMXinfo;
+
+import javax.management.MBeanServerConnection;
+import javax.management.ObjectName;
+import javax.management.openmbean.TabularData;
+import javax.management.openmbean.CompositeData;
+import java.util.*;
+import java.nio.charset.Charset;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: lahiru
+ * Date: Aug 10, 2008
+ * Time: 12:19:16 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class Commandviewcontent extends Command {
+ private String object;
+ private String name;
+ private String vhost;
+ private int number = 0;
+ private QueueObject objname;
+ private MBeanServerConnection mbsc;
+ private String method1;
+ private ObjectName queue;
+
+ public Commandviewcontent(JMXinfo info, String name) {
+ super(info, name);
+ this.mbsc = info.getmbserverconnector();
+ this.objname = new QueueObject(mbsc);
+ this.method1 = "viewMessageContent";
+
+ }
+
+ public void viewcontent() {
+ Set set = null;
+ Object temp[] = {null};
+ objname.setQueryString(this.object, this.name, this.vhost);
+ set = objname.returnObjects();
+ String temp_header = "", header = "", message_data = "", encoding = null;
+
+ if (objname.getSet().size() != 0) {
+ Iterator it = set.iterator();
+ this.queue = (ObjectName) it.next();
+ try {
+ if (objname.getmessagecount(this.queue) == 0) {
+ echo("Selected Queue doesn't contain any messages");
+ return;
+ }
+ if (this.number == 0) {
+ echo("You haven't selected a MessageId Please use -id and give a message id");
+ echo("Or run view command with same arguemnts to view messageId list for the queue");
+ }
+
+// if(objname.getmessagecount(this.queue) < this.number)
+// {
+// echo("Given number is Greater than the Queue Depth");
+// return;
+// }
+ else {
+ Object[] params = {this.number};
+ String[] signature = {new String("long")};
+ CompositeData data = (CompositeData) this.mbsc.invoke(queue, this.method1, params, signature);
+ List<String> itemNames = new
+ ArrayList<String>(data.getCompositeType().keySet());
+ for (int j = 0; j < itemNames.size(); j++) {
+ temp_header = "";
+ temp_header = itemNames.get(j);
+ while (temp_header.length() < 15)
+ temp_header = " " + temp_header;
+
+ header = header + temp_header + "|";
+ }
+ echo(header);
+ encoding = String.valueOf(data.get(itemNames.get(2))); // set the encoding at the beginning because encoding comes later in the loop
+ if (encoding == null || encoding.length() == 0) {
+ encoding = Charset.defaultCharset().name();
+
+ }
+ for (int j = 0; j < itemNames.size(); j++) {
+ temp_header = "";
+ if (j != 1) {
+ temp_header = String.valueOf(data.get(itemNames.get(j)));
+ while (temp_header.length() < 15)
+ temp_header = " " + temp_header;
+ } else {
+ Byte[] arrayItems = (Byte[]) data.get(itemNames.get(j));
+ byte[] byteArray = new byte[arrayItems.length];
+ for (int i = 0; i < arrayItems.length; i++) {
+ byteArray[i] = arrayItems[i];
+ temp_header = new String(byteArray, encoding);
+ while (temp_header.length() < 15)
+ temp_header = " " + temp_header;
+ }
+ }
+ message_data = message_data + temp_header + "|";
+
+
+ }
+ echo(message_data);
+// Object keys[] = data.keySet().toArray();
+// CompositeData comdata = data.get(keys);
+// for(int i=0;i < keys.length;i++)
+// {
+// System.out.println(keys[i].toString());
+// CompositeData cdata = data.get(temp);
+// System.out.println(cdata.toString());
+// temp[0] = null;
+// }
+// TabularType tabular = data.getTabularType();
+//// System.out.println(tabular.toString());
+// List info = tabular.getIndexNames();
+// Iterator it1 = info.iterator();
+//
+// do{
+// String temp1 = (String)it1.next();
+// System.out.println(temp1);
+// }while(it1.hasNext());
+
+ }
+ } catch (Exception ex) {
+ echo("Given MessageId is invalid, There's no message with the given messageId");
+ ex.printStackTrace();
+ return;
+ }
+
+ } else {
+ if (isname()) {
+
+ echo("The Queue you have specified is not in the current broker");
+ echo("");
+ } else {
+ printusage();
+ }
+ }
+ }
+
+ public void execute() {
+ /* In here you it's easy to handle any number of otpions which are going to add with the list command which works
+ with main option object or o
+ */
+
+ if (checkoptionsetting("object") || checkoptionsetting("o")) {
+ String object = optionchecker("object");
+ if (object == null) {
+ object = optionchecker("o");
+ }
+ if (object.compareToIgnoreCase("queue") == 0)
+ setobject(object);
+ else {
+ unrecognizeoption();
+ echo("This command is only applicable for delete command so please start with queue");
+ }
+ if (checkoptionsetting("name") || checkoptionsetting("n")) {
+ String name = optionchecker("name");
+ if (name == null)
+ name = optionchecker("n");
+
+ setname(name);
+ }
+ if (checkoptionsetting("virtualhost") || checkoptionsetting("v")) {
+ String vhost = optionchecker("virtualhost");
+ if (vhost == null)
+ vhost = optionchecker("v");
+ setvhost(vhost);
+ }
+ if (checkoptionsetting("messageid") || checkoptionsetting("id")) {
+ String number = optionchecker("id");
+ if (number == null)
+ number = optionchecker("id");
+
+ setnumber(removeSpaces(number));
+ }
+ this.viewcontent();
+ } else if (checkoptionsetting("h") || checkoptionsetting("help"))
+ printusage();
+ else
+ unrecognizeoption();
+ }
+
+ public void printusage() {
+ echo("");
+ echo("Usage:viewcontent [OPTION] ... [OBJECT TYPE]...\n");
+ echo("view the information about given number of messages from the given queue object\n");
+ echo("To specify the desired queue you have to give the virtualhost name and the queue name with following commands\n");
+ echo("Where possible options include:\n");
+ echo(" -v --virtualhost Give the virtuallhost name of the desired queue");
+ echo(" -n --name Give the queue name of the desired queue you want to view messages");
+ echo(" -id Give the messageId of the required message you want to view the content");
+ echo(" -h --help Display the help and back to the qpid-cli prompt\n");
+
+ }
+
+ private void setobject(String object) {
+ this.object = object;
+ }
+
+ private void setname(String name) {
+ this.name = name;
+ }
+
+ private boolean isname() {
+ if (this.name == null)
+ return false;
+
+ else
+ return true;
+ }
+
+ public void setvhost(String vhost) {
+ this.vhost = vhost;
+ }
+
+ public String getvhost() {
+ return this.vhost;
+ }
+
+ private void setnumber(String number) {
+ Integer i = new Integer(number);
+ this.number = i.intValue();
+ }
+
+ private static String removeSpaces(String s) {
+ StringTokenizer st = new StringTokenizer(s, " ", false);
+ String t = "";
+ while (st.hasMoreElements()) t += st.nextElement();
+ return t;
+ }
+
+ public String getname() {
+ return this.name;
+ }
+
+ public String getobject() {
+ return this.object;
+ }
+
+ public int getnumber() {
+ return this.number;
+ }
+
+
+}
diff --git a/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/commands/objects/AllObjects.java b/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/commands/objects/AllObjects.java
new file mode 100644
index 0000000000..7f16109f0c
--- /dev/null
+++ b/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/commands/objects/AllObjects.java
@@ -0,0 +1,44 @@
+/*
+ *
+ * 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.
+ *
+ */
+
+package org.apache.qpid.commands.objects;
+
+import javax.management.MBeanServerConnection;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: lahiru
+ * Date: Jun 20, 2008
+ * Time: 9:04:22 AM
+ * To change this template use File | Settings | File Templates.
+ */
+public class AllObjects extends ObjectNames {
+
+ public AllObjects(MBeanServerConnection mbsc) {
+ ObjectNames(mbsc);
+// querystring = "org.apache.qpid:*";
+// set = returnObjects();
+ }
+
+ public void setQueryString(String object, String name) {
+ querystring = "org.apache.qpid:*";
+ }
+}
diff --git a/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/commands/objects/ConnectionObject.java b/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/commands/objects/ConnectionObject.java
new file mode 100644
index 0000000000..6c427660c0
--- /dev/null
+++ b/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/commands/objects/ConnectionObject.java
@@ -0,0 +1,54 @@
+/*
+ *
+ * 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.
+ *
+ */
+
+package org.apache.qpid.commands.objects;
+
+import javax.management.MBeanServerConnection;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: lahiru
+ * Date: Jun 26, 2008
+ * Time: 9:58:02 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class ConnectionObject extends ObjectNames {
+ public ConnectionObject(MBeanServerConnection mbsc) {
+ /*calling parent classes constructor */
+ ObjectNames(mbsc);
+// querystring = "org.apache.qpid:type=VirtualHost.Connection,*";
+// set = returnObjects();
+
+ }
+
+ public void setQueryString(String object, String name, String vhost) {
+ if (name != null && vhost == null)
+ querystring = "org.apache.qpid:type=Connection,name=" + name + ",*";
+ else if (name != null && vhost != null)
+ querystring = "org.apache.qpid:type=Connection,VirtualHost=" + vhost + ",name=" + name + ",*";
+ else if (name == null && vhost != null)
+ querystring = "org.apache.qpid:type=Connection,VirtualHost=" + vhost + ",*";
+ else
+ querystring = "org.apache.qpid:type=Connection,*";
+
+ }
+}
+
diff --git a/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/commands/objects/ExchangeObject.java b/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/commands/objects/ExchangeObject.java
new file mode 100644
index 0000000000..22439e9d61
--- /dev/null
+++ b/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/commands/objects/ExchangeObject.java
@@ -0,0 +1,53 @@
+/*
+ *
+ * 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.
+ *
+ */
+
+package org.apache.qpid.commands.objects;
+
+import javax.management.MBeanServerConnection;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: lahiru
+ * Date: Jun 24, 2008
+ * Time: 12:15:19 AM
+ * To change this template use File | Settings | File Templates.
+ */
+public class ExchangeObject extends ObjectNames {
+ public ExchangeObject(MBeanServerConnection mbsc) {
+ ObjectNames(mbsc);
+// querystring = "org.apache.qpid:type=VirtualHost.Exchange,*";
+// set = returnObjects();
+
+ }
+
+ public void setQueryString(String object, String name, String vhost) {
+ if (name != null && vhost == null)
+ querystring = "org.apache.qpid:type=VirtualHost.Exchange,name=" + name + ",*";
+ else if (name != null && vhost != null)
+ querystring = "org.apache.qpid:type=VirtualHost.Exchange,VirtualHost=" + vhost + ",name=" + name + ",*";
+ else if (name == null && vhost != null)
+ querystring = "org.apache.qpid:type=VirtualHost.Exchange,VirtualHost=" + vhost + ",*";
+ else
+ querystring = "org.apache.qpid:type=VirtualHost.Exchange,*";
+
+ }
+}
+
diff --git a/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/commands/objects/ObjectNames.java b/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/commands/objects/ObjectNames.java
new file mode 100644
index 0000000000..127c9f0a67
--- /dev/null
+++ b/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/commands/objects/ObjectNames.java
@@ -0,0 +1,477 @@
+/*
+ *
+ * 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.
+ *
+ */
+
+package org.apache.qpid.commands.objects;
+
+import javax.management.MBeanAttributeInfo;
+import javax.management.MBeanServerConnection;
+import javax.management.ObjectName;
+import javax.management.MBeanInfo;
+import java.util.Iterator;
+import java.util.Set;
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: lahiru
+ * Date: Jun 20, 2008
+ * Time: 8:39:01 AM
+ * To change this template use File | Settings | File Templates.
+ */
+public class ObjectNames {
+ public String querystring = null;
+ public MBeanServerConnection mbsc;
+ public Set set = null;
+ public String attributes = "";
+ public String attributevalues = "";// = null;
+
+ /* method return the Set objects according to the Object type */
+ public void ObjectNames(MBeanServerConnection mbsc) {
+ this.mbsc = mbsc;
+ }
+
+ public Set returnObjects() {
+ try {
+ set = mbsc.queryNames(new ObjectName(querystring), null);
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ return set;
+ }
+
+ public void echo(String str) {
+ System.out.println(str);
+ }
+ /* display appropriate objects according to the ojbect type */
+
+ public void displayobjects(String output, String seperator) {
+ Iterator it = set.iterator();
+ String line = "";
+ String temp2 = "";
+ int iterator = 0;
+ try {
+ do {
+ ObjectName temp_object = null;
+ if (it.hasNext()) {
+ temp_object = (ObjectName) it.next();
+ if (temp_object == null)
+ System.out.println("null test");
+ }
+ // echo(temp_object.getCanonicalKeyPropertyListString());
+ MBeanInfo bean_info = mbsc.getMBeanInfo(temp_object);
+ MBeanAttributeInfo[] attr_info = bean_info.getAttributes();
+ if (attr_info == null) {
+ echo(temp_object.toString());
+ String temp = "";
+ while (temp_object.toString().length() > temp.length())
+ temp = "=" + temp;
+ if (output == null)
+ echo(temp);
+
+ } else {
+ for (MBeanAttributeInfo attr : attr_info) {
+ Object toWrite = null;
+
+ try {
+ String temp1 = attr.getName();
+ if (output == null) {
+ while (temp1.length() < 15)
+ temp1 = " " + temp1;
+ attributes = attributes + temp1 + "|";
+ } else if (output.compareToIgnoreCase("csv") == 0)
+ attributes = attributes + temp1 + seperator;
+ else {
+ echo("Wrong output format current version is supporting only for CSV");
+ return;
+ }
+ } catch (Exception x) {
+ x.printStackTrace();
+ }
+ }
+ if (attributes.equalsIgnoreCase("")) {
+ echo(temp_object.toString());
+ String temp = "";
+ while (temp_object.toString().length() > temp.length())
+ temp = "=" + temp;
+ echo(temp);
+ echo("There are no attributes for this object Type");
+ return;
+ }
+ for (MBeanAttributeInfo attr : attr_info) {
+ Object toWrite = null;
+ temp2 = null;
+ try {
+ toWrite = mbsc.getAttribute(temp_object, attr.getName());
+ } catch (Exception x) {
+ temp2 = "-";
+ }
+ if (toWrite != null)
+ temp2 = toWrite.toString();
+ else
+ temp2 = "-";
+ if (output == null) {
+
+ while (temp2.length() < 15)
+ temp2 = " " + temp2;
+
+ attributevalues = attributevalues + temp2 + "|";
+ } else if (output.compareToIgnoreCase("csv") == 0)
+ attributevalues = attributevalues + temp2 + seperator;
+
+ //echo(temp1 + " " + temp2 + " " + temp3);
+
+
+ }
+ }
+ iterator++;
+ if (iterator == 1) {
+ echo(attributes);
+ for (int i = 0; i < attributes.length(); i++)
+ line = line + "-";
+ if (output == null)
+ echo(line);
+ }
+ echo(attributevalues);
+ line = "";
+ attributes = "";
+ attributevalues = "";
+ } while (it.hasNext());
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+
+ }
+
+ public void reportgenerator(String output, String seperator, List<String> column) {
+ Iterator it = set.iterator();
+ String line = "";
+ String temp2 = "";
+ int iterator = 0;
+ try {
+ do {
+ ObjectName temp_object = null;
+ if (it.hasNext()) {
+ temp_object = (ObjectName) it.next();
+ if (temp_object == null)
+ System.out.println("null test");
+ }
+ // echo(temp_object.getCanonicalKeyPropertyListString());
+ MBeanInfo bean_info = mbsc.getMBeanInfo(temp_object);
+ MBeanAttributeInfo[] attr_info = bean_info.getAttributes();
+ if (attr_info == null) {
+ echo(temp_object.toString());
+ String temp = "";
+ while (temp_object.toString().length() > temp.length())
+ temp = "=" + temp;
+ if (output == null)
+ echo(temp);
+
+ } else {
+ for (MBeanAttributeInfo attr : attr_info) {
+ Object toWrite = null;
+
+ try {
+ String temp1 = attr.getName();
+ if (column.contains(temp1)) {
+ if (output == null) {
+ while (temp1.length() < 15)
+ temp1 = " " + temp1;
+ attributes = attributes + temp1 + "|";
+ } else if (output.compareToIgnoreCase("csv") == 0)
+ attributes = attributes + temp1 + seperator;
+ else {
+ echo("Wrong output format current version is supporting only for CSV");
+ return;
+ }
+ }
+ } catch (Exception x) {
+ x.printStackTrace();
+ }
+ }
+ if (attributes.equalsIgnoreCase("")) {
+ echo(temp_object.toString());
+ String temp = "";
+ while (temp_object.toString().length() > temp.length())
+ temp = "=" + temp;
+ echo(temp);
+ echo("There are no attributes for this object Type");
+ return;
+ }
+ for (MBeanAttributeInfo attr : attr_info) {
+ Object toWrite = null;
+ temp2 = null;
+ if (column.contains(attr.getName())) {
+ try {
+ toWrite = mbsc.getAttribute(temp_object, attr.getName());
+ } catch (Exception x) {
+ temp2 = "-";
+ }
+ if (toWrite != null)
+ temp2 = toWrite.toString();
+ else
+ temp2 = "-";
+ if (output == null) {
+
+ while (temp2.length() < 15)
+ temp2 = " " + temp2;
+
+ attributevalues = attributevalues + temp2 + "|";
+ } else if (output.compareToIgnoreCase("csv") == 0)
+ attributevalues = attributevalues + temp2 + seperator;
+
+ //echo(temp1 + " " + temp2 + " " + temp3);
+
+ }
+
+
+ }
+ }
+ iterator++;
+ if (iterator == 1) {
+ echo(attributes);
+ for (int i = 0; i < attributes.length(); i++)
+ line = line + "-";
+ if (output == null)
+ echo(line);
+ }
+ echo(attributevalues);
+ line = "";
+ attributes = "";
+ attributevalues = "";
+ } while (it.hasNext());
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+
+ }
+
+ public void displayqueues(String output, String seperator) {
+ Iterator it = set.iterator();
+ String line = "";
+ int iterator = 0;
+ int attr_count = 0;
+ String temp1 = "";
+ String temp2 = "";
+ try {
+ do {
+ attr_count = 0;
+ ObjectName temp_object = null;
+ if (it.hasNext()) {
+ temp_object = (ObjectName) it.next();
+ }
+ // echo(temp_object.getCanonicalKeyPropertyListString());
+ MBeanInfo bean_info = mbsc.getMBeanInfo(temp_object);
+ MBeanAttributeInfo[] attr_info = bean_info.getAttributes();
+ if (attr_info == null) {
+ echo(temp_object.toString());
+ String temp = "";
+ while (temp_object.toString().length() > temp.length())
+ temp = "=" + temp;
+ if (output == null)
+ echo(temp);
+
+ } else {
+ for (MBeanAttributeInfo attr : attr_info) {
+ Object toWrite = null;
+ attr_count++;
+ try {
+ toWrite = mbsc.getAttribute(temp_object, attr.getName());
+ if (output == null) {
+ switch (attr_count) {
+ case 1:
+ case 3:
+ temp1 = attr.getName();
+ while (temp1.length() < 10)
+ temp1 = " " + temp1;
+ attributes = attributes + temp1 + "|";
+ temp2 = toWrite.toString();
+ while (temp2.length() < 10)
+ temp2 = " " + temp2;
+ attributevalues = attributevalues + temp2 + "|";
+ break;
+ case 6:
+ temp1 = attr.getName();
+ while (temp1.length() < 20)
+ temp1 = " " + temp1;
+ attributes = attributes + temp1 + "|";
+ temp2 = toWrite.toString();
+ while (temp2.length() < 20)
+ temp2 = " " + temp2;
+ attributevalues = attributevalues + temp2 + "|";
+ break;
+ case 7:
+ temp1 = attr.getName();
+ while (temp1.length() < 13)
+ temp1 = " " + temp1;
+ attributes = attributes + temp1 + "|";
+ temp2 = toWrite.toString();
+ while (temp2.length() < 13)
+ temp2 = " " + temp2;
+ attributevalues = attributevalues + temp2 + "|";
+ break;
+ case 9:
+ temp1 = attr.getName();
+ while (temp1.length() < 20)
+ temp1 = " " + temp1;
+ attributes = attributes + temp1 + "|";
+ temp2 = toWrite.toString();
+ while (temp2.length() < 20)
+ temp2 = " " + temp2;
+ attributevalues = attributevalues + temp2 + "|";
+ break;
+ }
+ } else if (output.compareToIgnoreCase("csv") == 0) {
+ switch (attr_count) {
+ case 1:
+ case 3:
+ case 6:
+ temp1 = attr.getName();
+ attributes = attributes + temp1 + seperator;
+ temp2 = toWrite.toString();
+ attributevalues = attributevalues + temp2 + seperator;
+ break;
+ case 7:
+ temp1 = attr.getName();
+ attributes = attributes + temp1 + seperator;
+ temp2 = toWrite.toString();
+ attributevalues = attributevalues + temp2 + seperator;
+ break;
+ case 9:
+ temp1 = attr.getName();
+ attributes = attributes + temp1 + seperator;
+ temp2 = toWrite.toString();
+ attributevalues = attributevalues + temp2 + seperator;
+ break;
+ }
+ } else {
+ echo("Wrong output format specified currently CLI supports only csv output format");
+ return;
+ }
+
+
+ } catch (Exception x) {
+ x.printStackTrace();
+ }
+
+ }
+ }
+ iterator++;
+ if (iterator == 1) {
+ for (int i = 0; i < attributes.length(); i++)
+ line = line + "-";
+ if (output == null)
+ echo(line);
+ echo(attributes);
+ if (output == null)
+ echo(line);
+ }
+ echo(attributevalues);
+ line = "";
+ attributes = "";
+ attributevalues = "";
+ } while (it.hasNext());
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+
+ public void displayinfo(String output, String seperator) {
+ Iterator it = set.iterator();
+ String temp1, temp2 = "";
+ try {
+ do {
+
+ ObjectName temp_object = null;
+ if (it.hasNext()) {
+ temp_object = (ObjectName) it.next();
+ }
+ // echo(temp_object.getCanonicalKeyPropertyListString());
+ MBeanInfo bean_info = mbsc.getMBeanInfo(temp_object);
+ MBeanAttributeInfo[] attr_info = bean_info.getAttributes();
+ if (attr_info == null) {
+ echo(temp_object.toString());
+ String temp = "";
+ while (temp_object.toString().length() > temp.length())
+ temp = "=" + temp;
+ echo(temp);
+
+ } else {
+ echo(temp_object.toString());
+ String temp = "";
+ while (temp_object.toString().length() > temp.length())
+ temp = "=" + temp;
+ echo(temp);
+
+ for (MBeanAttributeInfo attr : attr_info) {
+ Object toWrite = null;
+
+ try {
+ toWrite = mbsc.getAttribute(temp_object, attr.getName());
+ } catch (Exception x) {
+ temp2 = "-";
+ }
+ temp1 = attr.getName();
+ if (toWrite != null)
+ temp2 = toWrite.toString();
+
+ if (output == null) {
+ while (temp1.length() < 35)
+ temp1 = " " + temp1;
+
+ while (temp2.length() < 35)
+ temp2 = " " + temp2;
+ echo(temp1 + " " + temp2);
+ } else if (output.compareToIgnoreCase("csv") == 0)
+ echo(temp1 + seperator + temp2);
+ else {
+ echo("Wrong output format specified currently CLI supports only csv output format");
+ return;
+ }
+ }
+ echo("");
+ echo("");
+
+ }
+ } while (it.hasNext());
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+
+ }
+
+ public void setQueryString(String object, String name, String vhost) {
+
+ }
+
+ public void setQueryStringforinfo(String object, String name, String virtualhost) {
+
+ }
+
+ public String getQueryString() {
+ return querystring;
+ }
+
+ public Set getSet() {
+ return set;
+ }
+
+}
diff --git a/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/commands/objects/QueueObject.java b/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/commands/objects/QueueObject.java
new file mode 100644
index 0000000000..7bbcbf5840
--- /dev/null
+++ b/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/commands/objects/QueueObject.java
@@ -0,0 +1,86 @@
+/*
+ *
+ * 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.
+ *
+ */
+
+package org.apache.qpid.commands.objects;
+
+import javax.management.MBeanServerConnection;
+import javax.management.MBeanAttributeInfo;
+import javax.management.MBeanInfo;
+import javax.management.ObjectName;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: lahiru
+ * Date: Jun 20, 2008
+ * Time: 8:49:56 AM
+ * To change this template use File | Settings | File Templates.
+ */
+public class QueueObject extends ObjectNames {
+ public QueueObject(MBeanServerConnection mbsc) {
+ ObjectNames(mbsc);
+ }
+
+ public void setQueryString(String object, String name, String vhost) {
+ if (name != null && vhost == null)
+ querystring = "org.apache.qpid:type=VirtualHost.Queue,name=" + name + ",*";
+ else if (name != null && vhost != null)
+ querystring = "org.apache.qpid:type=VirtualHost.Queue,VirtualHost=" + vhost + ",name=" + name + ",*";
+ else if (name == null && vhost != null)
+ querystring = "org.apache.qpid:type=VirtualHost.Queue,VirtualHost=" + vhost + ",*";
+ else
+ querystring = "org.apache.qpid:type=VirtualHost.Queue,*";
+ }
+
+ public int getmessagecount(ObjectName queue) {
+ int attr_count = 0;
+ String value;
+ Integer depth = null;
+
+ try {
+ MBeanInfo bean_info;
+ bean_info = mbsc.getMBeanInfo(queue);
+ MBeanAttributeInfo[] attr_info = bean_info.getAttributes();
+ if (attr_info == null)
+ return 0;
+ else {
+ for (MBeanAttributeInfo attr : attr_info) {
+ Object toWrite = null;
+ attr_count++;
+ toWrite = mbsc.getAttribute(queue, attr.getName());
+ if (attr_count == 7) {
+ value = toWrite.toString();
+ depth = new Integer(value);
+ }
+ }
+
+ }
+
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ if (depth != null)
+ return depth.intValue();
+ else
+ return -1;
+ }
+
+
+}
diff --git a/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/commands/objects/UserManagementObject.java b/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/commands/objects/UserManagementObject.java
new file mode 100644
index 0000000000..a5f84ea39e
--- /dev/null
+++ b/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/commands/objects/UserManagementObject.java
@@ -0,0 +1,45 @@
+/*
+ *
+ * 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.
+ *
+ */
+
+package org.apache.qpid.commands.objects;
+
+import javax.management.MBeanServerConnection;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: lahiru
+ * Date: Jun 24, 2008
+ * Time: 12:11:52 AM
+ * To change this template use File | Settings | File Templates.
+ */
+public class UserManagementObject extends ObjectNames {
+ public UserManagementObject(MBeanServerConnection mbsc) {
+ ObjectNames(mbsc);
+// querystring = "org.apache.qpid:type=UserManagement,*";
+// set = returnObjects();
+
+ }
+
+ public void setQueryString(String object, String name, String vhost) {
+ querystring = "org.apache.qpid:type=UserManagement,*";
+ }
+
+}
diff --git a/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/commands/objects/VirtualHostObject.java b/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/commands/objects/VirtualHostObject.java
new file mode 100644
index 0000000000..16bb159990
--- /dev/null
+++ b/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/commands/objects/VirtualHostObject.java
@@ -0,0 +1,53 @@
+/*
+ *
+ * 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.
+ *
+ */
+
+package org.apache.qpid.commands.objects;
+
+import javax.management.MBeanServerConnection;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: lahiru
+ * Date: Jun 20, 2008
+ * Time: 9:02:04 AM
+ * To change this template use File | Settings | File Templates.
+ */
+public class VirtualHostObject extends ObjectNames {
+
+ public VirtualHostObject(MBeanServerConnection mbsc) {
+ ObjectNames(mbsc);
+// querystring = "org.apache.qpid:type=VirtualHost.VirtualHostManager,*";
+// set = returnObjects();
+ }
+
+ public void setQueryString(String object, String name, String vhost) {
+ if (name != null && vhost == null)
+ querystring = "org.apache.qpid:type=VirtualHost.VirtualHostManager,name=" + name + ",*";
+ else if (name != null && vhost != null)
+ querystring = "org.apache.qpid:type=VirtualHost.VirtualHostManager,VirtualHost=" + vhost + ",name=" + name + ",*";
+ else if (name == null && vhost != null)
+ querystring = "org.apache.qpid:type=VirtualHost.VirtualHostManager,VirtualHost=" + vhost + ",*";
+ else
+ querystring = "org.apache.qpid:type=VirtualHost.VirtualHostManager,*";
+
+
+ }
+}
diff --git a/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/utils/CommandLineOption.java b/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/utils/CommandLineOption.java
new file mode 100644
index 0000000000..fb6afa6344
--- /dev/null
+++ b/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/utils/CommandLineOption.java
@@ -0,0 +1,112 @@
+/*
+ *
+ * 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.
+ *
+ */
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * 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.
+ *
+ */
+
+
+package org.apache.qpid.utils;
+
+import java.util.ArrayList;
+
+public class CommandLineOption implements CommandLineOptionConstants {
+ private String type;
+ private ArrayList optionValues;
+
+ public CommandLineOption(String type, String[] values) {
+ setOptionType(type);
+ ArrayList arrayList = new ArrayList(values.length);
+ for (int i = 0; i < values.length; i++) {
+ arrayList.add(values[i]);
+ }
+ this.optionValues = arrayList;
+ }
+
+ private void setOptionType(String type) {
+ //cater for the long options first
+ if (type.startsWith("--")) {
+ type = type.replaceFirst("--", "");
+ }
+ if (type.startsWith("-")) {
+ type = type.replaceFirst("-", "");
+ }
+
+ //we do not change the case of the option!
+
+ this.type = type;
+ }
+
+ /**
+ * @param type
+ */
+ public CommandLineOption(String type, ArrayList values) {
+ setOptionType(type);
+
+ if (null != values) {
+ this.optionValues = values;
+ }
+ }
+
+
+ /**
+ * @return Returns the type.
+ * @see CommandLineOptionConstants
+ */
+ public String getOptionType() {
+ return type;
+ }
+
+
+ /**
+ * @return Returns the optionValues.
+ */
+ public String getOptionValue() {
+ if ((optionValues != null) && (optionValues.size() > 0)) {
+ return (String) optionValues.get(0);
+ } else {
+ return null;
+ }
+ }
+
+
+ /**
+ * @return Returns the optionValues.
+ */
+ public ArrayList getOptionValues() {
+ return optionValues;
+ }
+
+
+}
diff --git a/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/utils/CommandLineOptionConstants.java b/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/utils/CommandLineOptionConstants.java
new file mode 100644
index 0000000000..fe84e2ebd2
--- /dev/null
+++ b/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/utils/CommandLineOptionConstants.java
@@ -0,0 +1,53 @@
+/*
+ *
+ * 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.
+ *
+ */
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * 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.
+ *
+ */
+
+
+package org.apache.qpid.utils;
+
+
+public interface CommandLineOptionConstants {
+ static interface JMXCommandLineOptionConstants {
+ String HOST_OPTION = "h";
+ String PORT_OPTION = "p";
+ String INTERVAL_OPTION = "i";
+ String REPORT_OPTION = "r";
+
+ }
+
+
+}
diff --git a/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/utils/CommandLineOptionParser.java b/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/utils/CommandLineOptionParser.java
new file mode 100644
index 0000000000..33a117cad5
--- /dev/null
+++ b/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/utils/CommandLineOptionParser.java
@@ -0,0 +1,218 @@
+/*
+ *
+ * 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.
+ *
+ */
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * 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.
+ *
+ */
+
+package org.apache.qpid.utils;
+
+import java.util.Map;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.StringTokenizer;
+
+
+public class CommandLineOptionParser {
+ private static int STARTED = 0;
+ private static int NEW_OPTION = 1;
+ private static int SUB_PARAM_OF_OPTION = 2;
+
+ private Map commandlineoption;
+ private String commandname;
+
+ public CommandLineOptionParser(Map commandlineoptions) {
+ this.commandlineoption = commandlineoptions;
+ }
+
+ public CommandLineOptionParser(String[] args) {
+ /* check whether user just type the enter key */
+ this.commandlineoption = this.parse(args);
+
+ }
+
+ public CommandLineOptionParser(String[] args, String first) {
+ this.commandname = first;
+ this.commandlineoption = this.parsefirst(args);
+ }
+
+ public Map parse(String[] args) {
+ Map commandLineOptions = new HashMap();
+
+ if (0 == args.length) {
+ return commandLineOptions;
+ } else if (1 == args.length) {
+ commandname = args[0];
+ return commandLineOptions;
+ }
+ /* when user is not giving the command line option with a "=" */
+// if (!args[2].startsWith("-"))
+// return commandLineOptions;
+
+ //State 0 means started
+ //State 1 means earlier one was a new -option
+ //State 2 means earlier one was a sub param of a -option
+
+ int state = STARTED;
+ ArrayList optionBundle = null;
+ String optionType = null;
+ CommandLineOption commandLineOption;
+ String newcommand = "";
+ String[] newargs;
+ int j;
+ if (args[1].compareTo("list") == 0 || args[1].compareTo("info") == 0 || args[1].compareTo("delete") == 0 ||
+ args[1].compareTo("move") == 0 || args[1].compareTo("view") == 0 || args[1].compareTo("viewcontent") == 0) {
+ String object = args[0];
+ for (j = 0; j < (args.length - 1); j++) {
+ newcommand = newcommand + args[j + 1] + " ";
+ }
+ newcommand = newcommand + "-o " + object;
+ newargs = newcommand.split(" ");
+ args = newargs;
+ } else
+ if (!args[1].startsWith("-")) //if user give command like list queue or something without minus argument
+ return commandLineOptions; //for the second wordxi
+
+ commandname = args[0];
+ for (int i = 0; i < args.length; i++) {
+ if (args[i].startsWith("-")) {
+ if (STARTED == state) {
+ // fresh one
+ state = NEW_OPTION;
+ optionType = args[i];
+ } else if (SUB_PARAM_OF_OPTION == state || NEW_OPTION == state) {
+ // new one but old one should be saved
+ commandLineOption =
+ new CommandLineOption(optionType, optionBundle);
+ commandLineOptions.put(commandLineOption.getOptionType(),
+ commandLineOption);
+ state = NEW_OPTION;
+ optionType = args[i];
+ optionBundle = null;
+
+ }
+ } else {
+ if (NEW_OPTION == state) {
+ optionBundle = new ArrayList();
+ optionBundle.add(args[i]);
+ state = SUB_PARAM_OF_OPTION;
+
+ } else if (SUB_PARAM_OF_OPTION == state) {
+ optionBundle.add(args[i]);
+ }
+
+
+ }
+ }
+ commandLineOption = new CommandLineOption(optionType, optionBundle);
+ commandLineOptions.put(commandLineOption.getOptionType(), commandLineOption);
+ return commandLineOptions;
+
+ }
+
+ public Map parsefirst(String[] args) {
+ Map commandLineOptions = new HashMap();
+ if (0 == args.length) {
+ return commandLineOptions;
+ } else if (1 == args.length) {
+ return commandLineOptions;
+ }
+ /* when user is not giving the command line option with a "=" */
+// if (!args[2].startsWith("-"))
+// return commandLineOptions;
+
+ //State 0 means started
+ //State 1 means earlier one was a new -option
+ //State 2 means earlier one was a sub param of a -option
+
+ int state = STARTED;
+ ArrayList optionBundle = null;
+ String optionType = null;
+ CommandLineOption commandLineOption;
+ String newcommand = "";
+ String[] newargs;
+ int j;
+
+ for (int i = 0; i < args.length; i++) {
+ if (args[i].startsWith("-")) {
+ if (STARTED == state) {
+ // fresh one
+ state = NEW_OPTION;
+ optionType = args[i];
+ } else if (SUB_PARAM_OF_OPTION == state || NEW_OPTION == state) {
+ // new one but old one should be saved
+ commandLineOption =
+ new CommandLineOption(optionType, optionBundle);
+ commandLineOptions.put(commandLineOption.getOptionType(),
+ commandLineOption);
+ state = NEW_OPTION;
+ optionType = args[i];
+ optionBundle = null;
+
+ }
+ } else {
+ if (NEW_OPTION == state) {
+ optionBundle = new ArrayList();
+ optionBundle.add(args[i]);
+ state = SUB_PARAM_OF_OPTION;
+
+ } else if (SUB_PARAM_OF_OPTION == state) {
+ optionBundle.add(args[i]);
+ }
+
+
+ }
+ }
+ commandLineOption = new CommandLineOption(optionType, optionBundle);
+ commandLineOptions.put(commandLineOption.getOptionType(), commandLineOption);
+ return commandLineOptions;
+
+ }
+
+ public Map getAlloptions() {
+ return this.commandlineoption;
+ }
+
+ public String getcommandname() {
+ return this.commandname;
+ }
+
+ private static String removeSpaces(String s) {
+ StringTokenizer st = new StringTokenizer(s, " ", false);
+ String t = "";
+ while (st.hasMoreElements()) t += st.nextElement();
+ return t;
+ }
+
+}
diff --git a/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/utils/JMXConfigProperty.java b/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/utils/JMXConfigProperty.java
new file mode 100644
index 0000000000..27e4527619
--- /dev/null
+++ b/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/utils/JMXConfigProperty.java
@@ -0,0 +1,47 @@
+/*
+*
+* 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.
+*
+*/
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * 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.
+ *
+ */
+
+package org.apache.qpid.utils;
+
+
+public class JMXConfigProperty {
+
+ private static final String DEFAULT_HOST_NAME = "localhost";
+ private static final String DEFAULT_PORT = "8999";
+ private static final String DEFAULT_INTERVAL = "4000";
+}
diff --git a/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/utils/JMXConfiguration.java b/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/utils/JMXConfiguration.java
new file mode 100644
index 0000000000..622f9d78bd
--- /dev/null
+++ b/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/utils/JMXConfiguration.java
@@ -0,0 +1,148 @@
+/*
+ *
+ * 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.
+ *
+ */
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * 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.
+ *
+ */
+
+package org.apache.qpid.utils;
+
+import org.apache.qpid.Command;
+
+import java.util.Map;
+
+public class JMXConfiguration {
+ private String hostname = "localhost";
+ private String port = "8999";
+ private String interval = "40000";
+ private String outputpath = ".";
+ private String report_file = "report.output";
+ private boolean isreport_mode = false;
+
+ public JMXConfiguration(Map map) {
+ if (checkoptionsetting(CommandLineOptionConstants.JMXCommandLineOptionConstants.HOST_OPTION, map)) {
+ this.hostname = optionchecker(CommandLineOptionConstants.JMXCommandLineOptionConstants.HOST_OPTION, map);
+ }
+ if (checkoptionsetting(CommandLineOptionConstants.JMXCommandLineOptionConstants.PORT_OPTION, map)) {
+ this.port = optionchecker(CommandLineOptionConstants.JMXCommandLineOptionConstants.PORT_OPTION, map);
+ }
+ if (checkoptionsetting(CommandLineOptionConstants.JMXCommandLineOptionConstants.REPORT_OPTION, map)) {
+
+ this.report_file = optionchecker(CommandLineOptionConstants.JMXCommandLineOptionConstants.REPORT_OPTION, map);
+ }
+
+ }
+
+ public void sethostname(String hostname) {
+ this.hostname = hostname;
+ }
+
+ public void setport(String port) {
+ this.port = port;
+ }
+
+ public void setinterval(String interval) {
+ this.interval = interval;
+ }
+
+ public void setoutputpath(String output) {
+ this.outputpath = output;
+ }
+
+ public String gethostname() {
+ return this.hostname;
+ }
+
+ public String getport() {
+ return this.port;
+ }
+
+ public String getinterval() {
+ return this.interval;
+ }
+
+ public String getoutputpath() {
+ return this.outputpath;
+ }
+
+ public CommandLineOption loadoption(String option, Map options) {
+ CommandLineOption op = null;
+ if (option != null) {
+ op = (CommandLineOption) options.get(option);
+
+ }
+ return op;
+
+ }
+
+ public void setreportfile(String reportfile) {
+ this.report_file = reportfile;
+ this.isreport_mode = true;
+
+ }
+
+ public boolean isreportmode() {
+ return this.isreport_mode;
+ }
+
+ public String getreportfile() {
+ return this.report_file;
+ }
+
+ public String optionchecker(String option_letter, Map map) {
+
+ if (map == null)
+ return null;
+ CommandLineOption option = (CommandLineOption) map.get(option_letter);
+ if (option == null)
+ return null;
+ String value = option.getOptionValue();
+ return value;
+ }
+
+ public boolean checkoptionsetting(String option_letter, Map map) {
+ if (map == null)
+ return false;
+ CommandLineOption option = (CommandLineOption) map.get(option_letter);
+ if (option == null)
+ return false;
+ String value = option.getOptionType();
+
+ if (value != null)
+ return true;
+ else
+ return false;
+ }
+
+}
diff --git a/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/utils/JMXinfo.java b/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/utils/JMXinfo.java
new file mode 100644
index 0000000000..af3e5c7be0
--- /dev/null
+++ b/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/utils/JMXinfo.java
@@ -0,0 +1,72 @@
+ /*
+ *
+ * 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.
+ *
+ */
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * 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.
+ *
+ */
+package org.apache.qpid.utils;
+
+import javax.management.remote.JMXConnector;
+import javax.management.MBeanServerConnection;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: lahiru
+ * Date: Jun 3, 2008
+ * Time: 9:21:08 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class JMXinfo {
+ private JMXConnector jmxconnector;
+ private CommandLineOptionParser input;
+ private MBeanServerConnection mbserverconnector;
+
+ public JMXinfo(JMXConnector jmxc, CommandLineOptionParser input, MBeanServerConnection mbsc) {
+ this.jmxconnector = jmxc;
+ this.input = input;
+ this.mbserverconnector = mbsc;
+ }
+
+ public JMXConnector getjmxconnectot() {
+ return jmxconnector;
+ }
+
+ public CommandLineOptionParser getCommandLineOptionParser() {
+ return input;
+ }
+
+ public MBeanServerConnection getmbserverconnector() {
+ return mbserverconnector;
+ }
+}
diff --git a/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/AllTest.java b/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/AllTest.java
new file mode 100644
index 0000000000..bdae5340b5
--- /dev/null
+++ b/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/AllTest.java
@@ -0,0 +1,80 @@
+/*
+ *
+ * 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.
+ *
+ */
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * 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.
+ *
+ */
+package org.apache.qpid;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.apache.qpid.commands.*;
+import org.apache.qpid.commands.objects.*;
+import org.apache.qpid.utils.TestCommandLineOption;
+import org.apache.qpid.utils.TestCommandLineOptionParser;
+import org.apache.qpid.utils.TestJMXConfiguration;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: lahiru
+ * Date: Jul 7, 2008
+ * Time: 1:09:50 PM
+ * To change this template use File | Settings | File Templates.
+ */
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+ TestCommand.class,
+ TestCommandExecusionEngine.class,
+ TestCommandLineOption.class,
+ TestCommandLineOptionParser.class,
+ TestConnector.class,
+ TestJMXConfiguration.class,
+ TestAllObject.class,
+ TestConnectionObject.class,
+ TestExchangeObject.class,
+ TestQueueObject.class,
+ TestVirtualHostObject.class,
+ TestUserManagementObject.class,
+ TestCommanddelete.class,
+ TestCommandlist.class,
+ TestCommandinfo.class,
+ TestCommandmove.class,
+ TestCommandview.class,
+ TestCommandviewcontent.class,
+ TestCommandLineInterpreter.class
+
+
+ })
+public class AllTest {
+}
diff --git a/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/ConnectionConstants.java b/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/ConnectionConstants.java
new file mode 100644
index 0000000000..58953e1693
--- /dev/null
+++ b/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/ConnectionConstants.java
@@ -0,0 +1,51 @@
+/*
+ *
+ * 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.
+ *
+ */
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * 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.
+ *
+ */
+
+package org.apache.qpid;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: lahiru
+ * Date: Aug 16, 2008
+ * Time: 4:55:21 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public interface ConnectionConstants {
+ String BROKER_HOSTNAME="localhost";
+ String BROKER_PORT="8999";
+}
diff --git a/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/TestCommandExecusionEngine.java b/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/TestCommandExecusionEngine.java
new file mode 100644
index 0000000000..bb5fa914d0
--- /dev/null
+++ b/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/TestCommandExecusionEngine.java
@@ -0,0 +1,90 @@
+/*
+ *
+ * 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.
+ *
+ */
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * 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.
+ *
+ */
+package org.apache.qpid;
+
+import junit.framework.TestCase;
+import org.apache.qpid.utils.JMXinfo;
+import org.apache.qpid.utils.CommandLineOptionParser;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.Assert;
+import org.junit.After;
+
+import java.io.IOException;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: lahiru
+ * Date: Jun 30, 2008
+ * Time: 12:06:25 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class TestCommandExecusionEngine {
+ String line;
+ String [] command;
+ CommandLineOptionParser commandlineoptionparser;
+ JMXinfo info;
+ CommandExecusionEngine engine;
+ Connector connector;
+ @Before
+ public void setup(){
+
+ connector = ConnectorFactory.getConnector("localhost","8999");
+
+
+ }
+ @Test
+ public void TestCommandSelector()
+ {
+ line = "list -o queue";
+ command = line.split(" ");
+ commandlineoptionparser = new CommandLineOptionParser(command);
+ info = new JMXinfo(connector.getConnector(), commandlineoptionparser,connector.getMBeanServerConnection());
+ engine = new CommandExecusionEngine(info);
+ Assert.assertEquals(engine.CommandSelector(),true);
+ }
+ @After
+ public void cleanup()
+ {
+ try {
+ connector.getConnector().close();
+ } catch (IOException e) {
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ }
+ }
+}
diff --git a/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/TestCommandLineInterpreter.java b/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/TestCommandLineInterpreter.java
new file mode 100644
index 0000000000..36a2d29dfd
--- /dev/null
+++ b/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/TestCommandLineInterpreter.java
@@ -0,0 +1,101 @@
+/*
+ *
+ * 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.
+ *
+ */
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * 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.
+ *
+ */
+package org.apache.qpid;
+
+import junit.framework.TestCase;
+import org.apache.qpid.utils.JMXinfo;
+import org.apache.qpid.utils.CommandLineOptionParser;
+import org.apache.qpid.commands.Commandinfo;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.Assert;
+import org.junit.After;
+
+import javax.management.remote.JMXConnector;
+import javax.management.MBeanServerConnection;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: lahiru
+ * Date: Jun 30, 2008
+ * Time: 12:08:52 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class TestCommandLineInterpreter {
+
+// CommandLineInterpreter test = new CommandLineInterpreter();
+ /* In this class there are only methodes which are displaying data on console so no test can be written*/
+ String command = "-h " + ConnectionConstants.BROKER_HOSTNAME + " -p " + ConnectionConstants.BROKER_PORT + " info -o queue -n ping -v test";
+ Connector conn= null;
+ JMXConnector jmxc=null;
+ MBeanServerConnection mbsc=null;
+ CommandLineOptionParser parser=null;
+
+
+ String [] args = null;
+ @Before
+ public void startup()
+ {
+ args = command.split(" ");
+// System.out.println(args[0]);
+ conn = ConnectorFactory.getConnector(ConnectionConstants.BROKER_HOSTNAME, ConnectionConstants.BROKER_PORT);
+ jmxc = conn.getConnector();
+ mbsc = conn.getMBeanServerConnection();
+ parser = new CommandLineOptionParser(args,args[0]);
+
+ }
+ @Test
+ public void TestSetQueryString()
+ {
+ CommandLineInterpreter.oneshotmode(args,parser,jmxc,mbsc);
+ Assert.assertEquals(args[0],"info");
+ Assert.assertEquals(args[1],"-o");
+ Assert.assertEquals(args[2],"queue");
+ Assert.assertEquals(args[3],"-n");
+ Assert.assertEquals(args[4],"ping");
+ Assert.assertEquals(args[5],"-v");
+ Assert.assertEquals(args[6],"test");
+ }
+
+ @After
+ public void cleanup()
+ {
+
+ }
+}
+
diff --git a/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/TestConnector.java b/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/TestConnector.java
new file mode 100644
index 0000000000..e6b80aae66
--- /dev/null
+++ b/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/TestConnector.java
@@ -0,0 +1,106 @@
+/*
+*
+* 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.
+*
+*/
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * 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.
+ *
+ */
+package org.apache.qpid;
+
+import junit.framework.TestCase;
+
+import javax.management.remote.JMXServiceURL;
+import javax.management.remote.JMXConnectorFactory;
+import javax.management.remote.JMXConnector;
+import javax.management.MBeanServerConnection;
+import java.net.MalformedURLException;
+import java.io.IOException;
+
+import org.junit.Test;
+import org.junit.Before;
+import org.junit.After;
+import org.junit.Assert;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: lahiru
+ * Date: Jun 30, 2008
+ * Time: 12:11:50 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class TestConnector {
+ Connector test;
+ JMXServiceURL svc_url;
+ JMXConnector connector;
+ MBeanServerConnection mbsc;
+
+ @Before
+ public void setup()
+ {
+ test = ConnectorFactory.getConnector("localhost","8999");
+ String url = "service:jmx:rmi:///jndi/rmi://localhost:8999/jmxrmi";
+
+ }
+ @Test
+ public void testGetURL()
+ {
+
+
+// Assert.assertNotNull(test);
+ Assert.assertEquals(test.getURL(),test.getURL());
+ }
+ @Test
+ public void testGetConnector()
+ {
+ Assert.assertEquals(test.getConnector(),test.getConnector());
+ }
+ @Test
+ public void testGetMBeanServerConnection()
+ {
+ Assert.assertEquals(test.getMBeanServerConnection(),test.getMBeanServerConnection());
+ }
+ @After
+ public void cleanup()
+ {
+ try {
+
+ test.getConnector().close();
+ test = null;
+ } catch (IOException e) {
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ }
+ test = null;
+ }
+
+
+}
diff --git a/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/TestReportGenerator.java b/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/TestReportGenerator.java
new file mode 100644
index 0000000000..a2ed94d948
--- /dev/null
+++ b/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/TestReportGenerator.java
@@ -0,0 +1,50 @@
+/*
+*
+* 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.
+*
+*/
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * 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.
+ *
+ */
+package org.apache.qpid;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: lahiru
+ * Date: Aug 13, 2008
+ * Time: 7:16:17 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class TestReportGenerator {
+
+
+}
diff --git a/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/commands/TestCommand.java b/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/commands/TestCommand.java
new file mode 100644
index 0000000000..2c92b8d66d
--- /dev/null
+++ b/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/commands/TestCommand.java
@@ -0,0 +1,99 @@
+/*
+ *
+ * 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.
+ *
+ */
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * 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.
+ *
+ */
+package org.apache.qpid.commands;
+
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import junit.framework.JUnit4TestAdapter;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.After;
+import org.junit.Assert;
+import org.apache.qpid.Connector;
+import org.apache.qpid.ConnectorFactory;
+import org.apache.qpid.ConnectionConstants;
+import org.apache.qpid.utils.JMXinfo;
+import org.apache.qpid.utils.CommandLineOptionParser;
+
+import javax.management.MBeanServerConnection;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: lahiru
+ * Date: Jun 30, 2008
+ * Time: 12:21:32 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class TestCommand{
+ String command = "list -o queue";
+ String [] list;
+ Connector test;
+ MBeanServerConnection mbsc;
+ JMXinfo info;
+ CommandLineOptionParser parser;
+ Command cmd;
+ @Before
+ public void setup()
+ {
+ list = command.split(" ");
+ parser = new CommandLineOptionParser(list);
+ test = ConnectorFactory.getConnector(ConnectionConstants.BROKER_HOSTNAME,ConnectionConstants.BROKER_PORT);
+ info = new JMXinfo(test.getConnector(),parser,test.getMBeanServerConnection());
+ cmd = new Command(info,"list");
+
+ }
+ @Test
+ public void TestOptionChecker()
+ {
+ Assert.assertEquals(cmd.optionchecker("o"),"queue");
+ }
+ @Test
+ public void TestCheckOptionSetting()
+ {
+ Assert.assertEquals(cmd.checkoptionsetting("o"),true);
+ Assert.assertEquals(cmd.checkoptionsetting("p"),false);
+ }
+ @After
+ public void cleanup()
+ {
+ parser = null;
+ test = null;
+ info = null;
+ cmd = null;
+ }
+}
diff --git a/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/commands/TestCommanddelete.java b/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/commands/TestCommanddelete.java
new file mode 100644
index 0000000000..5bdca118d5
--- /dev/null
+++ b/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/commands/TestCommanddelete.java
@@ -0,0 +1,99 @@
+/*
+ *
+ * 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.
+ *
+ */
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * 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.
+ *
+ */
+package org.apache.qpid.commands;
+
+import org.junit.After;
+import org.junit.Test;
+import org.junit.Before;
+import org.junit.Assert;
+import org.apache.qpid.ConnectorFactory;
+import org.apache.qpid.Connector;
+import org.apache.qpid.ConnectionConstants;
+import org.apache.qpid.utils.JMXinfo;
+import org.apache.qpid.utils.CommandLineOptionParser;
+
+import javax.management.remote.JMXConnector;
+import javax.management.MBeanServerConnection;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: lahiru
+ * Date: Aug 11, 2008
+ * Time: 10:13:45 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class TestCommanddelete {
+ JMXinfo info=null;
+ String command = "delete -o queue -n ping -v test -t 1";
+ Commanddelete delete = null;
+ Connector conn;
+ @Before
+ public void startup()
+ {
+ conn = ConnectorFactory.getConnector(ConnectionConstants.BROKER_HOSTNAME, ConnectionConstants.BROKER_PORT);
+ JMXConnector jmxc = conn.getConnector();
+ MBeanServerConnection mbsc = conn.getMBeanServerConnection();
+ CommandLineOptionParser parser = new CommandLineOptionParser(command.split(" "));
+ info = new JMXinfo(jmxc,parser,mbsc);
+ delete = new Commanddelete(info,"delete");
+
+
+
+ }
+ @Test
+ public void TestSetQueryString()
+ {
+ delete.execute();
+ Assert.assertEquals(delete.getobject(),"queue");
+ Assert.assertEquals(delete.getvhost(),"test");
+ Assert.assertEquals(delete.getname(),"ping");
+ Assert.assertEquals(delete.getnumber(),1);
+
+ }
+
+ @After
+ public void cleanup()
+ {
+ try{
+ conn.getConnector().close();
+ }catch(Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+}
diff --git a/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/commands/TestCommandinfo.java b/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/commands/TestCommandinfo.java
new file mode 100644
index 0000000000..f4bb403e18
--- /dev/null
+++ b/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/commands/TestCommandinfo.java
@@ -0,0 +1,95 @@
+/*
+ *
+ * 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.
+ *
+ */
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * 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.
+ *
+ */
+package org.apache.qpid.commands;
+
+import org.apache.qpid.utils.JMXinfo;
+import org.apache.qpid.utils.CommandLineOptionParser;
+import org.apache.qpid.Connector;
+import org.apache.qpid.ConnectorFactory;
+import org.apache.qpid.ConnectionConstants;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.Assert;
+import org.junit.After;
+
+import javax.management.remote.JMXConnector;
+import javax.management.MBeanServerConnection;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: lahiru
+ * Date: Aug 16, 2008
+ * Time: 6:30:24 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class TestCommandinfo {
+ JMXinfo info=null;
+ String command = "info -o queue -n ping -v test";
+ Commandinfo infocommand = null;
+ Connector conn = null;
+ @Before
+ public void startup()
+ {
+ conn = ConnectorFactory.getConnector(ConnectionConstants.BROKER_HOSTNAME, ConnectionConstants.BROKER_PORT);
+ JMXConnector jmxc = conn.getConnector();
+ MBeanServerConnection mbsc = conn.getMBeanServerConnection();
+ CommandLineOptionParser parser = new CommandLineOptionParser(command.split(" "));
+ info = new JMXinfo(jmxc,parser,mbsc);
+ infocommand = new Commandinfo(info,"list");
+
+ }
+ @Test
+ public void TestSetQueryString()
+ {
+ infocommand.execute();
+ Assert.assertEquals(infocommand.getobject(),"queue");
+ Assert.assertEquals(infocommand.getvirtualhost(),"test");
+ Assert.assertEquals(infocommand.getname(),"ping");
+ }
+
+ @After
+ public void cleanup()
+ {
+ try{
+ conn.getConnector().close();
+ }catch(Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+}
diff --git a/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/commands/TestCommandlist.java b/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/commands/TestCommandlist.java
new file mode 100644
index 0000000000..c8e044d6fe
--- /dev/null
+++ b/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/commands/TestCommandlist.java
@@ -0,0 +1,100 @@
+/*
+ *
+ * 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.
+ *
+ */
+ /*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * 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.
+ *
+ */
+package org.apache.qpid.commands;
+
+import junit.framework.TestCase;
+import org.apache.qpid.ConnectionConstants;
+import org.apache.qpid.Connector;
+import org.apache.qpid.ConnectorFactory;
+import org.apache.qpid.utils.CommandLineOptionParser;
+import org.apache.qpid.utils.JMXinfo;
+import org.junit.Test;
+import org.junit.Before;
+import org.junit.After;
+import org.junit.Assert;
+
+import javax.management.remote.JMXConnector;
+import javax.management.MBeanServerConnection;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: lahiru
+ * Date: Jun 30, 2008
+ * Time: 12:18:28 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class TestCommandlist {
+ /* All the methods in Commandlist doesn't have any arguments
+ and no return type.
+ */
+ JMXinfo info=null;
+ String command = "list -o queue -n ping -v test";
+ Commandlist list = null;
+ Connector conn = null;
+ @Before
+ public void startup()
+ {
+ conn = ConnectorFactory.getConnector(ConnectionConstants.BROKER_HOSTNAME, ConnectionConstants.BROKER_PORT);
+ JMXConnector jmxc = conn.getConnector();
+ MBeanServerConnection mbsc = conn.getMBeanServerConnection();
+ CommandLineOptionParser parser = new CommandLineOptionParser(command.split(" "));
+ info = new JMXinfo(jmxc,parser,mbsc);
+ list = new Commandlist(info,"list");
+
+ }
+ @Test
+ public void TestSetQueryString()
+ {
+ list.execute();
+ Assert.assertEquals(list.getobject(),"queue");
+ Assert.assertEquals(list.getvhost(),"test");
+ Assert.assertEquals(list.getname(),"ping");
+ }
+
+ @After
+ public void cleanup()
+ {
+ try{
+ conn.getConnector().close();
+ }catch(Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+
+}
diff --git a/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/commands/TestCommandmove.java b/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/commands/TestCommandmove.java
new file mode 100644
index 0000000000..278fa72365
--- /dev/null
+++ b/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/commands/TestCommandmove.java
@@ -0,0 +1,100 @@
+/*
+ *
+ * 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.
+ *
+ */
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * 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.
+ *
+ */
+package org.apache.qpid.commands;
+
+import org.apache.qpid.ConnectionConstants;
+import org.apache.qpid.Connector;
+import org.apache.qpid.ConnectorFactory;
+import org.apache.qpid.utils.CommandLineOptionParser;
+import org.apache.qpid.utils.JMXinfo;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.After;
+import org.junit.Assert;
+
+import javax.management.remote.JMXConnector;
+import javax.management.MBeanServerConnection;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: lahiru
+ * Date: Aug 11, 2008
+ * Time: 10:14:34 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class TestCommandmove {
+ JMXinfo info=null;
+ String command = "move -o queue -n1 ping -v1 test -n2 message_queue -fmid 10 -tmid 12";
+ Commandmove move = null;
+ Connector conn=null;
+ @Before
+ public void startup()
+ {
+ conn = ConnectorFactory.getConnector(ConnectionConstants.BROKER_HOSTNAME, ConnectionConstants.BROKER_PORT);
+ JMXConnector jmxc = conn.getConnector();
+ MBeanServerConnection mbsc = conn.getMBeanServerConnection();
+ CommandLineOptionParser parser = new CommandLineOptionParser(command.split(" "));
+ info = new JMXinfo(jmxc,parser,mbsc);
+ move = new Commandmove(info,"move");
+
+
+
+ }
+ @Test
+ public void TestSetQueryString()
+ {
+ move.execute();
+ Assert.assertEquals(move.getobject(),"queue");
+ Assert.assertEquals(move.getvhost(),"test");
+ Assert.assertEquals(move.getname1(),"ping");
+ Assert.assertEquals(move.getname2(),"message_queue");
+ Assert.assertEquals(move.getfmid(),10);
+ Assert.assertEquals(move.gettmid(),12);
+ }
+
+ @After
+ public void cleanup()
+ {
+ try{
+ conn.getConnector().close();
+ }catch(Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+}
diff --git a/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/commands/TestCommandview.java b/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/commands/TestCommandview.java
new file mode 100644
index 0000000000..385d197475
--- /dev/null
+++ b/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/commands/TestCommandview.java
@@ -0,0 +1,96 @@
+/*
+ *
+ * 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.
+ *
+ */
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * 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.
+ *
+ */
+package org.apache.qpid.commands;
+
+import org.apache.qpid.ConnectionConstants;
+import org.apache.qpid.ConnectorFactory;
+import org.apache.qpid.Connector;
+import org.apache.qpid.utils.CommandLineOptionParser;
+import org.apache.qpid.utils.JMXinfo;
+import org.junit.Test;
+import org.junit.Before;
+import org.junit.After;
+import org.junit.Assert;
+
+import javax.management.MBeanServerConnection;
+import javax.management.remote.JMXConnector;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: lahiru
+ * Date: Aug 11, 2008
+ * Time: 10:14:58 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class TestCommandview {
+ JMXinfo info=null;
+ String command = "view -o queue -n ping -v test -t 10";
+ Commandview view =null;
+ Connector conn=null;
+ @Before
+ public void startup()
+ {
+ conn = ConnectorFactory.getConnector(ConnectionConstants.BROKER_HOSTNAME, ConnectionConstants.BROKER_PORT);
+ JMXConnector jmxc = conn.getConnector();
+ MBeanServerConnection mbsc = conn.getMBeanServerConnection();
+ CommandLineOptionParser parser = new CommandLineOptionParser(command.split(" "));
+ info = new JMXinfo(jmxc,parser,mbsc);
+ view = new Commandview(info,"view");
+ }
+ @Test
+ public void TestSetQueryString()
+ {
+ view.execute();
+ Assert.assertEquals(view.getobject(),"queue");
+ Assert.assertEquals(view.getvhost(),"test");
+ Assert.assertEquals(view.getname(),"ping");
+ Assert.assertEquals(view.getnumber(),10);
+
+ }
+
+ @After
+ public void cleanup()
+ {
+ try{
+ conn.getConnector().close();
+ }catch(Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+}
diff --git a/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/commands/TestCommandviewcontent.java b/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/commands/TestCommandviewcontent.java
new file mode 100644
index 0000000000..2b8f0e3ffd
--- /dev/null
+++ b/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/commands/TestCommandviewcontent.java
@@ -0,0 +1,99 @@
+/*
+ *
+ * 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.
+ *
+ */
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * 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.
+ *
+ */
+package org.apache.qpid.commands;
+
+import org.apache.qpid.utils.JMXinfo;
+import org.apache.qpid.utils.CommandLineOptionParser;
+import org.apache.qpid.Connector;
+import org.apache.qpid.ConnectorFactory;
+import org.apache.qpid.ConnectionConstants;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.After;
+import org.junit.Assert;
+
+import javax.management.remote.JMXConnector;
+import javax.management.MBeanServerConnection;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: lahiru
+ * Date: Aug 11, 2008
+ * Time: 10:15:17 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class TestCommandviewcontent {
+ JMXinfo info=null;
+ String command = "viewcontent -o queue -n ping -v test -id 10";
+ Commandviewcontent viewcontent =null;
+ Connector conn = null;
+ @Before
+ public void startup()
+ {
+ conn = ConnectorFactory.getConnector(ConnectionConstants.BROKER_HOSTNAME, ConnectionConstants.BROKER_PORT);
+ JMXConnector jmxc = conn.getConnector();
+ MBeanServerConnection mbsc = conn.getMBeanServerConnection();
+ CommandLineOptionParser parser = new CommandLineOptionParser(command.split(" "));
+ info = new JMXinfo(jmxc,parser,mbsc);
+ viewcontent = new Commandviewcontent(info,"viewcontent");
+
+
+
+ }
+ @Test
+ public void TestSetQueryString()
+ {
+ viewcontent.execute();
+ Assert.assertEquals(viewcontent.getobject(),"queue");
+ Assert.assertEquals(viewcontent.getnumber(),10);
+ Assert.assertEquals(viewcontent.getname(),"ping");
+ Assert.assertEquals(viewcontent.getvhost(),"test");
+
+ }
+
+ @After
+ public void cleanup()
+ {
+ try{
+ conn.getConnector().close();
+ }catch(Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+}
diff --git a/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/commands/objects/TestAllObject.java b/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/commands/objects/TestAllObject.java
new file mode 100644
index 0000000000..25069e6dbb
--- /dev/null
+++ b/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/commands/objects/TestAllObject.java
@@ -0,0 +1,93 @@
+/*
+ *
+ * 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.
+ *
+ */
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * 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.
+ *
+ */
+package org.apache.qpid.commands.objects;
+
+import junit.framework.TestCase;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.After;
+import org.junit.Assert;
+import org.apache.qpid.ConnectorFactory;
+import org.apache.qpid.Connector;
+
+import javax.management.MBeanServerConnection;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: lahiru
+ * Date: Jun 30, 2008
+ * Time: 12:23:25 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class TestAllObject {
+ Connector conn;
+ MBeanServerConnection mbsc;
+ AllObjects test;
+ String test1,test2;
+
+ @Before
+ public void startup()
+ {
+ conn = ConnectorFactory.getConnector("localhost", "8999");
+ mbsc = conn.getMBeanServerConnection();
+ test = new AllObjects(mbsc);
+ test1 = "empty input1";
+ test2 = "empty input2";
+
+
+ }
+ @Test
+ public void TestSetQueryString()
+ {
+ test.setQueryString(test1,test2);
+ Assert.assertEquals(test.querystring,"org.apache.qpid:*");
+
+ }
+
+ @After
+ public void cleanup()
+ {
+ try{
+ conn.getConnector().close();
+ }catch(Exception ex)
+ {
+ ex.printStackTrace();
+ }
+
+ }
+}
diff --git a/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/commands/objects/TestConnectionObject.java b/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/commands/objects/TestConnectionObject.java
new file mode 100644
index 0000000000..8f98d1ac37
--- /dev/null
+++ b/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/commands/objects/TestConnectionObject.java
@@ -0,0 +1,105 @@
+/*
+ *
+ * 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.
+ *
+ */
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * 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.
+ *
+ */
+package org.apache.qpid.commands.objects;
+
+import junit.framework.TestCase;
+import org.apache.qpid.ConnectorFactory;
+import org.apache.qpid.Connector;
+import org.junit.After;
+import org.junit.Test;
+import org.junit.Assert;
+import org.junit.Before;
+
+import javax.management.MBeanServerConnection;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: lahiru
+ * Date: Jun 30, 2008
+ * Time: 12:24:14 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class TestConnectionObject {
+ Connector conn;
+ MBeanServerConnection mbsc;
+ ConnectionObject test;
+ String test1,test2,test3;
+
+ @Before
+ public void startup()
+ {
+ conn = ConnectorFactory.getConnector("localhost", "8999");
+ mbsc = conn.getMBeanServerConnection();
+ test = new ConnectionObject(mbsc);
+ test1 = "ping";
+ test2 = "test";
+ test3 = "object";
+
+
+ }
+ @Test
+ public void TestSetQueryString()
+ {
+ test.setQueryString(test3,test1,null);
+ Assert.assertEquals(test.querystring,"org.apache.qpid:type=Connection,name=ping,*");
+ test.querystring = null;
+ test.setQueryString(test3,null,test2);
+ Assert.assertEquals(test.querystring,"org.apache.qpid:type=Connection,VirtualHost=test,*");
+ test.querystring = null;
+ test.setQueryString(test3,test1,test2);
+ Assert.assertEquals(test.querystring,"org.apache.qpid:type=Connection,VirtualHost=test,name=ping,*");
+ test.querystring = null;
+ test.setQueryString(test3,null,null);
+ Assert.assertEquals(test.querystring,"org.apache.qpid:type=Connection,*");
+
+
+
+ }
+
+ @After
+ public void cleanup()
+ {
+ try{
+ conn.getConnector().close();
+ }catch(Exception ex)
+ {
+ ex.printStackTrace();
+ }
+
+ }
+}
diff --git a/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/commands/objects/TestExchangeObject.java b/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/commands/objects/TestExchangeObject.java
new file mode 100644
index 0000000000..64f2bef79a
--- /dev/null
+++ b/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/commands/objects/TestExchangeObject.java
@@ -0,0 +1,103 @@
+/*
+ *
+ * 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.
+ *
+ */
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * 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.
+ *
+ */
+package org.apache.qpid.commands.objects;
+
+import junit.framework.TestCase;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.After;
+import org.junit.Before;
+import org.apache.qpid.Connector;
+import org.apache.qpid.ConnectorFactory;
+
+import javax.management.MBeanServerConnection;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: lahiru
+ * Date: Jun 30, 2008
+ * Time: 12:24:49 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class TestExchangeObject {
+ Connector conn;
+ MBeanServerConnection mbsc;
+ ExchangeObject test;
+ String test1,test2,test3;
+
+ @Before
+ public void startup()
+ {
+ conn = ConnectorFactory.getConnector("localhost", "8999");
+ mbsc = conn.getMBeanServerConnection();
+ test = new ExchangeObject(mbsc);
+ test1 = "ping";
+ test2 = "test";
+ test3 = "object";
+
+
+ }
+ @Test
+ public void TestSetQueryString()
+ {
+ test.setQueryString(test3,test1,null);
+// System.out.println(test.querystring);
+// System.out.println("org.apache.qpid:type=VitualHost.Exchange,name=ping,*");
+ Assert.assertEquals(test.querystring,"org.apache.qpid:type=VirtualHost.Exchange,name=ping,*");
+ test.querystring = null;
+ test.setQueryString(test3,null,test2);
+ Assert.assertEquals(test.querystring,"org.apache.qpid:type=VirtualHost.Exchange,VirtualHost=test,*");
+ test.querystring = null;
+ test.setQueryString(test3,test1,test2);
+ Assert.assertEquals(test.querystring,"org.apache.qpid:type=VirtualHost.Exchange,VirtualHost=test,name=ping,*");
+ test.querystring = null;
+ test.setQueryString(test3,null,null);
+ }
+
+ @After
+ public void cleanup()
+ {
+ try{
+ conn.getConnector().close();
+ }catch(Exception ex)
+ {
+ ex.printStackTrace();
+ }
+
+ }
+}
diff --git a/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/commands/objects/TestObjectNames.java b/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/commands/objects/TestObjectNames.java
new file mode 100644
index 0000000000..b26d1f5a82
--- /dev/null
+++ b/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/commands/objects/TestObjectNames.java
@@ -0,0 +1,51 @@
+/*
+ *
+ * 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.
+ *
+ */
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * 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.
+ *
+ */
+package org.apache.qpid.commands.objects;
+
+import junit.framework.TestCase;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: lahiru
+ * Date: Jun 30, 2008
+ * Time: 12:22:54 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class TestObjectNames {
+
+}
diff --git a/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/commands/objects/TestQueueObject.java b/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/commands/objects/TestQueueObject.java
new file mode 100644
index 0000000000..96b153f65d
--- /dev/null
+++ b/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/commands/objects/TestQueueObject.java
@@ -0,0 +1,106 @@
+/*
+ *
+ * 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.
+ *
+ */
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * 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.
+ *
+ */
+package org.apache.qpid.commands.objects;
+
+import junit.framework.TestCase;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.After;
+import org.junit.Before;
+import org.apache.qpid.Connector;
+import org.apache.qpid.ConnectorFactory;
+
+import javax.management.MBeanServerConnection;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: lahiru
+ * Date: Jun 30, 2008
+ * Time: 12:25:21 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class TestQueueObject{
+ Connector conn;
+ MBeanServerConnection mbsc;
+ QueueObject test;
+ String test1,test2,test3;
+
+ @Before
+ public void startup()
+ {
+ conn = ConnectorFactory.getConnector("localhost", "8999");
+ mbsc = conn.getMBeanServerConnection();
+ test = new QueueObject(mbsc);
+ test1 = "ping";
+ test2 = "test";
+ test3 = "object";
+
+
+ }
+ @Test
+ public void TestSetQueryString()
+ {
+ test.setQueryString(test3,test1,null);
+ Assert.assertEquals(test.querystring,"org.apache.qpid:type=VirtualHost.Queue,name=ping,*");
+ test.querystring = null;
+ test.setQueryString(test3,null,test2);
+ Assert.assertEquals(test.querystring,"org.apache.qpid:type=VirtualHost.Queue,VirtualHost=test,*");
+ test.querystring = null;
+ test.setQueryString(test3,test1,test2);
+ Assert.assertEquals(test.querystring,"org.apache.qpid:type=VirtualHost.Queue,VirtualHost=test,name=ping,*");
+ test.querystring = null;
+ test.setQueryString(test3,null,null);
+ Assert.assertEquals(test.querystring,"org.apache.qpid:type=VirtualHost.Queue,*");
+
+
+
+ }
+
+ @After
+ public void cleanup()
+ {
+ try{
+ conn.getConnector().close();
+ }catch(Exception ex)
+ {
+ ex.printStackTrace();
+ }
+
+ }
+}
+
diff --git a/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/commands/objects/TestUserManagementObject.java b/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/commands/objects/TestUserManagementObject.java
new file mode 100644
index 0000000000..a9123eb604
--- /dev/null
+++ b/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/commands/objects/TestUserManagementObject.java
@@ -0,0 +1,102 @@
+/*
+ *
+ * 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.
+ *
+ */
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * 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.
+ *
+ */
+package org.apache.qpid.commands.objects;
+
+import junit.framework.TestCase;
+import org.junit.Assert;
+import org.junit.After;
+import org.junit.Test;
+import org.junit.Before;
+import org.apache.qpid.Connector;
+import org.apache.qpid.ConnectorFactory;
+
+import javax.management.MBeanServerConnection;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: lahiru
+ * Date: Jun 30, 2008
+ * Time: 12:26:09 PM
+ * To change this template use File | Settings | File Templates.
+ */
+
+
+
+public class TestUserManagementObject{
+ Connector conn;
+ MBeanServerConnection mbsc;
+ UserManagementObject test;
+ String test1,test2,test3;
+
+ @Before
+ public void startup()
+ {
+ conn = ConnectorFactory.getConnector("localhost", "8999");
+ mbsc = conn.getMBeanServerConnection();
+ test = new UserManagementObject(mbsc);
+ test1 = "ping";
+ test2 = "test";
+ test3 = "object";
+
+
+ }
+ @Test
+ public void TestSetQueryString()
+ {
+ test.setQueryString(test3,test1,test2);
+ Assert.assertEquals(test.querystring,"org.apache.qpid:type=UserManagement,*");
+
+
+
+
+ }
+
+ @After
+ public void cleanup()
+ {
+ try{
+ conn.getConnector().close();
+ }catch(Exception ex)
+ {
+ ex.printStackTrace();
+ }
+
+ }
+}
+
+
diff --git a/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/commands/objects/TestVirtualHostObject.java b/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/commands/objects/TestVirtualHostObject.java
new file mode 100644
index 0000000000..29a233733d
--- /dev/null
+++ b/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/commands/objects/TestVirtualHostObject.java
@@ -0,0 +1,88 @@
+/*
+*
+* 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.
+*
+*/
+package org.apache.qpid.commands.objects;
+
+import junit.framework.TestCase;
+import org.junit.Assert;
+import org.junit.After;
+import org.junit.Test;
+import org.junit.Before;
+import org.apache.qpid.Connector;
+import org.apache.qpid.ConnectorFactory;
+
+import javax.management.MBeanServerConnection;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: lahiru
+ * Date: Jun 30, 2008
+ * Time: 12:26:40 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class TestVirtualHostObject{
+ Connector conn;
+ MBeanServerConnection mbsc;
+ VirtualHostObject test;
+ String test1,test2,test3;
+
+ @Before
+ public void startup()
+ {
+ conn = ConnectorFactory.getConnector("localhost", "8999");
+ mbsc = conn.getMBeanServerConnection();
+ test = new VirtualHostObject(mbsc);
+ test1 = "ping";
+ test2 = "test";
+ test3 = "object";
+
+
+ }
+ @Test
+ public void TestSetQueryString()
+ {
+ test.setQueryString(test3,test1,null);
+ Assert.assertEquals(test.querystring,"org.apache.qpid:type=VirtualHost.VirtualHostManager,name=ping,*");
+ test.querystring = null;
+ test.setQueryString(test3,null,test2);
+ Assert.assertEquals(test.querystring,"org.apache.qpid:type=VirtualHost.VirtualHostManager,VirtualHost=test,*");
+ test.querystring = null;
+ test.setQueryString(test3,test1,test2);
+ Assert.assertEquals(test.querystring,"org.apache.qpid:type=VirtualHost.VirtualHostManager,VirtualHost=test,name=ping,*");
+ test.querystring = null;
+ test.setQueryString(test3,null,null);
+ Assert.assertEquals(test.querystring,"org.apache.qpid:type=VirtualHost.VirtualHostManager,*");
+
+
+
+ }
+
+ @After
+ public void cleanup()
+ {
+ try{
+ conn.getConnector().close();
+ }catch(Exception ex)
+ {
+ ex.printStackTrace();
+ }
+
+ }
+}
diff --git a/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/utils/TestCommandLineOption.java b/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/utils/TestCommandLineOption.java
new file mode 100644
index 0000000000..58d71a4de6
--- /dev/null
+++ b/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/utils/TestCommandLineOption.java
@@ -0,0 +1,85 @@
+/*
+ *
+ * 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.
+ *
+ */
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * 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.
+ *
+ */
+package org.apache.qpid.utils;
+
+import junit.framework.TestCase;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.Assert;
+import org.junit.After;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: lahiru
+ * Date: Jun 30, 2008
+ * Time: 12:17:26 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class TestCommandLineOption {
+ String input1;
+ String input2;
+ String options;
+ String [] list;
+ CommandLineOption option;
+
+ @Before
+ public void setup()
+ {
+ input1 = "-h";
+ input2 = "--help";
+ options = "localhost testing";
+ list = options.split(" ");
+ option = new CommandLineOption(input1,list);
+
+ }
+ @Test
+ public void TestGetOptinValue()
+ {
+ Assert.assertEquals(option.getOptionValue(),"localhost");
+ }
+ @Test
+ public void TestGetOptionType()
+ {
+ Assert.assertEquals(option.getOptionType(),"h");
+ }
+ @After
+ public void cleanup()
+ {
+ option = null;
+ }
+}
diff --git a/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/utils/TestCommandLineOptionParser.java b/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/utils/TestCommandLineOptionParser.java
new file mode 100644
index 0000000000..989fc61418
--- /dev/null
+++ b/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/utils/TestCommandLineOptionParser.java
@@ -0,0 +1,100 @@
+/*
+ *
+ * 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.
+ *
+ */
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * 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.
+ *
+ */
+package org.apache.qpid.utils;
+
+import junit.framework.TestCase;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.After;
+import org.junit.Assert;
+
+import java.util.Map;
+import java.util.HashMap;
+import java.util.ArrayList;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: lahiru
+ * Date: Jun 30, 2008
+ * Time: 12:16:30 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class TestCommandLineOptionParser {
+ CommandLineOptionParser parser;
+ String [] input;
+ CommandLineOption option1;
+ CommandLineOption option2;
+ ArrayList list1;
+ ArrayList list2;
+ @Before
+ public void setup()
+ {
+ String temp = "run -h localhost -p 23232";
+ input = temp.split(" ");
+ parser = new CommandLineOptionParser(input);
+ list1 = new ArrayList();
+ list2 = new ArrayList();
+ }
+ @Test
+ public void TestParse()
+ {
+ Map hash = new HashMap();
+
+ list1.add("localhost");
+ list2.add("23232");
+ option1 = new CommandLineOption("h",list1);
+ option2 = new CommandLineOption("p",list2);
+ hash.put("h",option1);
+ hash.put("p",option2);
+ option1 = (CommandLineOption)parser.parse(input).get("h");
+ Assert.assertEquals(option1.getOptionType(),"h");
+ Assert.assertEquals(option1.getOptionValue(),"localhost");
+ option1 = (CommandLineOption)parser.parse(input).get("p");
+ Assert.assertEquals(option1.getOptionType(),"p");
+ Assert.assertEquals(option1.getOptionValue(),"23232");
+ Assert.assertEquals(parser.parse(input).size(),hash.size());
+ }
+ @After
+ public void cleanup()
+ {
+ parser = null;
+ option1 = null;
+ option2 = null;
+
+ }
+}
diff --git a/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/utils/TestJMXConfigProperty.java b/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/utils/TestJMXConfigProperty.java
new file mode 100644
index 0000000000..a5d3122406
--- /dev/null
+++ b/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/utils/TestJMXConfigProperty.java
@@ -0,0 +1,51 @@
+/*
+ *
+ * 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.
+ *
+ */
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * 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.
+ *
+ */
+package org.apache.qpid.utils;
+
+import junit.framework.TestCase;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: lahiru
+ * Date: Jun 30, 2008
+ * Time: 12:15:35 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class TestJMXConfigProperty {
+
+}
diff --git a/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/utils/TestJMXConfiguration.java b/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/utils/TestJMXConfiguration.java
new file mode 100644
index 0000000000..02dd7219db
--- /dev/null
+++ b/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/utils/TestJMXConfiguration.java
@@ -0,0 +1,85 @@
+/*
+ *
+ * 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.
+ *
+ */
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * 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.
+ *
+ */
+package org.apache.qpid.utils;
+
+import junit.framework.TestCase;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.After;
+import org.junit.Assert;
+
+import java.util.ArrayList;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: lahiru
+ * Date: Jun 30, 2008
+ * Time: 12:14:32 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class TestJMXConfiguration {
+ CommandLineOptionParser clop;
+ JMXConfiguration jmc;
+ CommandLineOption option;
+ String [] input;
+ @Before
+ public void setup()
+ {
+ String temp = "command -h 127.0.0.1 -p 1234";
+ input = temp.split(" ");
+ clop = new CommandLineOptionParser(input);
+ jmc = new JMXConfiguration(clop.getAlloptions());
+ }
+ @Test
+ public void TestLoadOption()
+ {
+ ArrayList list = new ArrayList();
+ list.add("127.0.0.1");
+ option = new CommandLineOption("-h",list);
+ CommandLineOption expect = jmc.loadoption("h",clop.getAlloptions());
+ Assert.assertEquals(expect.getOptionType(),option.getOptionType());
+ Assert.assertEquals(expect.getOptionValue(),option.getOptionValue());
+ }
+ @After
+ public void cleanup()
+ {
+ clop = null;
+ jmc = null;
+ option = null;
+ }
+}
diff --git a/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/utils/TestJMXinfo.java b/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/utils/TestJMXinfo.java
new file mode 100644
index 0000000000..449609c639
--- /dev/null
+++ b/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/utils/TestJMXinfo.java
@@ -0,0 +1,53 @@
+/*
+ *
+ * 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.
+ *
+ */
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * 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.
+ *
+ */
+package org.apache.qpid.utils;
+
+import junit.framework.TestCase;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: lahiru
+ * Date: Jun 30, 2008
+ * Time: 12:12:43 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class TestJMXinfo {
+ /* this class is having only three simple getter methods. Therefore no
+ testcases
+ */
+}