jaroslav@356: /** jaroslav@356: * Back 2 Browser Bytecode Translator jaroslav@356: * Copyright (C) 2012 Jaroslav Tulach jaroslav@356: * jaroslav@356: * This program is free software: you can redistribute it and/or modify jaroslav@356: * it under the terms of the GNU General Public License as published by jaroslav@356: * the Free Software Foundation, version 2 of the License. jaroslav@356: * jaroslav@356: * This program is distributed in the hope that it will be useful, jaroslav@356: * but WITHOUT ANY WARRANTY; without even the implied warranty of jaroslav@356: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the jaroslav@356: * GNU General Public License for more details. jaroslav@356: * jaroslav@356: * You should have received a copy of the GNU General Public License jaroslav@356: * along with this program. Look for COPYING file in the top folder. jaroslav@356: * If not, see http://opensource.org/licenses/GPL-2.0. jaroslav@356: */ jaroslav@372: package org.apidesign.bck2brwsr.vmtest.impl; jaroslav@356: jaroslav@370: import java.io.IOException; jaroslav@356: import org.apidesign.bck2brwsr.launcher.Bck2BrwsrLauncher; jaroslav@370: import org.apidesign.bck2brwsr.launcher.JSLauncher; jaroslav@370: import org.apidesign.bck2brwsr.launcher.MethodInvocation; jaroslav@372: import org.apidesign.vm4brwsr.Bck2Brwsr; jaroslav@372: import org.testng.annotations.AfterGroups; jaroslav@372: import org.testng.annotations.AfterSuite; jaroslav@372: import org.testng.annotations.BeforeGroups; jaroslav@372: import org.testng.annotations.BeforeSuite; jaroslav@356: jaroslav@356: /** jaroslav@356: * jaroslav@356: * @author Jaroslav Tulach jaroslav@356: */ jaroslav@372: public final class Launchers { jaroslav@372: public static final Launchers INSTANCE = new Launchers(); jaroslav@356: jaroslav@372: private JSLauncher jsl; jaroslav@372: private Bck2BrwsrLauncher brwsr; jaroslav@372: jaroslav@372: private Launchers() { jaroslav@356: } jaroslav@356: jaroslav@372: @BeforeGroups("run") jaroslav@372: public void initializeLauncher() throws IOException { jaroslav@372: jsl = new JSLauncher(); jaroslav@372: jsl.addClassLoader(Bck2Brwsr.class.getClassLoader()); jaroslav@372: jsl.initialize(); jaroslav@372: Bck2BrwsrLauncher l = new Bck2BrwsrLauncher(); jaroslav@372: l.addClassLoader(Bck2Brwsr.class.getClassLoader()); jaroslav@372: l.initialize(); jaroslav@372: l.setTimeout(180000); jaroslav@372: brwsr = l; jaroslav@356: } jaroslav@356: jaroslav@372: @AfterGroups("run") jaroslav@372: public void shutDownLauncher() throws IOException, InterruptedException { jaroslav@372: brwsr.shutdown(); jaroslav@372: } jaroslav@372: jaroslav@372: public MethodInvocation addMethod(Class clazz, String name, boolean inBrwsr) throws IOException { jaroslav@372: if (!inBrwsr) { jaroslav@372: return jsl.addMethod(clazz, name); jaroslav@370: } else { jaroslav@372: return brwsr.addMethod(clazz, name); jaroslav@370: } jaroslav@356: } jaroslav@356: }