vmtest/src/main/java/org/apidesign/bck2brwsr/vmtest/impl/Launchers.java
author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
Tue, 25 Dec 2012 13:31:35 +0100
changeset 380 4ce33ad7d507
parent 372 3485327d3080
child 382 57fc3a0563c9
permissions -rw-r--r--
Removing unused imports
jaroslav@356
     1
/**
jaroslav@356
     2
 * Back 2 Browser Bytecode Translator
jaroslav@356
     3
 * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
jaroslav@356
     4
 *
jaroslav@356
     5
 * This program is free software: you can redistribute it and/or modify
jaroslav@356
     6
 * it under the terms of the GNU General Public License as published by
jaroslav@356
     7
 * the Free Software Foundation, version 2 of the License.
jaroslav@356
     8
 *
jaroslav@356
     9
 * This program is distributed in the hope that it will be useful,
jaroslav@356
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
jaroslav@356
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
jaroslav@356
    12
 * GNU General Public License for more details.
jaroslav@356
    13
 *
jaroslav@356
    14
 * You should have received a copy of the GNU General Public License
jaroslav@356
    15
 * along with this program. Look for COPYING file in the top folder.
jaroslav@356
    16
 * If not, see http://opensource.org/licenses/GPL-2.0.
jaroslav@356
    17
 */
jaroslav@372
    18
package org.apidesign.bck2brwsr.vmtest.impl;
jaroslav@356
    19
jaroslav@370
    20
import java.io.IOException;
jaroslav@356
    21
import org.apidesign.bck2brwsr.launcher.Bck2BrwsrLauncher;
jaroslav@370
    22
import org.apidesign.bck2brwsr.launcher.JSLauncher;
jaroslav@370
    23
import org.apidesign.bck2brwsr.launcher.MethodInvocation;
jaroslav@372
    24
import org.apidesign.vm4brwsr.Bck2Brwsr;
jaroslav@372
    25
import org.testng.annotations.AfterGroups;
jaroslav@372
    26
import org.testng.annotations.BeforeGroups;
jaroslav@356
    27
jaroslav@356
    28
/**
jaroslav@356
    29
 *
jaroslav@356
    30
 * @author Jaroslav Tulach <jtulach@netbeans.org>
jaroslav@356
    31
 */
jaroslav@372
    32
public final class Launchers {
jaroslav@372
    33
    public static final Launchers INSTANCE = new Launchers();
jaroslav@356
    34
    
jaroslav@372
    35
    private JSLauncher jsl;
jaroslav@372
    36
    private Bck2BrwsrLauncher brwsr;
jaroslav@372
    37
    
jaroslav@372
    38
    private Launchers() {
jaroslav@356
    39
    }
jaroslav@356
    40
jaroslav@372
    41
    @BeforeGroups("run")
jaroslav@372
    42
    public void initializeLauncher() throws IOException {
jaroslav@372
    43
        jsl = new JSLauncher();
jaroslav@372
    44
        jsl.addClassLoader(Bck2Brwsr.class.getClassLoader());
jaroslav@372
    45
        jsl.initialize();
jaroslav@372
    46
        Bck2BrwsrLauncher l = new Bck2BrwsrLauncher();
jaroslav@372
    47
        l.addClassLoader(Bck2Brwsr.class.getClassLoader());
jaroslav@372
    48
        l.initialize();
jaroslav@372
    49
        l.setTimeout(180000);
jaroslav@372
    50
        brwsr = l;
jaroslav@356
    51
    }
jaroslav@356
    52
jaroslav@372
    53
    @AfterGroups("run")
jaroslav@372
    54
    public void shutDownLauncher() throws IOException, InterruptedException {
jaroslav@372
    55
        brwsr.shutdown();
jaroslav@372
    56
    }
jaroslav@372
    57
jaroslav@372
    58
    public MethodInvocation addMethod(Class<?> clazz, String name, boolean inBrwsr) throws IOException {
jaroslav@372
    59
        if (!inBrwsr) {
jaroslav@372
    60
            return jsl.addMethod(clazz, name);
jaroslav@370
    61
        } else {
jaroslav@372
    62
            return brwsr.addMethod(clazz, name);
jaroslav@370
    63
        }
jaroslav@356
    64
    }
jaroslav@356
    65
}