Path: blob/master/test/jdk/javax/xml/jaxp/transform/8004476/TestBase.java
41154 views
/*1* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223import java.security.Policy;2425/**26*27*28* @author [email protected]29*/30public class TestBase {31public static boolean isWindows = false;32static {33if (System.getProperty("os.name").indexOf("Windows")>-1) {34isWindows = true;35}36};3738String filepath;39boolean hasSM;40String curDir;41Policy origPolicy;42String testName;43static String errMessage;4445int passed = 0, failed = 0;4647/**48* Creates a new instance of StreamReader49*/50public TestBase(String name) {51testName = name;52}5354//junit @Override55protected void setUp() {56if (System.getSecurityManager() != null) {57hasSM = true;58System.setSecurityManager(null);59}6061filepath = System.getProperty("test.src");62if (filepath == null) {63//current directory64filepath = System.getProperty("user.dir");65}66origPolicy = Policy.getPolicy();6768}6970//junit @Override71public void tearDown() {72// turn off security manager and restore policy73System.setSecurityManager(null);74Policy.setPolicy(origPolicy);75if (hasSM) {76System.setSecurityManager(new SecurityManager());77}78System.out.println("\nNumber of tests passed: " + passed);79System.out.println("Number of tests failed: " + failed + "\n");8081if (errMessage != null ) {82throw new RuntimeException(errMessage);83}84}8586void fail(String errMsg) {87if (errMessage == null) {88errMessage = errMsg;89} else {90errMessage = errMessage + "\n" + errMsg;91}92failed++;93}9495void success(String msg) {96passed++;97System.out.println(msg);98}99100}101102103