public void testPlayAndStopByEndOfAudio()
      throws IllegalStateException, IOException, InterruptedException {
    IAudioRecorder ar = new AudioRecorder(FILE);
    ar.startRecording();
    Thread.sleep(1000);
    ar.stopRecording();

    ar.startPlaying();
    Thread.sleep(2000);
    assertFalse(ar.isPlaying());
  }
 public void testRecordAndPlay() {
   try {
     IAudioRecorder ar = new AudioRecorder(FILE);
     ar.startRecording();
     assertTrue(ar.isRecording());
     Thread.sleep(2000);
     ar.stopRecording();
     ar.startPlaying();
     assertTrue(ar.isPlaying());
     Thread.sleep(2500);
     assertFalse(ar.isPlaying());
     ar.release();
   } catch (Exception e) {
     fail(e.getMessage());
   }
 }
 public void testRecording() {
   try {
     IAudioRecorder ar = new AudioRecorder(FILE);
     ar.startRecording();
     assertTrue(ar.isRecording());
     Thread.sleep(1000);
     ar.stopRecording();
     assertFalse(ar.isRecording());
     File f = new File(FILE);
     assertTrue(f.exists());
     assertTrue(f.length() > 1024);
     ar.release();
   } catch (Exception e) {
     fail(e.getMessage());
   }
 }
 public void testRecordRepeatedlyAndPlayEnd() {
   try {
     IAudioRecorder ar = new AudioRecorder(FILE);
     for (int i = 0; i < 3; i++) {
       ar.startRecording();
       assertTrue(ar.isRecording());
       Thread.sleep(2000);
       ar.stopRecording();
     }
     ar.startPlaying();
     assertTrue(ar.isPlaying());
     Thread.sleep(2500);
     assertFalse(ar.isPlaying());
     ar.release();
   } catch (Exception e) {
     fail(e.getMessage());
   }
 }