Skip to content

8360562: sun/security/tools/keytool/i18n.java add an ability to add comment for failures #26412

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 45 additions & 3 deletions test/jdk/sun/security/tools/keytool/i18n.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -63,11 +63,21 @@

import jdk.test.lib.UIBuilder;

import javax.swing.*;
import javax.swing.JDialog;
import javax.swing.SwingUtilities;
import javax.swing.JTextArea;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JFrame;
import java.awt.FlowLayout;
import java.awt.BorderLayout;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.util.Locale;

import static javax.swing.BorderFactory.createEmptyBorder;

public class i18n {
private static final String[][] TABLE = new String[][]{
{"-help", "All the output in this test should be in ${LANG}. "
Expand Down Expand Up @@ -238,11 +248,12 @@ public class i18n {
"Output in ${LANG}. Check keytool error: java.lang"
+ ".IllegalArgumentException: if -protected is "
+ "specified, then -storepass, -keypass, and -new "
+ "must not be specified."},
+ "must not be specified."}
};
private static String TEST_SRC = System.getProperty("test.src");
private static int TIMEOUT_MS = 120000;
private volatile boolean failed = false;
private volatile String failureReason = "";
private volatile boolean aborted = false;
private Thread currentThread = null;

Expand Down Expand Up @@ -334,6 +345,7 @@ public boolean validate(String command, String instruction, String message) {

if (failed) {
System.out.println(command + ": TEST FAILED");
System.out.println("REASON: " + failureReason);
System.out.println(message);
} else {
System.out.println(command + ": TEST PASSED");
Expand All @@ -352,11 +364,41 @@ public void pass() {

public void fail() {
failed = true;
failureReason = requestFailDescription();
currentThread.interrupt();
}

public void abort() {
aborted = true;
currentThread.interrupt();
}

/**
* Opens a prompt to enter a failure reason to be filled by the tester
*/
public static String requestFailDescription() {

final JDialog dialogWindow = new JDialog(new JFrame(), "Failure Description", true);
final JTextArea reasonTextArea = new JTextArea(5, 20);

final JButton okButton = new JButton("OK");
okButton.addActionListener(_ -> dialogWindow.setVisible(false));

final JPanel okayBtnPanel = new JPanel(
new FlowLayout(FlowLayout.CENTER, 4, 0));
okayBtnPanel.setBorder(createEmptyBorder(4, 0, 0, 0));
okayBtnPanel.add(okButton);

final JPanel mainPanel = new JPanel(new BorderLayout());
mainPanel.add(new JScrollPane(reasonTextArea), BorderLayout.CENTER);
mainPanel.add(okayBtnPanel, BorderLayout.SOUTH);

dialogWindow.add(mainPanel);
dialogWindow.pack();
dialogWindow.setVisible(true);

dialogWindow.dispose();

return reasonTextArea.getText();
}
}