samples/deadlock/test/org/apidesign/deadlock/logs/ParallelControlFlowTest.java
author Jaroslav Tulach <jtulach@netbeans.org>
Sat, 14 Jun 2008 10:04:53 +0200
changeset 210 acf2c31e22d4
parent 209 1c999569643b
child 263 7e8e995065c5
permissions -rw-r--r--
Merge: Geertjan's changes to the end of the chapter
     1 package org.apidesign.deadlock.logs;
     2 
     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.*;
    14 
    15 public class ParallelControlFlowTest extends NbTestCase {
    16     public ParallelControlFlowTest(String testName) {
    17         super(testName);
    18     }
    19 
    20     @Override
    21     protected Level logLevel() {
    22         return Level.WARNING;
    23     }
    24 
    25 // BEGIN: test.parallel.test.controlflow
    26     public void testMain() throws Exception {
    27         org.netbeans.junit.Log.controlFlow(Logger.global, null,
    28             "THREAD: 1st MSG: cnt: 0" +
    29             "THREAD: 2nd MSG: .*0" +
    30             "THREAD: 1st MSG: ...: 1" +
    31             "THREAD: 2nd MSG: cnt: 1" +
    32             "THREAD: 1st MSG: cnt: 2" +
    33             "THREAD: 2nd MSG: cnt: 2" +
    34             "THREAD: 1st MSG: cnt: 3" +
    35             "THREAD: 2nd MSG: cnt: 3" +
    36             "THREAD: 1st MSG: cnt: 4" +
    37             "THREAD: 2nd MSG: cnt: 4" +
    38             "THREAD: 1st MSG: cnt: 5" +
    39             "THREAD: 2nd MSG: cnt: 5" +
    40             "THREAD: 1st MSG: cnt: 6" +
    41             "THREAD: 2nd MSG: cnt: 6" +
    42             "THREAD: 1st MSG: cnt: 7" +
    43             "THREAD: 2nd MSG: cnt: 7" +
    44             "THREAD: 1st MSG: cnt: 8" +
    45             "THREAD: 2nd MSG: cnt: 8" +
    46             "THREAD: 1st MSG: cnt: 9" +
    47             "THREAD: 2nd MSG: cnt: 9",
    48             500
    49         );
    50         Parallel.main(null);
    51         fail("Ok, just print the logged output");
    52     }
    53 // END: test.parallel.test.controlflow
    54     
    55     
    56     // BEGIN: test.parallel.test.fivetwo
    57     public void testFiveAndThenTwo() throws Exception {
    58         org.netbeans.junit.Log.controlFlow(Logger.global, null,
    59             "THREAD: 1st MSG: cnt: 5" +
    60             "THREAD: 2nd MSG: cnt: 2" +
    61             "THREAD: 1st MSG: cnt: 6",
    62             5000
    63         );
    64         Parallel.main(null);
    65         fail("Ok, just print the logged output");
    66     }
    67     // END: test.parallel.test.fivetwo
    68     
    69 }