test/jdk/javax/sound/sampled/spi/AudioFileReader/AIFFLargeHeader.java
author prr
Fri, 25 May 2018 12:12:24 -0700
changeset 50347 b2f046ae8eb6
parent 47216 71c04702a3d5
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
41905
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
     1
/*
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
     2
 * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
     4
 *
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
     7
 * published by the Free Software Foundation.
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
     8
 *
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    13
 * accompanied this code).
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    14
 *
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    18
 *
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    21
 * questions.
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    22
 */
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    23
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    24
import java.io.ByteArrayInputStream;
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    25
import java.io.File;
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    26
import java.io.FileInputStream;
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    27
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    28
import javax.sound.sampled.AudioSystem;
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    29
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    30
/**
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    31
 * @test
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    32
 * @bug 4399551
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    33
 * @summary Repost of bug candidate: cannot replay aif file. AIFF headers were
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    34
 *          checked for certain size also tests that ulaw encoded AIFC files can
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    35
 *          be read.
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    36
 */
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    37
public class AIFFLargeHeader {
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    38
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    39
    public static void main(String args[]) throws Exception {
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    40
        System.out.println();
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    41
        System.out.println();
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    42
        System.out.println("4399551: Repost of bug candidate: cannot replay aif file (Review ID: 108108)");
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    43
        // try to read this file
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    44
        AudioSystem.getAudioInputStream(new ByteArrayInputStream(SHORT_AIFC_ULAW));
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    45
        System.out.println("  test passed.");
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    46
    }
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    47
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    48
    public static String getString(byte b) {
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    49
        //String res = Integer.toHexString(b & 0xFF).toUpperCase();
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    50
        //while (res.length()<2) res="0"+res;
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    51
        //return res;
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    52
        return String.valueOf(b);
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    53
    }
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    54
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    55
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    56
    public static void printFile(String filename) throws Exception {
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    57
        File file = new File(filename);
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    58
        FileInputStream fis = new FileInputStream(file);
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    59
        byte[] data = new byte[(int) file.length()];
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    60
        fis.read(data);
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    61
        String s = "";
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    62
        for (int i=0; i<data.length; i++) {
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    63
            s+=getString(data[i])+", ";
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    64
            if (s.length()>72) {
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    65
                System.out.println(s);
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    66
                s="";
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    67
            }
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    68
        }
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    69
        System.out.println(s);
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    70
    }
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    71
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    72
    public static byte[] SHORT_AIFC_ULAW = {
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    73
        70, 79, 82, 77, 0, 0, 2, 50, 65, 73, 70, 67, 70, 86, 69, 82, 0, 0, 0, 4,
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    74
        -94, -128, 81, 64, 67, 79, 77, 77, 0, 0, 0, 30, 0, 1, 0, 1, 118, -9, 0, 16,
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    75
        64, 12, -84, 68, 0, 0, 0, 0, 0, 0, 117, 108, 97, 119, 7, 117, 110, 107, 110,
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    76
        111, 119, 110, 83, 83, 78, 68, 0, 0, 1, -13, 0, 0, 0, 0, 0, 0, 0, 0, 103,
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    77
        103, 103, -1, -1, 91, 77, 103, -45, -25, 91, 77, 73, 73, 77, 103, 103, 77,
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    78
        73, 91, -1, -1, 91, 77, 73, 65, 77, -25, -51, -25, 77, 65, 91, -45, -51,
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    79
        -1, 65, 58, 65, 91, -1, -1, -25, -1, 77, 62, 65, -1, -59, -63, -1, 65, 58,
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    80
        65, -1, -51, -59, -45, 103, 77, 77, -1, -59, -59, -25, 77, 91, -25, -59,
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    81
        -59, -25, 91, 91, -1, -45, -45, -1, 91, 103, -45, -59, -51, -1, 103, 103,
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    82
        -25, -25, -45, -45, -1, -1, -1, -1, 103, 91, -25, -59, -59, -25, -1, -25,
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    83
        -1, 103, 103, -45, -51, -1, 77, 91, -25, -51, -51, -1, 103, -25, -25, 103,
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    84
        73, 73, 103, -59, -63, -51, -1, 77, 73, 77, -1, -51, -51, -1, 77, 65, 65,
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    85
        77, -25, -45, -25, 91, 73, 73, 77, 77, 91, -25, -45, -25, 103, 77, 77, 77,
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    86
        91, -45, -59, -59, -1, 91, 91, -1, -25, -1, -45, -51, -1, 91, 77, 103, -25,
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    87
        103, 103, -25, -51, -25, 91, 103, -1, -1, 91, 73, 77, -1, -45, -1, 91, 77,
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    88
        77, 103, 103, 77, 73, 91, -25, -25, 103, 65, 65, 91, -25, -45, -25, 77, 65,
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    89
        73, 103, -45, -51, 103, 77, 73, 91, 103, 103, 103, 103, 91, 77, 73, 77, 103,
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    90
        -1, -1, 103, 91, 77, 77, 91, 91, 103, 103, -1, -25, -25, -1, -25, -25, 103,
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    91
        77, 91, -25, -51, -59, -51, -25, -1, -1, -45, -51, -25, 91, 91, -25, -59,
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    92
        -51, -25, 91, 77, 103, -45, -59, -63, -25, 77, 77, -25, -63, -59, -45, -25,
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    93
        103, 77, 77, 103, -45, -45, -45, -1, 91, 77, 91, -1, -59, -68, -51, 103,
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    94
        73, 77, 103, -45, -51, -45, 103, 73, 91, -25, -45, 91, 73, -1, -51, -25,
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    95
        73, 62, 77, -25, -25, -1, 103, 91, 77, 73, 77, -1, -45, -45, 103, 73, 73,
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    96
        91, 103, 103, 77, 73, 77, 103, -1, 103, 91, 91, 91, 103, -1, -25, -1, 103,
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    97
        103, 91, 77, 77, 103, -1, -45, -45, -1, 91, 91, -1, 103, 77, 91, -1, -25,
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    98
        91, 65, 73, 103, 103, 73, 73, 77, 91, 91, 73, 73, 91, 91, 91, 91, -1, -25,
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
    99
        91, 73, 91, -25, -1, 73, 62, 62, 73, 103, -25, -45, 91, 77, 91, 103, 91,
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
   100
        73, 77, 103, 103, 77, 77, 103, 103, 77, 73, 73, 103, 103, 103, 91, 77, 77,
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
   101
        91, -25, -1, -25, -25, -45, -59, -59, -45, 73, 56, 65, -25, -68, -63, -25,
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
   102
        91, -1, -45, -1, -1, -45, -59, -63, -1, 103, 103, -25, -25, 103, 91, -1,
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
   103
        -45, -51, -25, 103, 91, 91, 103, -25, -25, -25, 103, 73, 77, -1, -51, -45,
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
   104
        103, 91, 103, -25, -1, 91, 91, 91, -1, -45, -51, -25, 91, 77, 103, -1, -1,
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
   105
        91, -1, -1, -1, 103, 91, 91, 73, 77, 103, -25, -25, 103, 91, 103, 103, 103,
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
   106
        -1, -45, -1, 77, 77, -1
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
   107
    };
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
   108
e8e5df013c6e 8167615: Opensource unit/regression tests for JavaSound
serb
parents:
diff changeset
   109
}