TestCreateSoundbank.java revision 9330:8b1f1c2a400f
1139743Simp/*
243412Snewton * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
343412Snewton * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
443412Snewton *
543412Snewton * This code is free software; you can redistribute it and/or modify it
643412Snewton * under the terms of the GNU General Public License version 2 only, as
743412Snewton * published by the Free Software Foundation.
843412Snewton *
943412Snewton * This code is distributed in the hope that it will be useful, but WITHOUT
1043412Snewton * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1143412Snewton * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
1243412Snewton * version 2 for more details (a copy is included in the LICENSE file that
1343412Snewton * accompanied this code).
1443412Snewton *
1543412Snewton * You should have received a copy of the GNU General Public License version
1643412Snewton * 2 along with this work; if not, write to the Free Software Foundation,
1743412Snewton * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1843412Snewton *
1943412Snewton * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2043412Snewton * or visit www.oracle.com if you need additional information or have any
2143412Snewton * questions.
2243412Snewton */
2343412Snewton
2443412Snewton/* @test
2543412Snewton @summary Test EmergencySoundbank createSoundbank() method */
2643412Snewton
2743412Snewtonimport java.io.File;
2843412Snewton
2943412Snewtonimport javax.sound.midi.Instrument;
3043412Snewtonimport javax.sound.midi.Patch;
31101709Srwatsonimport javax.sound.midi.Soundbank;
32116174Sobrien
33116174Sobrienimport com.sun.media.sound.EmergencySoundbank;
34116174Sobrienimport com.sun.media.sound.ModelInstrument;
3543412Snewtonimport com.sun.media.sound.ModelPatch;
36280258Srwatson
3743412Snewtonpublic class TestCreateSoundbank {
3843412Snewton
3943412Snewton    public static void main(String[] args) throws Exception {
4043412Snewton
4176166Smarkm        Soundbank soundbank = EmergencySoundbank.createSoundbank();
42141486Sjhb        for (int i = 0; i < 128; i++) {
4343412Snewton            Patch patch = new ModelPatch(0, i, false);
4476166Smarkm            ModelInstrument ins = (ModelInstrument)soundbank.getInstrument(patch);
4576166Smarkm            if(ins == null)
46164033Srwatson                throw new Exception("Instrument " + i + " is missing!");
4776166Smarkm            if(ins.getPerformers().length == 0)
4876166Smarkm                throw new Exception("Instrument " + i + " doesn't have any performers!");
49134266Sjhb        }
5076166Smarkm        Patch patch = new ModelPatch(0, 0, true);
5143412Snewton        ModelInstrument ins = (ModelInstrument)soundbank.getInstrument(patch);
5243412Snewton        if(ins == null)
5343412Snewton            throw new Exception("Drumkit instrument is missing!");
5443412Snewton        if(ins.getPerformers().length == 0)
5565302Sobrien            throw new Exception("Drumkit instrument doesn't have any performers!");
5665302Sobrien    }
5765302Sobrien}
5865302Sobrien