001: /*
002:
003: Derby - Class org.apache.derbyTesting.unitTests.harness.BasicUnitTest
004:
005: Licensed to the Apache Software Foundation (ASF) under one or more
006: contributor license agreements. See the NOTICE file distributed with
007: this work for additional information regarding copyright ownership.
008: The ASF licenses this file to You under the Apache License, Version 2.0
009: (the "License"); you may not use this file except in compliance with
010: the License. You may obtain a copy of the License at
011:
012: http://www.apache.org/licenses/LICENSE-2.0
013:
014: Unless required by applicable law or agreed to in writing, software
015: distributed under the License is distributed on an "AS IS" BASIS,
016: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: See the License for the specific language governing permissions and
018: limitations under the License.
019:
020: */
021:
022: package org.apache.derbyTesting.unitTests.harness;
023:
024: import org.apache.derbyTesting.unitTests.harness.UnitTest;
025: import org.apache.derby.iapi.services.stream.HeaderPrintWriter;
026:
027: // For testing
028: //import java.io.OutputStreamWriter;
029:
030: class BasicUnitTest implements UnitTest {
031: String traceMessage;
032: int testType;
033: int testDuration;
034: boolean result;
035: Error exception;
036:
037: BasicUnitTest(String traceMessage, int testType, int testDuration,
038: boolean result, Error exception) {
039: this .traceMessage = traceMessage;
040: this .testType = testType;
041: this .testDuration = testDuration;
042: this .result = result;
043: this .exception = exception;
044: }
045:
046: public String toString() {
047: return ("testType: " + testType + " testDuration: "
048: + testDuration + " traceMessage: " + traceMessage
049: + " result: " + result + " exception: " + exception);
050: }
051:
052: public boolean Execute(HeaderPrintWriter output) {
053:
054: output.printlnWithHeader(toString());
055: if (exception != null)
056: throw exception;
057:
058: return result;
059: }
060:
061: public int UnitTestDuration() {
062: return testDuration;
063: }
064:
065: public int UnitTestType() {
066: return testType;
067: }
068:
069: private void executeCatch(HeaderPrintWriter output) {
070: try {
071: Execute(output);
072: } catch (Error e) {
073: System.out.println("Caught exception:" + e);
074: }
075: }
076:
077: /*
078:
079: public static void main(String[] Args){
080:
081: OutputStreamWriter osw = new OutputStreamWriter(System.out);
082: BasicGetLogHeader glh = new BasicGetLogHeader(
083: true, true, "hi" );
084: BasicHeaderPrintWriter hpw = new BasicHeaderPrintWriter(osw,glh);
085:
086:
087: BasicUnitTest t1 =
088: new BasicUnitTest("hi Eric",1,1,true,null);
089:
090: t1.executeCatch(hpw);
091:
092: BasicUnitTest t2 =
093: new BasicUnitTest("hi my dear boy",1,1,true,null);
094:
095: t2.executeCatch(hpw);
096:
097: BasicUnitTest t3 =
098: new BasicUnitTest("hi my dear boy",1,1,true,
099: new Error("bogus Error"));
100:
101: t3.executeCatch(hpw);
102:
103:
104:
105: }
106:
107: */
108: }
|