Path: blob/master/test/jdk/javax/sound/sampled/spi/AudioFileReader/AuNotSpecified.java
40527 views
/*1* Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223import java.io.ByteArrayInputStream;2425import javax.sound.sampled.AudioInputStream;26import javax.sound.sampled.AudioSystem;2728/**29* @test30* @bug 494045931* @summary AudioInputStream.getFrameLength() returns 0 instead of NOT_SPECIFIED32*/33public class AuNotSpecified {34public static boolean failed = false;3536public static void main(String[] params) throws Exception {3738AudioInputStream is =39AudioSystem.getAudioInputStream(new40ByteArrayInputStream(new byte[] {41(byte)0x2E, (byte)0x73, (byte)0x6E, (byte)0x64, (byte)0x00,42(byte)0x00, (byte)0x00, (byte)0x18,43(byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0x00,44(byte)0x00, (byte)0x00, (byte)0x03,45(byte)0x00, (byte)0x00, (byte)0x1F, (byte)0x40, (byte)0x00,46(byte)0x00, (byte)0x00, (byte)0x01,47(byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,48(byte)0x00, (byte)0x00, (byte)0x00,49}));50if (is.getFrameLength() != AudioSystem.NOT_SPECIFIED) {51System.out.println("frame length should be NOT_SPECIFIED, but is: "+is.getFrameLength());52failed=true;53}54//assertTrue(is.getFrameLength() == AudioSystem.NOT_SPECIFIED);55//assertTrue(is.read(new byte[8]) == 8);56//assertTrue(is.read(new byte[2]) == -1);57if (failed) throw new Exception("Test FAILED!");58System.out.println("Test Passed.");59}60}616263