test/jdk/sun/security/tools/keytool/KeyToolTest.java
changeset 49882 a02abc7e5536
parent 47216 71c04702a3d5
child 51944 28085dba5d9a
equal deleted inserted replaced
49881:29419b836244 49882:a02abc7e5536
     1 /*
     1 /*
     2  * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     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
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    63 import java.io.*;
    63 import java.io.*;
    64 import java.security.KeyPairGenerator;
    64 import java.security.KeyPairGenerator;
    65 import java.security.NoSuchAlgorithmException;
    65 import java.security.NoSuchAlgorithmException;
    66 import java.util.*;
    66 import java.util.*;
    67 import java.security.cert.X509Certificate;
    67 import java.security.cert.X509Certificate;
       
    68 import jdk.test.lib.util.FileUtils;
    68 import sun.security.util.ObjectIdentifier;
    69 import sun.security.util.ObjectIdentifier;
    69 
    70 
    70 public class KeyToolTest {
    71 public class KeyToolTest {
    71 
    72 
    72     // The stdout and stderr outputs after a keytool run
    73     // The stdout and stderr outputs after a keytool run
   116      */
   117      */
   117     void remove(String filename) {
   118     void remove(String filename) {
   118         if (debug) {
   119         if (debug) {
   119             System.err.println("Removing " + filename);
   120             System.err.println("Removing " + filename);
   120         }
   121         }
   121         new File(filename).delete();
   122         try{
   122         if (new File(filename).exists()) {
   123             FileUtils.deleteFileIfExistsWithRetry(Paths.get(filename));
   123             throw new RuntimeException("Error deleting " + filename);
   124         }catch(IOException e) {
       
   125             throw new RuntimeException("Error deleting " + filename, e);
   124         }
   126         }
   125     }
   127     }
   126 
   128 
   127     /**
   129     /**
   128      * Run a set of keytool command with given terminal input.
   130      * Run a set of keytool command with given terminal input.