Path: blob/master/test/jdk/javax/sound/midi/MidiSystem/ProviderCacheing.java
41154 views
/*1* Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223import java.util.List;2425import com.sun.media.sound.JDK13Services;2627/**28* @test29* @bug 477651130* @summary RFE: Setting the default MixerProvider. Test the cacheing of31* providers. This is a part of the test for 4776511.32* @modules java.desktop/com.sun.media.sound33*/34public class ProviderCacheing {3536private static final Class[] providerClasses = {37javax.sound.midi.spi.MidiDeviceProvider.class,38javax.sound.midi.spi.MidiFileReader.class,39javax.sound.midi.spi.MidiFileWriter.class,40javax.sound.midi.spi.SoundbankReader.class,41};4243public static void main(String[] args) throws Exception {44boolean allCached = true;45for (int i = 0; i < providerClasses.length; i++) {46List list0 = JDK13Services.getProviders(providerClasses[i]);47List list1 = JDK13Services.getProviders(providerClasses[i]);48if (list0 == list1) {49out("Providers should not be cached for " + providerClasses[i]);50allCached = false;51}52}5354if (! allCached) {55throw new Exception("Test failed");56} else {57out("Test passed");58}59}6061private static void out(String message) {62System.out.println(message);63}64}656667