You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by kt...@apache.org on 2013/05/07 17:03:11 UTC

svn commit: r1479932 - in /accumulo/branches/1.5/core/src: main/java/org/apache/accumulo/core/util/shell/commands/SetIterCommand.java test/java/org/apache/accumulo/core/util/shell/ShellTest.java

Author: kturner
Date: Tue May  7 15:03:11 2013
New Revision: 1479932

URL: http://svn.apache.org/r1479932
Log:
ACCUMULO-1358 Appled patch from Mike Drob, with modification to delete table in unit test.

Modified:
    accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/commands/SetIterCommand.java
    accumulo/branches/1.5/core/src/test/java/org/apache/accumulo/core/util/shell/ShellTest.java

Modified: accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/commands/SetIterCommand.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/commands/SetIterCommand.java?rev=1479932&r1=1479931&r2=1479932&view=diff
==============================================================================
--- accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/commands/SetIterCommand.java (original)
+++ accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/commands/SetIterCommand.java Tue May  7 15:03:11 2013
@@ -175,14 +175,23 @@ public class SetIterCommand extends Comm
       clazz = classloader.loadClass(className).asSubclass(OptionDescriber.class);
       skvi = clazz.newInstance();
     } catch (ClassNotFoundException e) {
-      throw new IllegalArgumentException(e.getMessage());
+      StringBuilder msg = new StringBuilder("Unable to load ").append(className);
+      if (className.indexOf('.') < 0) {
+        msg.append("; did you use a fully qualified package name?");
+      } else {
+        msg.append("; class not found.");
+      }
+      throw new ShellCommandException(ErrorCode.INITIALIZATION_FAILURE, msg.toString());
     } catch (InstantiationException e) {
       throw new IllegalArgumentException(e.getMessage());
     } catch (IllegalAccessException e) {
       throw new IllegalArgumentException(e.getMessage());
     } catch (ClassCastException e) {
-      throw new ShellCommandException(ErrorCode.INITIALIZATION_FAILURE, "Unable to load " + className + " as type " + OptionDescriber.class.getName()
-          + "; configure with 'config' instead");
+      StringBuilder msg = new StringBuilder("Loaded ");
+      msg.append(className).append(" but it does not implement ");
+      msg.append(OptionDescriber.class.getSimpleName());
+      msg.append("; use 'config -s' instead.");
+      throw new ShellCommandException(ErrorCode.INITIALIZATION_FAILURE, msg.toString());
     }
     
     final IteratorOptions itopts = skvi.describeOptions();

Modified: accumulo/branches/1.5/core/src/test/java/org/apache/accumulo/core/util/shell/ShellTest.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/core/src/test/java/org/apache/accumulo/core/util/shell/ShellTest.java?rev=1479932&r1=1479931&r2=1479932&view=diff
==============================================================================
--- accumulo/branches/1.5/core/src/test/java/org/apache/accumulo/core/util/shell/ShellTest.java (original)
+++ accumulo/branches/1.5/core/src/test/java/org/apache/accumulo/core/util/shell/ShellTest.java Tue May  7 15:03:11 2013
@@ -199,4 +199,23 @@ public class ShellTest {
     assertEquals(0, shell.start());
     assertGoodExit("Unknown command", false);
   }
+  
+  @Test
+  public void setIterTest() throws IOException {
+    Shell.log.debug("Starting setiter test --------------------------");
+    exec("createtable t", true);
+    
+    String cmdJustClass = "setiter -class VersioningIterator -p 1";
+    exec(cmdJustClass, false, "java.lang.IllegalArgumentException", false);
+    exec(cmdJustClass, false, "fully qualified package name", true);
+    
+    String cmdFullPackage = "setiter -class o.a.a.foo -p 1";
+    exec(cmdFullPackage, false, "java.lang.IllegalArgumentException", false);
+    exec(cmdFullPackage, false, "class not found", true);
+    
+    String cmdNoOption = "setiter -class java.lang.String -p 1";
+    exec(cmdNoOption, false, "Loaded", true);
+    
+    exec("deletetable t -f", true, "Table: [t] has been deleted");
+  }
 }