11/*
2- * Copyright (c) 2018, 2019 , Oracle and/or its affiliates. All rights reserved.
2+ * Copyright (c) 2018, 2021 , Oracle and/or its affiliates. All rights reserved.
33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44 *
55 * This code is free software; you can redistribute it and/or modify it
2323
2424/*
2525 * @test
26- * @bug 8153732 8212202 8221263 8221412 8222108
26+ * @bug 8153732 8212202 8221263 8221412 8222108 8263311
2727 * @requires (os.family == "Windows")
2828 * @summary Windows remote printer changes do not reflect in lookupPrintServices()
29- * @run main/manual/othervm -Dsun.java2d.print.minRefreshTime=120 RemotePrinterStatusRefresh
29+ * @run main/manual RemotePrinterStatusRefresh
3030 */
3131
3232import java .awt .BorderLayout ;
6363
6464public class RemotePrinterStatusRefresh extends WindowAdapter {
6565
66- private static final long DEFAULT_REFRESH_TIME = 240L ;
67- private static final long MINIMAL_REFRESH_TIME = 120L ;
68-
69- private static final long refreshTime = getRefreshTime ();
70-
71- private static final long TIMEOUT = refreshTime * 4 + 60 ;
66+ private static final long TIMEOUT = 15L * 60 ;
7267
7368
7469 private static final CountDownLatch latch = new CountDownLatch (1 );
@@ -86,7 +81,6 @@ public class RemotePrinterStatusRefresh extends WindowAdapter {
8681 private final ServiceItemListModel beforeList ;
8782 private final ServiceItemListModel afterList ;
8883
89- private JTextField nextRefresh ;
9084 private JTextField timeLeft ;
9185
9286 private final Timer timer ;
@@ -184,22 +178,18 @@ public Component getListCellRendererComponent(JList<?> list,
184178 + "configured printers.\n "
185179 + "Step 1: Add or Remove a network printer using "
186180 + "Windows Control Panel.\n "
187- + "Step 2: Wait for 2\u2013 4 minutes after adding or removing.\n "
188- + " \" Next printer refresh in\" gives you a "
189- + "rough estimation on when update will happen.\n "
190- + "Step 3: Click Refresh."
181+ + "Step 2: Click Refresh."
191182 + "\" After\" list is populated with updated list "
192183 + "of printers.\n "
193- + "Step 4 : Compare the list of printers in \" Before\" and "
184+ + "Step 3 : Compare the list of printers in \" Before\" and "
194185 + "\" After\" lists.\n "
195186 + " Added printers are highlighted with "
196187 + "green color, removed ones \u2014 with "
197188 + "red color.\n "
198- + "Step 5 : Click Pass if the list of printers is correctly "
189+ + "Step 4 : Click Pass if the list of printers is correctly "
199190 + "updated.\n "
200- + "Step 6: If the list is not updated, wait for another "
201- + "2\u2013 4 minutes, and then click Refresh again.\n "
202- + "Step 7: If the list does not update, click Fail.\n "
191+ + "Step 5: If the list is not updated, click Refresh again.\n "
192+ + "Step 6: If the list does not update, click Fail.\n "
203193 + "\n "
204194 + "You have to click Refresh to enable Pass and Fail buttons. "
205195 + "If no button is pressed,\n "
@@ -216,18 +206,6 @@ public static void main(String[] args) throws Exception {
216206 }
217207 }
218208
219- private static long getRefreshTime () {
220- String refreshTime =
221- System .getProperty ("sun.java2d.print.minRefreshTime" ,
222- Long .toString (DEFAULT_REFRESH_TIME ));
223- try {
224- long value = Long .parseLong (refreshTime );
225- return value < MINIMAL_REFRESH_TIME ? MINIMAL_REFRESH_TIME : value ;
226- } catch (NumberFormatException e ) {
227- return DEFAULT_REFRESH_TIME ;
228- }
229- }
230-
231209 private static void createUI () {
232210 test = new RemotePrinterStatusRefresh ();
233211 }
@@ -278,31 +256,6 @@ private JPanel createInfoPanel() {
278256 javaVersion .setEditable (false );
279257 javaLabel .setLabelFor (javaVersion );
280258
281- JLabel refreshTimeLabel = new JLabel ("Refresh interval:" );
282- long minutes = refreshTime / 60 ;
283- long seconds = refreshTime % 60 ;
284- String interval = String .format ("%1$d seconds%2$s" ,
285- refreshTime ,
286- minutes > 0
287- ? String .format (" (%1$d %2$s%3$s)" ,
288- minutes ,
289- minutes > 1 ? "minutes" : "minute" ,
290- seconds > 0
291- ? String .format (" %1$d %2$s" ,
292- seconds ,
293- seconds > 1 ? "seconds" : "second" )
294- : "" )
295- : ""
296- );
297- JTextField refreshInterval = new JTextField (interval );
298- refreshInterval .setEditable (false );
299- refreshTimeLabel .setLabelFor (refreshInterval );
300-
301- JLabel nextRefreshLabel = new JLabel ("Next printer refresh in:" );
302- nextRefresh = new JTextField ();
303- nextRefresh .setEditable (false );
304- nextRefreshLabel .setLabelFor (nextRefresh );
305-
306259 JLabel timeoutLabel = new JLabel ("Time left:" );
307260 timeLeft = new JTextField ();
308261 timeLeft .setEditable (false );
@@ -317,14 +270,10 @@ private JPanel createInfoPanel() {
317270 layout .createSequentialGroup ()
318271 .addGroup (layout .createParallelGroup (GroupLayout .Alignment .LEADING )
319272 .addComponent (javaLabel )
320- .addComponent (refreshTimeLabel )
321- .addComponent (nextRefreshLabel )
322273 .addComponent (timeoutLabel )
323274 )
324275 .addGroup (layout .createParallelGroup (GroupLayout .Alignment .LEADING , true )
325276 .addComponent (javaVersion )
326- .addComponent (refreshInterval )
327- .addComponent (nextRefresh )
328277 .addComponent (timeLeft )
329278 )
330279 );
@@ -334,12 +283,6 @@ private JPanel createInfoPanel() {
334283 .addComponent (javaLabel )
335284 .addComponent (javaVersion )
336285 )
337- .addGroup (layout .createParallelGroup (GroupLayout .Alignment .BASELINE )
338- .addComponent (refreshTimeLabel )
339- .addComponent (refreshInterval ))
340- .addGroup (layout .createParallelGroup (GroupLayout .Alignment .BASELINE )
341- .addComponent (nextRefreshLabel )
342- .addComponent (nextRefresh ))
343286 .addGroup (layout .createParallelGroup (GroupLayout .Alignment .BASELINE )
344287 .addComponent (timeoutLabel )
345288 .addComponent (timeLeft ))
@@ -493,7 +436,6 @@ private void updateTimeLeft(ActionEvent e) {
493436 disposeUI ();
494437 }
495438 timeLeft .setText (formatTime (left ));
496- nextRefresh .setText (formatTime (refreshTime - (elapsed % refreshTime )));
497439 }
498440
499441 private static String formatTime (final long seconds ) {
0 commit comments