testlog.java.svn-base

来自「cqME :java framework for TCK test.」· SVN-BASE 代码 · 共 109 行

SVN-BASE
109
字号
/* * $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.agent;import com.sun.tck.cldc.javatest.agent.TestResult;import com.sun.tck.cldc.lib.Status;/** * Structure to store some selected information  * from {@link com.sun.tck.cldc.javatest.agent.TestResult} */class TestLog {        /**     * Test url splitted by <code>"/"</code> character.     */    public String [] url;        /**     * Test ref.     */    public String ref;        /**     * Test log.     */    public String log;        /**     * Test status.     */    public Status status;    /**     * Creates instance of <code>TestLog</code>.     * @param tr TestResult to take information from.     * @param ref test ref     * @param log test log     */    public TestLog(TestResult tr, String ref, String log) {        url = SimpleStringTokenizer.split(tr.getName(), "/");        this.ref = ref;        this.log = log;        status = tr.getStatus();    }    /**     * Creates instance of <code>TestLog</code> on the basis of provided      * RMS log information.     * @param rms_log array of strings read from RMS      *                in { @link com.sun.tck.midp.javatest.agent.MIDletGUIAgent}     *                format.     */    public TestLog(String[] rms_log) {        url = SimpleStringTokenizer.split(rms_log[0], "/");        ref = rms_log.length > 1 ? rms_log[1] : "";        log = rms_log.length > 2 ? rms_log[2] : "";        status = rms_log.length > 3 ? parseStatus(rms_log[3])                                    : Status.error("no status provided");    }        /**     * Parses status from RMS log information.     * @param s status strings read from RMS      *                in {@link com.sun.tck.midp.javatest.agent.MIDletGUIAgent}     *                format.     * @return parsed <code>Status</code>     */    private Status parseStatus(String s) {        int space_pos = s.indexOf(' ');        String reason = (space_pos == -1) ? "" : s.substring(space_pos + 1);                if (s.indexOf("Passed.") == 0) {            return Status.passed(reason);        } else if (s.indexOf("Failed.") == 0) {            return Status.failed(reason);        } else if (s.indexOf("Error.") == 0) {            return Status.error(reason);        } else {            return Status.error("Can't parse status: " + reason);        }        }}

⌨️ 快捷键说明

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