Path: blob/master/test/jdk/javax/sound/sampled/Lines/ToString.java
41153 views
/*1* Copyright (c) 2019, 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. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package bug.javax.sound.sampled;2627import javax.sound.sampled.Clip;28import javax.sound.sampled.DataLine;29import javax.sound.sampled.Line;30import javax.sound.sampled.Mixer;31import javax.sound.sampled.Port;32import javax.sound.sampled.SourceDataLine;33import javax.sound.sampled.TargetDataLine;3435/**36* @test37* @bug 822143638* @run main/othervm bug.javax.sound.sampled.ToString39*/40public final class ToString {4142public static void main(final String[] args) {4344// Behavior of toString() methods is not specified, the checks in45// this test just defends against accidental changes.4647String custom = new Line.Info(ToString.class).toString();48if (!custom.contains("bug.javax.sound.sampled")) {49throw new RuntimeException("Package is missing: " + custom);50}51String ints = new Line.Info(int.class).toString();52if (ints.contains("javax.sound.sampled")) {53throw new RuntimeException("Package is present: " + ints);54}55String array = new Line.Info(int[].class).toString();56if (array.contains("javax.sound.sampled")) {57throw new RuntimeException("Package is present: " + array);58}5960String line = new Line.Info(Line.class).toString();61if (!line.equals("interface Line")) {62throw new RuntimeException("Wrong string: " + line);63}64String target = new Line.Info(TargetDataLine.class).toString();65if (!target.equals("interface TargetDataLine")) {66throw new RuntimeException("Wrong string: " + target);67}68String source = new Line.Info(SourceDataLine.class).toString();69if (!source.equals("interface SourceDataLine")) {70throw new RuntimeException("Wrong string: " + source);71}72String port = new Line.Info(Port.class).toString();73if (!port.equals("interface Port")) {74throw new RuntimeException("Wrong string: " + port);75}76String data = new Line.Info(DataLine.class).toString();77if (!data.equals("interface DataLine")) {78throw new RuntimeException("Wrong string: " + data);79}80String mixer = new Line.Info(Mixer.class).toString();81if (!mixer.equals("interface Mixer")) {82throw new RuntimeException("Wrong string: " + mixer);83}84String clip = new Line.Info(Clip.class).toString();85if (!clip.equals("interface Clip")) {86throw new RuntimeException("Wrong string: " + clip);87}8889String dataLine = new DataLine.Info(DataLine.class, null, 0).toString();90if (!dataLine.contains("interface DataLine")) {91throw new RuntimeException("Wrong string: " + dataLine);92}93}94}959697