< prev index next >

test/jdk/java/io/File/DeleteOnExit.java

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 2002, 2010, 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 * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. --- 1,7 ---- /* ! * Copyright (c) 2002, 2019, 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 * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation.
*** 20,30 **** * or visit www.oracle.com if you need additional information or have any * questions. */ /* @test ! @bug 4614121 4809375 6437591 @summary Basic test for deleteOnExit method @author kladko */ --- 20,30 ---- * or visit www.oracle.com if you need additional information or have any * questions. */ /* @test ! @bug 4614121 4809375 6437591 8193072 @summary Basic test for deleteOnExit method @author kladko */
*** 44,75 **** static File file4 = new File(dir + File.separator + "deletedOnExit4"); static File file5 = new File(dir + File.separator + "dxnsdnguidfgejngognrogn"); static File file6 = new File(dir + File.separator + "mmmmmmsdmfgmdsmfgmdsfgm"); static File file7 = new File(dir + File.separator + "12345566777"); public static void main (String args[]) throws Exception{ if (args.length == 0) { String cmd = java + " -classpath " + System.getProperty("test.classes") + " DeleteOnExit -test"; Runtime.getRuntime().exec(cmd).waitFor(); if (file1.exists() || file2.exists() || file3.exists() || dir.exists() || file4.exists() || file5.exists() || ! file6.exists() || file7.exists()) { System.out.println(file1 + ", exists = " + file1.exists()); System.out.println(file2 + ", exists = " + file2.exists()); System.out.println(file3 + ", exists = " + file3.exists()); System.out.println(dir + ", exists = " + dir.exists()); System.out.println(file4 + ", exists = " + file4.exists()); System.out.println(file5 + ", exists = " + file5.exists()); System.out.println(file6 + ", exists = " + file6.exists()); System.out.println(file7 + ", exists = " + file7.exists()); // cleanup undeleted dir if test fails dir.delete(); throw new Exception("File exists"); } } else { file1.createNewFile(); file2.createNewFile(); file3.createNewFile(); --- 44,84 ---- static File file4 = new File(dir + File.separator + "deletedOnExit4"); static File file5 = new File(dir + File.separator + "dxnsdnguidfgejngognrogn"); static File file6 = new File(dir + File.separator + "mmmmmmsdmfgmdsmfgmdsfgm"); static File file7 = new File(dir + File.separator + "12345566777"); + // used to test cancelDeleteOnExit() + static File file8 = new File(tmpdir + "cancelledDeleteOnExit8"); + static File file9 = new File(tmpdir + "uncancelledDeleteOnExit9"); + public static void main (String args[]) throws Exception{ if (args.length == 0) { String cmd = java + " -classpath " + System.getProperty("test.classes") + " DeleteOnExit -test"; Runtime.getRuntime().exec(cmd).waitFor(); if (file1.exists() || file2.exists() || file3.exists() || dir.exists() || file4.exists() || file5.exists() || ! file6.exists() || file7.exists() || file9.exists()) { System.out.println(file1 + ", exists = " + file1.exists()); System.out.println(file2 + ", exists = " + file2.exists()); System.out.println(file3 + ", exists = " + file3.exists()); System.out.println(dir + ", exists = " + dir.exists()); System.out.println(file4 + ", exists = " + file4.exists()); System.out.println(file5 + ", exists = " + file5.exists()); System.out.println(file6 + ", exists = " + file6.exists()); System.out.println(file7 + ", exists = " + file7.exists()); + System.out.println(file9 + ", exists = " + file9.exists()); // cleanup undeleted dir if test fails dir.delete(); throw new Exception("File exists"); + } else if (!file8.exists()) { + System.out.println(file8 + ", exists = " + file8.exists()); + + throw new Exception("File does not exist"); } } else { file1.createNewFile(); file2.createNewFile(); file3.createNewFile();
*** 99,106 **** --- 108,124 ---- file4.deleteOnExit(); file5.deleteOnExit(); file6.deleteOnExit(); file7.deleteOnExit(); } + + // Check cancelDeleteOnExit + file8.createNewFile(); + file8.deleteOnExit(); + file8.cancelDeleteOnExit(); + file9.createNewFile(); + file9.deleteOnExit(); + file9.deleteOnExit(); + file9.cancelDeleteOnExit(); } } }
< prev index next >