KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derbyTesting > functionTests > harness > RunClass


1 /*
2
3    Derby - Class org.apache.derbyTesting.functionTests.harness.RunClass
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.functionTests.harness;
23
24 import java.lang.reflect.Method JavaDoc;
25
26
27 // the purpose of this class is to run Java-based test cases in a separate thread
28
public class RunClass implements Runnable JavaDoc
29 {
30
31     /**
32         param args the arguments to pass into ij
33     */

34     public RunClass(Method JavaDoc methodToCall, Object JavaDoc args[])
35     {
36         mainMethod = methodToCall;
37         arguments=args;
38     }
39
40     Object JavaDoc arguments[];
41     Method JavaDoc mainMethod;
42
43     public void run()
44     {
45         synchronized (this)
46         {
47             try
48             {
49                 // we're invoking the test class's main method - which is always static
50
// thus we can pass null, an underlying object argument would be
51
// ignored anyway.
52
mainMethod.invoke(null, arguments);
53             }
54             catch (IllegalAccessException JavaDoc iae)
55             {
56             iae.printStackTrace();
57                 System.out.println("RunClass: " + iae + " make sure the test class is public.");
58                 System.exit(1);
59             }
60             catch (Exception JavaDoc e)
61             {
62                 System.out.println("RunClass --> " + e);
63                 e.printStackTrace();
64             }
65         }
66     }
67 }
68
Popular Tags