cdcdistributedscript.java.svn-base
来自「cqME :java framework for TCK test.」· SVN-BASE 代码 · 共 121 行
SVN-BASE
121 行
/* * $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.j2me.javatest;import java.util.HashMap;import java.util.Iterator;import com.sun.javatest.Script;import com.sun.javatest.Status;import com.sun.javatest.TestDescription;import com.sun.javatest.TestEnvironment;/** * A Script to execute Java ME distributed tests on CDC. The script recognizes * two test keywords: "distributed" and "interactive". */public class CdcDistributedScript extends BaseDistributedScript { /** * Creates a Script instance. By default, this script delegates * to {@link ExecuteLocksCdcScript} to run non-distributed tests. */ public CdcDistributedScript() { super(new ExecuteLocksCdcScript()); } /** * Creates a Script instance. By default, this script delegates * the test execution of non-distributed tests to the specified * <code>delegateScript</code>. * * @param delegateScript * The script that should execute non-distributed * tests. */ public CdcDistributedScript(Script delegateScript) { super(delegateScript); } /** * Initializes test description. * * @param td the test description for the test to be run. */ public void initTestDescription(TestDescription td) { super.initTestDescription(td); if (isTestDistributed(td)) { this.td = getUpdatedTD(td, "executeArgs", " -bundleId $bundleId"); } } /** * Executes distributed test on CDC or delegates the execution of * non-distributed test to the one of the super implementations. * * @param args * Any script-specific options * @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 * @return The result of running the script */ public Status run(String[] args, TestDescription td, TestEnvironment env) { if (isTestDistributed(td)) { env.put("bundleId", td.getParameter("executeClass")); } return super.run(args, td, env); } private static TestDescription getUpdatedTD(TestDescription td, String field, String valueAddition) { int numParams = td.getParameterCount(); HashMap updatedParams = new HashMap(numParams * 2); Iterator keysIter = td.getParameterKeys(); for (int pos = 0; keysIter.hasNext(); pos = pos + 2) { String key = (String) keysIter.next(); String value = td.getParameter(key); if (key.equals(field)) { value = value + valueAddition; } updatedParams.put(key, value); } return new TestDescription(td.getRoot(), td.getFile(), updatedParams); }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?