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