19 import java.lang.reflect.InvocationTargetException;
20 import java.lang.reflect.Method;
21 import java.lang.reflect.Type;
22 import java.util.Locale;
27 System.loadLibrary (
"zorba_api" );
31 public static void main ( String... args )
34 Class<?> c = Class.forName(
"api_test.Tests");
35 Object t = c.newInstance();
37 Method[] allMethods = c.getDeclaredMethods();
38 for (Method m : allMethods) {
39 String mname = m.getName();
40 if (!mname.startsWith(
"test")
41 || (m.getGenericReturnType() !=
boolean.
class)) {
44 Type[] pType = m.getGenericParameterTypes();
45 if ((pType.length != 1)
46 || Locale.class.isAssignableFrom(pType[0].getClass())) {
50 System.out.format(
"invoking %s()%n", mname);
52 m.setAccessible(
true);
53 Object o = m.invoke(t);
54 System.out.format(
"%s() returned %b%n", mname, (Boolean) o);
56 System.out.println(
"Success");
58 System.out.println(
"Failed");
63 }
catch (InvocationTargetException x) {
64 Throwable cause = x.getCause();
65 System.err.format(
"invocation of %s failed: %s%n",
66 mname, cause.getMessage());
71 }
catch (Exception e) {
72 System.out.println(
"Failed");
73 System.out.println(
"Exception caught. " + e.getLocalizedMessage());
static void main(String...args)