[jbosstools-commits] JBoss Tools SVN: r41475 - in trunk: tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext and 1 other directory.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Mon May 28 06:51:49 EDT 2012


Author: jgargula
Date: 2012-05-28 06:51:49 -0400 (Mon, 28 May 2012)
New Revision: 41475

Modified:
   trunk/build/aggregate/soatests-site/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/smoke/DroolsViewsTest.java
   trunk/build/aggregate/soatests-site/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/smoke/RuleFlowTest.java
   trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTUtilExt.java
Log:
Added support for capturing standard output.

Modified: trunk/build/aggregate/soatests-site/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/smoke/DroolsViewsTest.java
===================================================================
--- trunk/build/aggregate/soatests-site/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/smoke/DroolsViewsTest.java	2012-05-28 02:51:02 UTC (rev 41474)
+++ trunk/build/aggregate/soatests-site/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/smoke/DroolsViewsTest.java	2012-05-28 10:51:49 UTC (rev 41475)
@@ -2,8 +2,6 @@
 
 import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.withLabel;
 
-import java.io.ByteArrayOutputStream;
-import java.io.PrintStream;
 import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.List;
@@ -18,6 +16,7 @@
 import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
 import org.jboss.tools.ui.bot.ext.SWTOpenExt;
 import org.jboss.tools.ui.bot.ext.SWTTestExt;
+import org.jboss.tools.ui.bot.ext.SWTUtilExt;
 import org.jboss.tools.ui.bot.ext.Timing;
 import org.jboss.tools.ui.bot.ext.gen.IView;
 import org.jboss.tools.ui.bot.ext.helper.DragAndDropHelper;
@@ -71,7 +70,10 @@
 
         // waits for running debugging
         while (!eclipse.isDebugging()) {
-            bot.sleep(Timing.time500MS());
+            bot.sleep(Timing.time1S());
+        	if (console.getConsoleText().contains("Finished")) {
+                fail("Probably debugging is not stopping at breakpoints.");
+            }
         }
 
         // waits for stopping at breakpoint
@@ -134,13 +136,9 @@
     public void agendaTest() {
         bot.editorByTitle(RULES_FILE).show();
         eclipse.stepOver();
-        // Some hacks to read output stream and check exception
-        PrintStream defaultOutputStream = System.out;
-        ByteArrayOutputStream pipeOut = new ByteArrayOutputStream();
-        System.setOut(new PrintStream(pipeOut));
+        SWTUtilExt.startCapturingStandardOutput();
         openView(IDELabel.View.AGENDA);
-        System.setOut(defaultOutputStream);
-        String output = new String(pipeOut.toByteArray());
+        final String output = SWTUtilExt.stopCapturingStandardOutput();
         System.out.print(output);
         HashSet<Activation> expectedSet = new HashSet<Activation>(2);
         // indicies are not compared

Modified: trunk/build/aggregate/soatests-site/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/smoke/RuleFlowTest.java
===================================================================
--- trunk/build/aggregate/soatests-site/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/smoke/RuleFlowTest.java	2012-05-28 02:51:02 UTC (rev 41474)
+++ trunk/build/aggregate/soatests-site/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/smoke/RuleFlowTest.java	2012-05-28 10:51:49 UTC (rev 41475)
@@ -41,7 +41,6 @@
 import org.jboss.tools.ui.bot.ext.SWTUtilExt;
 import org.jboss.tools.ui.bot.ext.Timing;
 import org.jboss.tools.ui.bot.ext.gen.ActionItem;
-//import org.jboss.tools.ui.bot.ext.helper.KeyboardHelper;
 import org.jboss.tools.ui.bot.ext.types.IDELabel;
 import org.jboss.tools.ui.bot.ext.types.ViewType;
 import org.junit.Test;
@@ -126,8 +125,11 @@
    */
   private void ruleFlowEditorCheck(String ruleFlowFileName) {
     packageExplorer.show();
-    packageExplorer.openFile(DroolsAllBotTests.DROOLS_PROJECT_NAME ,
+    SWTUtilExt.startCapturingStandardOutput();
+    packageExplorer.openFile(DroolsAllBotTests.DROOLS_PROJECT_NAME,
       DroolsAllBotTests.SRC_MAIN_RULES_TREE_NODE, ruleFlowFileName);
+    final String capturedOutput = SWTUtilExt.stopCapturingStandardOutput();
+    System.out.print(capturedOutput);
     // Test if Rule Flow File is opened in editor
     assertTrue("Rule Flow File is not opened properly. File " + ruleFlowFileName + " is not opened in editor",
       SWTEclipseExt.existEditorWithLabel(bot, ruleFlowFileName));
@@ -193,6 +195,9 @@
     gefEditor.save();
     gefEditor.close();
     checkEmptyRuleFile(DroolsAllBotTests.DROOLS_PROJECT_NAME , ruleFlowFileName);
+    assertFalse("Opening BPMN process throws IndexOutOfBoundsException exception."
+            + " Reported bug: https://issues.jboss.org/browse/JBIDE-11984",
+            capturedOutput.contains("IndexOutOfBoundsException"));
   }
 
     /**

Modified: trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTUtilExt.java
===================================================================
--- trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTUtilExt.java	2012-05-28 02:51:02 UTC (rev 41474)
+++ trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTUtilExt.java	2012-05-28 10:51:49 UTC (rev 41475)
@@ -16,10 +16,12 @@
 import static org.junit.Assert.fail;
 
 import java.io.BufferedReader;
+import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.FileReader;
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.PrintStream;
 import java.lang.reflect.InvocationTargetException;
 import java.util.ArrayList;
 import java.util.Iterator;
@@ -72,7 +74,7 @@
  */
 public class SWTUtilExt extends SWTUtils {
 
-	private Logger log = Logger.getLogger(SWTUtilExt.class);
+	private static Logger log = Logger.getLogger(SWTUtilExt.class);
 	protected SWTWorkbenchBot bot;
 	
 	private static class AlwaysMatchMatcher<T extends Widget> extends BaseMatcher<T> {
@@ -853,4 +855,41 @@
         return new SWTBotMenu(menuItem, matcher);
     }
 
+    /********** CAPTURING OF STANDARD OUTPUT **********/
+
+    /**
+     * Default output stream before redirecting.
+     */
+    private static PrintStream defaultOutputStream = System.out;
+    /**
+     * Redirected output stream for capturing output.
+     */
+    private static ByteArrayOutputStream capturingByteArrayOutputStream = null;
+
+    /**
+     * Starts capturing of standard output.
+     * Redirects standard output into other <code>PrintStream</code>
+     * which is captured.
+     */
+    public static void startCapturingStandardOutput() {
+        capturingByteArrayOutputStream = new ByteArrayOutputStream();
+        System.setOut(new PrintStream(capturingByteArrayOutputStream));
+        log.info("Capturing of standard output was started.");
+    }
+
+    /**
+     * Stops capturing of standard output by setting the default standard output.
+     * 
+     * @return Captured output.
+     */
+    public static String stopCapturingStandardOutput() {
+        System.setOut(defaultOutputStream);
+        final String capturedOutput = new String(capturingByteArrayOutputStream.toByteArray());
+        capturingByteArrayOutputStream = null;
+        log.info("Capturing of standard output was stopped.");
+        return capturedOutput;
+    }
+
+    /********** END OF CAPTURING OF STANDARD OUTPUT **********/
+
 }
\ No newline at end of file



More information about the jbosstools-commits mailing list