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.junit.After;
8 import org.junit.AfterClass;
9 import org.junit.Before;
10 import org.junit.BeforeClass;
11 import org.junit.Test;
12 import org.netbeans.junit.NbTestCase;
13 import static org.junit.Assert.*;
15 // BEGIN: test.parallel.test.sorted
16 public class ParallelSortedTest extends NbTestCase {
17 public ParallelSortedTest(String testName) {
22 protected Level logLevel() {
26 public void testMain() throws Exception {
27 Logger.global.addHandler(new BlockingHandler());
29 fail("Ok, just print the logged output");
32 private static final class BlockingHandler extends Handler {
36 public synchronized void publish(LogRecord record) {
37 if (!record.getMessage().startsWith("cnt")) {
40 boolean snd = Thread.currentThread().getName().equals("2nd");
41 if (runSecond == snd) {
43 runSecond = !runSecond;
47 } catch (InterruptedException ex) {
58 // END: test.parallel.test.sorted