equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
38 private static void checkBroken(final CyclicBarrier barrier) { |
38 private static void checkBroken(final CyclicBarrier barrier) { |
39 check(barrier.isBroken()); |
39 check(barrier.isBroken()); |
40 equal(barrier.getNumberWaiting(), 0); |
40 equal(barrier.getNumberWaiting(), 0); |
41 |
41 |
42 THROWS(BrokenBarrierException.class, |
42 THROWS(BrokenBarrierException.class, |
43 new Fun() { public void f() throws Throwable { |
43 () -> barrier.await(), |
44 barrier.await(); }}, |
44 () -> barrier.await(100, MILLISECONDS)); |
45 new Fun() { public void f() throws Throwable { |
|
46 barrier.await(100, MILLISECONDS); }}); |
|
47 } |
45 } |
48 |
46 |
49 private static void reset(CyclicBarrier barrier) { |
47 private static void reset(CyclicBarrier barrier) { |
50 barrier.reset(); |
48 barrier.reset(); |
51 check(! barrier.isBroken()); |
49 check(! barrier.isBroken()); |
415 else fail(x + " not equal to " + y);} |
413 else fail(x + " not equal to " + y);} |
416 public static void main(String[] args) throws Throwable { |
414 public static void main(String[] args) throws Throwable { |
417 try {realMain(args);} catch (Throwable t) {unexpected(t);} |
415 try {realMain(args);} catch (Throwable t) {unexpected(t);} |
418 System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed); |
416 System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed); |
419 if (failed > 0) throw new AssertionError("Some tests failed");} |
417 if (failed > 0) throw new AssertionError("Some tests failed");} |
420 abstract static class Fun { abstract void f() throws Throwable; } |
418 interface Fun {void f() throws Throwable;} |
421 private static void THROWS(Class<? extends Throwable> k, Fun... fs) { |
419 private static void THROWS(Class<? extends Throwable> k, Fun... fs) { |
422 for (Fun f : fs) |
420 for (Fun f : fs) |
423 try { f.f(); fail("Expected " + k.getName() + " not thrown"); } |
421 try { f.f(); fail("Expected " + k.getName() + " not thrown"); } |
424 catch (Throwable t) { |
422 catch (Throwable t) { |
425 if (k.isAssignableFrom(t.getClass())) pass(); |
423 if (k.isAssignableFrom(t.getClass())) pass(); |