jdk/test/java/awt/xembed/server/RunTestXEmbed.java
author goetz
Tue, 14 Jun 2016 10:44:59 +0200
changeset 39056 d99e63b6d962
parent 36915 2258afe73d4c
child 40261 86a49ba76f52
permissions -rw-r--r--
8159690: [TESTBUG] Mark headful tests with @key headful. Reviewed-by: simonis, alexsch
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
443
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
     1
/*
39056
d99e63b6d962 8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents: 36915
diff changeset
     2
 * Copyright (c) 2004, 2016, Oracle and/or its affiliates. All rights reserved.
443
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
     4
 *
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
     7
 * published by the Free Software Foundation.
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
     8
 *
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    13
 * accompanied this code).
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    14
 *
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    18
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 443
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 443
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 443
diff changeset
    21
 * questions.
443
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    22
 */
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    23
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    24
/**
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    25
 * @test
39056
d99e63b6d962 8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents: 36915
diff changeset
    26
 * @key headful
34413
bbed9966db6e 7146533: [TEST BUG] [macosx] skip java/awt/xembed/server/RunTestXEmbed.java for Mac OS X
kshefov
parents: 31448
diff changeset
    27
 * @bug 4931668 7146533
443
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    28
 * @summary Tests XEmbed server/client functionality
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    29
 * @author Denis Mikhalkin: area=awt.xembed
34413
bbed9966db6e 7146533: [TEST BUG] [macosx] skip java/awt/xembed/server/RunTestXEmbed.java for Mac OS X
kshefov
parents: 31448
diff changeset
    30
 * @requires (!(os.family=="mac") & !(os.family=="windows"))
bbed9966db6e 7146533: [TEST BUG] [macosx] skip java/awt/xembed/server/RunTestXEmbed.java for Mac OS X
kshefov
parents: 31448
diff changeset
    31
 * @library /lib/testlibrary
36915
2258afe73d4c 8150535: [TEST_BUG] fix @library for test/java/awt/TrayIcon/MouseMovedTest/MouseMovedTest.java
yan
parents: 34413
diff changeset
    32
 * @modules java.desktop/sun.awt
34413
bbed9966db6e 7146533: [TEST BUG] [macosx] skip java/awt/xembed/server/RunTestXEmbed.java for Mac OS X
kshefov
parents: 31448
diff changeset
    33
 * @build jdk.testlibrary.Platform
443
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    34
 * @compile JavaClient.java TesterClient.java TestXEmbedServer.java
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    35
 * @run main/timeout=6000 RunTestXEmbed
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    36
 */
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    37
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    38
import java.awt.Rectangle;
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    39
import java.lang.reflect.Method;
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    40
import java.util.logging.*;
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    41
import java.util.*;
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    42
import java.io.*;
36915
2258afe73d4c 8150535: [TEST_BUG] fix @library for test/java/awt/TrayIcon/MouseMovedTest/MouseMovedTest.java
yan
parents: 34413
diff changeset
    43
import jdk.testlibrary.Platform;
443
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    44
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    45
public class RunTestXEmbed extends TestXEmbedServer {
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    46
    private static final Logger log = Logger.getLogger("test.xembed");
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    47
    private Method test;
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    48
    private boolean passed = false;
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    49
    public RunTestXEmbed(Method test) {
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    50
        super(false);
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    51
        this.test = test;
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    52
    }
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    53
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    54
    public Process startClient(Rectangle bounds[], long window) {
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    55
        try {
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    56
            String java_home = System.getProperty("java.home");
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    57
            StringBuilder buf = new StringBuilder();
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    58
            for (int i = 0; i < bounds.length; i++) {
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    59
                buf.append(" " + bounds[i].x);
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    60
                buf.append(" " + bounds[i].y);
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    61
                buf.append(" " + bounds[i].width);
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    62
                buf.append(" " + bounds[i].height);
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    63
            }
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    64
            Map envs = System.getenv();
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    65
            String enva[] = new String[envs.size()];
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    66
            int ind = 0;
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    67
            Iterator iter = envs.entrySet().iterator();
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    68
            while (iter.hasNext()) {
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    69
                Map.Entry entry = (Map.Entry)iter.next();
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    70
                if (!"AWT_TOOLKIT".equals(entry.getKey())) {
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    71
                    enva[ind++] = entry.getKey() + "=" + entry.getValue();
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    72
                } else {
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    73
                    enva[ind++] = "AWT_TOOLKIT=sun.awt.X11.XToolkit";
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    74
                }
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    75
            }
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    76
            Process proc = Runtime.getRuntime().exec(java_home +
36915
2258afe73d4c 8150535: [TEST_BUG] fix @library for test/java/awt/TrayIcon/MouseMovedTest/MouseMovedTest.java
yan
parents: 34413
diff changeset
    77
                                                     "/bin/java -XaddExports:java.desktop/sun.awt.X11=ALL-UNNAMED -Dawt.toolkit=sun.awt.X11.XToolkit TesterClient "
443
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    78
                                                     + test.getName() + " " + window + buf,
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    79
                                                     enva);
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    80
            System.err.println("Test for " + test.getName() + " has started.");
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    81
            log.fine("Test for " + test.getName() + " has started.");
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    82
            new InputReader(proc.getInputStream());
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    83
            new InputReader(proc.getErrorStream());
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    84
            try {
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    85
                passed = (proc.waitFor() == 0);
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    86
            } catch (InterruptedException ie) {
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    87
            }
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    88
            log.fine("Test for " + test.getName() + " has finished.");
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    89
            File logFile = new File("java3.txt");
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    90
            if (logFile.exists()) {
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    91
                logFile.renameTo(new File(test.getName() + ".txt"));
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    92
            }
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    93
            return proc;
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    94
        } catch (IOException ex1) {
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    95
            ex1.printStackTrace();
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    96
        }
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    97
        return null;
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    98
    }
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    99
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   100
    public static void main(String[] args) throws Throwable {
34413
bbed9966db6e 7146533: [TEST BUG] [macosx] skip java/awt/xembed/server/RunTestXEmbed.java for Mac OS X
kshefov
parents: 31448
diff changeset
   101
        if (Platform.isWindows() || Platform.isOSX()) {
443
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   102
            return;
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   103
        }
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   104
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   105
        // Enabled XEmbed
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   106
        System.setProperty("sun.awt.xembedserver", "true");
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   107
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   108
        if (args.length == 1) {
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   109
            Class cl = Class.forName("sun.awt.X11.XEmbedServerTester");
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   110
            Method meth = cl.getMethod(args[0], new Class[0]);
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   111
            System.err.println("Performing single test " + args[0]);
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   112
            boolean res = performTest(meth);
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   113
            if (!res) {
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   114
                System.err.println("Test " + args[0] + " has failed");
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   115
            } else {
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   116
                System.err.println("Test " + args[0] + " has passed");
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   117
            }
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   118
        } else {
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   119
            Class cl = Class.forName("sun.awt.X11.XEmbedServerTester");
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   120
            Method[] meths = cl.getMethods();
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   121
            LinkedList failed = new LinkedList();
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   122
            for (int i = 0; i < meths.length; i++) {
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   123
                Method meth = meths[i];
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   124
                if (meth.getReturnType() == Void.TYPE && meth.getName().startsWith("test") && meth.getParameterTypes().length == 0) {
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   125
                    System.err.println("Performing " + meth.getName());
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   126
                    boolean res = performTest(meth);
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   127
                    if (!res) {
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   128
                        failed.add(meth);
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   129
                    }
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   130
                }
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   131
            }
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   132
            log.info("Testing finished.");
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   133
            if (failed.size() != 0) {
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   134
                System.err.println("Some tests have failed:");
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   135
                Iterator iter = failed.iterator();
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   136
                while(iter.hasNext()) {
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   137
                    Method meth = (Method)iter.next();
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   138
                    System.err.println(meth.getName());
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   139
                }
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   140
                throw new RuntimeException("TestFAILED: some of the testcases are failed");
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   141
            } else {
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   142
                System.err.println("All PASSED");
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   143
            }
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   144
        }
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   145
    }
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   146
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   147
    private static boolean performTest(Method meth) {
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   148
        RunTestXEmbed test = new RunTestXEmbed(meth);
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   149
        test.addClient();
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   150
        test.dispose();
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   151
        return test.isPassed();
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   152
    }
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   153
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   154
    public boolean isPassed() {
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   155
        return passed;
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   156
    }
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   157
}
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   158
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   159
class InputReader extends Thread {
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   160
    private InputStream stream;
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   161
    public InputReader(InputStream stream) {
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   162
        this.stream = stream;
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   163
        start();
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   164
    }
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   165
    public void run() {
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   166
        while (!interrupted()) {
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   167
            try {
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   168
                int inp = stream.read();
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   169
                if (inp != -1) {
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   170
                    System.out.write(inp);
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   171
                } else {
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   172
                    try {
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   173
                        Thread.sleep(100);
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   174
                    } catch (Exception iie) {
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   175
                    }
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   176
                }
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   177
            } catch (IOException ie) {
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   178
                break;
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   179
            }
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   180
        }
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   181
    }
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   182
}