jdk/test/javax/xml/jaxp/transform/8004476/TestBase.java
author iignatyev
Tue, 16 Dec 2014 02:14:11 +0300
changeset 28198 1e41fbf783e3
parent 23034 2da284ebc112
permissions -rw-r--r--
8065279: Remove testlibrary_tests from compact profile in jtreg Reviewed-by: kvn Contributed-by: dmitrij.pochepko@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
21364
decde35d5139 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
diff changeset
     1
/*
decde35d5139 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
diff changeset
     2
 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
23034
2da284ebc112 8036004: Incorrect license header for a test class
joehw
parents: 21849
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2da284ebc112 8036004: Incorrect license header for a test class
joehw
parents: 21849
diff changeset
     4
 *
2da284ebc112 8036004: Incorrect license header for a test class
joehw
parents: 21849
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
2da284ebc112 8036004: Incorrect license header for a test class
joehw
parents: 21849
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
2da284ebc112 8036004: Incorrect license header for a test class
joehw
parents: 21849
diff changeset
     7
 * published by the Free Software Foundation.
2da284ebc112 8036004: Incorrect license header for a test class
joehw
parents: 21849
diff changeset
     8
 *
2da284ebc112 8036004: Incorrect license header for a test class
joehw
parents: 21849
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
2da284ebc112 8036004: Incorrect license header for a test class
joehw
parents: 21849
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2da284ebc112 8036004: Incorrect license header for a test class
joehw
parents: 21849
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
2da284ebc112 8036004: Incorrect license header for a test class
joehw
parents: 21849
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
2da284ebc112 8036004: Incorrect license header for a test class
joehw
parents: 21849
diff changeset
    13
 * accompanied this code).
2da284ebc112 8036004: Incorrect license header for a test class
joehw
parents: 21849
diff changeset
    14
 *
2da284ebc112 8036004: Incorrect license header for a test class
joehw
parents: 21849
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
2da284ebc112 8036004: Incorrect license header for a test class
joehw
parents: 21849
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
2da284ebc112 8036004: Incorrect license header for a test class
joehw
parents: 21849
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2da284ebc112 8036004: Incorrect license header for a test class
joehw
parents: 21849
diff changeset
    18
 *
2da284ebc112 8036004: Incorrect license header for a test class
joehw
parents: 21849
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2da284ebc112 8036004: Incorrect license header for a test class
joehw
parents: 21849
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
2da284ebc112 8036004: Incorrect license header for a test class
joehw
parents: 21849
diff changeset
    21
 * questions.
21364
decde35d5139 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
diff changeset
    22
 */
23034
2da284ebc112 8036004: Incorrect license header for a test class
joehw
parents: 21849
diff changeset
    23
21364
decde35d5139 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
diff changeset
    24
import java.security.Policy;
decde35d5139 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
diff changeset
    25
decde35d5139 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
diff changeset
    26
/**
decde35d5139 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
diff changeset
    27
 *
decde35d5139 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
diff changeset
    28
 *
decde35d5139 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
diff changeset
    29
 * @author huizhe.wang@oracle.com
decde35d5139 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
diff changeset
    30
 */
decde35d5139 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
diff changeset
    31
public class TestBase {
decde35d5139 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
diff changeset
    32
    public static boolean isWindows = false;
decde35d5139 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
diff changeset
    33
    static {
decde35d5139 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
diff changeset
    34
        if (System.getProperty("os.name").indexOf("Windows")>-1) {
decde35d5139 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
diff changeset
    35
            isWindows = true;
decde35d5139 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
diff changeset
    36
        }
decde35d5139 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
diff changeset
    37
    };
decde35d5139 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
diff changeset
    38
decde35d5139 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
diff changeset
    39
    String filepath;
decde35d5139 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
diff changeset
    40
    boolean hasSM;
decde35d5139 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
diff changeset
    41
    String curDir;
decde35d5139 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
diff changeset
    42
    Policy origPolicy;
decde35d5139 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
diff changeset
    43
    String testName;
decde35d5139 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
diff changeset
    44
    static String errMessage;
decde35d5139 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
diff changeset
    45
decde35d5139 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
diff changeset
    46
    int passed = 0, failed = 0;
decde35d5139 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
diff changeset
    47
decde35d5139 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
diff changeset
    48
    /**
decde35d5139 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
diff changeset
    49
     * Creates a new instance of StreamReader
decde35d5139 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
diff changeset
    50
     */
decde35d5139 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
diff changeset
    51
    public TestBase(String name) {
decde35d5139 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
diff changeset
    52
        testName = name;
decde35d5139 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
diff changeset
    53
    }
decde35d5139 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
diff changeset
    54
decde35d5139 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
diff changeset
    55
    //junit @Override
decde35d5139 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
diff changeset
    56
    protected void setUp() {
decde35d5139 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
diff changeset
    57
        if (System.getSecurityManager() != null) {
decde35d5139 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
diff changeset
    58
            hasSM = true;
decde35d5139 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
diff changeset
    59
            System.setSecurityManager(null);
decde35d5139 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
diff changeset
    60
        }
decde35d5139 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
diff changeset
    61
decde35d5139 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
diff changeset
    62
        filepath = System.getProperty("test.src");
decde35d5139 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
diff changeset
    63
        if (filepath == null) {
decde35d5139 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
diff changeset
    64
            //current directory
decde35d5139 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
diff changeset
    65
            filepath = System.getProperty("user.dir");
decde35d5139 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
diff changeset
    66
        }
decde35d5139 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
diff changeset
    67
        origPolicy = Policy.getPolicy();
decde35d5139 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
diff changeset
    68
decde35d5139 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
diff changeset
    69
    }
decde35d5139 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
diff changeset
    70
decde35d5139 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
diff changeset
    71
    //junit @Override
decde35d5139 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
diff changeset
    72
    public void tearDown() {
decde35d5139 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
diff changeset
    73
        // turn off security manager and restore policy
decde35d5139 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
diff changeset
    74
        System.setSecurityManager(null);
decde35d5139 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
diff changeset
    75
        Policy.setPolicy(origPolicy);
decde35d5139 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
diff changeset
    76
        if (hasSM) {
decde35d5139 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
diff changeset
    77
            System.setSecurityManager(new SecurityManager());
decde35d5139 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
diff changeset
    78
        }
decde35d5139 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
diff changeset
    79
        System.out.println("\nNumber of tests passed: " + passed);
decde35d5139 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
diff changeset
    80
        System.out.println("Number of tests failed: " + failed + "\n");
decde35d5139 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
diff changeset
    81
decde35d5139 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
diff changeset
    82
        if (errMessage != null ) {
decde35d5139 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
diff changeset
    83
            throw new RuntimeException(errMessage);
decde35d5139 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
diff changeset
    84
        }
decde35d5139 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
diff changeset
    85
    }
decde35d5139 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
diff changeset
    86
decde35d5139 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
diff changeset
    87
    void fail(String errMsg) {
decde35d5139 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
diff changeset
    88
        if (errMessage == null) {
decde35d5139 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
diff changeset
    89
            errMessage = errMsg;
decde35d5139 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
diff changeset
    90
        } else {
decde35d5139 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
diff changeset
    91
            errMessage = errMessage + "\n" + errMsg;
decde35d5139 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
diff changeset
    92
        }
decde35d5139 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
diff changeset
    93
        failed++;
decde35d5139 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
diff changeset
    94
    }
decde35d5139 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
diff changeset
    95
decde35d5139 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
diff changeset
    96
    void success(String msg) {
decde35d5139 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
diff changeset
    97
        passed++;
decde35d5139 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
diff changeset
    98
        System.out.println(msg);
decde35d5139 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
diff changeset
    99
    }
decde35d5139 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
diff changeset
   100
decde35d5139 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
diff changeset
   101
}