samples/deadlock/test/org/apidesign/deadlock/logs/ParallelControlFlowTest.java
author Jaroslav Tulach <jtulach@netbeans.org>
Sat, 14 Jun 2008 18:51:38 +0200
changeset 263 7e8e995065c5
parent 210 acf2c31e22d4
permissions -rw-r--r--
Tests of all modules are executed and can fail the build
     1 package org.apidesign.deadlock.logs;
     2 
     3 import java.util.logging.Level;
     4 import java.util.logging.Logger;
     5 import org.netbeans.junit.NbTestCase;
     6 import static org.junit.Assert.*;
     7 
     8 public class ParallelControlFlowTest extends NbTestCase {
     9     public ParallelControlFlowTest(String testName) {
    10         super(testName);
    11     }
    12 
    13     @Override
    14     protected Level logLevel() {
    15         return Level.WARNING;
    16     }
    17 
    18 // BEGIN: test.parallel.test.controlflow
    19     public void testMain() throws Exception {
    20         org.netbeans.junit.Log.controlFlow(Logger.global, null,
    21             "THREAD: 1st MSG: cnt: 0" +
    22             "THREAD: 2nd MSG: .*0" +
    23             "THREAD: 1st MSG: ...: 1" +
    24             "THREAD: 2nd MSG: cnt: 1" +
    25             "THREAD: 1st MSG: cnt: 2" +
    26             "THREAD: 2nd MSG: cnt: 2" +
    27             "THREAD: 1st MSG: cnt: 3" +
    28             "THREAD: 2nd MSG: cnt: 3" +
    29             "THREAD: 1st MSG: cnt: 4" +
    30             "THREAD: 2nd MSG: cnt: 4" +
    31             "THREAD: 1st MSG: cnt: 5" +
    32             "THREAD: 2nd MSG: cnt: 5" +
    33             "THREAD: 1st MSG: cnt: 6" +
    34             "THREAD: 2nd MSG: cnt: 6" +
    35             "THREAD: 1st MSG: cnt: 7" +
    36             "THREAD: 2nd MSG: cnt: 7" +
    37             "THREAD: 1st MSG: cnt: 8" +
    38             "THREAD: 2nd MSG: cnt: 8" +
    39             "THREAD: 1st MSG: cnt: 9" +
    40             "THREAD: 2nd MSG: cnt: 9",
    41             500
    42         );
    43         Parallel.main(null);
    44         if (Boolean.getBoolean("no.failures")) return;
    45         fail("Ok, just print the logged output");
    46     }
    47 // END: test.parallel.test.controlflow
    48     
    49     
    50     // BEGIN: test.parallel.test.fivetwo
    51     public void testFiveAndThenTwo() throws Exception {
    52         org.netbeans.junit.Log.controlFlow(Logger.global, null,
    53             "THREAD: 1st MSG: cnt: 5" +
    54             "THREAD: 2nd MSG: cnt: 2" +
    55             "THREAD: 1st MSG: cnt: 6",
    56             5000
    57         );
    58         Parallel.main(null);
    59         if (Boolean.getBoolean("no.failures")) return;
    60         fail("Ok, just print the logged output");
    61     }
    62     // END: test.parallel.test.fivetwo
    63     
    64 }