Return-Path: Delivered-To: apmail-qpid-commits-archive@www.apache.org Received: (qmail 40282 invoked from network); 7 Jan 2009 11:40:44 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 7 Jan 2009 11:40:44 -0000 Received: (qmail 45888 invoked by uid 500); 7 Jan 2009 11:40:44 -0000 Delivered-To: apmail-qpid-commits-archive@qpid.apache.org Received: (qmail 45874 invoked by uid 500); 7 Jan 2009 11:40:44 -0000 Mailing-List: contact commits-help@qpid.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@qpid.apache.org Delivered-To: mailing list commits@qpid.apache.org Received: (qmail 45865 invoked by uid 99); 7 Jan 2009 11:40:44 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Jan 2009 03:40:44 -0800 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Jan 2009 11:40:30 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 5A460238895D; Wed, 7 Jan 2009 03:40:09 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r732308 - in /qpid/trunk/qpid/java/management/tools/qpid-cli: src/org/apache/qpid/ test/org/apache/qpid/ Date: Wed, 07 Jan 2009 11:40:08 -0000 To: commits@qpid.apache.org From: aidan@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090107114009.5A460238895D@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: aidan Date: Wed Jan 7 03:40:08 2009 New Revision: 732308 URL: http://svn.apache.org/viewvc?rev=732308&view=rev Log: QPID-1522: Fix spelling error in classname Added: qpid/trunk/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/CommandExecutionEngine.java qpid/trunk/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/TestCommandExecutionEngine.java Removed: qpid/trunk/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/CommandExecusionEngine.java qpid/trunk/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/TestCommandExecusionEngine.java Modified: qpid/trunk/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/CommandLineInterpreter.java qpid/trunk/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/AllTest.java Added: qpid/trunk/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/CommandExecutionEngine.java URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/CommandExecutionEngine.java?rev=732308&view=auto ============================================================================== --- qpid/trunk/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/CommandExecutionEngine.java (added) +++ qpid/trunk/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/CommandExecutionEngine.java Wed Jan 7 03:40:08 2009 @@ -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. + * + */ +/* + * + * 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.JMXinfo; +import org.apache.qpid.commands.*; + + +public class CommandExecutionEngine { + private Command currentcommand = null; + private String commandname = null; + private JMXinfo info = null; + + public CommandExecutionEngine(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"); + } +} Modified: qpid/trunk/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/CommandLineInterpreter.java URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/CommandLineInterpreter.java?rev=732308&r1=732307&r2=732308&view=diff ============================================================================== --- qpid/trunk/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/CommandLineInterpreter.java (original) +++ qpid/trunk/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/CommandLineInterpreter.java Wed Jan 7 03:40:08 2009 @@ -87,8 +87,6 @@ } /* Connecting with the broker */ -// commandlineoptionparser = new CommandLineOptionParser(args); -// JMXConfiguration config = new JMXConfiguration(commandlineoptionparser.getAlloptions()); try { if (commandlineoptionparser == null) commandlineoptionparser = new CommandLineOptionParser(args); @@ -122,7 +120,6 @@ 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"}))); @@ -136,7 +133,7 @@ command = line.split("\\s+"); commandlineoptionparser = new CommandLineOptionParser(command); JMXinfo info = new JMXinfo(jmxc, commandlineoptionparser, mbsc); - CommandExecusionEngine engine = new CommandExecusionEngine(info); + CommandExecutionEngine engine = new CommandExecutionEngine(info); if (engine.CommandSelector()) engine.runcommand(); } @@ -164,9 +161,6 @@ 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; @@ -184,7 +178,7 @@ 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); + CommandExecutionEngine engine = new CommandExecutionEngine(info); if (engine.CommandSelector()) engine.runcommand(); return args; Modified: qpid/trunk/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/AllTest.java URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/AllTest.java?rev=732308&r1=732307&r2=732308&view=diff ============================================================================== --- qpid/trunk/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/AllTest.java (original) +++ qpid/trunk/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/AllTest.java Wed Jan 7 03:40:08 2009 @@ -55,7 +55,7 @@ @RunWith(Suite.class) @Suite.SuiteClasses({ TestCommand.class, - TestCommandExecusionEngine.class, + TestCommandExecutionEngine.class, TestCommandLineOption.class, TestCommandLineOptionParser.class, TestConnector.class, Added: qpid/trunk/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/TestCommandExecutionEngine.java URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/TestCommandExecutionEngine.java?rev=732308&view=auto ============================================================================== --- qpid/trunk/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/TestCommandExecutionEngine.java (added) +++ qpid/trunk/qpid/java/management/tools/qpid-cli/test/org/apache/qpid/TestCommandExecutionEngine.java Wed Jan 7 03:40:08 2009 @@ -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 TestCommandExecutionEngine { + String line; + String [] command; + CommandLineOptionParser commandlineoptionparser; + JMXinfo info; + CommandExecutionEngine 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 CommandExecutionEngine(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. + } + } +}