directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject [directory-studio] branch master updated: Improve test execution and condition checks
Date Mon, 21 May 2018 07:12:53 GMT
This is an automated email from the ASF dual-hosted git repository.

seelmann pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/directory-studio.git


The following commit(s) were added to refs/heads/master by this push:
     new fc9aec7  Improve test execution and condition checks
fc9aec7 is described below

commit fc9aec7add3ab02abb412f9744ec79a33ccc02a9
Author: Stefan Seelmann <mail@stefan-seelmann.de>
AuthorDate: Mon May 21 09:12:42 2018 +0200

    Improve test execution and condition checks
---
 .../test/integration/ui/ApacheDSPluginTest.java    | 13 +++++++++++-
 .../ui/bots/ApacheDSServersViewBot.java            | 17 ++++++++++++++--
 .../test/integration/ui/bots/ConsoleViewBot.java   | 23 ++++++++++++++++++++++
 3 files changed, 50 insertions(+), 3 deletions(-)

diff --git a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/ApacheDSPluginTest.java
b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/ApacheDSPluginTest.java
index 5d70349..5f50cea 100644
--- a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/ApacheDSPluginTest.java
+++ b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/ApacheDSPluginTest.java
@@ -44,6 +44,8 @@ import org.apache.directory.studio.test.integration.ui.bots.ModificationLogsView
 import org.apache.directory.studio.test.integration.ui.bots.NewApacheDSServerWizardBot;
 import org.apache.directory.studio.test.integration.ui.bots.StudioBot;
 import org.apache.directory.studio.test.integration.ui.bots.utils.FrameworkRunnerWithScreenshotCaptureListener;
+import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences;
+import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -75,6 +77,14 @@ public class ApacheDSPluginTest
     }
 
 
+    @After
+    public void tearDown() throws Exception
+    {
+        connectionsViewBot.deleteTestConnections();
+        serversViewBot.deleteTestServers();
+    }
+
+
     /**
      * Run the following tests:
      * <ul>
@@ -405,10 +415,11 @@ public class ApacheDSPluginTest
 
         // Repair the server
         serversViewBot.repairServer( serverName );
+        consoleViewBot.waitForConsoleText("Database repaired");
         serversViewBot.waitForServerStop( serverName );
 
         // Wait a bit more after repair, another weird race condition...
-        BotUtils.sleep( 5000 );
+        BotUtils.sleep( SWTBotPreferences.TIMEOUT );
 
         // Start the server after repair
         serversViewBot.runServer( serverName );
diff --git a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ApacheDSServersViewBot.java
b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ApacheDSServersViewBot.java
index 46ba9fb..e1171ee 100644
--- a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ApacheDSServersViewBot.java
+++ b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ApacheDSServersViewBot.java
@@ -20,12 +20,15 @@
 package org.apache.directory.studio.test.integration.ui.bots;
 
 
+import java.util.ArrayList;
+
 import org.apache.directory.studio.ldapservers.LdapServersManager;
 import org.apache.directory.studio.ldapservers.model.LdapServer;
 import org.apache.directory.studio.ldapservers.model.LdapServerStatus;
 import org.apache.directory.studio.test.integration.ui.ContextMenuHelper;
 import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
 import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
+import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences;
 import org.eclipse.swtbot.swt.finder.waits.DefaultCondition;
 import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
 import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
@@ -224,7 +227,7 @@ public class ApacheDSServersViewBot
             {
                 return "Server " + serverName + " not started in servers view.";
             }
-        }, 60000 );
+        }, SWTBotPreferences.TIMEOUT * 20 );
     }
 
 
@@ -254,7 +257,7 @@ public class ApacheDSServersViewBot
             {
                 return "Server " + serverName + " not stopped in servers view.";
             }
-        }, 30000 );
+        }, SWTBotPreferences.TIMEOUT * 10 );
 
         // Wait a bit more to avoid unknown race conditions...
         BotUtils.sleep( 1000 );
@@ -300,4 +303,14 @@ public class ApacheDSServersViewBot
 
         return 0;
     }
+
+
+    public void deleteTestServers()
+    {
+        LdapServersManager ldapServersManager = LdapServersManager.getDefault();
+        for ( LdapServer server : new ArrayList<>( ldapServersManager.getServersList()
) )
+        {
+            ldapServersManager.removeServer( server );
+        }
+    }
 }
diff --git a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ConsoleViewBot.java
b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ConsoleViewBot.java
index 9d7bd5c..ae5f8f5 100644
--- a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ConsoleViewBot.java
+++ b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ConsoleViewBot.java
@@ -22,6 +22,8 @@ package org.apache.directory.studio.test.integration.ui.bots;
 
 import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
 import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
+import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences;
+import org.eclipse.swtbot.swt.finder.waits.DefaultCondition;
 
 
 public class ConsoleViewBot
@@ -43,4 +45,25 @@ public class ConsoleViewBot
         return view.bot().styledText().getText();
     }
 
+
+    public void waitForConsoleText( String text )
+    {
+        bot.waitUntil( new DefaultCondition()
+        {
+
+            @Override
+            public boolean test() throws Exception
+            {
+                return getConsoleText().contains( text );
+            }
+
+
+            @Override
+            public String getFailureMessage()
+            {
+                return "Text " + text + " was not found in console";
+            }
+        }, SWTBotPreferences.TIMEOUT * 20 );
+    }
+
 }

-- 
To stop receiving notification emails like this one, please contact
seelmann@apache.org.

Mime
View raw message