generictestbundle.java

来自「cqME :java framework for TCK test.」· Java 代码 · 共 150 行

JAVA
150
字号
/* * $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.cldc.communication;import java.util.Vector;import com.sun.tck.cldc.javatest.util.UTFConverter;public class GenericTestBundle implements TestBundle {    private Vector requests = new Vector();    private TestResultListener listener = null;    private String app = null;    private boolean interrupted = false;    public void setApp(String app) {        this.app = app;    }    public void setTestResultListener(TestResultListener listener) {        this.listener = listener;    }    public TestResultListener getTestResultListener() {        return listener;    }    public void addTest(byte[] req) {        requests.add(req);    }    public int getTestCount() {        return requests.size();    }///////////////////////////////////////////////////////////////////////    /**     */    public String getApp() {        return app;    }    /**     * Reads next test.     * Returns null if all tests from this bundle have already     * been executed.     */    public byte[] getNextTest() {        return requests.size() == 0 ? null : (byte[]) requests.remove(0);    }    /**     * Reports test result.     */    public void passTestResult(byte[] req, byte[] res) {       listener.passTestResult(req, res);    }    /**     * Reports VM exit.     */    public void passVMExitResult(byte[] req) {       listener.passVMExitResult(req);    }            /**     * Notifies this bundle that it is started     */    public void starting() {        for (int i =0; i < requests.size(); i++) {            listener.passBundleStarted((byte[])requests.get(i));        }    }    /**     * Notifies this bundle that it is restarted     */    public void restarting() {}    /**     * Notifies this bundle that it is finished     */    public void finishing() {}        /**     * Notifies this bundle that it is interrupted     */    public void setInterrupted() {        interrupted = true;    };    /**     * Returns true if this bundle have been interrupted     */    public boolean isInterrupted() {        return interrupted;    };///////////////////////////////////////////////////////////////////////    /**     * Prints bundle application name.     *      */    public void printAppName() {        System.out.println(app);    }    /**     * Prints names of tests in the bundle.     */    public void printTestList(String prefix) {        for (int i=0; i<requests.size(); i++) {            System.out.print(prefix); printTestName((byte[])(requests.elementAt(i)));        }    }    /**     * Prints name of the test contained in req.     */    public void printTestName(byte[] req) {        String [] args = UTFConverter.bytesToStrings(req);        System.out.println(args[0]);    }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?