8178383: Validation of FileIO in the tests for JavaSound should be stricter
Reviewed-by: prr
This commit is contained in:
parent
4098d419e8
commit
e41b775ecd
@ -216,9 +216,13 @@ sun/security/ssl/X509KeyManager/PreferredKey.java 8176354 generic-
|
||||
############################################################################
|
||||
|
||||
# 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
|
||||
|
||||
|
@ -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 @@ public class Available {
|
||||
assertEquals(avail - 1,readchunk.available());
|
||||
fis.close();
|
||||
reader = null;
|
||||
|
||||
|
||||
}
|
||||
finally
|
||||
{
|
||||
@ -69,10 +68,7 @@ public class Available {
|
||||
writer.close();
|
||||
if(reader != null)
|
||||
reader.close();
|
||||
|
||||
if(tempfile.exists())
|
||||
if(!tempfile.delete())
|
||||
tempfile.deleteOnExit();
|
||||
Files.delete(Paths.get(tempfile.getAbsolutePath()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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 @@ public class Close {
|
||||
reader = new RIFFReader(fis);
|
||||
reader.close();
|
||||
reader = null;
|
||||
|
||||
|
||||
}
|
||||
finally
|
||||
{
|
||||
@ -63,10 +62,7 @@ public class Close {
|
||||
writer.close();
|
||||
if(reader != null)
|
||||
reader.close();
|
||||
|
||||
if(tempfile.exists())
|
||||
if(!tempfile.delete())
|
||||
tempfile.deleteOnExit();
|
||||
Files.delete(Paths.get(tempfile.getAbsolutePath()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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 @@ public class GetFilePointer {
|
||||
assertEquals(p+1,readchunk.getFilePointer());
|
||||
fis.close();
|
||||
reader = null;
|
||||
|
||||
|
||||
}
|
||||
finally
|
||||
{
|
||||
@ -69,10 +68,7 @@ public class GetFilePointer {
|
||||
writer.close();
|
||||
if(reader != null)
|
||||
reader.close();
|
||||
|
||||
if(tempfile.exists())
|
||||
if(!tempfile.delete())
|
||||
tempfile.deleteOnExit();
|
||||
Files.delete(Paths.get(tempfile.getAbsolutePath()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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 @@ public class GetSize {
|
||||
readchunk.readByte();
|
||||
fis.close();
|
||||
reader = null;
|
||||
|
||||
|
||||
}
|
||||
finally
|
||||
{
|
||||
@ -68,10 +67,7 @@ public class GetSize {
|
||||
writer.close();
|
||||
if(reader != null)
|
||||
reader.close();
|
||||
|
||||
if(tempfile.exists())
|
||||
if(!tempfile.delete())
|
||||
tempfile.deleteOnExit();
|
||||
Files.delete(Paths.get(tempfile.getAbsolutePath()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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 @@ public class HasNextChunk {
|
||||
assertTrue(!reader.hasNextChunk());
|
||||
fis.close();
|
||||
reader = null;
|
||||
|
||||
|
||||
}
|
||||
finally
|
||||
{
|
||||
@ -76,10 +75,7 @@ public class HasNextChunk {
|
||||
writer.close();
|
||||
if(reader != null)
|
||||
reader.close();
|
||||
|
||||
if(tempfile.exists())
|
||||
if(!tempfile.delete())
|
||||
tempfile.deleteOnExit();
|
||||
Files.delete(Paths.get(tempfile.getAbsolutePath()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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 @@ public class Read {
|
||||
assertEquals(readchunk.read(), 33);
|
||||
fis.close();
|
||||
reader = null;
|
||||
|
||||
}
|
||||
finally
|
||||
{
|
||||
@ -70,10 +70,7 @@ public class Read {
|
||||
writer.close();
|
||||
if(reader != null)
|
||||
reader.close();
|
||||
|
||||
if(tempfile.exists())
|
||||
if(!tempfile.delete())
|
||||
tempfile.deleteOnExit();
|
||||
Files.delete(Paths.get(tempfile.getAbsolutePath()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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 @@ public class ReadByte {
|
||||
assertEquals((int)reader.readByte(), 33);
|
||||
fis.close();
|
||||
reader = null;
|
||||
|
||||
}
|
||||
finally
|
||||
{
|
||||
@ -70,10 +70,7 @@ public class ReadByte {
|
||||
writer.close();
|
||||
if(reader != null)
|
||||
reader.close();
|
||||
|
||||
if(tempfile.exists())
|
||||
if(!tempfile.delete())
|
||||
tempfile.deleteOnExit();
|
||||
Files.delete(Paths.get(tempfile.getAbsolutePath()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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 @@ public class ReadByteArrayIntInt {
|
||||
assertEquals(readchunk.read(), 3);
|
||||
fis.close();
|
||||
reader = null;
|
||||
|
||||
|
||||
}
|
||||
finally
|
||||
{
|
||||
@ -72,10 +71,7 @@ public class ReadByteArrayIntInt {
|
||||
writer.close();
|
||||
if(reader != null)
|
||||
reader.close();
|
||||
|
||||
if(tempfile.exists())
|
||||
if(!tempfile.delete())
|
||||
tempfile.deleteOnExit();
|
||||
Files.delete(Paths.get(tempfile.getAbsolutePath()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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 @@ public class ReadInt {
|
||||
assertEquals(reader.readInt(), 133);
|
||||
fis.close();
|
||||
reader = null;
|
||||
|
||||
|
||||
}
|
||||
finally
|
||||
{
|
||||
@ -70,10 +69,7 @@ public class ReadInt {
|
||||
writer.close();
|
||||
if(reader != null)
|
||||
reader.close();
|
||||
|
||||
if(tempfile.exists())
|
||||
if(!tempfile.delete())
|
||||
tempfile.deleteOnExit();
|
||||
Files.delete(Paths.get(tempfile.getAbsolutePath()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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 @@ public class ReadLong {
|
||||
assertEquals(reader.readLong(), 133L);
|
||||
fis.close();
|
||||
reader = null;
|
||||
|
||||
|
||||
}
|
||||
finally
|
||||
{
|
||||
@ -70,10 +69,7 @@ public class ReadLong {
|
||||
writer.close();
|
||||
if(reader != null)
|
||||
reader.close();
|
||||
|
||||
if(tempfile.exists())
|
||||
if(!tempfile.delete())
|
||||
tempfile.deleteOnExit();
|
||||
Files.delete(Paths.get(tempfile.getAbsolutePath()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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 @@ public class ReadShort {
|
||||
assertEquals(reader.readShort(), (short)133);
|
||||
fis.close();
|
||||
reader = null;
|
||||
|
||||
|
||||
}
|
||||
finally
|
||||
{
|
||||
@ -70,10 +69,7 @@ public class ReadShort {
|
||||
writer.close();
|
||||
if(reader != null)
|
||||
reader.close();
|
||||
|
||||
if(tempfile.exists())
|
||||
if(!tempfile.delete())
|
||||
tempfile.deleteOnExit();
|
||||
Files.delete(Paths.get(tempfile.getAbsolutePath()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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 @@ public class ReadString {
|
||||
assertEquals(reader.readString(5), "HELLO");
|
||||
fis.close();
|
||||
reader = null;
|
||||
|
||||
|
||||
}
|
||||
finally
|
||||
{
|
||||
@ -70,10 +69,7 @@ public class ReadString {
|
||||
writer.close();
|
||||
if(reader != null)
|
||||
reader.close();
|
||||
|
||||
if(tempfile.exists())
|
||||
if(!tempfile.delete())
|
||||
tempfile.deleteOnExit();
|
||||
Files.delete(Paths.get(tempfile.getAbsolutePath()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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 @@ public class ReadUnsignedByte {
|
||||
assertEquals(reader.readUnsignedByte(), 77);
|
||||
fis.close();
|
||||
reader = null;
|
||||
|
||||
|
||||
}
|
||||
finally
|
||||
{
|
||||
@ -70,10 +69,7 @@ public class ReadUnsignedByte {
|
||||
writer.close();
|
||||
if(reader != null)
|
||||
reader.close();
|
||||
|
||||
if(tempfile.exists())
|
||||
if(!tempfile.delete())
|
||||
tempfile.deleteOnExit();
|
||||
Files.delete(Paths.get(tempfile.getAbsolutePath()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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 @@ public class ReadUnsignedInt {
|
||||
assertEquals(reader.readUnsignedInt(), 55377L);
|
||||
fis.close();
|
||||
reader = null;
|
||||
|
||||
|
||||
}
|
||||
finally
|
||||
{
|
||||
@ -70,10 +69,7 @@ public class ReadUnsignedInt {
|
||||
writer.close();
|
||||
if(reader != null)
|
||||
reader.close();
|
||||
|
||||
if(tempfile.exists())
|
||||
if(!tempfile.delete())
|
||||
tempfile.deleteOnExit();
|
||||
Files.delete(Paths.get(tempfile.getAbsolutePath()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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 @@ public class ReadUnsignedShort {
|
||||
assertEquals(reader.readUnsignedShort(), 377);
|
||||
fis.close();
|
||||
reader = null;
|
||||
|
||||
|
||||
}
|
||||
finally
|
||||
{
|
||||
@ -70,10 +69,7 @@ public class ReadUnsignedShort {
|
||||
writer.close();
|
||||
if(reader != null)
|
||||
reader.close();
|
||||
|
||||
if(tempfile.exists())
|
||||
if(!tempfile.delete())
|
||||
tempfile.deleteOnExit();
|
||||
Files.delete(Paths.get(tempfile.getAbsolutePath()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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 @@ public class Skip {
|
||||
assertEquals(readchunk.read(), 44);
|
||||
fis.close();
|
||||
reader = null;
|
||||
|
||||
|
||||
}
|
||||
finally
|
||||
{
|
||||
@ -83,10 +83,7 @@ public class Skip {
|
||||
writer.close();
|
||||
if(reader != null)
|
||||
reader.close();
|
||||
|
||||
if(tempfile.exists())
|
||||
if(!tempfile.delete())
|
||||
tempfile.deleteOnExit();
|
||||
Files.delete(Paths.get(tempfile.getAbsolutePath()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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 @@ public class WriteOutputStream {
|
||||
assertEquals(readchunk.read(), 33);
|
||||
fis.close();
|
||||
reader = null;
|
||||
|
||||
|
||||
}
|
||||
finally
|
||||
{
|
||||
@ -72,10 +71,7 @@ public class WriteOutputStream {
|
||||
writer.close();
|
||||
if(reader != null)
|
||||
reader.close();
|
||||
|
||||
if(tempfile.exists())
|
||||
if(!tempfile.delete())
|
||||
tempfile.deleteOnExit();
|
||||
Files.delete(Paths.get(tempfile.getAbsolutePath()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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 final class FrameLengthAfterConversion {
|
||||
}
|
||||
}
|
||||
|
||||
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 @@ public final class FrameLengthAfterConversion {
|
||||
*/
|
||||
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 @@ public final class FrameLengthAfterConversion {
|
||||
out.toByteArray());
|
||||
validate(AudioSystem.getAudioInputStream(input).getFrameLength());
|
||||
} catch (IllegalArgumentException | UnsupportedAudioFileException
|
||||
| IOException ignored) {
|
||||
ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
@ -156,18 +157,19 @@ public final class FrameLengthAfterConversion {
|
||||
*/
|
||||
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()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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.InputStream;
|
||||
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 final class ShortHeader {
|
||||
|
||||
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()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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.File;
|
||||
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 @@ public class WriterCloseInput {
|
||||
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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user