changeset 16986:41703cb17ee1

8177560: @headful key can be removed from the tests for JavaSound Reviewed-by: prr
author serb
date Fri, 31 Mar 2017 18:23:14 +0300
parents 19042d75c724
children e0f119ab7b1c
files test/javax/sound/midi/Devices/InitializationHang.java test/javax/sound/midi/Sequencer/SeqRecordDoesNotCopy.java test/javax/sound/midi/Sequencer/SeqRecordsRealTimeEvents.java test/javax/sound/midi/Sequencer/SeqStartRecording.java test/javax/sound/midi/Synthesizer/bug4685396.java test/javax/sound/sampled/Clip/ClipCloseLoss.java test/javax/sound/sampled/Clip/bug5070081.java test/javax/sound/sampled/DataLine/LongFramePosition.java test/javax/sound/sampled/DirectAudio/bug6372428.java
diffstat 9 files changed, 69 insertions(+), 41 deletions(-) [+]
line wrap: on
line diff
--- a/test/javax/sound/midi/Devices/InitializationHang.java	Thu Mar 30 16:40:45 2017 +0300
+++ b/test/javax/sound/midi/Devices/InitializationHang.java	Fri Mar 31 18:23:14 2017 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,18 +24,21 @@
 import java.awt.Toolkit;
 
 import javax.sound.midi.MidiSystem;
+import javax.sound.midi.MidiUnavailableException;
 
 /**
  * @test
  * @bug 8068412
- * @key headful
- * @author Sergey Bylokhov
  */
 public final class InitializationHang {
 
-    public static void main(final String[] argv) throws Exception {
-        MidiSystem.getReceiver();
-        Toolkit.getDefaultToolkit();
+    public static void main(final String[] argv) {
+        try {
+            MidiSystem.getReceiver();
+            Toolkit.getDefaultToolkit();
+        } catch (final MidiUnavailableException ignored) {
+            // the test is not applicable
+        }
     }
 }
 
--- a/test/javax/sound/midi/Sequencer/SeqRecordDoesNotCopy.java	Thu Mar 30 16:40:45 2017 +0300
+++ b/test/javax/sound/midi/Sequencer/SeqRecordDoesNotCopy.java	Fri Mar 31 18:23:14 2017 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,6 +24,7 @@
 import javax.sound.midi.MidiEvent;
 import javax.sound.midi.MidiMessage;
 import javax.sound.midi.MidiSystem;
+import javax.sound.midi.MidiUnavailableException;
 import javax.sound.midi.Receiver;
 import javax.sound.midi.Sequence;
 import javax.sound.midi.Sequencer;
@@ -34,12 +35,18 @@
  * @test
  * @bug 5048381
  * @summary Sequencer doesn't create distinct messages when recording events.
- * @key headful
  */
 public class SeqRecordDoesNotCopy {
-    public static void main(String argv[]) throws Exception {
-        Sequencer s = MidiSystem.getSequencer();
-        s.open();
+
+    public static void main(String argv[]) {
+        Sequencer s = null;
+        try {
+            s = MidiSystem.getSequencer();
+            s.open();
+        } catch (final MidiUnavailableException ignored) {
+            // the test is not applicable
+            return;
+        }
         try {
             Sequence seq = new Sequence(Sequence.PPQ, 384, 2);
             s.setSequence(seq);
@@ -86,7 +93,7 @@
         } catch (Exception e) {
             System.out.println("Unexpected Exception: "+e);
             //e.printStackTrace();
-            throw new Exception("Test FAILED!");
+            throw new RuntimeException("Test FAILED!");
         } finally {
             s.close();
         }
--- a/test/javax/sound/midi/Sequencer/SeqRecordsRealTimeEvents.java	Thu Mar 30 16:40:45 2017 +0300
+++ b/test/javax/sound/midi/Sequencer/SeqRecordsRealTimeEvents.java	Fri Mar 31 18:23:14 2017 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,6 +24,7 @@
 import javax.sound.midi.MidiEvent;
 import javax.sound.midi.MidiMessage;
 import javax.sound.midi.MidiSystem;
+import javax.sound.midi.MidiUnavailableException;
 import javax.sound.midi.Receiver;
 import javax.sound.midi.Sequence;
 import javax.sound.midi.Sequencer;
@@ -34,12 +35,18 @@
  * @test
  * @bug 5048381
  * @summary Sequencer records real time messages into the sequence
- * @key headful
  */
 public class SeqRecordsRealTimeEvents {
-    public static void main(String argv[]) throws Exception {
-        Sequencer s = MidiSystem.getSequencer();
-        s.open();
+
+    public static void main(String argv[]) {
+        Sequencer s = null;
+        try {
+            s = MidiSystem.getSequencer();
+            s.open();
+        } catch (final MidiUnavailableException ignored) {
+            // the test is not applicable
+            return;
+        }
         try {
             Sequence seq = new Sequence(Sequence.PPQ, 384, 2);
             s.setSequence(seq);
@@ -90,7 +97,7 @@
         } catch (Exception e) {
             System.out.println("Unexpected Exception: "+e);
             //e.printStackTrace();
-            throw new Exception("Test FAILED!");
+            throw new RuntimeException("Test FAILED!");
         } finally {
             s.close();
         }
--- a/test/javax/sound/midi/Sequencer/SeqStartRecording.java	Thu Mar 30 16:40:45 2017 +0300
+++ b/test/javax/sound/midi/Sequencer/SeqStartRecording.java	Fri Mar 31 18:23:14 2017 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -22,25 +22,32 @@
  */
 
 import javax.sound.midi.MidiSystem;
+import javax.sound.midi.MidiUnavailableException;
 import javax.sound.midi.Sequencer;
 
 /**
  * @test
  * @bug 5001943
  * @summary Sequencer.startRecording throws unexpected NPE
- * @key headful
  */
 public class SeqStartRecording {
-    public static void main(String argv[]) throws Exception {
-        Sequencer seq = MidiSystem.getSequencer();
-        seq.open();
+
+    public static void main(String argv[]) {
+        Sequencer seq = null;
+        try {
+            seq = MidiSystem.getSequencer();
+            seq.open();
+        } catch (final MidiUnavailableException ignored) {
+            // the test is not applicable
+            return;
+        }
         try {
             seq.startRecording();
             System.out.println("Test passed.");
         } catch (NullPointerException npe) {
             System.out.println("Caught NPE: "+npe);
             npe.printStackTrace();
-            throw new Exception("Test FAILED!");
+            throw new RuntimeException("Test FAILED!");
         } catch (Exception e) {
             System.out.println("Unexpected Exception: "+e);
             e.printStackTrace();
--- a/test/javax/sound/midi/Synthesizer/bug4685396.java	Thu Mar 30 16:40:45 2017 +0300
+++ b/test/javax/sound/midi/Synthesizer/bug4685396.java	Fri Mar 31 18:23:14 2017 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,7 @@
 
 import javax.sound.midi.Instrument;
 import javax.sound.midi.MidiSystem;
+import javax.sound.midi.MidiUnavailableException;
 import javax.sound.midi.Soundbank;
 import javax.sound.midi.Synthesizer;
 
@@ -31,7 +32,6 @@
  * @bug 4685396
  * @summary Tests that Synthesizer.remapInstrument works
  * @run main bug4685396
- * @key headful
  */
 public class bug4685396 {
 
@@ -49,8 +49,7 @@
             boolean reloadInstr,    // reload all instruments?
             boolean unloadFrom,     // unload "from" instrument?
             boolean unloadTo        // unload "to" instrument?
-            ) throws Exception
-    {
+            ) throws MidiUnavailableException {
         log("Starting test: reloadInstr=" + reloadInstr
                 + ", unloadFrom=" + unloadFrom
                 + ", unloadTo=" + unloadTo
@@ -164,6 +163,9 @@
         boolean success = false;
         try {
             success = test(reloadInstr, unloadFrom, unloadTo);
+        } catch (final MidiUnavailableException ignored) {
+            // the test is not applicable
+            success = true;
         } catch (Exception ex) {
             log("Exception: " + ex.toString());
         }
@@ -171,7 +173,7 @@
         return success;
     }
 
-    public static void main(String args[]) throws Exception {
+    public static void main(String args[]) {
         boolean failed = false;
         if (!runTest(true, false, false))
             failed = true;
--- a/test/javax/sound/sampled/Clip/ClipCloseLoss.java	Thu Mar 30 16:40:45 2017 +0300
+++ b/test/javax/sound/sampled/Clip/ClipCloseLoss.java	Fri Mar 31 18:23:14 2017 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -36,7 +36,6 @@
  * @bug 4946913
  * @summary DirectClip doesn't kill the thread correctly, sometimes
  * @run main/othervm ClipCloseLoss
- * @key headful
  */
 public class ClipCloseLoss {
     static int frameCount = 441000; // lets say 10 seconds
--- a/test/javax/sound/sampled/Clip/bug5070081.java	Thu Mar 30 16:40:45 2017 +0300
+++ b/test/javax/sound/sampled/Clip/bug5070081.java	Fri Mar 31 18:23:14 2017 +0300
@@ -27,13 +27,13 @@
 import javax.sound.sampled.AudioSystem;
 import javax.sound.sampled.Clip;
 import javax.sound.sampled.DataLine;
+import javax.sound.sampled.LineUnavailableException;
 
 /*
  * @test
  * @bug 5070081
  * @summary Tests that javax.sound.sampled.Clip does not loses position through
  *          stop/start
- * @key headful
  */
 public class bug5070081 {
 
@@ -45,10 +45,15 @@
 
     static boolean test() throws Exception {
         DataLine.Info info = new DataLine.Info(Clip.class, format);
-        Clip clip = (Clip)AudioSystem.getLine(info);
-        clip.open(format, soundData, 0, soundData.length);
-
+        Clip clip = null;
         boolean bSuccess = true;
+        try {
+            clip = (Clip) AudioSystem.getLine(info);
+            clip.open(format, soundData, 0, soundData.length);
+        } catch (LineUnavailableException | IllegalArgumentException ignored) {
+            // the test is not applicable
+            return bSuccess;
+        }
 
         long nLengthMS = clip.getMicrosecondLength()/1000;
 
--- a/test/javax/sound/sampled/DataLine/LongFramePosition.java	Thu Mar 30 16:40:45 2017 +0300
+++ b/test/javax/sound/sampled/DataLine/LongFramePosition.java	Fri Mar 31 18:23:14 2017 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,7 +30,6 @@
  * @test
  * @bug 5049129
  * @summary DataLine.getLongFramePosition
- * @key headful
  */
 public class LongFramePosition {
 
@@ -59,12 +58,12 @@
             } finally {
                 sdl.close();
             }
-        } catch(LineUnavailableException e){
+        } catch (LineUnavailableException | IllegalArgumentException e) {
             System.out.println(e);
             System.out.println("Cannot execute test.");
             return;
         }
-        if (failed) throw new Exception("Test FAILED!");
+        if (failed) throw new RuntimeException("Test FAILED!");
         System.out.println("Test Passed.");
     }
 }
--- a/test/javax/sound/sampled/DirectAudio/bug6372428.java	Thu Mar 30 16:40:45 2017 +0300
+++ b/test/javax/sound/sampled/DirectAudio/bug6372428.java	Fri Mar 31 18:23:14 2017 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -34,7 +34,6 @@
  * @summary playback and capture doesn't interrupt after terminating thread that
  *          calls start()
  * @run main bug6372428
- * @key headful
  */
 public class bug6372428 {
     public bug6372428() {