📄 interactivetestsuite.java.svn-base
字号:
/* * $Id$ * * Copyright 1996-2007 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License version * 2 only, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License version 2 for more details (a copy is * included at /legal/license.txt). * * You should have received a copy of the GNU General Public License * version 2 along with this work; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA * * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa * Clara, CA 95054 or visit www.sun.com if you need additional * information or have any questions. * */package example;import java.io.File;import java.util.Arrays;import java.util.HashSet;import java.util.Map;import java.util.Set;import com.sun.javatest.Harness;import com.sun.javatest.InterviewParameters;import com.sun.javatest.Script;import com.sun.javatest.TestDescription;import com.sun.javatest.TestEnvironment;import com.sun.javatest.WorkDirectory;import com.sun.javatest.util.BackupPolicy;import com.sun.javatest.util.I18NResourceBundle;import com.sun.tck.cldc.javatest.TestBundler;import com.sun.tck.j2me.J2meTckFrameworkInfo;import com.sun.tck.j2me.interview.BasicTckInterview;import com.sun.tck.j2me.javatest.J2meBaseTestSuite;public class InteractiveTestSuite extends J2meBaseTestSuite { public InteractiveTestSuite(File root, Map tsInfo, ClassLoader cl) throws Fault { super(root, tsInfo, cl); } /** * Creates an configuration interview instance customized for this * test suite. */ public InterviewParameters createInterview() throws Fault { try { return BasicTckInterview.createBuilder(this) .setDistributed(true) // required for interactive tests .setMidpModeOnly(true) .setBundleSizeLimit(150000) .setKeywordsEnabled(true) .setPreverifierAware(false) .setEnableSeparatorQuestion(true) .build(); } catch (com.sun.interview.Interview.Fault fault) { fault.printStackTrace(); throw new com.sun.javatest.TestSuite.Fault(i18n, "ts.errorInitInterview", fault.getMessage()); } } /** * Creates a Script instance to execute the tests. * <p> * This method is overridden here in order to register extra JAR * files required for the interactive tests. */ public Script createScript(TestDescription td, String[] exclTestCases, TestEnvironment scriptEnv, WorkDirectory workDir, BackupPolicy backupPolicy) throws Fault { Script script = super.createScript( td, exclTestCases, scriptEnv, workDir, backupPolicy); if (isInteractiveTest(td)) { TestBundler.getTestBundler().registerExtraJars( td.getRootRelativeURL(), extraJars); } return script; } // This method is overridden here in order to calculate a list // of JAR files required for the interactive tests. We calculate // the list just once, when the test execution is about to start. protected void startRun(Harness harness) throws Fault { super.startRun(harness); calculateExtraJars(); } private void calculateExtraJars() { Set<String> jarFiles = new HashSet<String>( Arrays.asList(getDistrTestExtraJars())); jarFiles.add(EXTRA_JAR_FOR_INTERACTIVE_TEST); extraJars = jarFiles.toArray(new String[jarFiles.size()]); } private static boolean isInteractiveTest(TestDescription td) { return td.getKeywordTable().contains("interactive"); } private String[] extraJars; private static final String EXTRA_JAR_FOR_INTERACTIVE_TEST = J2meTckFrameworkInfo.getFrameworkLibDir().getAbsolutePath() + File.separator + "midp_testlibs.jar"; private static final I18NResourceBundle i18n = I18NResourceBundle.getBundleForClass(InteractiveTestSuite.class);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -