jdk/test/javax/sound/sampled/spi/AudioFileReader/AuNotSpecified.java
changeset 41905 e8e5df013c6e
equal deleted inserted replaced
41904:524d908e49ea 41905:e8e5df013c6e
       
     1 /*
       
     2  * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
       
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     4  *
       
     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
       
     7  * published by the Free Software Foundation.
       
     8  *
       
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
       
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    12  * version 2 for more details (a copy is included in the LICENSE file that
       
    13  * accompanied this code).
       
    14  *
       
    15  * You should have received a copy of the GNU General Public License version
       
    16  * 2 along with this work; if not, write to the Free Software Foundation,
       
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    18  *
       
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
       
    20  * or visit www.oracle.com if you need additional information or have any
       
    21  * questions.
       
    22  */
       
    23 
       
    24 import java.io.ByteArrayInputStream;
       
    25 
       
    26 import javax.sound.sampled.AudioInputStream;
       
    27 import javax.sound.sampled.AudioSystem;
       
    28 
       
    29 /**
       
    30  * @test
       
    31  * @bug 4940459
       
    32  * @summary AudioInputStream.getFrameLength() returns 0 instead of NOT_SPECIFIED
       
    33  */
       
    34 public class AuNotSpecified {
       
    35     public static boolean failed = false;
       
    36 
       
    37     public static void main(String[] params) throws Exception {
       
    38 
       
    39         AudioInputStream is =
       
    40             AudioSystem.getAudioInputStream(new
       
    41                                             ByteArrayInputStream(new byte[] {
       
    42                                                 (byte)0x2E, (byte)0x73, (byte)0x6E, (byte)0x64, (byte)0x00,
       
    43                                                 (byte)0x00, (byte)0x00, (byte)0x18,
       
    44                                                 (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0x00,
       
    45                                                 (byte)0x00, (byte)0x00, (byte)0x03,
       
    46                                                 (byte)0x00, (byte)0x00, (byte)0x1F, (byte)0x40, (byte)0x00,
       
    47                                                 (byte)0x00, (byte)0x00, (byte)0x01,
       
    48                                                 (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
       
    49                                                 (byte)0x00, (byte)0x00, (byte)0x00,
       
    50                                             }));
       
    51         if (is.getFrameLength() != AudioSystem.NOT_SPECIFIED) {
       
    52             System.out.println("frame length should be NOT_SPECIFIED, but is: "+is.getFrameLength());
       
    53             failed=true;
       
    54         }
       
    55         //assertTrue(is.getFrameLength() == AudioSystem.NOT_SPECIFIED);
       
    56         //assertTrue(is.read(new byte[8]) == 8);
       
    57         //assertTrue(is.read(new byte[2]) == -1);
       
    58         if (failed) throw new Exception("Test FAILED!");
       
    59         System.out.println("Test Passed.");
       
    60     }
       
    61 }