exportscript.java
来自「cqME :java framework for TCK test.」· Java 代码 · 共 142 行
JAVA
142 行
/* * $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 com.sun.tck.midp.javatest;import java.util.Set;import com.sun.javatest.Status;import com.sun.javatest.TestDescription;import com.sun.javatest.TestEnvironment;import com.sun.tck.cldc.javatest.TestBundler;import com.sun.tck.j2me.javatest.TestExportInfo;/** * An extension of MidTCKScript that exports tests for offline, standalone * execution. Exports only tests that can be ran standalone, i.e. not marked * with any of interactive/ota/jtonly keywords and tests that don't contain * remote components. * <p> * An attempt to execute non-exportable test will be reported as test failure. */public class ExportScript extends MidTCKScript { /** * Initialize the environment to be used when running the test. * @param env the environment to be used when running the test */ public void initTestEnvironment(TestEnvironment env) { super.initTestEnvironment(env); testExportInfo = TestExportInfo.fromEnv(env); } /** * {@inheritDoc} */ public void initTestDescription(TestDescription td) { super.initTestDescription(td); Set keys = td.getKeywordTable(); otaKey = (keys.contains("ota")); JTonlyKey = (keys.contains("jtonly")); interactiveKey = (keys.contains("interactive")); singleKey = (keys.contains("single")); trustedKey = (keys.contains("trusted")); untrustedKey = (keys.contains("untrusted")); distributedKey = (keys.contains("distributed")); noExportKey = (keys.contains("noExport") || keys.contains("noexport")); } /** * This implementation always returns <code>false</code>. * @return <code>false</code> */ protected boolean isNegative() { return false; } /** * Executes a test only if the test can be exported, otherwise returns * <code>Status.failed</code>. Increases a counter of dispatched tests. * * @param args * Any script-specific options. Ignored by this implementation. * @param td * The test description for the test to be performed. * @param env * The test environment giving the details of how to run the * test. Ignored by this implementation. * @return The result of test execution. */ protected Status runRuntimeTest(String[] args, TestDescription td, TestEnvironment env) { if (otaKey || JTonlyKey || noExportKey || td.getParameter("executeClass") == null) { TestBundler.getTestBundler().testSkippedForBundling(); } if (distributedKey) { String testPrefix = "<" + td.getRootRelativeURL() + ">"; // "testMsgSwitch" for J2MEDistributedTest should contain testPrefix only. // there is no need to provide an address where to connect to. // New distributed tests use commService for communications. env.put("testMsgSwitch", testPrefix); } if (noExportKey) { return Status.failed("Test can not be exported"); } if (otaKey) { return Status.failed("Can not export OTA tests"); } if (JTonlyKey) { return Status.failed( "Can not export tests, that should be executed on JT side"); } String executeClass = td.getParameter("executeClass"); if (executeClass == null) { return error_noExecuteClass; } String executeArgs = getExecuteArgs(td); return execute("testExecute", executeClass, executeArgs); } public void setTestExportInfo(TestExportInfo testExportInfo) { this.testExportInfo = testExportInfo; } protected TestExportInfo testExportInfo; // Keys are set from test description keywords protected boolean otaKey; protected boolean JTonlyKey; protected boolean interactiveKey; protected boolean singleKey; protected boolean trustedKey; protected boolean untrustedKey; protected boolean distributedKey; private boolean noExportKey = false;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?