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