TestGetSoundbankInputStream.java revision 829:b06c29386f63
1262569Simp/* 2262569Simp * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3262569Simp * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4262569Simp * 5262569Simp * This code is free software; you can redistribute it and/or modify it 6262569Simp * under the terms of the GNU General Public License version 2 only, as 7262569Simp * published by the Free Software Foundation. Sun designates this 8262569Simp * particular file as subject to the "Classpath" exception as provided 9262569Simp * by Sun in the LICENSE file that accompanied this code. 10262569Simp * 11262569Simp * This code is distributed in the hope that it will be useful, but WITHOUT 12262569Simp * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13262569Simp * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14262569Simp * version 2 for more details (a copy is included in the LICENSE file that 15262569Simp * accompanied this code). 16262569Simp * 17262569Simp * You should have received a copy of the GNU General Public License version 18262569Simp * 2 along with this work; if not, write to the Free Software Foundation, 19262569Simp * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20262569Simp * 21262569Simp * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 22262569Simp * CA 95054 USA or visit www.sun.com if you need additional information or 23262569Simp * have any questions. 24262569Simp */ 25262569Simp 26262569Simp/* @test 27262569Simp @summary Test DLSSoundbankReader getSoundbank(InputStream) method */ 28262569Simp 29262569Simpimport java.io.BufferedInputStream; 30262569Simpimport java.io.File; 31262569Simpimport java.io.FileInputStream; 32262569Simp 33262569Simpimport javax.sound.midi.Patch; 34262569Simpimport javax.sound.midi.Soundbank; 35262569Simp 36262569Simpimport com.sun.media.sound.DLSSoundbankReader; 37262569Simp 38262569Simppublic class TestGetSoundbankInputStream { 39262569Simp 40262569Simp private static void assertTrue(boolean value) throws Exception 41262569Simp { 42262569Simp if(!value) 43262569Simp throw new RuntimeException("assertTrue fails!"); 44262569Simp } 45262569Simp 46262569Simp public static void main(String[] args) throws Exception { 47262569Simp File file = new File(System.getProperty("test.src", "."), "ding.dls"); 48262569Simp FileInputStream fis = new FileInputStream(file); 49262569Simp BufferedInputStream bis = new BufferedInputStream(fis); 50262569Simp try 51262569Simp { 52262569Simp Soundbank dls = new DLSSoundbankReader().getSoundbank(bis); 53262569Simp assertTrue(dls.getInstruments().length == 1); 54262569Simp Patch patch = dls.getInstruments()[0].getPatch(); 55262569Simp assertTrue(patch.getProgram() == 0); 56262569Simp assertTrue(patch.getBank() == 0); 57262569Simp } 58262569Simp finally 59262569Simp { 60262569Simp bis.close(); 61262569Simp } 62262569Simp } 63262569Simp} 64262569Simp