geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tush...@apache.org
Subject [2/6] incubator-geode git commit: Adding remaining methods in HeadlessGfsh to get parity with TestableGfsh Fixing issue with exit command in HeadlessGfsh
Date Thu, 05 Nov 2015 10:44:57 GMT
Adding remaining methods in HeadlessGfsh to get parity with TestableGfsh
Fixing issue with exit command in HeadlessGfsh


Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/876b00ab
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/876b00ab
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/876b00ab

Branch: refs/heads/feature/GEODE-17
Commit: 876b00abd249370665769edaab9b3649578c26fc
Parents: 0ba0aee
Author: tushark <tushark@apache.org>
Authored: Thu Nov 5 16:00:39 2015 +0530
Committer: tushark <tushark@apache.org>
Committed: Thu Nov 5 16:00:39 2015 +0530

----------------------------------------------------------------------
 .../internal/security/HeadlessGfsh.java         | 30 +++++++++++++++++---
 .../security/HeadlessGfshJUnitTest.java         |  9 +++++-
 2 files changed, 34 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/876b00ab/gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/security/HeadlessGfsh.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/security/HeadlessGfsh.java
b/gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/security/HeadlessGfsh.java
index d73a260..6622710 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/security/HeadlessGfsh.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/security/HeadlessGfsh.java
@@ -83,9 +83,17 @@ public class HeadlessGfsh  implements ResultHandler {
   }
   
   public Object getResult() throws InterruptedException {
-    Object result = queue.poll(timeout, TimeUnit.SECONDS);
-    queue.clear();
-    return result;
+    //Dont wait for when some command calls gfsh.stop();
+    if(shell.stopCalledThroughAPI)
+      return null;
+    try {
+      Object result = queue.poll(timeout, TimeUnit.SECONDS);
+      queue.clear();
+      return result;
+    } catch (InterruptedException e) {
+      e.printStackTrace();
+      throw e;
+    }
   }
   
   public void clear(){
@@ -93,6 +101,11 @@ public class HeadlessGfsh  implements ResultHandler {
     outputString = null;
   }
   
+  public void clearEvents(){
+    queue.clear();
+    outputString = null;
+  }
+  
   public void terminate() {    
     shell.terminate();
   }
@@ -107,7 +120,11 @@ public class HeadlessGfsh  implements ResultHandler {
 
   public boolean hasError() {
     return shell.hasError();
-  }   
+  }
+  
+  public String getError() {
+    return shell.errorString;
+  }
   
   public static class HeadlessGfshShell extends Gfsh {
 
@@ -117,6 +134,7 @@ public class HeadlessGfsh  implements ResultHandler {
     private ByteArrayOutputStream output = null;
     private String errorString = null;
     private boolean hasError = false;
+    boolean stopCalledThroughAPI=false;
 
     protected HeadlessGfshShell(String testName, ResultHandler handler) throws ClassNotFoundException,
IOException {
       super(false, new String[] {}, new HeadlessGfshConfig(testName));
@@ -149,6 +167,10 @@ public class HeadlessGfsh  implements ResultHandler {
       stop();
     }
     
+    public void stop(){
+      stopCalledThroughAPI = true;
+    }
+    
     private void stopPromptLoop() {
       lock.lock();
       try {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/876b00ab/gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/security/HeadlessGfshJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/security/HeadlessGfshJUnitTest.java
b/gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/security/HeadlessGfshJUnitTest.java
index a5abc33..ff30fe4 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/security/HeadlessGfshJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/security/HeadlessGfshJUnitTest.java
@@ -47,7 +47,7 @@ public class HeadlessGfshJUnitTest {
     cache = (GemFireCacheImpl) CacheFactory.create(ds);
     ObjectName name = MBeanJMXAdapter.getDistributedSystemName();
     
-    HeadlessGfsh gfsh = new HeadlessGfsh("Test",20);
+    HeadlessGfsh gfsh = new HeadlessGfsh("Test",25);
     for(int i=0;i<5;i++) {
       gfsh.executeCommand("connect --jmx-manager=localhost["+port+"]");
       Object result = gfsh.getResult();
@@ -60,6 +60,13 @@ public class HeadlessGfshJUnitTest {
       gfsh.executeCommand("disconnect");
       gfsh.getResult();
     }
+    
+    long l1 = System.currentTimeMillis();
+    gfsh.executeCommand("exit");
+    long l2 = System.currentTimeMillis();
+    gfsh.getResult();
+    long l3 = System.currentTimeMillis();
+    System.out.println("L3-l2="+ (l3-l2) + " Total time= " + (l3-l1)/1000);
     gfsh.terminate();    
     cache.close();
     ds.disconnect();


Mime
View raw message