1*ef39d40dSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*ef39d40dSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*ef39d40dSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*ef39d40dSAndrew Rist * distributed with this work for additional information 6*ef39d40dSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*ef39d40dSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*ef39d40dSAndrew Rist * "License"); you may not use this file except in compliance 9*ef39d40dSAndrew Rist * with the License. You may obtain a copy of the License at 10*ef39d40dSAndrew Rist * 11*ef39d40dSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*ef39d40dSAndrew Rist * 13*ef39d40dSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*ef39d40dSAndrew Rist * software distributed under the License is distributed on an 15*ef39d40dSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*ef39d40dSAndrew Rist * KIND, either express or implied. See the License for the 17*ef39d40dSAndrew Rist * specific language governing permissions and limitations 18*ef39d40dSAndrew Rist * under the License. 19*ef39d40dSAndrew Rist * 20*ef39d40dSAndrew Rist *************************************************************/ 21*ef39d40dSAndrew Rist 22*ef39d40dSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir package lib; 25cdf0e10cSrcweir 26cdf0e10cSrcweir /** 27cdf0e10cSrcweir * The class is a simple implementation of Status class. It implements simple 28cdf0e10cSrcweir * Status behaviour: its state, reason and log are defined when creating 29cdf0e10cSrcweir * the SimpleSTatus instance. 30cdf0e10cSrcweir */ 31cdf0e10cSrcweir class SimpleStatus { 32cdf0e10cSrcweir /* Run states. */ 33cdf0e10cSrcweir 34cdf0e10cSrcweir /** 35cdf0e10cSrcweir * The constatnt represents PASSED runtime state. 36cdf0e10cSrcweir */ 37cdf0e10cSrcweir public final static int PASSED = 0; 38cdf0e10cSrcweir 39cdf0e10cSrcweir /** 40cdf0e10cSrcweir * The constant represents EXCEPTION runtime state. 41cdf0e10cSrcweir */ 42cdf0e10cSrcweir public final static int EXCEPTION = 3; 43cdf0e10cSrcweir 44cdf0e10cSrcweir /** 45cdf0e10cSrcweir * The constant represents EXCLUDED runtime state. 46cdf0e10cSrcweir */ 47cdf0e10cSrcweir public final static int EXCLUDED = 2; 48cdf0e10cSrcweir 49cdf0e10cSrcweir /** 50cdf0e10cSrcweir * The constant represents SKIPPED runtime state. 51cdf0e10cSrcweir */ 52cdf0e10cSrcweir public final static int SKIPPED = 1; 53cdf0e10cSrcweir 54cdf0e10cSrcweir /** 55cdf0e10cSrcweir * This is a private indicator for a user defined runtime state 56cdf0e10cSrcweir */ 57cdf0e10cSrcweir private final static int USER_DEFINED = 4; 58cdf0e10cSrcweir 59cdf0e10cSrcweir /* Test states */ 60cdf0e10cSrcweir 61cdf0e10cSrcweir /** 62cdf0e10cSrcweir * The constant represents FAILED state. 63cdf0e10cSrcweir */ 64cdf0e10cSrcweir public final static boolean FAILED = false; 65cdf0e10cSrcweir 66cdf0e10cSrcweir /** 67cdf0e10cSrcweir * The constant represents OK state. 68cdf0e10cSrcweir */ 69cdf0e10cSrcweir public final static boolean OK = true; 70cdf0e10cSrcweir 71cdf0e10cSrcweir /** 72cdf0e10cSrcweir * The field is holding state of the status. 73cdf0e10cSrcweir */ 74cdf0e10cSrcweir protected final boolean state; 75cdf0e10cSrcweir 76cdf0e10cSrcweir /** 77cdf0e10cSrcweir * The field is holding reason of the status. 78cdf0e10cSrcweir */ 79cdf0e10cSrcweir protected final int runState; 80cdf0e10cSrcweir 81cdf0e10cSrcweir /** 82cdf0e10cSrcweir * This is the run state: either SKIPPED, PASSED, etc. 83cdf0e10cSrcweir * or user defined. Deriving classes can overwrite it for own run states. 84cdf0e10cSrcweir */ 85cdf0e10cSrcweir protected String runStateString; 86cdf0e10cSrcweir 87cdf0e10cSrcweir /** 88cdf0e10cSrcweir * The constructor initialize state and reason field. 89cdf0e10cSrcweir */ SimpleStatus( int runState, boolean state )90cdf0e10cSrcweir protected SimpleStatus( int runState, boolean state ) { 91cdf0e10cSrcweir this.state = state; 92cdf0e10cSrcweir this.runState = runState; 93cdf0e10cSrcweir if ( runState == PASSED ) { 94cdf0e10cSrcweir runStateString = "PASSED"; 95cdf0e10cSrcweir } else if ( runState == EXCLUDED ) { 96cdf0e10cSrcweir runStateString = "EXCLUDED"; 97cdf0e10cSrcweir } else if ( runState == SKIPPED ) { 98cdf0e10cSrcweir runStateString = "SKIPPED"; 99cdf0e10cSrcweir } else if ( runState == EXCEPTION ) { 100cdf0e10cSrcweir runStateString = "EXCEPTION"; 101cdf0e10cSrcweir } else { 102cdf0e10cSrcweir runStateString = "UNKNOWN"; 103cdf0e10cSrcweir } 104cdf0e10cSrcweir } 105cdf0e10cSrcweir 106cdf0e10cSrcweir /** 107cdf0e10cSrcweir * The constructor initialize state and reson field. 108cdf0e10cSrcweir */ SimpleStatus(String runStateString, boolean state)109cdf0e10cSrcweir protected SimpleStatus(String runStateString, boolean state) { 110cdf0e10cSrcweir this.state = state; 111cdf0e10cSrcweir this.runState = USER_DEFINED; 112cdf0e10cSrcweir this.runStateString = runStateString; 113cdf0e10cSrcweir } 114cdf0e10cSrcweir 115cdf0e10cSrcweir /** 116cdf0e10cSrcweir * getState implementation. Just returns the state field value. 117cdf0e10cSrcweir */ getState()118cdf0e10cSrcweir public boolean getState() { 119cdf0e10cSrcweir return state; 120cdf0e10cSrcweir } 121cdf0e10cSrcweir 122cdf0e10cSrcweir /** 123cdf0e10cSrcweir * getRunState() implementation. Just returns th runState field value. 124cdf0e10cSrcweir */ getRunState()125cdf0e10cSrcweir public int getRunState() { 126cdf0e10cSrcweir return runState; 127cdf0e10cSrcweir } 128cdf0e10cSrcweir 129cdf0e10cSrcweir /** 130cdf0e10cSrcweir * getReason implementation. Just returns the reason field value. 131cdf0e10cSrcweir */ getRunStateString()132cdf0e10cSrcweir public String getRunStateString() { 133cdf0e10cSrcweir return runStateString; 134cdf0e10cSrcweir } 135cdf0e10cSrcweir 136cdf0e10cSrcweir /** 137cdf0e10cSrcweir * Get the ressult: passed or failed. 138cdf0e10cSrcweir */ getStateString()139cdf0e10cSrcweir public String getStateString() { 140cdf0e10cSrcweir if (state) 141cdf0e10cSrcweir return "OK"; 142cdf0e10cSrcweir return "FAILED"; 143cdf0e10cSrcweir 144cdf0e10cSrcweir } 145cdf0e10cSrcweir }