Unifying test that fails too often with a hope that it will produce reasonable error message next time
1.1 --- a/dispatch/test/unit/src/net/sf/dvbcentral/dispatch/StreamingTest.java Fri Apr 10 06:14:38 2009 +0200
1.2 +++ b/dispatch/test/unit/src/net/sf/dvbcentral/dispatch/StreamingTest.java Fri Apr 10 10:00:03 2009 +0200
1.3 @@ -92,30 +92,24 @@
1.4 frontend.useRandom(System.currentTimeMillis());
1.5
1.6 dispatch.addDispatchListener(1, this);
1.7 -
1.8 - synchronized (this) {
1.9 - while (expectingCnt < 10000) {
1.10 - wait();
1.11 -
1.12 - if (err != null) {
1.13 - break;
1.14 - }
1.15 - }
1.16 - }
1.17 -
1.18 - if (err != null) {
1.19 - fail("Not all data delivered: " + expectingCnt + "\n: err: " + err);
1.20 - }
1.21 - logCheck();
1.22 + checkLoop();
1.23 }
1.24 public void testRandomSequenceOfReadsWith1151835179020() throws Exception {
1.25 frontend.useRandom(1151835179020L);
1.26
1.27 dispatch.addDispatchListener(1, this);
1.28 + checkLoop();
1.29 + }
1.30 +
1.31 + private void checkLoop() throws Exception {
1.32
1.33 while (expectingCnt < 10000) {
1.34 synchronized (this) {
1.35 + long before = System.currentTimeMillis();
1.36 wait(5000);
1.37 + if (System.currentTimeMillis() - before > 4500) {
1.38 + fail("Too long waiting and only cnt: " + expectingCnt);
1.39 + }
1.40 }
1.41
1.42 if (err != null) {