public StatisticLoggingStreamListenerTest()
     throws FileNotFoundException, IOException, SQLException {
   super();
   this.logger = WMSLoggerFactory.getLogger(this.getClass());
   try {
     Class.forName("org.hsqldb.jdbcDriver");
   } catch (Exception e) {
     System.out.println("ERROR: failed to load HSQLDB JDBC driver.");
     e.printStackTrace();
     return;
   }
   this.connection = DriverManager.getConnection("jdbc:hsqldb:mem:streamingstats");
   StreamingEventLogger.createInstanceForTestPurpose(logger, connection, true);
   this.streamingEventLogger = StreamingEventLogger.getInstance();
 }
 private void dumpDB2Log(int numberOfEntries) {
   List<StreamingStatLogEntry> logEntries =
       ((StreamingEventLogger) StreamingEventLogger.getInstance())
           .getLogEntryLatest(numberOfEntries);
   int i = 0;
   logger.debug("Dumping " + logEntries.size() + "/" + numberOfEntries + " entries to the log");
   for (StreamingStatLogEntry logEntry : logEntries) {
     logger.debug("Log entry [" + i + "] : " + logEntry.toString());
     i++;
   }
 }
  @Test
  public void testStatisticLoggingSBMediaStreamActionNotify2TestOnStop() throws SQLException {
    // Establish connection
    Date dateBeforeConnection = new Date();
    IClient client = new IClientMock("queryString");
    IMediaStreamMock mediaStream = new IMediaStreamMock("sample.mp4", client);
    statLogSBMediaStreamAcitonNotify.onPlay(mediaStream, mediaStream.getName(), 0.0, 0.0, 0);
    statLogSBMediaStreamAcitonNotify.onStop(mediaStream);
    // Fetch data
    StreamingStatLogEntry logEntry = StreamingEventLogger.getInstance().getLogEntryLatest();
    logger.debug("Found log entry: " + logEntry.toString());

    Assert.assertEquals("Result is:", 2, logEntry.getEventID());
    Assert.assertEquals("Result is:", mediaStream.getClientId(), logEntry.getUserID());
    Assert.assertTrue(dateBeforeConnection.getTime() <= logEntry.getTimestamp().getTime());
    Assert.assertEquals("Result is:", Event.STOP, logEntry.getEvent());
  }