jdk/test/java/awt/datatransfer/Clipboard/GetContentsInterruptedTest.java
author goetz
Tue, 14 Jun 2016 10:44:59 +0200
changeset 39056 d99e63b6d962
parent 25569 2bea87828632
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:
25569
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
     1
/*
39056
d99e63b6d962 8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents: 25569
diff changeset
     2
 * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
25569
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
     4
 *
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    10
 *
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    15
 * accompanied this code).
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    16
 *
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    20
 *
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    23
 * questions.
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    24
 */
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    25
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    26
import java.awt.*;
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    27
import java.awt.datatransfer.Clipboard;
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    28
import java.awt.datatransfer.ClipboardOwner;
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    29
import java.awt.datatransfer.StringSelection;
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    30
import java.awt.datatransfer.Transferable;
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    31
import java.io.File;
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    32
import java.io.IOException;
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    33
import java.io.InputStream;
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    34
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    35
/*
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    36
 * @test
39056
d99e63b6d962 8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents: 25569
diff changeset
    37
 * @key headful
25569
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    38
 * @bug 4532299 4648733
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    39
 * @summary Tests that getting clipboard contents on the interrupted thread will
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    40
 *          not cause deadlock.Also check that lostOwnership event occurs while
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    41
 *          cross-JVM interaction
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    42
 * @author Kanishk Jethi
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    43
 * @run main GetContentsInterruptedTest
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    44
 */
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    45
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    46
public class GetContentsInterruptedTest implements ClipboardOwner {
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    47
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    48
    final Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    49
    final Transferable transferable = new StringSelection("TEXT");
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    50
    private final Object o = new Object();
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    51
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    52
    public static void main(String args[]) throws Exception {
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    53
        if (System.getProperty("os.name").startsWith("Mac")) {
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    54
            System.out.println("This tests should not be run on OS X. " +
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    55
                    "See CR 7124344 for more info");
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    56
        } else {
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    57
            boolean subTestFlag = false;
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    58
            for (String arg : args) {
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    59
                if (arg.indexOf("SubTest") != -1)
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    60
                    subTestFlag = true;
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    61
            }
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    62
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    63
            if (!subTestFlag) {
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    64
                new GetContentsInterruptedTest().performTest();
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    65
            } else {
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    66
                new GetContentsInterruptedTest().execute();
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    67
            }
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    68
        }
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    69
    }
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    70
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    71
    private void performTest() throws Exception {
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    72
        int retCode;
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    73
        String javaPath = System.getProperty("java.home", "");
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    74
        String javaClasspath = System.getProperty("java.class.path", ".");
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    75
        String command = javaPath + File.separator + "bin" +
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    76
            File.separator + "java -classpath " + javaClasspath +
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    77
            " GetContentsInterruptedTest SubTest";
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    78
        System.out.println(command);
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    79
        boolean processExit = false;
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    80
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    81
        clipboard.setContents(transferable, this);
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    82
        Process process = Runtime.getRuntime().exec(command);
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    83
        synchronized (o) {
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    84
            o.wait(10000);
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    85
        }
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    86
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    87
        try {
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    88
            retCode = process.exitValue();
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    89
            processExit = true;
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    90
        }catch (IllegalThreadStateException e){
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    91
            throw new RuntimeException(e);
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    92
        }
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    93
        System.out.println("[RESULT] : " +
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    94
                "The sub process has cleanly exited : PASS");
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    95
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    96
        System.out.println("[RESULT] : Child returned: " + retCode );
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    97
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    98
        InputStream errorStream = process.getErrorStream();
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    99
        System.out.println("========= Child process stderr ========");
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   100
        dumpStream(errorStream);
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   101
        System.out.println("=======================================");
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   102
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   103
        InputStream processInputStream = process.getInputStream();
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   104
        System.out.println("========= Child process output ========");
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   105
        dumpStream(processInputStream);
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   106
        System.out.println("=======================================");
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   107
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   108
        if (!processExit) {
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   109
            process.destroy();
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   110
            throw new RuntimeException("[RESULT] : " +
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   111
                    "The sub process has not exited : FAIL");
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   112
        }
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   113
    }
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   114
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   115
    /*
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   116
     * execute is run through another instance of this class.
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   117
     * it acquires the systemClipboard through another JVM.
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   118
     */
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   119
    public void execute() {
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   120
        System.out.println("Hello world");
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   121
        final ClipboardOwner clipboardOwner = new ClipboardOwner() {
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   122
            public void lostOwnership(Clipboard clipboard, Transferable contents) {
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   123
                System.exit(0);
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   124
            }
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   125
        };
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   126
        clipboard.setContents(transferable, clipboardOwner);
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   127
        synchronized (o) {
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   128
            try {
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   129
                o.wait();
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   130
            } catch (InterruptedException ie) {
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   131
                ie.printStackTrace();
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   132
            }
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   133
        }
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   134
    }
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   135
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   136
    public void dumpStream(InputStream in) throws IOException {
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   137
        String tempString;
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   138
        int count = in.available();
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   139
        while (count > 0) {
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   140
            byte[] b = new byte[count];
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   141
            in.read(b);
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   142
            tempString = new String(b);
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   143
            if (tempString.indexOf("Exception") != -1 )
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   144
                throw new RuntimeException("[RESULT] :" +
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   145
                        " Exception in child process : FAIL");
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   146
            System.out.println(tempString);
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   147
            count = in.available();
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   148
        }
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   149
    }
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   150
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   151
    public void lostOwnership(Clipboard clip, Transferable contents) {
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   152
        new Thread(() -> {
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   153
            try {
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   154
                Thread.sleep(3000);
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   155
            } catch (InterruptedException e) {
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   156
                throw new RuntimeException(e);
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   157
            }
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   158
            clipboard.getContents(null);
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   159
            Thread.currentThread().interrupt();
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   160
            clipboard.getContents(null);
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   161
            clipboard.setContents(transferable, null);
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   162
        }).start();
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   163
    }
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   164
}
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   165