0N/A/*
2362N/A * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/A
0N/A/*
0N/A * Copyright 2003 Wily Technology, Inc.
0N/A */
0N/A
0N/A/**
0N/A * Cheesy class to run all of our test cases in a hard-coded fashion.
0N/A * Will be replaced by Sun's iterator that uses the source decorations to figure out what to do.
0N/A */
0N/A
0N/Aimport java.lang.reflect.*;
0N/A
0N/Apublic class FakeTestDriver {
0N/A
0N/A private String[] fTestList = {
0N/A "javafake.lang.instrument.AddTransformerTest",
0N/A "javafake.lang.instrument.AppendToBootstrapClassPathTest",
0N/A "javafake.lang.instrument.AppendToClassPathTest",
0N/A "javafake.lang.instrument.GetAllLoadedClassesTest",
0N/A "javafake.lang.instrument.GetInitiatedClassesTest",
0N/A "javafake.lang.instrument.GetObjectSizeTest",
0N/A "javafake.lang.instrument.NoTransformerAddedTest",
0N/A "javafake.lang.instrument.NullTransformerAddTest",
0N/A "javafake.lang.instrument.RedefineClassesTests",
0N/A "javafake.lang.instrument.RemoveAbsentTransformerTest",
0N/A "javafake.lang.instrument.RemoveTransformerTest",
0N/A "javafake.lang.instrument.SingleTransformerTest",
0N/A "javafake.lang.instrument.TransformerManagementThreadAddTests",
0N/A "javafake.lang.instrument.TransformerManagementThreadRemoveTests",
0N/A "javafake.lang.instrument.TransformMethodTest",
0N/A };
0N/A
0N/A public static void
0N/A main(String[] args) {
0N/A (new FakeTestDriver()).runSuppliedTests(args);
0N/A }
0N/A
0N/A private
0N/A FakeTestDriver() {
0N/A }
0N/A
0N/A private void
0N/A runAllTests() {
0N/A runSuppliedTests(fTestList);
0N/A }
0N/A
0N/A private void
0N/A runSuppliedTests(String[] classnames) {
0N/A for (int x = 0; x < classnames.length; x++ ) {
0N/A loadAndRunOneTest(classnames[x]);
0N/A }
0N/A }
0N/A
0N/A private void
0N/A loadAndRunOneTest(String classname) {
0N/A log("trying to run: " + classname);
0N/A
0N/A Class testclass = loadOneTest(classname);
0N/A
0N/A if ( testclass != null ) {
0N/A boolean result = runOneTest(testclass);
0N/A if ( result ) {
0N/A log(classname + " SUCCEEDED");
0N/A }
0N/A else {
0N/A log(classname + " FAILED");
0N/A }
0N/A }
0N/A else {
0N/A log(classname + " could not be loaded");
0N/A }
0N/A }
0N/A
0N/A private Class
0N/A loadOneTest(String classname) {
0N/A Class result = null;
0N/A
0N/A try {
0N/A result = Class.forName(classname);
0N/A }
0N/A catch (Throwable t) {
0N/A t.printStackTrace();
0N/A result = null;
0N/A }
0N/A return result;
0N/A }
0N/A
0N/A private boolean
0N/A runOneTest(Class testclass) {
0N/A Method mainMethod = null;
0N/A
0N/A try {
0N/A String[] forType = new String[0];
0N/A mainMethod = testclass.getMethod("main",
0N/A new Class[] {
0N/A forType.getClass()
0N/A });
0N/A }
0N/A catch (Throwable t) {
0N/A log(testclass.getName() + " is malformed");
0N/A t.printStackTrace();
0N/A return false;
0N/A }
0N/A
0N/A try {
0N/A mainMethod.invoke(null, new Object[] {new String[] {testclass.getName()}});
0N/A return true;
0N/A }
0N/A catch (Throwable t) {
0N/A t.printStackTrace();
0N/A return false;
0N/A }
0N/A }
0N/A
0N/A private void
0N/A log(String m) {
0N/A System.out.println(m);
0N/A }
0N/A}