Mercurial > hg > openjdk > jdk9 > jdk
changeset 17170:7b5027da67f7
8178383: Validation of FileIO in the tests for JavaSound should be stricter
Reviewed-by: prr
line wrap: on
line diff
--- a/test/ProblemList.txt Fri May 05 08:34:22 2017 -0700 +++ b/test/ProblemList.txt Sat May 06 13:17:36 2017 -0700 @@ -216,9 +216,13 @@ ############################################################################ # jdk_sound -javax/sound/sampled/DirectAudio/bug6372428.java 8055097 generic-all -javax/sound/sampled/Clip/bug5070081.java 8055097 generic-all -javax/sound/sampled/DataLine/LongFramePosition.java 8055097 generic-all +javax/sound/sampled/AudioInputStream/FrameLengthAfterConversion.java 8178401 windows-all + +javax/sound/sampled/Clip/ClipCloseLoss.java 8178403 generic-all + +javax/sound/sampled/DirectAudio/bug6372428.java 8055097 generic-all +javax/sound/sampled/Clip/bug5070081.java 8055097 generic-all +javax/sound/sampled/DataLine/LongFramePosition.java 8055097 generic-all javax/sound/sampled/Clip/Drain/ClipDrain.java 7062792 generic-all
--- a/test/javax/sound/midi/Gervill/RiffReaderWriter/Available.java Fri May 05 08:34:22 2017 -0700 +++ b/test/javax/sound/midi/Gervill/RiffReaderWriter/Available.java Sat May 06 13:17:36 2017 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2017, 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 @@ -28,10 +28,11 @@ import java.io.File; import java.io.FileInputStream; +import java.nio.file.Files; +import java.nio.file.Paths; -import javax.sound.sampled.*; - -import com.sun.media.sound.*; +import com.sun.media.sound.RIFFReader; +import com.sun.media.sound.RIFFWriter; public class Available { @@ -60,8 +61,6 @@ assertEquals(avail - 1,readchunk.available()); fis.close(); reader = null; - - } finally { @@ -69,10 +68,7 @@ writer.close(); if(reader != null) reader.close(); - - if(tempfile.exists()) - if(!tempfile.delete()) - tempfile.deleteOnExit(); + Files.delete(Paths.get(tempfile.getAbsolutePath())); } } }
--- a/test/javax/sound/midi/Gervill/RiffReaderWriter/Close.java Fri May 05 08:34:22 2017 -0700 +++ b/test/javax/sound/midi/Gervill/RiffReaderWriter/Close.java Sat May 06 13:17:36 2017 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2017, 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 @@ -28,10 +28,11 @@ import java.io.File; import java.io.FileInputStream; +import java.nio.file.Files; +import java.nio.file.Paths; -import javax.sound.sampled.*; - -import com.sun.media.sound.*; +import com.sun.media.sound.RIFFReader; +import com.sun.media.sound.RIFFWriter; public class Close { @@ -54,8 +55,6 @@ reader = new RIFFReader(fis); reader.close(); reader = null; - - } finally { @@ -63,10 +62,7 @@ writer.close(); if(reader != null) reader.close(); - - if(tempfile.exists()) - if(!tempfile.delete()) - tempfile.deleteOnExit(); + Files.delete(Paths.get(tempfile.getAbsolutePath())); } } }
--- a/test/javax/sound/midi/Gervill/RiffReaderWriter/GetFilePointer.java Fri May 05 08:34:22 2017 -0700 +++ b/test/javax/sound/midi/Gervill/RiffReaderWriter/GetFilePointer.java Sat May 06 13:17:36 2017 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2017, 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 @@ -28,10 +28,11 @@ import java.io.File; import java.io.FileInputStream; +import java.nio.file.Files; +import java.nio.file.Paths; -import javax.sound.sampled.*; - -import com.sun.media.sound.*; +import com.sun.media.sound.RIFFReader; +import com.sun.media.sound.RIFFWriter; public class GetFilePointer { @@ -60,8 +61,6 @@ assertEquals(p+1,readchunk.getFilePointer()); fis.close(); reader = null; - - } finally { @@ -69,10 +68,7 @@ writer.close(); if(reader != null) reader.close(); - - if(tempfile.exists()) - if(!tempfile.delete()) - tempfile.deleteOnExit(); + Files.delete(Paths.get(tempfile.getAbsolutePath())); } } }
--- a/test/javax/sound/midi/Gervill/RiffReaderWriter/GetSize.java Fri May 05 08:34:22 2017 -0700 +++ b/test/javax/sound/midi/Gervill/RiffReaderWriter/GetSize.java Sat May 06 13:17:36 2017 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2017, 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 @@ -28,10 +28,11 @@ import java.io.File; import java.io.FileInputStream; +import java.nio.file.Files; +import java.nio.file.Paths; -import javax.sound.sampled.*; - -import com.sun.media.sound.*; +import com.sun.media.sound.RIFFReader; +import com.sun.media.sound.RIFFWriter; public class GetSize { @@ -59,8 +60,6 @@ readchunk.readByte(); fis.close(); reader = null; - - } finally { @@ -68,10 +67,7 @@ writer.close(); if(reader != null) reader.close(); - - if(tempfile.exists()) - if(!tempfile.delete()) - tempfile.deleteOnExit(); + Files.delete(Paths.get(tempfile.getAbsolutePath())); } } }
--- a/test/javax/sound/midi/Gervill/RiffReaderWriter/HasNextChunk.java Fri May 05 08:34:22 2017 -0700 +++ b/test/javax/sound/midi/Gervill/RiffReaderWriter/HasNextChunk.java Sat May 06 13:17:36 2017 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2017, 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 @@ -28,10 +28,11 @@ import java.io.File; import java.io.FileInputStream; +import java.nio.file.Files; +import java.nio.file.Paths; -import javax.sound.sampled.*; - -import com.sun.media.sound.*; +import com.sun.media.sound.RIFFReader; +import com.sun.media.sound.RIFFWriter; public class HasNextChunk { @@ -67,8 +68,6 @@ assertTrue(!reader.hasNextChunk()); fis.close(); reader = null; - - } finally { @@ -76,10 +75,7 @@ writer.close(); if(reader != null) reader.close(); - - if(tempfile.exists()) - if(!tempfile.delete()) - tempfile.deleteOnExit(); + Files.delete(Paths.get(tempfile.getAbsolutePath())); } } }
--- a/test/javax/sound/midi/Gervill/RiffReaderWriter/Read.java Fri May 05 08:34:22 2017 -0700 +++ b/test/javax/sound/midi/Gervill/RiffReaderWriter/Read.java Sat May 06 13:17:36 2017 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2017, 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 @@ -28,10 +28,11 @@ import java.io.File; import java.io.FileInputStream; +import java.nio.file.Files; +import java.nio.file.Paths; -import javax.sound.sampled.*; - -import com.sun.media.sound.*; +import com.sun.media.sound.RIFFReader; +import com.sun.media.sound.RIFFWriter; public class Read { @@ -62,7 +63,6 @@ assertEquals(readchunk.read(), 33); fis.close(); reader = null; - } finally { @@ -70,10 +70,7 @@ writer.close(); if(reader != null) reader.close(); - - if(tempfile.exists()) - if(!tempfile.delete()) - tempfile.deleteOnExit(); + Files.delete(Paths.get(tempfile.getAbsolutePath())); } } }
--- a/test/javax/sound/midi/Gervill/RiffReaderWriter/ReadByte.java Fri May 05 08:34:22 2017 -0700 +++ b/test/javax/sound/midi/Gervill/RiffReaderWriter/ReadByte.java Sat May 06 13:17:36 2017 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2017, 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 @@ -28,10 +28,11 @@ import java.io.File; import java.io.FileInputStream; +import java.nio.file.Files; +import java.nio.file.Paths; -import javax.sound.sampled.*; - -import com.sun.media.sound.*; +import com.sun.media.sound.RIFFReader; +import com.sun.media.sound.RIFFWriter; public class ReadByte { @@ -62,7 +63,6 @@ assertEquals((int)reader.readByte(), 33); fis.close(); reader = null; - } finally { @@ -70,10 +70,7 @@ writer.close(); if(reader != null) reader.close(); - - if(tempfile.exists()) - if(!tempfile.delete()) - tempfile.deleteOnExit(); + Files.delete(Paths.get(tempfile.getAbsolutePath())); } } }
--- a/test/javax/sound/midi/Gervill/RiffReaderWriter/ReadByteArrayIntInt.java Fri May 05 08:34:22 2017 -0700 +++ b/test/javax/sound/midi/Gervill/RiffReaderWriter/ReadByteArrayIntInt.java Sat May 06 13:17:36 2017 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2017, 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 @@ -28,10 +28,11 @@ import java.io.File; import java.io.FileInputStream; +import java.nio.file.Files; +import java.nio.file.Paths; -import javax.sound.sampled.*; - -import com.sun.media.sound.*; +import com.sun.media.sound.RIFFReader; +import com.sun.media.sound.RIFFWriter; public class ReadByteArrayIntInt { @@ -63,8 +64,6 @@ assertEquals(readchunk.read(), 3); fis.close(); reader = null; - - } finally { @@ -72,10 +71,7 @@ writer.close(); if(reader != null) reader.close(); - - if(tempfile.exists()) - if(!tempfile.delete()) - tempfile.deleteOnExit(); + Files.delete(Paths.get(tempfile.getAbsolutePath())); } } }
--- a/test/javax/sound/midi/Gervill/RiffReaderWriter/ReadInt.java Fri May 05 08:34:22 2017 -0700 +++ b/test/javax/sound/midi/Gervill/RiffReaderWriter/ReadInt.java Sat May 06 13:17:36 2017 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2017, 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 @@ -28,10 +28,11 @@ import java.io.File; import java.io.FileInputStream; +import java.nio.file.Files; +import java.nio.file.Paths; -import javax.sound.sampled.*; - -import com.sun.media.sound.*; +import com.sun.media.sound.RIFFReader; +import com.sun.media.sound.RIFFWriter; public class ReadInt { @@ -61,8 +62,6 @@ assertEquals(reader.readInt(), 133); fis.close(); reader = null; - - } finally { @@ -70,10 +69,7 @@ writer.close(); if(reader != null) reader.close(); - - if(tempfile.exists()) - if(!tempfile.delete()) - tempfile.deleteOnExit(); + Files.delete(Paths.get(tempfile.getAbsolutePath())); } } }
--- a/test/javax/sound/midi/Gervill/RiffReaderWriter/ReadLong.java Fri May 05 08:34:22 2017 -0700 +++ b/test/javax/sound/midi/Gervill/RiffReaderWriter/ReadLong.java Sat May 06 13:17:36 2017 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2017, 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 @@ -28,10 +28,11 @@ import java.io.File; import java.io.FileInputStream; +import java.nio.file.Files; +import java.nio.file.Paths; -import javax.sound.sampled.*; - -import com.sun.media.sound.*; +import com.sun.media.sound.RIFFReader; +import com.sun.media.sound.RIFFWriter; public class ReadLong { @@ -61,8 +62,6 @@ assertEquals(reader.readLong(), 133L); fis.close(); reader = null; - - } finally { @@ -70,10 +69,7 @@ writer.close(); if(reader != null) reader.close(); - - if(tempfile.exists()) - if(!tempfile.delete()) - tempfile.deleteOnExit(); + Files.delete(Paths.get(tempfile.getAbsolutePath())); } } }
--- a/test/javax/sound/midi/Gervill/RiffReaderWriter/ReadShort.java Fri May 05 08:34:22 2017 -0700 +++ b/test/javax/sound/midi/Gervill/RiffReaderWriter/ReadShort.java Sat May 06 13:17:36 2017 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2017, 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 @@ -28,10 +28,11 @@ import java.io.File; import java.io.FileInputStream; +import java.nio.file.Files; +import java.nio.file.Paths; -import javax.sound.sampled.*; - -import com.sun.media.sound.*; +import com.sun.media.sound.RIFFReader; +import com.sun.media.sound.RIFFWriter; public class ReadShort { @@ -61,8 +62,6 @@ assertEquals(reader.readShort(), (short)133); fis.close(); reader = null; - - } finally { @@ -70,10 +69,7 @@ writer.close(); if(reader != null) reader.close(); - - if(tempfile.exists()) - if(!tempfile.delete()) - tempfile.deleteOnExit(); + Files.delete(Paths.get(tempfile.getAbsolutePath())); } } }
--- a/test/javax/sound/midi/Gervill/RiffReaderWriter/ReadString.java Fri May 05 08:34:22 2017 -0700 +++ b/test/javax/sound/midi/Gervill/RiffReaderWriter/ReadString.java Sat May 06 13:17:36 2017 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2017, 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 @@ -28,10 +28,11 @@ import java.io.File; import java.io.FileInputStream; +import java.nio.file.Files; +import java.nio.file.Paths; -import javax.sound.sampled.*; - -import com.sun.media.sound.*; +import com.sun.media.sound.RIFFReader; +import com.sun.media.sound.RIFFWriter; public class ReadString { @@ -61,8 +62,6 @@ assertEquals(reader.readString(5), "HELLO"); fis.close(); reader = null; - - } finally { @@ -70,10 +69,7 @@ writer.close(); if(reader != null) reader.close(); - - if(tempfile.exists()) - if(!tempfile.delete()) - tempfile.deleteOnExit(); + Files.delete(Paths.get(tempfile.getAbsolutePath())); } } }
--- a/test/javax/sound/midi/Gervill/RiffReaderWriter/ReadUnsignedByte.java Fri May 05 08:34:22 2017 -0700 +++ b/test/javax/sound/midi/Gervill/RiffReaderWriter/ReadUnsignedByte.java Sat May 06 13:17:36 2017 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2017, 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 @@ -28,10 +28,11 @@ import java.io.File; import java.io.FileInputStream; +import java.nio.file.Files; +import java.nio.file.Paths; -import javax.sound.sampled.*; - -import com.sun.media.sound.*; +import com.sun.media.sound.RIFFReader; +import com.sun.media.sound.RIFFWriter; public class ReadUnsignedByte { @@ -61,8 +62,6 @@ assertEquals(reader.readUnsignedByte(), 77); fis.close(); reader = null; - - } finally { @@ -70,10 +69,7 @@ writer.close(); if(reader != null) reader.close(); - - if(tempfile.exists()) - if(!tempfile.delete()) - tempfile.deleteOnExit(); + Files.delete(Paths.get(tempfile.getAbsolutePath())); } } }
--- a/test/javax/sound/midi/Gervill/RiffReaderWriter/ReadUnsignedInt.java Fri May 05 08:34:22 2017 -0700 +++ b/test/javax/sound/midi/Gervill/RiffReaderWriter/ReadUnsignedInt.java Sat May 06 13:17:36 2017 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2017, 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 @@ -28,10 +28,11 @@ import java.io.File; import java.io.FileInputStream; +import java.nio.file.Files; +import java.nio.file.Paths; -import javax.sound.sampled.*; - -import com.sun.media.sound.*; +import com.sun.media.sound.RIFFReader; +import com.sun.media.sound.RIFFWriter; public class ReadUnsignedInt { @@ -61,8 +62,6 @@ assertEquals(reader.readUnsignedInt(), 55377L); fis.close(); reader = null; - - } finally { @@ -70,10 +69,7 @@ writer.close(); if(reader != null) reader.close(); - - if(tempfile.exists()) - if(!tempfile.delete()) - tempfile.deleteOnExit(); + Files.delete(Paths.get(tempfile.getAbsolutePath())); } } }
--- a/test/javax/sound/midi/Gervill/RiffReaderWriter/ReadUnsignedShort.java Fri May 05 08:34:22 2017 -0700 +++ b/test/javax/sound/midi/Gervill/RiffReaderWriter/ReadUnsignedShort.java Sat May 06 13:17:36 2017 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2017, 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 @@ -28,10 +28,11 @@ import java.io.File; import java.io.FileInputStream; +import java.nio.file.Files; +import java.nio.file.Paths; -import javax.sound.sampled.*; - -import com.sun.media.sound.*; +import com.sun.media.sound.RIFFReader; +import com.sun.media.sound.RIFFWriter; public class ReadUnsignedShort { @@ -61,8 +62,6 @@ assertEquals(reader.readUnsignedShort(), 377); fis.close(); reader = null; - - } finally { @@ -70,10 +69,7 @@ writer.close(); if(reader != null) reader.close(); - - if(tempfile.exists()) - if(!tempfile.delete()) - tempfile.deleteOnExit(); + Files.delete(Paths.get(tempfile.getAbsolutePath())); } } }
--- a/test/javax/sound/midi/Gervill/RiffReaderWriter/Skip.java Fri May 05 08:34:22 2017 -0700 +++ b/test/javax/sound/midi/Gervill/RiffReaderWriter/Skip.java Sat May 06 13:17:36 2017 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2017, 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 @@ -28,6 +28,8 @@ import java.io.File; import java.io.FileInputStream; +import java.nio.file.Files; +import java.nio.file.Paths; import com.sun.media.sound.RIFFReader; import com.sun.media.sound.RIFFWriter; @@ -74,8 +76,6 @@ assertEquals(readchunk.read(), 44); fis.close(); reader = null; - - } finally { @@ -83,10 +83,7 @@ writer.close(); if(reader != null) reader.close(); - - if(tempfile.exists()) - if(!tempfile.delete()) - tempfile.deleteOnExit(); + Files.delete(Paths.get(tempfile.getAbsolutePath())); } } }
--- a/test/javax/sound/midi/Gervill/RiffReaderWriter/WriteOutputStream.java Fri May 05 08:34:22 2017 -0700 +++ b/test/javax/sound/midi/Gervill/RiffReaderWriter/WriteOutputStream.java Sat May 06 13:17:36 2017 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2017, 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 @@ -29,10 +29,11 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; +import java.nio.file.Files; +import java.nio.file.Paths; -import javax.sound.sampled.*; - -import com.sun.media.sound.*; +import com.sun.media.sound.RIFFReader; +import com.sun.media.sound.RIFFWriter; public class WriteOutputStream { @@ -63,8 +64,6 @@ assertEquals(readchunk.read(), 33); fis.close(); reader = null; - - } finally { @@ -72,10 +71,7 @@ writer.close(); if(reader != null) reader.close(); - - if(tempfile.exists()) - if(!tempfile.delete()) - tempfile.deleteOnExit(); + Files.delete(Paths.get(tempfile.getAbsolutePath())); } } }
--- a/test/javax/sound/sampled/AudioInputStream/FrameLengthAfterConversion.java Fri May 05 08:34:22 2017 -0700 +++ b/test/javax/sound/sampled/AudioInputStream/FrameLengthAfterConversion.java Sat May 06 13:17:36 2017 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2017, 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 @@ -94,7 +94,7 @@ } } - public static void main(final String[] args) { + public static void main(final String[] args) throws IOException { for (final FormatConversionProvider fcp : load( FormatConversionProvider.class)) { System.out.println("fcp = " + fcp); @@ -139,7 +139,8 @@ */ private static void testAfterSaveToStream(final AudioFileWriter afw, final AudioFileFormat.Type type, - final AudioInputStream ais) { + final AudioInputStream ais) + throws IOException { try { final ByteArrayOutputStream out = new ByteArrayOutputStream(); afw.write(ais, type, out); @@ -147,7 +148,7 @@ out.toByteArray()); validate(AudioSystem.getAudioInputStream(input).getFrameLength()); } catch (IllegalArgumentException | UnsupportedAudioFileException - | IOException ignored) { + ignored) { } } @@ -156,18 +157,19 @@ */ private static void testAfterSaveToFile(final AudioFileWriter afw, final AudioFileFormat.Type type, - AudioInputStream ais) { + AudioInputStream ais) + throws IOException { + final File temp = File.createTempFile("sound", ".tmp"); try { - final File temp = File.createTempFile("sound", ".tmp"); - temp.deleteOnExit(); afw.write(ais, type, temp); ais = AudioSystem.getAudioInputStream(temp); final long frameLength = ais.getFrameLength(); ais.close(); - Files.delete(Paths.get(temp.getAbsolutePath())); validate(frameLength); } catch (IllegalArgumentException | UnsupportedAudioFileException - | IOException ignored) { + ignored) { + } finally { + Files.delete(Paths.get(temp.getAbsolutePath())); } }
--- a/test/javax/sound/sampled/spi/AudioFileReader/ShortHeader.java Fri May 05 08:34:22 2017 -0700 +++ b/test/javax/sound/sampled/spi/AudioFileReader/ShortHeader.java Sat May 06 13:17:36 2017 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, 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 @@ -30,6 +30,7 @@ import java.io.OutputStream; import java.net.URL; import java.nio.file.Files; +import java.nio.file.Paths; import java.util.Arrays; import javax.sound.sampled.AudioSystem; @@ -51,14 +52,16 @@ public static void main(final String[] args) throws Exception { final File file = Files.createTempFile("audio", "test").toFile(); - file.deleteOnExit(); - try (final OutputStream fos = new FileOutputStream(file)) { - fos.write(W); - } - - testAS(file); - for (final AudioFileReader afr : load(AudioFileReader.class)) { - testAFR(afr, file); + try { + try (final OutputStream fos = new FileOutputStream(file)) { + fos.write(W); + } + testAS(file); + for (final AudioFileReader afr : load(AudioFileReader.class)) { + testAFR(afr, file); + } + } finally { + Files.delete(Paths.get(file.getAbsolutePath())); } }
--- a/test/javax/sound/sampled/spi/AudioFileWriter/WriterCloseInput.java Fri May 05 08:34:22 2017 -0700 +++ b/test/javax/sound/sampled/spi/AudioFileWriter/WriterCloseInput.java Sat May 06 13:17:36 2017 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2017, 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 @@ -33,6 +33,9 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.nio.file.Files; +import java.nio.file.Paths; + import javax.sound.sampled.AudioFileFormat; import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioInputStream; @@ -89,7 +92,7 @@ if (isFile) { File f = File.createTempFile("WriterCloseInput" + testTotal, "tmp"); AudioSystem.write(inStream, fileType, f); - f.delete(); + Files.delete(Paths.get(f.getAbsolutePath())); } else { OutputStream outStream = new NullOutputStream(); AudioSystem.write(inStream, fileType, outStream);