1/* 2 * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24/** 25 * <p>This is the base class for automatic main tests. 26 * <p>When using jtreg you would include this class into 27 * the build list via something like: 28 * <pre> 29 @library ../../../regtesthelpers 30 @build AbstractTest 31 @run main YourTest 32 </pre> 33 * Note that if you are about to create a test based on 34 * Applet-template, then put those lines into html-file, not in java-file. 35 * <p> And put an 36 * import test.java.awt.regtesthelpers.AbstractTest; 37 * into the java source. 38 */ 39 40package test.java.awt.regtesthelpers; 41 42public abstract class AbstractTest 43{ 44 public static void pass() 45 { 46 Sysout.println( "The test passed." ); 47 Sysout.println( "The test is over, hit Ctl-C to stop Java VM" ); 48 }//pass() 49 50 public static void fail() 51 { 52 //test writer didn't specify why test failed, so give generic 53 fail("no reason given."); 54 } 55 56 public static void fail( String whyFailed ) 57 { 58 Sysout.println( "The test failed: " + whyFailed ); 59 Sysout.println( "The test is over, hit Ctl-C to stop Java VM" ); 60 throw new RuntimeException( whyFailed ); 61 } 62 63 public static void fail(Exception ex) throws Exception 64 { 65 Sysout.println( "The test failed with exception:" ); 66 ex.printStackTrace(); 67 Sysout.println( "The test is over, hit Ctl-C to stop Java VM" ); 68 throw ex; 69 } 70} 71