Path: blob/master/test/jdk/javax/sound/sampled/Mixers/BogusMixers.java
41153 views
/*1* Copyright (c) 2002, 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 javax.sound.sampled.AudioSystem;24import javax.sound.sampled.DataLine;25import javax.sound.sampled.Line;26import javax.sound.sampled.Mixer;2728/**29* @test30* @bug 466706431* @summary Java Sound provides bogus SourceDataLine and TargetDataLine32*/33public class BogusMixers {3435public static void main(String[] args) throws Exception {36try {37out("4667064: Java Sound provides bogus SourceDataLine and TargetDataLine");3839Mixer.Info[] aInfos = AudioSystem.getMixerInfo();40out(" available Mixers:");41for (int i = 0; i < aInfos.length; i++) {42if (aInfos[i].getName().startsWith("Java Sound Audio Engine")) {43Mixer mixer = AudioSystem.getMixer(aInfos[i]);44Line.Info[] tlInfos = mixer.getTargetLineInfo();45for (int ii = 0; ii<tlInfos.length; ii++) {46if (tlInfos[ii].getLineClass() == DataLine.class) {47throw new Exception("Bogus TargetDataLine with DataLine info present!");48}49}50}51if (aInfos[i].getName().startsWith("WinOS,waveOut,multi threaded")) {52throw new Exception("Bogus mixer 'WinOS,waveOut,multi threaded' present!");53}54out(aInfos[i].getName());55}56if (aInfos.length == 0)57{58out("[No mixers available] - not a failure of this test case.");59}60} catch (Exception e) {61e.printStackTrace();62throw e;63}64out("Test passed");65}6667static void out(String s) {68System.out.println(s); System.out.flush();69}70}717273