Skip to content

Commit d227657

Browse files
committed
8328367: Convert java/awt/Component/UpdatingBootTime test to main
Backport-of: 03c25b15eb73e594d1329be397cd34e206d2682b
1 parent 9512e53 commit d227657

File tree

3 files changed

+98
-265
lines changed

3 files changed

+98
-265
lines changed
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
/*
2+
* Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*/
23+
24+
/*
25+
* @test
26+
* @bug 6461933 7194219
27+
* @summary adjust system boot time in nowMillisUTC() frequently
28+
* @library /java/awt/regtesthelpers
29+
* @build PassFailJFrame
30+
* @run main/manual UpdatingBootTime
31+
*/
32+
33+
/*
34+
* Test verifies that time updated by the system is correctly
35+
* picked up by the Java application.
36+
*/
37+
38+
import java.awt.BorderLayout;
39+
import java.awt.Button;
40+
import java.awt.event.MouseAdapter;
41+
import java.awt.event.MouseEvent;
42+
import java.lang.reflect.InvocationTargetException;
43+
import java.util.Date;
44+
import javax.swing.JFrame;
45+
import javax.swing.JScrollPane;
46+
import javax.swing.JTextArea;
47+
48+
public class UpdatingBootTime {
49+
private static JFrame initialize () {
50+
JFrame frame = new JFrame("Updating Boot Time Test Frame");
51+
frame.setLayout(new BorderLayout());
52+
JTextArea textOutput = new JTextArea("Events on the button:", 14, 40);
53+
textOutput.setLineWrap(true);
54+
JScrollPane textScrollPane = new JScrollPane(textOutput);
55+
frame.add(textScrollPane, BorderLayout.CENTER);
56+
Button b = new Button("Press me");
57+
frame.add(b, BorderLayout.NORTH);
58+
b.addMouseListener(new MouseAdapter() {
59+
public void mousePressed(MouseEvent e) {
60+
textOutput.append("\nEvent occurred : " + e);
61+
textOutput.append("\nThe event time is : " + (new Date(e.getWhen())));
62+
textOutput.append("\nThe system time is : " + (new Date()));
63+
textOutput.append("\n------------------------------------");
64+
textOutput.setCaretPosition(textOutput.getText().length());
65+
}
66+
});
67+
frame.pack();
68+
return frame;
69+
}
70+
71+
public static void main(String[] args) throws InterruptedException,
72+
InvocationTargetException {
73+
String instructions =
74+
"""
75+
1) In the test window press "Press me" button.
76+
2) Two timestamps should be printed.
77+
3) Verify that they are not differ a lot:
78+
it is okay to observe a 1 or 2 seconds difference.
79+
4) Change the system time significantly (by a month or a year)
80+
by using the OS abilities.
81+
5) Click on the button once again.
82+
6) Printed times should still be the same.
83+
Pay attention to the Month/Year if they were changed.
84+
7) It is okay to observe a 1 or 2 seconds difference and this is not a fail.
85+
8) If the difference is more then 1-2 seconds noticed press fail,
86+
otherwise press pass.
87+
""";
88+
89+
PassFailJFrame.builder()
90+
.title("Updating Boot Time Test Instructions")
91+
.instructions(instructions)
92+
.rows((int) instructions.lines().count() + 1)
93+
.columns(40)
94+
.testUI(UpdatingBootTime::initialize)
95+
.build()
96+
.awaitAndCheck();
97+
}
98+
}

test/jdk/java/awt/Component/UpdatingBootTime/UpdatingBootTime.html

Lines changed: 0 additions & 43 deletions
This file was deleted.

test/jdk/java/awt/Component/UpdatingBootTime/UpdatingBootTime.java

Lines changed: 0 additions & 222 deletions
This file was deleted.

0 commit comments

Comments
 (0)