KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derbyTesting > unitTests > harness > BasicUnitTest


1 /*
2
3    Derby - Class org.apache.derbyTesting.unitTests.harness.BasicUnitTest
4
5    Licensed to the Apache Software Foundation (ASF) under one or more
6    contributor license agreements. See the NOTICE file distributed with
7    this work for additional information regarding copyright ownership.
8    The ASF licenses this file to You under the Apache License, Version 2.0
9    (the "License"); you may not use this file except in compliance with
10    the License. You may obtain a copy of the License at
11
12       http://www.apache.org/licenses/LICENSE-2.0
13
14    Unless required by applicable law or agreed to in writing, software
15    distributed under the License is distributed on an "AS IS" BASIS,
16    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17    See the License for the specific language governing permissions and
18    limitations under the License.
19
20  */

21
22 package org.apache.derbyTesting.unitTests.harness;
23
24 import org.apache.derbyTesting.unitTests.harness.UnitTest;
25 import org.apache.derby.iapi.services.stream.HeaderPrintWriter;
26
27 // For testing
28
//import java.io.OutputStreamWriter;
29

30 class BasicUnitTest implements UnitTest
31 {
32     String JavaDoc traceMessage;
33     int testType;
34     int testDuration;
35     boolean result;
36     Error JavaDoc exception;
37
38     BasicUnitTest(String JavaDoc traceMessage,
39                   int testType,
40                   int testDuration,
41                   boolean result,
42                   Error JavaDoc exception){
43         this.traceMessage = traceMessage;
44         this.testType = testType;
45         this.testDuration = testDuration;
46         this.result = result;
47         this.exception = exception;
48     }
49
50     public String JavaDoc toString(){
51         return ("testType: "+testType+" testDuration: "+
52             testDuration+" traceMessage: "+traceMessage+
53             " result: "+result+" exception: "+exception);
54     }
55
56
57     public boolean Execute (HeaderPrintWriter output) {
58     
59         output.printlnWithHeader(toString());
60         if (exception != null)
61             throw exception;
62     
63         return result;
64     }
65
66
67
68     public int UnitTestDuration(){
69         return testDuration;
70     }
71
72     public int UnitTestType(){
73         return testType;
74     }
75
76     private void executeCatch(HeaderPrintWriter output){
77          try{
78              Execute(output);
79          }
80          catch (Error JavaDoc e){
81              System.out.println("Caught exception:"+ e);
82          }
83     }
84
85 /*
86
87     public static void main(String[] Args){
88
89         OutputStreamWriter osw = new OutputStreamWriter(System.out);
90         BasicGetLogHeader glh = new BasicGetLogHeader(
91                 true, true, "hi" );
92         BasicHeaderPrintWriter hpw = new BasicHeaderPrintWriter(osw,glh);
93  
94          
95         BasicUnitTest t1 =
96               new BasicUnitTest("hi Eric",1,1,true,null);
97                   
98         t1.executeCatch(hpw);
99
100         BasicUnitTest t2 =
101              new BasicUnitTest("hi my dear boy",1,1,true,null);
102
103         t2.executeCatch(hpw);
104
105         BasicUnitTest t3 =
106              new BasicUnitTest("hi my dear boy",1,1,true,
107                 new Error("bogus Error"));
108
109         t3.executeCatch(hpw);
110
111         
112
113     }
114     
115 */

116 }
117
118
Popular Tags