GetReceivers.java revision 829:b06c29386f63
1117397Skan/*
2117397Skan * Copyright 2007 Sun Microsystems, Inc.  All Rights Reserved.
3169691Skan * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4117397Skan *
5117397Skan * This code is free software; you can redistribute it and/or modify it
6117397Skan * under the terms of the GNU General Public License version 2 only, as
7117397Skan * published by the Free Software Foundation.  Sun designates this
8117397Skan * particular file as subject to the "Classpath" exception as provided
9117397Skan * by Sun in the LICENSE file that accompanied this code.
10117397Skan *
11117397Skan * This code is distributed in the hope that it will be useful, but WITHOUT
12117397Skan * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13117397Skan * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14117397Skan * version 2 for more details (a copy is included in the LICENSE file that
15117397Skan * accompanied this code).
16117397Skan *
17117397Skan * You should have received a copy of the GNU General Public License version
18169691Skan * 2 along with this work; if not, write to the Free Software Foundation,
19117397Skan * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20117397Skan *
21117397Skan * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22117397Skan * CA 95054 USA or visit www.sun.com if you need additional information or
23117397Skan * have any questions.
24117397Skan */
25117397Skan
26117397Skan/* @test
27117397Skan   @summary Test SoftSynthesizer getReceivers method */
28117397Skan
29117397Skanimport javax.sound.midi.MidiDevice;
30169691Skanimport javax.sound.midi.MidiUnavailableException;
31117397Skanimport javax.sound.midi.Patch;
32169691Skanimport javax.sound.midi.Receiver;
33169691Skanimport javax.sound.sampled.*;
34132720Skanimport javax.sound.midi.MidiDevice.Info;
35132720Skan
36132720Skanimport com.sun.media.sound.*;
37132720Skan
38132720Skanpublic class GetReceivers {
39132720Skan
40132720Skan    private static void assertEquals(Object a, Object b) throws Exception
41132720Skan    {
42132720Skan        if(!a.equals(b))
43132720Skan            throw new RuntimeException("assertEquals fails!");
44132720Skan    }
45132720Skan
46132720Skan    private static void assertTrue(boolean value) throws Exception
47132720Skan    {
48132720Skan        if(!value)
49132720Skan            throw new RuntimeException("assertTrue fails!");
50132720Skan    }
51132720Skan
52117397Skan    public static void main(String[] args) throws Exception {
53169691Skan        AudioSynthesizer synth = new SoftSynthesizer();
54169691Skan        synth.open(new DummySourceDataLine(), null);
55        assertTrue(synth.getReceivers().size() == 0);
56        Receiver recv = synth.getReceiver();
57        assertTrue(synth.getReceivers().size() == 1);
58        recv.close();
59        assertTrue(synth.getReceivers().size() == 0);
60        synth.close();
61
62    }
63}
64