< prev index next >
test/javax/sound/midi/Sequencer/SeqRecordDoesNotCopy.java
Print this page
@@ -1,7 +1,7 @@
/*
- * 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
@@ -22,26 +22,33 @@
*/
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;
import javax.sound.midi.ShortMessage;
import javax.sound.midi.Track;
/**
* @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();
+
+ 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);
Track t = seq.getTracks()[0];
ShortMessage msg = new ShortMessage();
@@ -84,11 +91,11 @@
System.out.println("Did not detect any duplicate messages.");
System.out.println("Test passed.");
} catch (Exception e) {
System.out.println("Unexpected Exception: "+e);
//e.printStackTrace();
- throw new Exception("Test FAILED!");
+ throw new RuntimeException("Test FAILED!");
} finally {
s.close();
}
}
public static void printEvent(MidiEvent event)
< prev index next >