@Test
  public void testSendMeasurements() throws Exception {
    System.out.println();

    writer = new AsciiDataWriter();
    writer.setDataEncoding(new TextEncodingImpl(",", "\n"));
    writer.setOutput(System.out);

    ISensorDataInterface locOutput = driver.getObservationOutputs().get("avlData");
    locOutput.registerListener(this);

    driver.start();

    synchronized (this) {
      while (sampleCount < 50) wait();
    }

    driver.stop();
  }
  @Override
  public void handleEvent(Event<?> e) {
    assertTrue(e instanceof SensorDataEvent);
    SensorDataEvent newDataEvent = (SensorDataEvent) e;

    try {
      // System.out.print("\nNew data received from sensor " + newDataEvent.getSensorId());
      writer.setDataComponents(newDataEvent.getRecordDescription());
      writer.reset();
      writer.write(newDataEvent.getRecords()[0]);
      writer.flush();

      sampleCount++;
    } catch (IOException e1) {
      e1.printStackTrace();
    }

    synchronized (this) {
      this.notify();
    }
  }