rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/tck/NotifyWaitTest.java
author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
Wed, 19 Nov 2014 19:32:00 +0100
changeset 1723 3a1f262311cf
parent 1513 rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/NotifyWaitTest.java@ba912ef24b27
child 1787 ea12a3bb4b33
permissions -rw-r--r--
Separating compact profile tests into own project, so launcher.http can depend on compact profile JAR
jaroslav@425
     1
/**
jaroslav@425
     2
 * Back 2 Browser Bytecode Translator
jaroslav@425
     3
 * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
jaroslav@425
     4
 *
jaroslav@425
     5
 * This program is free software: you can redistribute it and/or modify
jaroslav@425
     6
 * it under the terms of the GNU General Public License as published by
jaroslav@425
     7
 * the Free Software Foundation, version 2 of the License.
jaroslav@425
     8
 *
jaroslav@425
     9
 * This program is distributed in the hope that it will be useful,
jaroslav@425
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
jaroslav@425
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
jaroslav@425
    12
 * GNU General Public License for more details.
jaroslav@425
    13
 *
jaroslav@425
    14
 * You should have received a copy of the GNU General Public License
jaroslav@425
    15
 * along with this program. Look for COPYING file in the top folder.
jaroslav@425
    16
 * If not, see http://opensource.org/licenses/GPL-2.0.
jaroslav@424
    17
 */
jaroslav@424
    18
package org.apidesign.bck2brwsr.tck;
jaroslav@424
    19
jaroslav@1285
    20
import org.apidesign.bck2brwsr.vmtest.BrwsrTest;
jaroslav@424
    21
import org.apidesign.bck2brwsr.vmtest.Compare;
jaroslav@424
    22
import org.apidesign.bck2brwsr.vmtest.VMTest;
jaroslav@424
    23
import org.testng.annotations.Factory;
jaroslav@424
    24
jaroslav@424
    25
/**
jaroslav@424
    26
 *
jaroslav@424
    27
 * @author Jaroslav Tulach <jtulach@netbeans.org>
jaroslav@424
    28
 */
jaroslav@1285
    29
public class NotifyWaitTest {
jaroslav@424
    30
    
jaroslav@1513
    31
jaroslav@1285
    32
    @Compare public synchronized String canCallNotify() throws Exception {
jaroslav@1285
    33
        notify();
jaroslav@1285
    34
        return "OK";
jaroslav@1285
    35
    }
jaroslav@1285
    36
jaroslav@1285
    37
    @Compare public synchronized String canCallNotifyAll() throws Exception {
jaroslav@1285
    38
        notifyAll();
jaroslav@1285
    39
        return "OK";
jaroslav@1285
    40
    }
jaroslav@1285
    41
    
jaroslav@1285
    42
    @BrwsrTest public synchronized String throwsInterruptedException() {
jaroslav@1285
    43
        try {
jaroslav@1285
    44
            wait();
jaroslav@1285
    45
            throw new IllegalStateException();
jaroslav@1285
    46
        } catch (InterruptedException ex) {
jaroslav@1285
    47
            return "OK";
jaroslav@424
    48
        }
jaroslav@1285
    49
    }
jaroslav@1285
    50
jaroslav@1285
    51
    @BrwsrTest public synchronized String waitMsThrowsInterruptedException() {
jaroslav@1285
    52
        try {
jaroslav@1285
    53
            wait(32);
jaroslav@1285
    54
            throw new IllegalStateException();
jaroslav@1285
    55
        } catch (InterruptedException ex) {
jaroslav@1285
    56
            return "OK";
jaroslav@1285
    57
        }
jaroslav@424
    58
    }
jaroslav@424
    59
    
jaroslav@424
    60
    @Factory public static Object[] create() {
jaroslav@1285
    61
        return VMTest.create(NotifyWaitTest.class);
jaroslav@424
    62
    }
jaroslav@424
    63
}