Update ooo320-m1
[ooovba.git] / qadevOOo / runner / lib / Status.java
blob91c57f20a2e0fff720e63e7402679888e27d15bf
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: Status.java,v $
10 * $Revision: 1.5 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 package lib;
33 /**
34 * Status represents a result of a testing activity performed. The result is
35 * described in two ways: state and runtime state. The state describes if the
36 * activity was successful (OK state) or not (FAILED state). The runtime state
37 * describes what happend during the activity: the test can be:
38 * - PASSED - the activity completed normally (although it can complete with
39 * FAILED state)
40 * - SKIPPED - the activity was not performed because of a reason (it also can
41 * has OK or FAILED state)
42 * - EXCEPTION - the activity was abnormally terminated because of an
43 * unexpected exception. It always has a FAILED state.
44 * - EXCLUDED - the activity is expected to fail. The state represents how
45 * the state really completed: OK or FAILED.
46 * - other variants are not formalized now and can be represented by
47 * Status.failed() method. They always have a FAILED state.
49 public class Status extends SimpleStatus {
51 /**
52 * Construct a status: use runState and state
53 * @param runState: either PASSED, SKIPPED, etc.
54 * @param state: OK or FAILED.
56 public Status(int runState, boolean state ) {
57 super(runState, state);
60 /**
61 * Construct a status: use own message and state.
62 * @parame messaeg An own message for the status.
63 * @param state: OK or FAILED.
65 public Status(String message, boolean state) {
66 super( message, state );
69 /**
70 * This is a factory method for creating a Status representing normal
71 * actibity termination.
73 * @param state describes a test state (OK if state == true, FAILED
74 * otherwise).
76 public static Status passed( boolean state ) {
77 return new Status(PASSED, state );
80 /**
81 * This is a factory method for creating a Status representing an exception
82 * activity termination. The Status alway has FAILED state.
84 * @param t the exception with that the activity completed.
86 public static Status exception( Throwable t ) {
87 return new ExceptionStatus( t );
90 /**
91 * This is a factory method for creating a Status representing a skipped
92 * activity.
94 * @param state describes a test state (OK if state == true, FAILED
95 * otherwise).
97 public static Status skipped( boolean state ) {
98 return new Status( SKIPPED, state );
102 * This is a factory method for creating a Status representing that the
103 * result of the activity was excluded. It alwas has FAILED state.
105 public static Status excluded() {
106 return new Status( EXCLUDED, false );
110 * Creates a Status representing an activity failed for an arbitrary reason.
111 * It always has FAILED state.
113 * @param reason describes why the activity failed
115 public static Status failed(final String reason) {
116 return new Status(reason, FAILED);
120 * The method returns a human-readable description of the status.
121 * The Status implementation of the method returns the status state
122 * description and appends to it it the reason, for example:
123 * "FAILED.The getLabel works wrong", "PASSED.OK".
125 public String toString() {
126 String str = getRunStateString() + "." + getStateString();;
128 return str;
132 * Checks whether the status runstate is passed.
134 public boolean isPassed() {
135 return getRunState() == PASSED;
139 * Checks whether the status runstate is skipped.
141 public boolean isSkipped() {
142 return getRunState() == SKIPPED;
146 * Checks whether the status runstate is excluded.
148 public boolean isExcluded() {
149 return getRunState() == EXCLUDED;
153 * Checks whether the status runstate is exception.
155 public boolean isException() {
156 return getRunState() == EXCEPTION;
160 * Checks whether the status state is failed.
162 public boolean isFailed() {
163 return !getState();
167 * Checks whether the status state is ok.
169 public boolean isOK() {
170 return getState();
173 public String getDescription () {
174 return getRunStateString();