accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From medi...@apache.org
Subject svn commit: r1377480 - /accumulo/trunk/server/src/main/java/org/apache/accumulo/server/test/functional/FunctionalTest.java
Date Sun, 26 Aug 2012 18:49:06 GMT
Author: medined
Date: Sun Aug 26 18:49:06 2012
New Revision: 1377480

URL: http://svn.apache.org/viewvc?rev=1377480&view=rev
Log:
ACCUMULO-742: In FunctionalTest, display CLI parameters upon parse error

Modified:
    accumulo/trunk/server/src/main/java/org/apache/accumulo/server/test/functional/FunctionalTest.java

Modified: accumulo/trunk/server/src/main/java/org/apache/accumulo/server/test/functional/FunctionalTest.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/server/src/main/java/org/apache/accumulo/server/test/functional/FunctionalTest.java?rev=1377480&r1=1377479&r2=1377480&view=diff
==============================================================================
--- accumulo/trunk/server/src/main/java/org/apache/accumulo/server/test/functional/FunctionalTest.java
(original)
+++ accumulo/trunk/server/src/main/java/org/apache/accumulo/server/test/functional/FunctionalTest.java
Sun Aug 26 18:49:06 2012
@@ -45,10 +45,10 @@ import org.apache.accumulo.server.conf.S
 import org.apache.accumulo.start.classloader.AccumuloClassLoader;
 import org.apache.commons.cli.BasicParser;
 import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.HelpFormatter;
 import org.apache.commons.cli.Option;
 import org.apache.commons.cli.Options;
 import org.apache.commons.cli.ParseException;
-import org.apache.commons.cli.Parser;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.io.Text;
@@ -271,14 +271,11 @@ public abstract class FunctionalTest {
   }
   
   public static void main(String[] args) throws Exception {
-    Parser p = new BasicParser();
-    
     CommandLine cl = null;
     try {
-      cl = p.parse(opts, args);
+      cl = new BasicParser().parse(opts, args);
     } catch (ParseException e) {
-      System.out.println("Parse Exception, exiting.");
-      return;
+      printHelpAndExit(e.toString());
     }
     
     String master = cl.getOptionValue(masterOpt.getOpt(), "localhost");
@@ -287,6 +284,9 @@ public abstract class FunctionalTest {
     String instanceName = cl.getOptionValue(instanceNameOpt.getOpt(), "FuncTest");
     
     String remainingArgs[] = cl.getArgs();
+    if (remainingArgs.length < 2) {
+      printHelpAndExit("Missing java classname to test and/or options.");
+    }
     String clazz = remainingArgs[0];
     String opt = remainingArgs[1];
     
@@ -311,9 +311,18 @@ public abstract class FunctionalTest {
       fTest.run();
     } else if (opt.equals("cleanup")) {
       fTest.cleanup();
+    } else {
+    	printHelpAndExit("Unknown option: " + opt);
     }
     
   }
+
+  static void printHelpAndExit(String message) {
+      System.out.println(message);
+      HelpFormatter formatter = new HelpFormatter();
+      formatter.printHelp( "FunctionalTest {options} java_class [getconfig|setup|run|cleanup]",
opts );
+      System.exit(1);
+  }
   
   static Mutation nm(String row, String cf, String cq, Value value) {
     Mutation m = new Mutation(new Text(row));



Mime
View raw message