Ejemplo n.º 1
0
  /**
   * Test method for {@code AudioPlayer#play(URL)}
   *
   * @throws Exception audio fault exception, e.g. can't open stream, unhandleable audio format
   * @throws MalformedURLException wrong URL
   */
  @Test(timeout = 4 * MAX_DURATION)
  public void testPlay() throws MalformedURLException, Exception {
    File wav1 = new File(TestUtils.getRegressionDataFile(6851, "20111003_121226.wav"));
    File wav2 = new File(TestUtils.getRegressionDataFile(6851, "20111003_121557.wav"));

    for (File w : new File[] {wav1, wav2}) {
      System.out.println("Playing " + w.toPath());
      URL url = w.toURI().toURL();
      long start = System.currentTimeMillis();
      AudioPlayer.play(url);
      assertTrue(AudioPlayer.playing());
      assertFalse(AudioPlayer.paused());
      AudioPlayer.pause();
      assertFalse(AudioPlayer.playing());
      assertTrue(AudioPlayer.paused());
      AudioPlayer.play(url, AudioPlayer.position());
      while (AudioPlayer.playing() && (System.currentTimeMillis() - start) < MAX_DURATION) {
        Thread.sleep(500);
      }
      long duration = System.currentTimeMillis() - start;
      System.out.println("Play finished after " + Utils.getDurationString(duration));
      assertTrue(duration < MAX_DURATION);
      AudioPlayer.reset();
      Thread.sleep(1000); // precaution, see #13809
    }
  }
Ejemplo n.º 2
0
 /**
  * Non-regression test for ticket <a href="https://josm.openstreetmap.de/ticket/7714">#7714</a>
  *
  * @throws IOException if an error occurs during reading
  */
 @Test
 public void testTicket7714() throws IOException, XMLStreamException, FactoryConfigurationError {
   File file = new File(TestUtils.getRegressionDataFile(7714, "doc.kml"));
   try (InputStream is = new FileInputStream(file)) {
     NonRegFunctionalTests.testGeneric("#7714", KmlReader.parseDataSet(is, null));
   }
 }