From 3d30e142c1f7035b5e419190101d848fb465b987 Mon Sep 17 00:00:00 2001 From: zzz <zzz@mail.i2p> Date: Fri, 18 Feb 2011 15:37:56 +0000 Subject: [PATCH] fix LogSettingsTest hang on fail --- .../test/net/i2p/util/LogSettingsTest.java | 39 ++++++++++++++----- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/core/java/test/net/i2p/util/LogSettingsTest.java b/core/java/test/net/i2p/util/LogSettingsTest.java index b4de805f09..529190a77c 100644 --- a/core/java/test/net/i2p/util/LogSettingsTest.java +++ b/core/java/test/net/i2p/util/LogSettingsTest.java @@ -89,8 +89,12 @@ public class LogSettingsTest extends TestCase { log.error("DEBUG" + ": error"); log.log(Log.CRIT, "DEBUG" + ": crit"); - // The following will take about 10 seconds as we wait for the - // LogWriter to flush. There is no public flush() method + // Wait for the LogWriter to flush, then write extra stuff so + // the test doesn't hang on failure + try { Thread.sleep(12*1000); } catch (InterruptedException ie) {} + for (int i = 0; i < 5; i++) + pout.println(""); + pout.flush(); String l1 = in.readLine(); String l2 = in.readLine(); String l3 = in.readLine(); @@ -134,8 +138,12 @@ public class LogSettingsTest extends TestCase { log.error("INFO" + ": error"); log.log(Log.CRIT, "INFO" + ": crit"); - // The following will take about 10 seconds as we wait for the - // LogWriter to flush. There is no public flush() method + // Wait for the LogWriter to flush, then write extra stuff so + // the test doesn't hang on failure + try { Thread.sleep(12*1000); } catch (InterruptedException ie) {} + for (int i = 0; i < 4; i++) + pout.println(""); + pout.flush(); String l1 = in.readLine(); String l2 = in.readLine(); String l3 = in.readLine(); @@ -177,8 +185,12 @@ public class LogSettingsTest extends TestCase { log.error("WARN" + ": error"); log.log(Log.CRIT, "WARN" + ": crit"); - // The following will take about 10 seconds as we wait for the - // LogWriter to flush. There is no public flush() method + // Wait for the LogWriter to flush, then write extra stuff so + // the test doesn't hang on failure + try { Thread.sleep(12*1000); } catch (InterruptedException ie) {} + for (int i = 0; i < 3; i++) + pout.println(""); + pout.flush(); String l1 = in.readLine(); String l2 = in.readLine(); String l3 = in.readLine(); @@ -217,8 +229,12 @@ public class LogSettingsTest extends TestCase { log.error("ERROR" + ": error"); log.log(Log.CRIT, "ERROR" + ": crit"); - // The following will take about 10 seconds as we wait for the - // LogWriter to flush. There is no public flush() method + // Wait for the LogWriter to flush, then write extra stuff so + // the test doesn't hang on failure + try { Thread.sleep(12*1000); } catch (InterruptedException ie) {} + for (int i = 0; i < 2; i++) + pout.println(""); + pout.flush(); String l1 = in.readLine(); String l2 = in.readLine(); @@ -255,8 +271,11 @@ public class LogSettingsTest extends TestCase { log.error("CRIT" + ": error"); log.log(Log.CRIT, "CRIT" + ": crit"); - // The following will take about 10 seconds as we wait for the - // LogWriter to flush. There is no public flush() method + // Wait for the LogWriter to flush, then write extra stuff so + // the test doesn't hang on failure + try { Thread.sleep(12*1000); } catch (InterruptedException ie) {} + pout.println(""); + pout.flush(); String l1 = in.readLine(); assertTrue( -- GitLab