RemoveInstrument.java revision 2362
8e2d2e537700b0760344a69708799ffe9685e529Frans van Dunne/*
8e2d2e537700b0760344a69708799ffe9685e529Frans van Dunne * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
8e2d2e537700b0760344a69708799ffe9685e529Frans van Dunne * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8e2d2e537700b0760344a69708799ffe9685e529Frans van Dunne *
8e2d2e537700b0760344a69708799ffe9685e529Frans van Dunne * This code is free software; you can redistribute it and/or modify it
8e2d2e537700b0760344a69708799ffe9685e529Frans van Dunne * under the terms of the GNU General Public License version 2 only, as
8e2d2e537700b0760344a69708799ffe9685e529Frans van Dunne * published by the Free Software Foundation. Oracle designates this
8e2d2e537700b0760344a69708799ffe9685e529Frans van Dunne * particular file as subject to the "Classpath" exception as provided
8e2d2e537700b0760344a69708799ffe9685e529Frans van Dunne * by Oracle in the LICENSE file that accompanied this code.
8e2d2e537700b0760344a69708799ffe9685e529Frans van Dunne *
8e2d2e537700b0760344a69708799ffe9685e529Frans van Dunne * This code is distributed in the hope that it will be useful, but WITHOUT
8e2d2e537700b0760344a69708799ffe9685e529Frans van Dunne * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
8e2d2e537700b0760344a69708799ffe9685e529Frans van Dunne * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
8e2d2e537700b0760344a69708799ffe9685e529Frans van Dunne * version 2 for more details (a copy is included in the LICENSE file that
49517467facf869d14d1e52e70cfa2199856fcf4Mario Amelung * accompanied this code).
49517467facf869d14d1e52e70cfa2199856fcf4Mario Amelung *
49517467facf869d14d1e52e70cfa2199856fcf4Mario Amelung * You should have received a copy of the GNU General Public License version
49517467facf869d14d1e52e70cfa2199856fcf4Mario Amelung * 2 along with this work; if not, write to the Free Software Foundation,
49517467facf869d14d1e52e70cfa2199856fcf4Mario Amelung * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* @test
@summary Test SimpleSoundbank removeInstrument method */
import javax.sound.midi.Patch;
import javax.sound.sampled.*;
import com.sun.media.sound.*;
public class RemoveInstrument {
private static void assertEquals(Object a, Object b) throws Exception
{
if(!a.equals(b))
throw new RuntimeException("assertEquals fails!");
}
private static void assertTrue(boolean a) throws Exception
{
if(!a)
throw new RuntimeException("assertEquals fails!");
}
public static void main(String[] args) throws Exception {
SimpleSoundbank soundbank = new SimpleSoundbank();
SimpleInstrument ins = new SimpleInstrument();
ins.setPatch(new Patch(3,7));
soundbank.addInstrument(ins);
soundbank.removeInstrument(ins);
assertEquals(soundbank.getInstruments().length, 0);
assertTrue(soundbank.getInstrument(new Patch(3,7)) == null);
}
}