1 package org.apidesign.deadlock.logs;
3 import java.util.logging.Handler;
4 import java.util.logging.Level;
5 import java.util.logging.LogRecord;
6 import java.util.logging.Logger;
7 import org.netbeans.junit.NbTestCase;
8 import static org.junit.Assert.*;
10 // BEGIN: test.parallel.test.sorted
11 public class ParallelSortedTest extends NbTestCase {
12 public ParallelSortedTest(String testName) {
17 protected Level logLevel() {
21 public void testMain() throws Exception {
22 Logger.global.addHandler(new BlockingHandler());
24 if (Boolean.getBoolean("no.failures")) return;
25 fail("Ok, just print the logged output");
28 private static final class BlockingHandler extends Handler {
32 public synchronized void publish(LogRecord record) {
33 if (!record.getMessage().startsWith("cnt")) {
36 boolean snd = Thread.currentThread().getName().equals("2nd");
37 if (runSecond == snd) {
39 runSecond = !runSecond;
43 } catch (InterruptedException ex) {
54 // END: test.parallel.test.sorted