예제 #1
0
 public String getName() {
   javax.sound.midi.MidiDevice.Info info = device.getDeviceInfo();
   return info.getName() + " " + info.getVendor();
 }
예제 #2
0
  public static void main(String[] args) throws Exception {
    boolean failed = false;
    out("#4616517: Receiver.send() does not work properly");
    if (!isMidiInstalled()) {
      out("Soundcard does not exist or sound drivers not installed!");
      out("This test requires sound drivers for execution.");
      return;
    }
    MidiDevice.Info[] infos = MidiSystem.getMidiDeviceInfo();
    MidiDevice outDevice = null;
    MidiDevice inDevice = null;
    for (int i = 0; i < infos.length; i++) {
      MidiDevice device = MidiSystem.getMidiDevice(infos[i]);
      if (!(device instanceof Synthesizer) && !(device instanceof Sequencer)) {
        if (device.getMaxReceivers() != 0) {
          outDevice = device;
        }
        if (device.getMaxTransmitters() != 0) {
          inDevice = device;
        }
      }
    }
    if (outDevice != null) {
      // set the default provider properties
      System.setProperty(Receiver.class.getName(), "#" + outDevice.getDeviceInfo().getName());
    }
    if (inDevice != null) {
      System.setProperty(Transmitter.class.getName(), "#" + inDevice.getDeviceInfo().getName());
    }
    out("Using MIDI OUT Device: " + outDevice);
    out("Using MIDI IN Device: " + inDevice);

    isTestExecuted = false;
    if (outDevice != null) {
      isTestExecuted = true;
      TestHelper testHelper = new ReceiverTestHelper(outDevice);
      try {
        doTest("Receiver", testHelper);
        failed |= testHelper.hasFailed();
      } catch (Exception e) {
        out("Exception occured, cannot test!");
        isTestExecuted = false;
      }
    }

    if (inDevice != null) {
      isTestExecuted = true;
      TestHelper testHelper = new TransmitterTestHelper(inDevice);
      try {
        doTest("Transmitter", testHelper);
        failed |= testHelper.hasFailed();
      } catch (Exception e) {
        out("Exception occured, cannot test!");
        isTestExecuted = false;
      }
    }

    isTestPassed = !failed;

    if (isTestExecuted) {
      if (isTestPassed) {
        out("Test PASSED.");
      } else {
        throw new Exception("Test FAILED.");
      }
    } else {
      out("Test NOT FAILED");
    }
  }