accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ctubb...@apache.org
Subject svn commit: r1479204 - in /accumulo/branches/1.5/core: ./ src/main/java/org/apache/accumulo/core/client/mock/ src/main/java/org/apache/accumulo/core/util/shell/ src/test/java/org/apache/accumulo/core/util/shell/ src/test/resources/
Date Sat, 04 May 2013 22:21:15 GMT
Author: ctubbsii
Date: Sat May  4 22:21:14 2013
New Revision: 1479204

URL: http://svn.apache.org/r1479204
Log:
ACCUMULO-1348 Applied patch from Mike Drob to 1.5 branch

Added:
    accumulo/branches/1.5/core/src/test/resources/shelltest.txt
Modified:
    accumulo/branches/1.5/core/pom.xml
    accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/client/mock/MockShell.java
    accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/Shell.java
    accumulo/branches/1.5/core/src/test/java/org/apache/accumulo/core/util/shell/ShellTest.java

Modified: accumulo/branches/1.5/core/pom.xml
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/core/pom.xml?rev=1479204&r1=1479203&r2=1479204&view=diff
==============================================================================
--- accumulo/branches/1.5/core/pom.xml (original)
+++ accumulo/branches/1.5/core/pom.xml Sat May  4 22:21:14 2013
@@ -109,6 +109,19 @@
     </dependency>
   </dependencies>
   <build>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <groupId>org.apache.rat</groupId>
+          <artifactId>apache-rat-plugin</artifactId>
+          <configuration>
+            <excludes>
+              <exclude>src/test/resources/shelltest.txt</exclude>
+            </excludes>
+          </configuration>
+        </plugin>
+      </plugins>
+    </pluginManagement>
     <plugins>
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>

Modified: accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/client/mock/MockShell.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/client/mock/MockShell.java?rev=1479204&r1=1479203&r2=1479204&view=diff
==============================================================================
--- accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/client/mock/MockShell.java
(original)
+++ accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/client/mock/MockShell.java
Sat May  4 22:21:14 2013
@@ -78,8 +78,13 @@ public class MockShell extends Shell {
     
     if (execFile != null) {
       java.util.Scanner scanner = new java.util.Scanner(new File(execFile));
-      while (scanner.hasNextLine())
-        execCommand(scanner.nextLine(), true, isVerbose());
+      try {
+        while (scanner.hasNextLine() && !hasExited()) {
+          execCommand(scanner.nextLine(), true, isVerbose());
+        }
+      } finally {
+        scanner.close();
+      }
     } else if (execCommand != null) {
       for (String command : execCommand.split("\n")) {
         execCommand(command, true, isVerbose());

Modified: accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/Shell.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/Shell.java?rev=1479204&r1=1479203&r2=1479204&view=diff
==============================================================================
--- accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/Shell.java
(original)
+++ accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/Shell.java
Sat May  4 22:21:14 2013
@@ -246,7 +246,7 @@ public class Shell extends ShellOptions 
     if (sysUser == null)
       sysUser = "root";
     String user = cl.getOptionValue(usernameOption.getOpt(), sysUser);
-
+    
     String passw = cl.getOptionValue(passwOption.getOpt(), null);
     tabCompletion = !cl.hasOption(tabCompleteOption.getLongOpt());
     String[] loginOptions = cl.getOptionValues(loginOption.getOpt());
@@ -261,13 +261,13 @@ public class Shell extends ShellOptions 
       
       if (loginOptions == null && cl.hasOption(tokenOption.getOpt()))
         throw new IllegalArgumentException("Must supply '-" + loginOption.getOpt() + "' option
with '-" + tokenOption.getOpt() + "' option");
-
+      
       if (passw != null && cl.hasOption(tokenOption.getOpt()))
         throw new IllegalArgumentException("Can not supply '-" + passwOption.getOpt() + "'
option with '-" + tokenOption.getOpt() + "' option");
-
+      
       if (user == null)
         throw new MissingArgumentException(usernameOption);
-
+      
       if (loginOptions != null && cl.hasOption(tokenOption.getOpt())) {
         Properties props = new Properties();
         for (String loginOption : loginOptions)
@@ -279,7 +279,7 @@ public class Shell extends ShellOptions 
         this.token = Class.forName(cl.getOptionValue(tokenOption.getOpt())).asSubclass(AuthenticationToken.class).newInstance();
         this.token.init(props);
       }
-
+      
       if (!cl.hasOption(fakeOption.getLongOpt())) {
         DistributedTrace.enable(instance, new ZooReader(instance.getZooKeepers(), instance.getZooKeepersSessionTimeOut()),
"shell", InetAddress.getLocalHost()
             .getHostName());
@@ -438,8 +438,13 @@ public class Shell extends ShellOptions 
     
     if (execFile != null) {
       java.util.Scanner scanner = new java.util.Scanner(new File(execFile));
-      while (scanner.hasNextLine())
-        execCommand(scanner.nextLine(), true, isVerbose());
+      try {
+        while (scanner.hasNextLine() && !hasExited()) {
+          execCommand(scanner.nextLine(), true, isVerbose());
+        }
+      } finally {
+        scanner.close();
+      }
     } else if (execCommand != null) {
       for (String command : execCommand.split("\n")) {
         execCommand(command, true, isVerbose());

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=1479204&r1=1479203&r2=1479204&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
Sat May  4 22:21:14 2013
@@ -163,7 +163,7 @@ public class ShellTest {
   public void userTest() throws Exception {
     Shell.log.debug("Starting user test --------------------------");
     // Test cannot be done via junit because createuser only prompts for password
-    //    exec("createuser root", false, "user exists");
+    // exec("createuser root", false, "user exists");
   }
   
   @Test
@@ -191,4 +191,12 @@ public class ShellTest {
     exec("deletetable t -f", true, "Table: [t] has been deleted");
     exec("deletetable tt -f", true, "Table: [tt] has been deleted");
   }
+  
+  @Test
+  public void execFileTest() throws IOException {
+    Shell.log.debug("Starting exec file test --------------------------");
+    shell.config("--fake", "-u", "test", "-p", "secret", "-f", "src/test/resources/shelltest.txt");
+    assertEquals(0, shell.start());
+    assertGoodExit("Unknown command", false);
+  }
 }

Added: accumulo/branches/1.5/core/src/test/resources/shelltest.txt
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/core/src/test/resources/shelltest.txt?rev=1479204&view=auto
==============================================================================
--- accumulo/branches/1.5/core/src/test/resources/shelltest.txt (added)
+++ accumulo/branches/1.5/core/src/test/resources/shelltest.txt Sat May  4 22:21:14 2013
@@ -0,0 +1,2 @@
+exit
+foo



Mime
View raw message