jdk/test/javax/swing/ToolTipManager/Test6657026.java
author cl
Fri, 18 Feb 2011 14:23:48 -0800
changeset 8267 6a5f458575cf
parent 5506 202f599c92aa
child 31448 1066345d2a8a
permissions -rw-r--r--
Added tag jdk7-b130 for changeset 8924242a88c8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4199
151e13fd2df1 6657026: Numerous static security flaws in Swing (findbugs)
malenkov
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4199
diff changeset
     2
 * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
4199
151e13fd2df1 6657026: Numerous static security flaws in Swing (findbugs)
malenkov
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
151e13fd2df1 6657026: Numerous static security flaws in Swing (findbugs)
malenkov
parents:
diff changeset
     4
 *
151e13fd2df1 6657026: Numerous static security flaws in Swing (findbugs)
malenkov
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
151e13fd2df1 6657026: Numerous static security flaws in Swing (findbugs)
malenkov
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
151e13fd2df1 6657026: Numerous static security flaws in Swing (findbugs)
malenkov
parents:
diff changeset
     7
 * published by the Free Software Foundation.
151e13fd2df1 6657026: Numerous static security flaws in Swing (findbugs)
malenkov
parents:
diff changeset
     8
 *
151e13fd2df1 6657026: Numerous static security flaws in Swing (findbugs)
malenkov
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
151e13fd2df1 6657026: Numerous static security flaws in Swing (findbugs)
malenkov
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
151e13fd2df1 6657026: Numerous static security flaws in Swing (findbugs)
malenkov
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
151e13fd2df1 6657026: Numerous static security flaws in Swing (findbugs)
malenkov
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
151e13fd2df1 6657026: Numerous static security flaws in Swing (findbugs)
malenkov
parents:
diff changeset
    13
 * accompanied this code).
151e13fd2df1 6657026: Numerous static security flaws in Swing (findbugs)
malenkov
parents:
diff changeset
    14
 *
151e13fd2df1 6657026: Numerous static security flaws in Swing (findbugs)
malenkov
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
151e13fd2df1 6657026: Numerous static security flaws in Swing (findbugs)
malenkov
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
151e13fd2df1 6657026: Numerous static security flaws in Swing (findbugs)
malenkov
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
151e13fd2df1 6657026: Numerous static security flaws in Swing (findbugs)
malenkov
parents:
diff changeset
    18
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4199
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4199
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4199
diff changeset
    21
 * questions.
4199
151e13fd2df1 6657026: Numerous static security flaws in Swing (findbugs)
malenkov
parents:
diff changeset
    22
 */
151e13fd2df1 6657026: Numerous static security flaws in Swing (findbugs)
malenkov
parents:
diff changeset
    23
151e13fd2df1 6657026: Numerous static security flaws in Swing (findbugs)
malenkov
parents:
diff changeset
    24
/*
151e13fd2df1 6657026: Numerous static security flaws in Swing (findbugs)
malenkov
parents:
diff changeset
    25
 * @test
151e13fd2df1 6657026: Numerous static security flaws in Swing (findbugs)
malenkov
parents:
diff changeset
    26
 * @bug 6657026
151e13fd2df1 6657026: Numerous static security flaws in Swing (findbugs)
malenkov
parents:
diff changeset
    27
 * @summary Tests shared ToolTipManager in different application contexts
151e13fd2df1 6657026: Numerous static security flaws in Swing (findbugs)
malenkov
parents:
diff changeset
    28
 * @author Sergey Malenkov
151e13fd2df1 6657026: Numerous static security flaws in Swing (findbugs)
malenkov
parents:
diff changeset
    29
 */
151e13fd2df1 6657026: Numerous static security flaws in Swing (findbugs)
malenkov
parents:
diff changeset
    30
151e13fd2df1 6657026: Numerous static security flaws in Swing (findbugs)
malenkov
parents:
diff changeset
    31
import sun.awt.SunToolkit;
151e13fd2df1 6657026: Numerous static security flaws in Swing (findbugs)
malenkov
parents:
diff changeset
    32
import javax.swing.ToolTipManager;
151e13fd2df1 6657026: Numerous static security flaws in Swing (findbugs)
malenkov
parents:
diff changeset
    33
151e13fd2df1 6657026: Numerous static security flaws in Swing (findbugs)
malenkov
parents:
diff changeset
    34
public class Test6657026 implements Runnable {
151e13fd2df1 6657026: Numerous static security flaws in Swing (findbugs)
malenkov
parents:
diff changeset
    35
151e13fd2df1 6657026: Numerous static security flaws in Swing (findbugs)
malenkov
parents:
diff changeset
    36
    private static final int DISMISS = 4000;
151e13fd2df1 6657026: Numerous static security flaws in Swing (findbugs)
malenkov
parents:
diff changeset
    37
    private static final int INITIAL = 750;
151e13fd2df1 6657026: Numerous static security flaws in Swing (findbugs)
malenkov
parents:
diff changeset
    38
    private static final int RESHOW = 500;
151e13fd2df1 6657026: Numerous static security flaws in Swing (findbugs)
malenkov
parents:
diff changeset
    39
151e13fd2df1 6657026: Numerous static security flaws in Swing (findbugs)
malenkov
parents:
diff changeset
    40
    public static void main(String[] args) throws InterruptedException {
151e13fd2df1 6657026: Numerous static security flaws in Swing (findbugs)
malenkov
parents:
diff changeset
    41
        ToolTipManager manager = ToolTipManager.sharedInstance();
151e13fd2df1 6657026: Numerous static security flaws in Swing (findbugs)
malenkov
parents:
diff changeset
    42
        if (DISMISS != manager.getDismissDelay()) {
151e13fd2df1 6657026: Numerous static security flaws in Swing (findbugs)
malenkov
parents:
diff changeset
    43
            throw new Error("unexpected dismiss delay");
151e13fd2df1 6657026: Numerous static security flaws in Swing (findbugs)
malenkov
parents:
diff changeset
    44
        }
151e13fd2df1 6657026: Numerous static security flaws in Swing (findbugs)
malenkov
parents:
diff changeset
    45
        if (INITIAL != manager.getInitialDelay()) {
151e13fd2df1 6657026: Numerous static security flaws in Swing (findbugs)
malenkov
parents:
diff changeset
    46
            throw new Error("unexpected initial delay");
151e13fd2df1 6657026: Numerous static security flaws in Swing (findbugs)
malenkov
parents:
diff changeset
    47
        }
151e13fd2df1 6657026: Numerous static security flaws in Swing (findbugs)
malenkov
parents:
diff changeset
    48
        if (RESHOW != manager.getReshowDelay()) {
151e13fd2df1 6657026: Numerous static security flaws in Swing (findbugs)
malenkov
parents:
diff changeset
    49
            throw new Error("unexpected reshow delay");
151e13fd2df1 6657026: Numerous static security flaws in Swing (findbugs)
malenkov
parents:
diff changeset
    50
        }
151e13fd2df1 6657026: Numerous static security flaws in Swing (findbugs)
malenkov
parents:
diff changeset
    51
        manager.setDismissDelay(DISMISS + 1);
151e13fd2df1 6657026: Numerous static security flaws in Swing (findbugs)
malenkov
parents:
diff changeset
    52
        manager.setInitialDelay(INITIAL + 1);
151e13fd2df1 6657026: Numerous static security flaws in Swing (findbugs)
malenkov
parents:
diff changeset
    53
        manager.setReshowDelay(RESHOW + 1);
151e13fd2df1 6657026: Numerous static security flaws in Swing (findbugs)
malenkov
parents:
diff changeset
    54
151e13fd2df1 6657026: Numerous static security flaws in Swing (findbugs)
malenkov
parents:
diff changeset
    55
        ThreadGroup group = new ThreadGroup("$$$");
151e13fd2df1 6657026: Numerous static security flaws in Swing (findbugs)
malenkov
parents:
diff changeset
    56
        Thread thread = new Thread(group, new Test6657026());
151e13fd2df1 6657026: Numerous static security flaws in Swing (findbugs)
malenkov
parents:
diff changeset
    57
        thread.start();
151e13fd2df1 6657026: Numerous static security flaws in Swing (findbugs)
malenkov
parents:
diff changeset
    58
        thread.join();
151e13fd2df1 6657026: Numerous static security flaws in Swing (findbugs)
malenkov
parents:
diff changeset
    59
    }
151e13fd2df1 6657026: Numerous static security flaws in Swing (findbugs)
malenkov
parents:
diff changeset
    60
151e13fd2df1 6657026: Numerous static security flaws in Swing (findbugs)
malenkov
parents:
diff changeset
    61
    public void run() {
151e13fd2df1 6657026: Numerous static security flaws in Swing (findbugs)
malenkov
parents:
diff changeset
    62
        SunToolkit.createNewAppContext();
151e13fd2df1 6657026: Numerous static security flaws in Swing (findbugs)
malenkov
parents:
diff changeset
    63
        ToolTipManager manager = ToolTipManager.sharedInstance();
151e13fd2df1 6657026: Numerous static security flaws in Swing (findbugs)
malenkov
parents:
diff changeset
    64
        if (DISMISS != manager.getDismissDelay()) {
151e13fd2df1 6657026: Numerous static security flaws in Swing (findbugs)
malenkov
parents:
diff changeset
    65
            throw new Error("shared dismiss delay");
151e13fd2df1 6657026: Numerous static security flaws in Swing (findbugs)
malenkov
parents:
diff changeset
    66
        }
151e13fd2df1 6657026: Numerous static security flaws in Swing (findbugs)
malenkov
parents:
diff changeset
    67
        if (INITIAL != manager.getInitialDelay()) {
151e13fd2df1 6657026: Numerous static security flaws in Swing (findbugs)
malenkov
parents:
diff changeset
    68
            throw new Error("shared initial delay");
151e13fd2df1 6657026: Numerous static security flaws in Swing (findbugs)
malenkov
parents:
diff changeset
    69
        }
151e13fd2df1 6657026: Numerous static security flaws in Swing (findbugs)
malenkov
parents:
diff changeset
    70
        if (RESHOW != manager.getReshowDelay()) {
151e13fd2df1 6657026: Numerous static security flaws in Swing (findbugs)
malenkov
parents:
diff changeset
    71
            throw new Error("shared reshow delay");
151e13fd2df1 6657026: Numerous static security flaws in Swing (findbugs)
malenkov
parents:
diff changeset
    72
        }
151e13fd2df1 6657026: Numerous static security flaws in Swing (findbugs)
malenkov
parents:
diff changeset
    73
    }
151e13fd2df1 6657026: Numerous static security flaws in Swing (findbugs)
malenkov
parents:
diff changeset
    74
}