jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fschumac...@apache.org
Subject svn commit: r1671295 - /jmeter/trunk/test/src/org/apache/jmeter/engine/DistributedRunnerTest.java
Date Sat, 04 Apr 2015 19:11:37 GMT
Author: fschumacher
Date: Sat Apr  4 19:11:37 2015
New Revision: 1671295

URL: http://svn.apache.org/r1671295
Log:
Omit exptected error messages while running tests.

Bugzilla Id: 57793

Modified:
    jmeter/trunk/test/src/org/apache/jmeter/engine/DistributedRunnerTest.java

Modified: jmeter/trunk/test/src/org/apache/jmeter/engine/DistributedRunnerTest.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/engine/DistributedRunnerTest.java?rev=1671295&r1=1671294&r2=1671295&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/engine/DistributedRunnerTest.java (original)
+++ jmeter/trunk/test/src/org/apache/jmeter/engine/DistributedRunnerTest.java Sat Apr  4 19:11:37
2015
@@ -18,8 +18,10 @@
 
 package org.apache.jmeter.engine;
 
+import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.IOException;
+import java.io.PrintStream;
 import java.net.MalformedURLException;
 import java.rmi.NotBoundException;
 import java.rmi.RemoteException;
@@ -70,17 +72,25 @@ public class DistributedRunnerTest exten
         JMeterUtils.setProperty(DistributedRunner.CONTINUE_ON_FAIL, "true");
         DistributedRunnerEmul obj = new DistributedRunnerEmul();
         List<String> hosts = Arrays.asList("test1", "test2");
-        try {
-            obj.init(hosts, new HashTree());
-            fail();
-        } catch (RuntimeException ignored) {
-        }
+        initRunner(obj, hosts);
         obj.start();
         obj.shutdown(hosts);
         obj.stop(hosts);
         obj.exit(hosts);
     }
 
+    private void initRunner(DistributedRunnerEmul runner, List<String> hosts) {
+        PrintStream origSystemOut = System.out;
+        ByteArrayOutputStream catchingOut = new ByteArrayOutputStream();
+        System.setOut(new PrintStream(catchingOut));
+        try {
+            runner.init(hosts, new HashTree());
+            fail();
+        } catch (RuntimeException ignored) {
+        }
+        System.setOut(origSystemOut);
+    }
+
     public void testFailure2() throws Exception {
         createJmeterEnv();
         JMeterUtils.setProperty(DistributedRunner.RETRIES_NUMBER, "1");
@@ -88,11 +98,7 @@ public class DistributedRunnerTest exten
         JMeterUtils.setProperty(DistributedRunner.CONTINUE_ON_FAIL, "false");
         DistributedRunnerEmul obj = new DistributedRunnerEmul();
         List<String> hosts = Arrays.asList("test1", "test2");
-        try {
-            obj.init(hosts, new HashTree());
-            fail();
-        } catch (RuntimeException ignored) {
-        }
+        initRunner(obj, hosts);
     }
 
     public void testFailure3() throws Exception {
@@ -102,11 +108,7 @@ public class DistributedRunnerTest exten
         JMeterUtils.setProperty(DistributedRunner.CONTINUE_ON_FAIL, "true");
         DistributedRunnerEmul obj = new DistributedRunnerEmul();
         List<String> hosts = Arrays.asList("test1", "test2");
-        try {
-            obj.init(hosts, new HashTree());
-            fail();
-        } catch (RuntimeException ignored) {
-        }
+        initRunner(obj, hosts);
         obj.start(hosts);
         obj.shutdown(hosts);
         obj.stop(hosts);



Mime
View raw message