You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by gd...@apache.org on 2007/05/05 13:22:52 UTC
svn commit: r535507 [2/4] - in /geronimo/server/trunk:
assemblies/geronimo-boilerplate-minimal/ configs/client-system/
configs/j2ee-system/ configs/jsr88-cli/ configs/online-deployer/
modules/geronimo-cli/ modules/geronimo-cli/src/ modules/geronimo-cli...
Added: geronimo/server/trunk/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/DeployCommandMetaData.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/DeployCommandMetaData.java?view=auto&rev=535507
==============================================================================
--- geronimo/server/trunk/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/DeployCommandMetaData.java (added)
+++ geronimo/server/trunk/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/DeployCommandMetaData.java Sat May 5 04:22:39 2007
@@ -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.geronimo.cli.deployer;
+
+import org.apache.geronimo.cli.CLParserException;
+
+
+/**
+ * @version $Rev: 515007 $ $Date: 2007-03-06 18:26:41 +1100 (Tue, 06 Mar 2007) $
+ */
+public class DeployCommandMetaData extends BaseCommandMetaData {
+ public static final CommandMetaData META_DATA = new DeployCommandMetaData();
+
+ private DeployCommandMetaData() {
+ super("deploy", "1. Common Commands", "[--inPlace] [--targets target;target;...] [module] [plan]",
+ "Normally both a module and plan are passed to the deployer. " +
+ "Sometimes the module contains a plan, or requires no plan, in which case " +
+ "the plan may be omitted. Sometimes the plan references a module already " +
+ "deployed in the Geronimo server environment, in which case a module does " +
+ "not need to be provided.\n" +
+ "If no targets are provided, the module is deployed to all available " +
+ "targets. Geronimo only provides one target (ever), so this is primarily " +
+ "useful when using a different driver.");
+ }
+
+ public CommandArgs parse(String[] args) throws CLParserException {
+ return new DistributeCommandArgs(args);
+ }
+
+}
Added: geronimo/server/trunk/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/DeployerCLI.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/DeployerCLI.java?view=auto&rev=535507
==============================================================================
--- geronimo/server/trunk/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/DeployerCLI.java (added)
+++ geronimo/server/trunk/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/DeployerCLI.java Sat May 5 04:22:39 2007
@@ -0,0 +1,60 @@
+/**
+ * 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.geronimo.cli.deployer;
+
+import org.apache.geronimo.cli.AbstractCLI;
+import org.apache.geronimo.cli.CLParser;
+import org.apache.geronimo.kernel.util.MainBootstrapper;
+import org.apache.geronimo.kernel.util.MainConfigurationBootstrapper;
+
+
+/**
+ * @version $Rev: 476049 $ $Date: 2006-11-17 15:35:17 +1100 (Fri, 17 Nov 2006) $
+ */
+public class DeployerCLI extends AbstractCLI {
+
+ public static void main(String[] args) {
+ int status = new DeployerCLI(args).executeMain();
+ System.exit(status);
+ }
+
+ protected DeployerCLI(String[] args) {
+ super(args, System.err);
+ }
+
+ @Override
+ protected boolean executeCommand(CLParser parser) {
+ DeployerCLParser deployerCLParser = (DeployerCLParser) parser;
+ CommandMetaData commandMetaData = deployerCLParser.getCommandMetaData();
+ if (commandMetaData == HelpCommandMetaData.META_DATA) {
+ parser.displayHelp();
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ protected CLParser getCLParser() {
+ return new DeployerCLParser(System.out);
+ }
+
+ @Override
+ protected MainConfigurationBootstrapper newMainConfigurationBootstrapper() {
+ return new MainBootstrapper();
+ }
+
+}
Added: geronimo/server/trunk/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/DeployerCLParser.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/DeployerCLParser.java?view=auto&rev=535507
==============================================================================
--- geronimo/server/trunk/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/DeployerCLParser.java (added)
+++ geronimo/server/trunk/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/DeployerCLParser.java Sat May 5 04:22:39 2007
@@ -0,0 +1,358 @@
+/**
+ * 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.geronimo.cli.deployer;
+
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.OptionBuilder;
+import org.apache.geronimo.cli.BaseCLParser;
+import org.apache.geronimo.cli.CLParserException;
+import org.apache.geronimo.cli.PrintHelper;
+
+
+/**
+ * @version $Rev: 476049 $ $Date: 2006-11-17 15:35:17 +1100 (Fri, 17 Nov 2006) $
+ */
+public class DeployerCLParser extends BaseCLParser {
+ private final static String ARGUMENT_URI_SHORTFORM = "u";
+ private final static String ARGUMENT_URI = "uri";
+
+ private final static String ARGUMENT_HOST_SHORTFORM = "host";
+
+ private final static String ARGUMENT_PORT_SHORTFORM = "port";
+ private final static String ARGUMENT_PORT = "port";
+
+ private final static String ARGUMENT_DRIVER_SHORTFORM = "d";
+ private final static String ARGUMENT_DRIVER = "driver";
+
+ private final static String ARGUMENT_USER_SHORTFORM = "u";
+ private final static String ARGUMENT_USER = "user";
+
+ private final static String ARGUMENT_PASSWORD_SHORTFORM = "p";
+ private final static String ARGUMENT_PASSWORD = "password";
+
+ private final static String ARGUMENT_SYSERR_SHORTFORM = "s";
+ private final static String ARGUMENT_SYSERR = "syserr";
+
+ private final static String ARGUMENT_VERBOSE_SHORTFORM = "v";
+ private final static String ARGUMENT_VERBOSE = "verbose";
+
+ private final static String ARGUMENT_OFFLINE_SHORTFORM = "o";
+ private final static String ARGUMENT_OFFLINE = "offline";
+
+ private final Collection<CommandMetaData> commandMetaData;
+
+ private CommandArgs commandArgs;
+ private CommandMetaData metaData;
+
+ public DeployerCLParser(OutputStream out) {
+ super(out);
+
+ commandMetaData = new ArrayList<CommandMetaData>();
+ commandMetaData.add(LoginCommandMetaData.META_DATA);
+ commandMetaData.add(DeployCommandMetaData.META_DATA);
+ commandMetaData.add(DistributeCommandMetaData.META_DATA);
+ commandMetaData.add(ListModulesCommandMetaData.META_DATA);
+ commandMetaData.add(ListTargetsCommandMetaData.META_DATA);
+ commandMetaData.add(RedeployCommandMetaData.META_DATA);
+ commandMetaData.add(StartCommandMetaData.META_DATA);
+ commandMetaData.add(StopCommandMetaData.META_DATA);
+ commandMetaData.add(RestartCommandMetaData.META_DATA);
+ commandMetaData.add(UndeployCommandMetaData.META_DATA);
+ commandMetaData.add(SearchPluginsCommandMetaData.META_DATA);
+ commandMetaData.add(InstallPluginCommandMetaData.META_DATA);
+ commandMetaData.add(HelpCommandMetaData.META_DATA);
+
+ addURI();
+ addHost();
+ addPort();
+ addDriver();
+ addUser();
+ addPassword();
+ addSyserr();
+ addVerbose();
+ addOffline();
+ }
+
+ public CommandMetaData getCommandMetaData() {
+ return metaData;
+ }
+
+ public CommandArgs getCommandArgs() {
+ return commandArgs;
+ }
+
+ public String getURI() {
+ return commandLine.getOptionValue(ARGUMENT_URI_SHORTFORM);
+ }
+
+ public String getHost() {
+ return commandLine.getOptionValue(ARGUMENT_HOST_SHORTFORM);
+ }
+
+ public Integer getPort() {
+ String port = commandLine.getOptionValue(ARGUMENT_PORT_SHORTFORM);
+ if (null == port) {
+ return null;
+ }
+ return new Integer(port);
+ }
+
+ public String getDriver() {
+ return commandLine.getOptionValue(ARGUMENT_DRIVER_SHORTFORM);
+ }
+
+ public String getUser() {
+ return commandLine.getOptionValue(ARGUMENT_USER_SHORTFORM);
+ }
+
+ public String getPassword() {
+ return commandLine.getOptionValue(ARGUMENT_PASSWORD_SHORTFORM);
+ }
+
+ public boolean isSyserr() {
+ return commandLine.hasOption(ARGUMENT_SYSERR_SHORTFORM);
+ }
+
+ public boolean isVerbose() {
+ return commandLine.hasOption(ARGUMENT_VERBOSE_SHORTFORM);
+ }
+
+ public boolean isOffline() {
+ return commandLine.hasOption(ARGUMENT_OFFLINE_SHORTFORM);
+ }
+
+ @Override
+ public void displayHelp() {
+ String[] args = new String[0];
+ if (null != commandArgs) {
+ args = commandArgs.getArgs();
+ } else if (null != metaData) {
+ args = new String[] {metaData.getCommandName()};
+ }
+ displayHelp(args);
+ }
+
+ @Override
+ protected void displayHelp(String[] args) {
+ PrintHelper printHelper = new PrintHelper(System.out);
+ PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out), true);
+
+ out.println();
+ if(args.length > 0) {
+ CommandMetaData commandLine = getCommandMetaData(args[0]);
+ if(commandLine != null) {
+ out.println("Help for command: "+commandLine.getCommandName());
+ out.println(" "+hangingIndent(commandLine.getCommandName()+" "+commandLine.getHelpArgumentList(), 4));
+ out.println();
+ out.print(PrintHelper.reformat(commandLine.getHelpText(), 8, 72));
+ out.println();
+ return;
+ } else if(args[0].equals("options")) {
+ out.println("Help on general options:");
+ printHelper.printOptions(out, options);
+ out.println();
+ return;
+ } else if(args[0].equals("all")) {
+ out.println();
+ out.println("All commands");
+ out.println();
+ for (CommandMetaData commandLine2 : commandMetaData) {
+ out.println(" "+hangingIndent(commandLine2.getCommandName()+" "+commandLine2.getHelpArgumentList(), 4));
+ out.print(PrintHelper.reformat(commandLine2.getHelpText(), 8, 72));
+ out.println();
+ }
+ out.println();
+ return;
+ }
+ }
+
+ out.println("usage: java -jar bin/deployer.jar [general options] command [command options]");
+ out.println();
+ out.println("The general options are:");
+ printHelper.printOptionsNoDesc(out, options);
+ out.println();
+ out.println("The available commands are:");
+ renderCommandList(out);
+ out.println();
+ out.println("For more information about a specific command, run");
+ out.println(" java -jar bin/deployer.jar help [command name]");
+ out.println();
+ out.println("For more information about all commands, run");
+ out.println(" java -jar bin/deployer.jar help all");
+ out.println();
+ out.println("For more information about general options, run");
+ out.println(" java -jar bin/deployer.jar help options");
+ out.println();
+ }
+
+ private void renderCommandList(PrintWriter out) {
+ Map temp = new HashMap();
+ for (CommandMetaData commandLine : commandMetaData) {
+ List list = (List) temp.get(commandLine.getCommandGroup());
+ if(list == null) {
+ list = new ArrayList();
+ temp.put(commandLine.getCommandGroup(), list);
+ }
+ list.add(commandLine.getCommandName());
+ }
+ List groups = new ArrayList(temp.keySet());
+ Collections.sort(groups);
+ for (int i = 0; i < groups.size(); i++) {
+ String name = (String) groups.get(i);
+ out.println(" "+name);
+ List list = (List) temp.get(name);
+ Collections.sort(list);
+ for (int j = 0; j < list.size(); j++) {
+ String cmd = (String) list.get(j);
+ out.println(" "+cmd);
+ }
+ }
+ }
+
+ protected CommandMetaData getCommandMetaData(String commandName) {
+ for (CommandMetaData commandLine : commandMetaData) {
+ if (commandLine.getCommandName().equals(commandName)) {
+ return commandLine;
+ }
+ }
+ return null;
+ }
+
+ protected String hangingIndent(String source, int cols) {
+ String s = PrintHelper.reformat(source, cols, 72);
+ return s.substring(cols);
+ }
+
+ @Override
+ protected void validateOptions() throws CLParserException {
+ try {
+ getPort();
+ } catch (NumberFormatException e) {
+ throw new CLParserException("Port [" + commandLine.getOptionValue(ARGUMENT_PORT_SHORTFORM) + "] is not an integer.");
+ }
+ }
+
+ @Override
+ protected void validateRemainingArgs() throws CLParserException {
+ String[] args = commandLine.getArgs();
+ if (0 == args.length) {
+ throw new CLParserException("No command has been provided.");
+ }
+
+ String command = args[0];
+ metaData = getCommandMetaData(command);
+ if (null == metaData) {
+ throw new CLParserException("Command [" + command + "] is undefined.");
+ }
+
+ String[] newArgs = new String[args.length - 1];
+ System.arraycopy(args, 1, newArgs, 0, newArgs.length);
+ commandArgs = metaData.parse(newArgs);
+ }
+
+ protected void addOffline() {
+ options.addOption(ARGUMENT_OFFLINE_SHORTFORM,
+ ARGUMENT_OFFLINE,
+ false,
+ "Deploy offline to a local server, using whatever deployers are available in the local server");
+ }
+
+ protected void addVerbose() {
+ options.addOption(ARGUMENT_VERBOSE_SHORTFORM,
+ ARGUMENT_VERBOSE,
+ false,
+ "Enables verbose execution mode. Disabled by default.");
+ }
+
+ protected void addSyserr() {
+ options.addOption(ARGUMENT_SYSERR_SHORTFORM,
+ ARGUMENT_SYSERR,
+ false,
+ "Enables error logging to syserr. Disabled by default.");
+ }
+
+ protected void addPassword() {
+ addOptionWithParam(ARGUMENT_PASSWORD,
+ ARGUMENT_PASSWORD_SHORTFORM,
+ "password",
+ "Specifies a password to use to authenticate to the server.");
+ }
+
+ protected void addUser() {
+ addOptionWithParam(ARGUMENT_USER,
+ ARGUMENT_USER_SHORTFORM,
+ "username",
+ "If the deployment operation requires authentication, then you can "
+ + "specify the username to use to connect. If no password is specified, the "
+ + "deployer will attempt to connect to the server with no password, and if "
+ + "that fails, will prompt you for a password.");
+ }
+
+ protected void addDriver() {
+ addOptionWithParam(ARGUMENT_DRIVER,
+ ARGUMENT_DRIVER_SHORTFORM,
+ "driver.jar",
+ "If you want to use this tool with a server other than Geronimo, "
+ + "then you must provide the path to its driver JAR. Currently, manifest "
+ + "Class-Path entries in that JAR are ignored.");
+ }
+
+ protected void addPort() {
+ addOptionWithParam(ARGUMENT_PORT,
+ ARGUMENT_PORT_SHORTFORM,
+ "port",
+ "The RMI listen port of a Geronimo server to deploy to. This option is "
+ + "not compatible with --uri, but is often used with --host. The default port is 1099.");
+ }
+
+ protected void addHost() {
+ addOptionWithParam(ARGUMENT_HOST_SHORTFORM,
+ ARGUMENT_HOST_SHORTFORM,
+ "hostname",
+ "The host name of a Geronimo server to deploy to. This option is "
+ + "not compatible with --uri, but is often used with --port.");
+ }
+
+ protected void addURI() {
+ addOptionWithParam(ARGUMENT_URI,
+ ARGUMENT_URI_SHORTFORM,
+ "uri",
+ "A URI to contact the server. If not specified, the deployer defaults to "
+ + "operating on a Geronimo server running on the standard port on localhost.\n"
+ + "A URI to connect to Geronimo (including optional host and port parameters) has the form: "
+ + "deployer:geronimo:jmx[://host[:port]] (though you could also just use --host and --port instead).");
+ }
+
+ protected void addOptionWithParam(String longOption, String shortOption, String argName, String desc) {
+ OptionBuilder optionBuilder = OptionBuilder.hasArg().withArgName(argName);
+ optionBuilder = optionBuilder.withLongOpt(longOption);
+ optionBuilder = optionBuilder.withDescription(desc);
+ Option option = optionBuilder.create(shortOption);
+ options.addOption(option);
+ }
+
+}
Added: geronimo/server/trunk/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/DistributeCommandArgs.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/DistributeCommandArgs.java?view=auto&rev=535507
==============================================================================
--- geronimo/server/trunk/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/DistributeCommandArgs.java (added)
+++ geronimo/server/trunk/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/DistributeCommandArgs.java Sat May 5 04:22:39 2007
@@ -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.
+ */
+package org.apache.geronimo.cli.deployer;
+
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.CommandLineParser;
+import org.apache.commons.cli.GnuParser;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.OptionBuilder;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.ParseException;
+import org.apache.geronimo.cli.CLParserException;
+
+/**
+ * @version $Rev: 476049 $ $Date: 2006-11-17 15:35:17 +1100 (Fri, 17 Nov 2006) $
+ */
+public class DistributeCommandArgs implements CommandArgs {
+ private final static String ARGUMENT_IN_PLACE_SHORTFORM = "i";
+ private final static String ARGUMENT_IN_PLACE = "inPlace";
+
+ private final static String ARGUMENT_TARGETS_SHORTFORM = "t";
+ private final static String ARGUMENT_TARGETS = "targets";
+
+ protected final Options options;
+ protected CommandLine commandLine;
+
+ public DistributeCommandArgs(String[] args) throws CLParserException {
+ options = new Options();
+ addInPlace();
+ addTargets();
+
+ CommandLineParser parser = new GnuParser();
+ try {
+ commandLine = parser.parse(options, args, true);
+ } catch (ParseException e) {
+ throw new CLParserException(e.getMessage(), e);
+ }
+
+ if (0 == commandLine.getArgs().length) {
+ throw new CLParserException("Must specify a module or plan (or both)");
+ } else if (2 < commandLine.getArgs().length) {
+ throw new CLParserException("Too many arguments");
+ }
+ }
+
+ protected void addTargets() {
+ OptionBuilder optionBuilder = OptionBuilder.hasArg().withArgName("targets");
+ optionBuilder = optionBuilder.withLongOpt(ARGUMENT_TARGETS);
+ optionBuilder = optionBuilder
+ .withDescription("If no targets are provided, the module is distributed to all available "
+ + "targets. Geronimo only provides one target (ever), so this is primarily "
+ + "useful when using a different driver.\n");
+ Option option = optionBuilder.create(ARGUMENT_TARGETS_SHORTFORM);
+ options.addOption(option);
+ }
+
+ protected void addInPlace() {
+ options.addOption(ARGUMENT_IN_PLACE_SHORTFORM,
+ ARGUMENT_IN_PLACE,
+ false,
+ "If inPlace is provided, the module is not copied to the configuration "
+ + "store of the selected targets. The targets directly use the module.");
+ }
+
+ public String[] getTargets() {
+ String targets = commandLine.getOptionValue(ARGUMENT_TARGETS_SHORTFORM);
+ if (null == targets) {
+ return new String[0];
+ }
+ return targets.split(";");
+ }
+
+ public boolean isInPlace() {
+ return commandLine.hasOption(ARGUMENT_IN_PLACE_SHORTFORM);
+ }
+
+ public String[] getArgs() {
+ return commandLine.getArgs();
+ }
+
+}
Added: geronimo/server/trunk/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/DistributeCommandMetaData.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/DistributeCommandMetaData.java?view=auto&rev=535507
==============================================================================
--- geronimo/server/trunk/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/DistributeCommandMetaData.java (added)
+++ geronimo/server/trunk/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/DistributeCommandMetaData.java Sat May 5 04:22:39 2007
@@ -0,0 +1,49 @@
+/**
+ * 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.geronimo.cli.deployer;
+
+import org.apache.geronimo.cli.CLParserException;
+
+
+
+/**
+ * @version $Rev: 515007 $ $Date: 2007-03-06 18:26:41 +1100 (Tue, 06 Mar 2007) $
+ */
+public class DistributeCommandMetaData extends BaseCommandMetaData {
+ public static final CommandMetaData META_DATA = new DistributeCommandMetaData();
+
+ private DistributeCommandMetaData() {
+ super("distribute", "2. Other Commands", "[--inPlace] [--targets target;target;...] [module] [plan]",
+ "Processes a module and adds it to the server environment, but does "+
+ "not start it or mark it to be started in the future. " +
+ "Normally both a module and plan are passed to the deployer. " +
+ "Sometimes the module contains a plan, or requires no plan, in which case " +
+ "the plan may be omitted. Sometimes the plan references a module already " +
+ "deployed in the Geronimo server environment, in which case a module does " +
+ "not need to be provided.\n" +
+ "If no targets are provided, the module is distributed to all available " +
+ "targets. Geronimo only provides one target (ever), so this is primarily " +
+ "useful when using a different driver.\n" +
+ "If inPlace is provided, the module is not copied to the configuration " +
+ "store of the selected targets. The targets directly use the module.");
+ }
+
+ public CommandArgs parse(String[] args) throws CLParserException {
+ return new DistributeCommandArgs(args);
+ }
+
+}
Added: geronimo/server/trunk/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/HelpCommandMetaData.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/HelpCommandMetaData.java?view=auto&rev=535507
==============================================================================
--- geronimo/server/trunk/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/HelpCommandMetaData.java (added)
+++ geronimo/server/trunk/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/HelpCommandMetaData.java Sat May 5 04:22:39 2007
@@ -0,0 +1,32 @@
+/**
+ * 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.geronimo.cli.deployer;
+
+
+
+/**
+ * @version $Rev: 515007 $ $Date: 2007-03-06 18:26:41 +1100 (Tue, 06 Mar 2007) $
+ */
+public class HelpCommandMetaData extends BaseCommandMetaData {
+ public static final CommandMetaData META_DATA = new HelpCommandMetaData();
+
+ private HelpCommandMetaData() {
+ super("help", "4. Informative Commands", "[command]",
+ "Display the help of the provided command or all the commands if 'all' is provided.");
+ }
+
+}
Added: geronimo/server/trunk/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/InstallPluginCommandMetaData.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/InstallPluginCommandMetaData.java?view=auto&rev=535507
==============================================================================
--- geronimo/server/trunk/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/InstallPluginCommandMetaData.java (added)
+++ geronimo/server/trunk/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/InstallPluginCommandMetaData.java Sat May 5 04:22:39 2007
@@ -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.geronimo.cli.deployer;
+
+import org.apache.geronimo.cli.CLParserException;
+
+
+
+/**
+ * @version $Rev: 515007 $ $Date: 2007-03-06 18:26:41 +1100 (Tue, 06 Mar 2007) $
+ */
+public class InstallPluginCommandMetaData extends BaseCommandMetaData {
+ public static final CommandMetaData META_DATA = new InstallPluginCommandMetaData();
+
+ private InstallPluginCommandMetaData() {
+ super("install-plugin", "3. Geronimo Plugins", "PluginFile",
+ "Installs a Geronimo plugin you've exported from a Geronimo server " +
+ "or downloaded from an external repository. The file must be a " +
+ "properly configured Geronimo CAR file. This is used to add new " +
+ "functionality to the Geronimo server.");
+ }
+
+ public CommandArgs parse(String[] newArgs) throws CLParserException {
+ if (newArgs.length != 1) {
+ throw new CLParserException("Must specify Plugin CAR file");
+ }
+ return new BaseCommandArgs(newArgs);
+ }
+
+}
Added: geronimo/server/trunk/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/ListModulesCommandArgs.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/ListModulesCommandArgs.java?view=auto&rev=535507
==============================================================================
--- geronimo/server/trunk/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/ListModulesCommandArgs.java (added)
+++ geronimo/server/trunk/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/ListModulesCommandArgs.java Sat May 5 04:22:39 2007
@@ -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.
+ */
+package org.apache.geronimo.cli.deployer;
+
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.CommandLineParser;
+import org.apache.commons.cli.GnuParser;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.OptionGroup;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.ParseException;
+import org.apache.geronimo.cli.CLParserException;
+
+/**
+ * @version $Rev: 476049 $ $Date: 2006-11-17 15:35:17 +1100 (Fri, 17 Nov 2006) $
+ */
+public class ListModulesCommandArgs implements CommandArgs {
+ private final static String ARGUMENT_ALL_SHORTFORM = "a";
+ private final static String ARGUMENT_ALL = "all";
+
+ private final static String ARGUMENT_STARTED_SHORTFORM = "s";
+ private final static String ARGUMENT_STARTED = "started";
+
+ private final static String ARGUMENT_STOPPED_SHORTFORM = "t";
+ private final static String ARGUMENT_STOPPED = "stopped";
+
+ protected final Options options;
+ protected CommandLine commandLine;
+
+ public ListModulesCommandArgs(String[] args) throws CLParserException {
+ options = new Options();
+ addState();
+
+ CommandLineParser parser = new GnuParser();
+ try {
+ commandLine = parser.parse(options, args, true);
+ } catch (ParseException e) {
+ throw new CLParserException(e.getMessage(), e);
+ }
+ }
+
+ public boolean isAll() {
+ return commandLine.hasOption(ARGUMENT_ALL_SHORTFORM);
+ }
+
+ public boolean isStarted() {
+ return commandLine.hasOption(ARGUMENT_STARTED_SHORTFORM);
+ }
+
+ public boolean isStopped() {
+ return commandLine.hasOption(ARGUMENT_STOPPED_SHORTFORM);
+ }
+
+ public String[] getArgs() {
+ return commandLine.getArgs();
+ }
+
+ protected void addState() {
+ OptionGroup optionGroup = new OptionGroup();
+
+ Option option = new Option(ARGUMENT_ALL_SHORTFORM,
+ ARGUMENT_ALL,
+ false,
+ "All modules will be listed.");
+ optionGroup.addOption(option);
+
+ option = new Option(ARGUMENT_STARTED_SHORTFORM,
+ ARGUMENT_STARTED,
+ false,
+ "Only started modules will be listed.");
+ optionGroup.addOption(option);
+
+ option = new Option(ARGUMENT_STOPPED_SHORTFORM,
+ ARGUMENT_STOPPED,
+ false,
+ "Only stopped modules will be listed.");
+ optionGroup.addOption(option);
+
+ options.addOptionGroup(optionGroup);
+ }
+
+}
Added: geronimo/server/trunk/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/ListModulesCommandMetaData.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/ListModulesCommandMetaData.java?view=auto&rev=535507
==============================================================================
--- geronimo/server/trunk/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/ListModulesCommandMetaData.java (added)
+++ geronimo/server/trunk/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/ListModulesCommandMetaData.java Sat May 5 04:22:39 2007
@@ -0,0 +1,41 @@
+/**
+ * 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.geronimo.cli.deployer;
+
+import org.apache.geronimo.cli.CLParserException;
+
+
+/**
+ * @version $Rev: 515007 $ $Date: 2007-03-06 18:26:41 +1100 (Tue, 06 Mar 2007) $
+ */
+public class ListModulesCommandMetaData extends BaseCommandMetaData {
+ public static final CommandMetaData META_DATA = new ListModulesCommandMetaData();
+
+ private ListModulesCommandMetaData() {
+ super("list-modules", "2. Other Commands", "[--all|--started|--stopped] [target*]",
+ "Lists the modules available on the specified targets. If " +
+ "--started or --stopped is specified, only started or stopped modules will " +
+ "be listed; otherwise all modules will be listed. If no targets are " +
+ "specified, then modules on all targets will be listed; otherwise only " +
+ "modules on the specified targets.");
+ }
+
+ public CommandArgs parse(String[] args) throws CLParserException {
+ return new ListModulesCommandArgs(args);
+ }
+
+}
Added: geronimo/server/trunk/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/ListTargetsCommandMetaData.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/ListTargetsCommandMetaData.java?view=auto&rev=535507
==============================================================================
--- geronimo/server/trunk/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/ListTargetsCommandMetaData.java (added)
+++ geronimo/server/trunk/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/ListTargetsCommandMetaData.java Sat May 5 04:22:39 2007
@@ -0,0 +1,42 @@
+/**
+ * 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.geronimo.cli.deployer;
+
+import org.apache.geronimo.cli.CLParserException;
+
+
+/**
+ * @version $Rev: 515007 $ $Date: 2007-03-06 18:26:41 +1100 (Tue, 06 Mar 2007) $
+ */
+public class ListTargetsCommandMetaData extends BaseCommandMetaData {
+ public static final CommandMetaData META_DATA = new ListTargetsCommandMetaData();
+
+ private ListTargetsCommandMetaData() {
+ super("list-targets", "2. Other Commands", "",
+ "Lists the targets known to the server you've connected to.\n" +
+ "In the case of Geronimo, each configuration store is a separate " +
+ "target. Geronimo does not yet support clusters as targets.");
+ }
+
+ public CommandArgs parse(String[] newArgs) throws CLParserException {
+ if (0 != newArgs.length) {
+ throw new CLParserException(getCommandName() + " does not take arguments.");
+ }
+ return new BaseCommandArgs(newArgs);
+ }
+
+}
Added: geronimo/server/trunk/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/LoginCommandMetaData.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/LoginCommandMetaData.java?view=auto&rev=535507
==============================================================================
--- geronimo/server/trunk/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/LoginCommandMetaData.java (added)
+++ geronimo/server/trunk/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/LoginCommandMetaData.java Sat May 5 04:22:39 2007
@@ -0,0 +1,42 @@
+/**
+ * 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.geronimo.cli.deployer;
+
+
+/**
+ * @version $Rev: 515007 $ $Date: 2007-03-06 18:26:41 +1100 (Tue, 06 Mar 2007) $
+ */
+public class LoginCommandMetaData extends BaseCommandMetaData {
+ public static final CommandMetaData META_DATA = new LoginCommandMetaData();
+
+ private LoginCommandMetaData() {
+ super("login", "1. Common Commands", "",
+ "Saves the username and password for this connection to the "+
+ "file .geronimo-deployer in the current user's home directory. " +
+ "Future connections to the same server will try to use this "+
+ "saved authentication information instead of prompting where " +
+ "possible. This information is saved separately per connection " +
+ "URL, so you can specify --url or --host and/or --port on the command " +
+ "line to save a login to a different server.\n" +
+ "WARNING: while the login information is not saved in " +
+ "clear text, it is not secure either. If you want to " +
+ "save the authentication securely, you should change the " +
+ ".geronimo-deployer file in your home directory so that nobody " +
+ "else can read or write it.");
+ }
+
+}
Added: geronimo/server/trunk/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/RedeployCommandMetaData.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/RedeployCommandMetaData.java?view=auto&rev=535507
==============================================================================
--- geronimo/server/trunk/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/RedeployCommandMetaData.java (added)
+++ geronimo/server/trunk/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/RedeployCommandMetaData.java Sat May 5 04:22:39 2007
@@ -0,0 +1,55 @@
+/**
+ * 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.geronimo.cli.deployer;
+
+import org.apache.geronimo.cli.CLParserException;
+
+
+/**
+ * @version $Rev: 515007 $ $Date: 2007-03-06 18:26:41 +1100 (Tue, 06 Mar 2007) $
+ */
+public class RedeployCommandMetaData extends BaseCommandMetaData {
+ public static final CommandMetaData META_DATA = new RedeployCommandMetaData();
+
+ private RedeployCommandMetaData() {
+ super("redeploy", "1. Common Commands", "[module] [plan] [ModuleID|TargetModuleID+]",
+ "A shortcut to undeploy a module from one or more servers, then " +
+ "deploy a new version. This is not a smooth cutover -- some client " +
+ "requests may be rejected while the redeploy takes place.\n" +
+ "Normally both a module and plan are passed to the deployer. " +
+ "Sometimes the module contains a plan, or requires no plan, in which case " +
+ "the plan may be omitted. Sometimes the plan references a module already " +
+ "deployed in the Geronimo server environment, in which case a module does " +
+ "not need to be provided.\n" +
+ "If more than one TargetModuleID is provided, all TargetModuleIDs " +
+ "must refer to the same module (just running on different targets).\n" +
+ "Regardless of whether the old module was running or not, the new " +
+ "module will be started.\n" +
+ "If no ModuleID or TargetModuleID is specified, and you're deploying to "+
+ "Geronimo, the deployer will attempt to guess the correct ModuleID for "+
+ "you based on the module and/or plan you provided.\n"+
+ "Note: To specify a TargetModuleID, use the form TargetName|ModuleName");
+ }
+
+ public CommandArgs parse(String[] newArgs) throws CLParserException {
+ if (newArgs.length == 0) {
+ throw new CLParserException("Must specify a module or plan (or both) and optionally module IDs to replace");
+ }
+ return super.parse(newArgs);
+ }
+
+}
Added: geronimo/server/trunk/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/RestartCommandMetaData.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/RestartCommandMetaData.java?view=auto&rev=535507
==============================================================================
--- geronimo/server/trunk/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/RestartCommandMetaData.java (added)
+++ geronimo/server/trunk/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/RestartCommandMetaData.java Sat May 5 04:22:39 2007
@@ -0,0 +1,43 @@
+/**
+ * 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.geronimo.cli.deployer;
+
+import org.apache.geronimo.cli.CLParserException;
+
+
+/**
+ * @version $Rev: 515007 $ $Date: 2007-03-06 18:26:41 +1100 (Tue, 06 Mar 2007) $
+ */
+public class RestartCommandMetaData extends BaseCommandMetaData {
+ public static final CommandMetaData META_DATA = new RestartCommandMetaData();
+
+ private RestartCommandMetaData() {
+ super("restart", "1. Common Commands", "[ModuleID|TargetModuleID]+",
+ "Accepts the configId of a module, or the fully-qualified " +
+ "TargetModuleID identifying both the module and the server or cluster it's " +
+ "on, and restarts that module. The module should be available to the server " +
+ "and running. If multiple modules are specified, they will all be restarted.\n");
+ }
+
+ public CommandArgs parse(String[] newArgs) throws CLParserException {
+ if (newArgs.length == 0) {
+ throw new CLParserException("Must specify a module or target module to replace");
+ }
+ return new BaseCommandArgs(newArgs);
+ }
+
+}
Added: geronimo/server/trunk/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/SearchPluginsCommandMetaData.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/SearchPluginsCommandMetaData.java?view=auto&rev=535507
==============================================================================
--- geronimo/server/trunk/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/SearchPluginsCommandMetaData.java (added)
+++ geronimo/server/trunk/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/SearchPluginsCommandMetaData.java Sat May 5 04:22:39 2007
@@ -0,0 +1,46 @@
+/**
+ * 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.geronimo.cli.deployer;
+
+import org.apache.geronimo.cli.CLParserException;
+
+
+/**
+ * @version $Rev: 515007 $ $Date: 2007-03-06 18:26:41 +1100 (Tue, 06 Mar 2007) $
+ */
+public class SearchPluginsCommandMetaData extends BaseCommandMetaData {
+ public static final CommandMetaData META_DATA = new SearchPluginsCommandMetaData();
+
+ private SearchPluginsCommandMetaData() {
+ super("search-plugins", "3. Geronimo Plugins", "[MavenRepoURL]",
+ "Lists the Geronimo plugins available in a Maven repository "+
+ "and lets you select a plugin to download and install. This "+
+ "is used to add new functionality to the Geronimo server. If " +
+ "no repository is specified the default repositories will be " +
+ "listed to select from, but this means there must have been " +
+ "some default repositories set (by hand or by having the " +
+ "console update to the latest defaults).");
+ }
+
+ public CommandArgs parse(String[] newArgs) throws CLParserException {
+ if (1 < newArgs.length) {
+ throw new CLParserException("Only one Maven repository can be specified.");
+ }
+ return new BaseCommandArgs(newArgs);
+ }
+
+}
Added: geronimo/server/trunk/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/StartCommandMetaData.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/StartCommandMetaData.java?view=auto&rev=535507
==============================================================================
--- geronimo/server/trunk/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/StartCommandMetaData.java (added)
+++ geronimo/server/trunk/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/StartCommandMetaData.java Sat May 5 04:22:39 2007
@@ -0,0 +1,46 @@
+/**
+ * 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.geronimo.cli.deployer;
+
+import org.apache.geronimo.cli.CLParserException;
+
+
+/**
+ * @version $Rev: 515007 $ $Date: 2007-03-06 18:26:41 +1100 (Tue, 06 Mar 2007) $
+ */
+public class StartCommandMetaData extends BaseCommandMetaData {
+ public static final CommandMetaData META_DATA = new StartCommandMetaData();
+
+ private StartCommandMetaData() {
+ super("start", "1. Common Commands", "[ModuleID|TargetModuleID]+",
+ "Accepts the configId of a module, or the fully-qualified " +
+ "TargetModuleID identifying both the module and the server or cluster it's " +
+ "on, and starts that module. The module should be available to the server " +
+ "but not currently running. If multiple modules are specified, they will " +
+ "all be started.\n" +
+ "If the server is not running, the module will be marked to start " +
+ "next time the server is started.");
+ }
+
+ public CommandArgs parse(String[] newArgs) throws CLParserException {
+ if (newArgs.length == 0) {
+ throw new CLParserException("Must specify a module or target module to start");
+ }
+ return super.parse(newArgs);
+ }
+
+}
Added: geronimo/server/trunk/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/StopCommandMetaData.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/StopCommandMetaData.java?view=auto&rev=535507
==============================================================================
--- geronimo/server/trunk/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/StopCommandMetaData.java (added)
+++ geronimo/server/trunk/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/StopCommandMetaData.java Sat May 5 04:22:39 2007
@@ -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.
+ */
+package org.apache.geronimo.cli.deployer;
+
+import org.apache.geronimo.cli.CLParserException;
+
+
+/**
+ * @version $Rev: 515007 $ $Date: 2007-03-06 18:26:41 +1100 (Tue, 06 Mar 2007) $
+ */
+public class StopCommandMetaData extends BaseCommandMetaData {
+ public static final CommandMetaData META_DATA = new StopCommandMetaData();
+
+ private StopCommandMetaData() {
+ super("stop", "1. Common Commands", "[ModuleID|TargetModuleID]+",
+ "Accepts the configId of a module, or the fully-qualified " +
+ "TargetModuleID identifying both the module and the server or cluster it's " +
+ "on, and stops that module. The module should be available to the server " +
+ "and running. After stop is completed, the server still has the module and " +
+ "deployment information available, it's just not running. If multiple " +
+ "modules are specified, they will all be stopped.\n" +
+ "If the server is not running, the module will be marked to not " +
+ "start next time the server is started.");
+ }
+
+ public CommandArgs parse(String[] newArgs) throws CLParserException {
+ if (newArgs.length == 0) {
+ throw new CLParserException("Must specify a module or target module to stop");
+ }
+ return super.parse(newArgs);
+ }
+
+}
Added: geronimo/server/trunk/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/UndeployCommandMetaData.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/UndeployCommandMetaData.java?view=auto&rev=535507
==============================================================================
--- geronimo/server/trunk/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/UndeployCommandMetaData.java (added)
+++ geronimo/server/trunk/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/UndeployCommandMetaData.java Sat May 5 04:22:39 2007
@@ -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.geronimo.cli.deployer;
+
+import org.apache.geronimo.cli.CLParserException;
+
+
+/**
+ * @version $Rev: 515007 $ $Date: 2007-03-06 18:26:41 +1100 (Tue, 06 Mar 2007) $
+ */
+public class UndeployCommandMetaData extends BaseCommandMetaData {
+ public static final CommandMetaData META_DATA = new UndeployCommandMetaData();
+
+ private UndeployCommandMetaData() {
+ super("undeploy", "1. Common Commands", "[ModuleID|TargetModuleID]+",
+ "Accepts the configId of a module, or the fully-qualified " +
+ "TargetModuleID identifying both the module and the server or cluster it's " +
+ "on, stops that module, and removes the deployment files for that module " +
+ "from the server environment. If multiple modules are specified, they will " +
+ "all be undeployed.");
+ }
+
+ public CommandArgs parse(String[] newArgs) throws CLParserException {
+ if (newArgs.length == 0) {
+ throw new CLParserException("Must specify a module or target module to undeploy");
+ }
+ return super.parse(newArgs);
+ }
+
+}
Added: geronimo/server/trunk/modules/geronimo-cli/src/test/java/org/apache/geronimo/cli/AbstractCLITest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-cli/src/test/java/org/apache/geronimo/cli/AbstractCLITest.java?view=auto&rev=535507
==============================================================================
--- geronimo/server/trunk/modules/geronimo-cli/src/test/java/org/apache/geronimo/cli/AbstractCLITest.java (added)
+++ geronimo/server/trunk/modules/geronimo-cli/src/test/java/org/apache/geronimo/cli/AbstractCLITest.java Sat May 5 04:22:39 2007
@@ -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.
+ */
+package org.apache.geronimo.cli;
+
+import java.io.ByteArrayOutputStream;
+import java.io.PrintStream;
+
+import org.apache.geronimo.kernel.util.MainConfigurationBootstrapper;
+
+import com.agical.rmock.extension.junit.RMockTestCase;
+
+/**
+ * @version $Rev:385659 $ $Date: 2007-03-07 14:40:07 +1100 (Wed, 07 Mar 2007) $
+ */
+public class AbstractCLITest extends RMockTestCase {
+
+ private CLParser parser;
+ private String[] args;
+ private MockCLI mockCLI;
+
+ @Override
+ protected void setUp() throws Exception {
+ parser = (CLParser) mock(CLParser.class);
+ args = new String[0];
+ mockCLI = new MockCLI(args, parser);
+ }
+
+ public void testParseExceptionReturn1() throws Exception {
+ parser.parse(args);
+ modify().throwException(new CLParserException("desc"));
+
+ parser.displayHelp();
+ startVerification();
+
+ int status = mockCLI.executeMain();
+ assertEquals(1, status);
+ }
+
+ public void testHelpOptionReturn0() throws Exception {
+ parser.parse(args);
+
+ parser.isHelp();
+ modify().returnValue(true);
+ parser.displayHelp();
+ startVerification();
+
+ int status = mockCLI.executeMain();
+ assertEquals(0, status);
+ }
+
+ public void testCommandExecutionReturn0() throws Exception {
+ parser.parse(args);
+
+ parser.isHelp();
+ startVerification();
+
+ int status = mockCLI.executeMain();
+ assertEquals(0, status);
+ }
+
+ private static class MockCLI extends AbstractCLI {
+
+ private final CLParser parser;
+
+ protected MockCLI(String[] args, CLParser parser) {
+ super(args, new PrintStream(new ByteArrayOutputStream()));
+ this.parser = parser;
+ }
+
+ @Override
+ protected CLParser getCLParser() {
+ return parser;
+ }
+
+ @Override
+ protected MainConfigurationBootstrapper newMainConfigurationBootstrapper() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ protected boolean executeCommand(CLParser parser) {
+ return true;
+ }
+
+ }
+
+}
Added: geronimo/server/trunk/modules/geronimo-cli/src/test/java/org/apache/geronimo/cli/BaseCLParserTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-cli/src/test/java/org/apache/geronimo/cli/BaseCLParserTest.java?view=auto&rev=535507
==============================================================================
--- geronimo/server/trunk/modules/geronimo-cli/src/test/java/org/apache/geronimo/cli/BaseCLParserTest.java (added)
+++ geronimo/server/trunk/modules/geronimo-cli/src/test/java/org/apache/geronimo/cli/BaseCLParserTest.java Sat May 5 04:22:39 2007
@@ -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.
+ */
+package org.apache.geronimo.cli;
+
+import junit.framework.TestCase;
+
+import org.apache.geronimo.cli.CLParserException;
+
+/**
+ * @version $Rev:385659 $ $Date: 2007-03-07 14:40:07 +1100 (Wed, 07 Mar 2007) $
+ */
+public class BaseCLParserTest extends TestCase {
+
+ private CLParser parser;
+
+ @Override
+ protected void setUp() throws Exception {
+ parser = new BaseCLParser(System.out);
+ }
+
+ public void testHelp() throws Exception {
+ parser.parse(new String[] {"--help"});
+ assertTrue(parser.isHelp());
+
+ parser.parse(new String[] {"-h"});
+ assertTrue(parser.isHelp());
+ }
+
+ public void testVerbose() throws Exception {
+ parser.parse(new String[0]);
+ assertFalse(parser.isVerboseInfo());
+
+ parser.parse(new String[] {"--verbose"});
+ assertTrue(parser.isVerboseInfo());
+
+ parser.parse(new String[] {"-v"});
+ assertTrue(parser.isVerboseInfo());
+ }
+
+ public void testVeryVerbose() throws Exception {
+ parser.parse(new String[0]);
+ assertFalse(parser.isVerboseDebug());
+
+ parser.parse(new String[] {"--veryverbose"});
+ assertTrue(parser.isVerboseDebug());
+
+ parser.parse(new String[] {"-vv"});
+ assertTrue(parser.isVerboseDebug());
+ }
+
+ public void testVeryVeryVerbose() throws Exception {
+ parser.parse(new String[0]);
+ assertFalse(parser.isVerboseDebug());
+
+ parser.parse(new String[] {"--veryveryverbose"});
+ assertTrue(parser.isVerboseTrace());
+
+ parser.parse(new String[] {"-vvv"});
+ assertTrue(parser.isVerboseTrace());
+ }
+
+ public void testMultiVerboseNotAllowed() throws Exception {
+ try {
+ parser.parse(new String[] {"-v", "-vv"});
+ fail();
+ } catch (CLParserException e) {
+ }
+
+ try {
+ parser.parse(new String[] {"-v", "-vvv"});
+ fail();
+ } catch (CLParserException e) {
+ }
+
+ try {
+ parser.parse(new String[] {"-vv", "-vvv"});
+ fail();
+ } catch (CLParserException e) {
+ }
+ }
+
+}
Added: geronimo/server/trunk/modules/geronimo-cli/src/test/java/org/apache/geronimo/cli/client/ClientCLParserTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-cli/src/test/java/org/apache/geronimo/cli/client/ClientCLParserTest.java?view=auto&rev=535507
==============================================================================
--- geronimo/server/trunk/modules/geronimo-cli/src/test/java/org/apache/geronimo/cli/client/ClientCLParserTest.java (added)
+++ geronimo/server/trunk/modules/geronimo-cli/src/test/java/org/apache/geronimo/cli/client/ClientCLParserTest.java Sat May 5 04:22:39 2007
@@ -0,0 +1,59 @@
+/**
+ * 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.geronimo.cli.client;
+
+import org.apache.geronimo.cli.CLParserException;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev:385659 $ $Date: 2007-03-07 14:40:07 +1100 (Wed, 07 Mar 2007) $
+ */
+public class ClientCLParserTest extends TestCase {
+
+ private ClientCLParser parser;
+
+ @Override
+ protected void setUp() throws Exception {
+ parser = new ClientCLParser(System.out);
+ }
+
+ public void testNoApplicationClientConfigurationFails() throws Exception {
+ try {
+ parser.parse(new String[] {"-v"});
+ fail();
+ } catch (CLParserException e) {
+ }
+ }
+
+ public void testGetApplicationClientConfiguration() throws Exception {
+ String configName = "configName";
+ parser.parse(new String[] {"-v", configName, "arg1", "arg2"});
+ assertEquals(configName, parser.getApplicationClientConfiguration());
+ }
+
+ public void testGetApplicationClientArgs() throws Exception {
+ String arg1 = "arg1";
+ String arg2 = "arg2";
+ parser.parse(new String[] {"-v", "configName", arg1, arg2});
+ String[] args = parser.getApplicationClientArgs();
+ assertEquals(2, args.length);
+ assertEquals(arg1, args[0]);
+ assertEquals(arg2, args[1]);
+ }
+
+}
Added: geronimo/server/trunk/modules/geronimo-cli/src/test/java/org/apache/geronimo/cli/daemon/DaemonCLParserTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-cli/src/test/java/org/apache/geronimo/cli/daemon/DaemonCLParserTest.java?view=auto&rev=535507
==============================================================================
--- geronimo/server/trunk/modules/geronimo-cli/src/test/java/org/apache/geronimo/cli/daemon/DaemonCLParserTest.java (added)
+++ geronimo/server/trunk/modules/geronimo-cli/src/test/java/org/apache/geronimo/cli/daemon/DaemonCLParserTest.java Sat May 5 04:22:39 2007
@@ -0,0 +1,79 @@
+/**
+ * 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.geronimo.cli.daemon;
+
+import junit.framework.TestCase;
+
+import org.apache.geronimo.cli.CLParserException;
+
+/**
+ * @version $Rev:385659 $ $Date: 2007-03-07 14:40:07 +1100 (Wed, 07 Mar 2007) $
+ */
+public class DaemonCLParserTest extends TestCase {
+
+ private DaemonCLParser parser;
+
+ @Override
+ protected void setUp() throws Exception {
+ parser = new DaemonCLParser(System.out);
+ }
+
+ public void testOverride() throws Exception {
+ parser.parse(new String[0]);
+ String[] override = parser.getOverride();
+ assertNull(override);
+
+ parser.parse(new String[] {"-o", "module1", "module2"});
+ override = parser.getOverride();
+ assertEquals(2, override.length);
+
+ parser.parse(new String[] {"--override", "module1", "module2"});
+ override = parser.getOverride();
+ assertEquals(2, override.length);
+ }
+
+ public void testLong() throws Exception {
+ parser.parse(new String[0]);
+ assertFalse(parser.isLongProgress());
+
+ parser.parse(new String[] {"--long"});
+ assertTrue(parser.isLongProgress());
+
+ parser.parse(new String[] {"-l"});
+ assertTrue(parser.isLongProgress());
+ }
+
+ public void testQuiet() throws Exception {
+ parser.parse(new String[0]);
+ assertFalse(parser.isNoProgress());
+
+ parser.parse(new String[] {"--quiet"});
+ assertTrue(parser.isNoProgress());
+
+ parser.parse(new String[] {"-q"});
+ assertTrue(parser.isNoProgress());
+ }
+
+ public void testQuietAndLongNotAllowed() throws Exception {
+ try {
+ parser.parse(new String[] {"--quiet", "--long"});
+ fail();
+ } catch (CLParserException e) {
+ }
+ }
+
+}
Added: geronimo/server/trunk/modules/geronimo-cli/src/test/java/org/apache/geronimo/cli/deployer/CommandFileCommandMetaDataTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-cli/src/test/java/org/apache/geronimo/cli/deployer/CommandFileCommandMetaDataTest.java?view=auto&rev=535507
==============================================================================
--- geronimo/server/trunk/modules/geronimo-cli/src/test/java/org/apache/geronimo/cli/deployer/CommandFileCommandMetaDataTest.java (added)
+++ geronimo/server/trunk/modules/geronimo-cli/src/test/java/org/apache/geronimo/cli/deployer/CommandFileCommandMetaDataTest.java Sat May 5 04:22:39 2007
@@ -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.
+ */
+package org.apache.geronimo.cli.deployer;
+
+import org.apache.geronimo.cli.CLParserException;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev:385659 $ $Date: 2007-03-07 14:40:07 +1100 (Wed, 07 Mar 2007) $
+ */
+public class CommandFileCommandMetaDataTest extends TestCase {
+
+ public void testWithCommandFile() throws Exception {
+ String file = "file";
+ CommandArgs args = CommandFileCommandMetaData.META_DATA.parse(new String[] {file});
+ assertEquals(file, args.getArgs()[0]);
+ }
+
+ public void testWithoutCommandFileFails() throws Exception {
+ try {
+ CommandFileCommandMetaData.META_DATA.parse(new String[0]);
+ fail();
+ } catch (CLParserException e) {
+ }
+ }
+
+ public void testWithMoreThanOneFileFails() throws Exception {
+ try {
+ CommandFileCommandMetaData.META_DATA.parse(new String[] {"file1", "file2"});
+ fail();
+ } catch (CLParserException e) {
+ }
+ }
+
+}
Added: geronimo/server/trunk/modules/geronimo-cli/src/test/java/org/apache/geronimo/cli/deployer/DeployerCLParserTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-cli/src/test/java/org/apache/geronimo/cli/deployer/DeployerCLParserTest.java?view=auto&rev=535507
==============================================================================
--- geronimo/server/trunk/modules/geronimo-cli/src/test/java/org/apache/geronimo/cli/deployer/DeployerCLParserTest.java (added)
+++ geronimo/server/trunk/modules/geronimo-cli/src/test/java/org/apache/geronimo/cli/deployer/DeployerCLParserTest.java Sat May 5 04:22:39 2007
@@ -0,0 +1,123 @@
+/**
+ * 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.geronimo.cli.deployer;
+
+import org.apache.geronimo.cli.CLParserException;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev:385659 $ $Date: 2007-03-07 14:40:07 +1100 (Wed, 07 Mar 2007) $
+ */
+public class DeployerCLParserTest extends TestCase {
+
+ private DeployerCLParser parser;
+
+ @Override
+ protected void setUp() throws Exception {
+ parser = new DeployerCLParser(System.out);
+ }
+
+ public void testNoOptionsSet() throws Exception {
+ String moduleId = "modulID";
+ parser.parse(new String[] {"start", moduleId});
+ assertNull(parser.getURI());
+ assertNull(parser.getHost());
+ assertNull(parser.getPort());
+ assertNull(parser.getDriver());
+ assertNull(parser.getUser());
+ assertNull(parser.getPassword());
+ assertFalse(parser.isSyserr());
+ assertFalse(parser.isOffline());
+
+ assertSame(StartCommandMetaData.META_DATA, parser.getCommandMetaData());
+ CommandArgs commandArgs = parser.getCommandArgs();
+ assertEquals(1, commandArgs.getArgs().length);
+ assertEquals(moduleId, commandArgs.getArgs()[0]);
+ }
+
+ public void testURI() throws Exception {
+ String uri = "uri";
+ parser.parse(new String[] {"-u", uri, "start", "dummyID"});
+ assertEquals(uri, parser.getURI());
+
+ parser.parse(new String[] {"--uri", uri, "start", "dummyID"});
+ assertEquals(uri, parser.getURI());
+ }
+
+ public void testHost() throws Exception {
+ String host = "host";
+ parser.parse(new String[] {"--host", host, "start", "dummyID"});
+ assertEquals(host, parser.getHost());
+ }
+
+ public void testPort() throws Exception {
+ String port = "1";
+ parser.parse(new String[] {"--port", port, "start", "dummyID"});
+ assertEquals(new Integer(1), parser.getPort());
+
+ try {
+ parser.parse(new String[] {"--port", "notAnInteger", "start", "dummyID"});
+ fail();
+ } catch (CLParserException e) {
+ }
+ }
+
+ public void testDriver() throws Exception {
+ String driver = "driver.jar";
+ parser.parse(new String[] {"--driver", driver, "start", "dummyID"});
+ assertEquals(driver, parser.getDriver());
+
+ parser.parse(new String[] {"-d", driver, "start", "dummyID"});
+ assertEquals(driver, parser.getDriver());
+ }
+
+ public void testUser() throws Exception {
+ String user = "username";
+ parser.parse(new String[] {"--user", user, "start", "dummyID"});
+ assertEquals(user, parser.getUser());
+
+ parser.parse(new String[] {"-u", user, "start", "dummyID"});
+ assertEquals(user, parser.getUser());
+ }
+
+ public void testPassword() throws Exception {
+ String password = "password";
+ parser.parse(new String[] {"--password", password, "start", "dummyID"});
+ assertEquals(password, parser.getPassword());
+
+ parser.parse(new String[] {"-p", password, "start", "dummyID"});
+ assertEquals(password, parser.getPassword());
+ }
+
+ public void testSyserr() throws Exception {
+ parser.parse(new String[] {"--syserr", "start", "dummyID"});
+ assertTrue(parser.isSyserr());
+
+ parser.parse(new String[] {"-s", "start", "dummyID"});
+ assertTrue(parser.isSyserr());
+ }
+
+ public void testOffline() throws Exception {
+ parser.parse(new String[] {"--offline", "start", "dummyID"});
+ assertTrue(parser.isOffline());
+
+ parser.parse(new String[] {"-o", "start", "dummyID"});
+ assertTrue(parser.isOffline());
+ }
+
+}
Added: geronimo/server/trunk/modules/geronimo-cli/src/test/java/org/apache/geronimo/cli/deployer/DistributeCommandArgsTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-cli/src/test/java/org/apache/geronimo/cli/deployer/DistributeCommandArgsTest.java?view=auto&rev=535507
==============================================================================
--- geronimo/server/trunk/modules/geronimo-cli/src/test/java/org/apache/geronimo/cli/deployer/DistributeCommandArgsTest.java (added)
+++ geronimo/server/trunk/modules/geronimo-cli/src/test/java/org/apache/geronimo/cli/deployer/DistributeCommandArgsTest.java Sat May 5 04:22:39 2007
@@ -0,0 +1,66 @@
+/**
+ * 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.geronimo.cli.deployer;
+
+import org.apache.geronimo.cli.CLParserException;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev:385659 $ $Date: 2007-03-07 14:40:07 +1100 (Wed, 07 Mar 2007) $
+ */
+public class DistributeCommandArgsTest extends TestCase {
+
+ public void testInPlace() throws Exception {
+ DistributeCommandArgs args = new DistributeCommandArgs(new String[] {"--inPlace", "plan.xml"});
+ assertTrue(args.isInPlace());
+
+ args = new DistributeCommandArgs(new String[] {"-i", "plan.xml"});
+ assertTrue(args.isInPlace());
+ }
+
+ public void testTargets() throws Exception {
+ DistributeCommandArgs args = new DistributeCommandArgs(new String[] {"--targets", "t1;t2", "plan.xml"});
+ String[] targets = args.getTargets();
+ assertEquals(2, targets.length);
+ assertEquals("t1", targets[0]);
+ assertEquals("t2", targets[1]);
+
+ args = new DistributeCommandArgs(new String[] {"-t", "t1;t2", "plan.xml"});
+ targets = args.getTargets();
+ assertEquals(2, targets.length);
+ assertEquals("t1", targets[0]);
+ assertEquals("t2", targets[1]);
+ }
+
+ public void testNoPlanOrModuleFails() throws Exception {
+ try {
+ new DistributeCommandArgs(new String[] {"--targets", "t1;t2"});
+ fail();
+ } catch (CLParserException e) {
+ }
+ }
+
+ public void testTooManyArgsFails() throws Exception {
+ try {
+ new DistributeCommandArgs(new String[] {"plan.xml", "module.jar", "extra"});
+ fail();
+ } catch (CLParserException e) {
+ }
+ }
+
+}