GetLoadedInstruments2.java revision 8729:0242fce0f717
156067Smarkm/*
256067Smarkm * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
3139106Sru * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
456067Smarkm *
556067Smarkm * This code is free software; you can redistribute it and/or modify it
656067Smarkm * under the terms of the GNU General Public License version 2 only, as
7125491Sru * published by the Free Software Foundation.
856549Smarkm *
9228308Sume * This code is distributed in the hope that it will be useful, but WITHOUT
10116517Smr * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11125261Sru * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12125261Sru * version 2 for more details (a copy is included in the LICENSE file that
13228284Sume * accompanied this code).
14125261Sru *
15116517Smr * You should have received a copy of the GNU General Public License version
16116517Smr * 2 along with this work; if not, write to the Free Software Foundation,
17117182Sru * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18117182Sru *
1956067Smarkm * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20125261Sru * or visit www.oracle.com if you need additional information or have any
2156067Smarkm * questions.
22125261Sru */
23125261Sru
24125261Sru/* @test
25125261Sru @summary Test SoftSynthesizer getLoadedInstruments method */
26125261Sru
27125261Sruimport javax.sound.midi.MidiDevice;
28178828Sdfrimport javax.sound.midi.MidiUnavailableException;
29178828Sdfrimport javax.sound.midi.Patch;
30178828Sdfrimport javax.sound.midi.Soundbank;
31178828Sdfrimport javax.sound.sampled.*;
3256067Smarkmimport javax.sound.midi.MidiDevice.Info;
33125261Sru
34125261Sruimport com.sun.media.sound.*;
35125261Sru
36125261Srupublic class GetLoadedInstruments2 {
37125261Sru
38125261Sru    private static void assertEquals(Object a, Object b) throws Exception {
39125261Sru        if (!a.equals(b))
40125261Sru            throw new RuntimeException("assertEquals fails!");
41125261Sru    }
42125261Sru
4356067Smarkm    private static void assertTrue(boolean value) throws Exception {
44145254Simp        if (!value)
45            throw new RuntimeException("assertTrue fails!");
46    }
47
48    public static void main(String[] args) throws Exception {
49        AudioSynthesizer synth = new SoftSynthesizer();
50        synth.openStream(null, null);
51        Soundbank defsbk = synth.getDefaultSoundbank();
52        if (defsbk != null) {
53            assertTrue(defsbk.getInstruments().length == synth
54                    .getLoadedInstruments().length);
55        }
56        synth.close();
57
58    }
59}
60