@Test
  public void testFactoryPopulatedAndReset() {
    final int BUFFER_SIZE = 301;
    List<String> listeners = listenerNamesToCollection(JAMonListenerFactory.getData());
    assertThat(listeners).hasSize(14);

    JAMonListenerFactory.put(new CompositeListener("tester"));
    JAMonListenerFactory.put(
        new JAMonBufferListener(
            "helloListener", new BufferList(new String[] {"hey"}, BUFFER_SIZE)));
    listeners = listenerNamesToCollection(JAMonListenerFactory.getData());
    assertThat(listeners).containsOnly(EXPECTED_LISTENERS);
    assertThat(listeners).hasSize(16);

    JAMonBufferListener jbl = (JAMonBufferListener) JAMonListenerFactory.get("helloListener");
    assertThat(jbl.getName()).isEqualTo("helloListener");
    assertThat(jbl.getBufferList().getBufferSize()).isEqualTo(BUFFER_SIZE);

    jbl = (JAMonBufferListener) JAMonListenerFactory.get("FIFOBuffer");
    assertThat(jbl.getName()).isEqualTo("FIFOBuffer");
    assertThat(jbl.getBufferList().getBufferSize()).isEqualTo(50);

    JAMonListenerFactory.reset();
    listeners = listenerNamesToCollection(JAMonListenerFactory.getData());
    assertThat(listeners).hasSize(14);
  }
  private static List<Integer> testArray(String label, int dateToAdd, boolean increase) {
    JAMonBufferListener jbl = (JAMonBufferListener) JAMonListenerFactory.get(label);
    BufferList bl = jbl.getBufferList();

    Calendar cal = new GregorianCalendar();
    if (increase) {
      for (int i = 1, j = -50; i <= 100; i++, j++) {
        cal.setTime(new Date());
        cal.add(dateToAdd, j);
        bl.addRow(new Object[] {"label" + i, new Integer(i), "Active" + i, cal.getTime()});
      }

    } else {
      for (int i = 100, j = 50; i >= 1; i--, j--) {
        cal.setTime(new Date());
        cal.add(dateToAdd, j);
        bl.addRow(new Object[] {"label" + i, new Integer(i), "Active" + i, cal.getTime()});
      }
    }

    // firstVal will be under date threshold, and secondVal will exceed it.
    int firstVal = -5;
    int secondVal = -10;

    if (dateToAdd == Calendar.HOUR_OF_DAY) {
      firstVal = -12;
      secondVal = -36;
    }

    cal.setTime(new Date());
    cal.add(dateToAdd, firstVal);
    bl.addRow(new Object[] {"label", new Integer(1000), "Active", cal.getTime()});

    cal.setTime(new Date());
    cal.add(dateToAdd, firstVal);
    bl.addRow(new Object[] {"label", new Integer(-1000), "Active", cal.getTime()});

    cal.setTime(new Date());
    cal.add(dateToAdd, secondVal);
    bl.addRow(new Object[] {"label", new Integer(1100), "Active", cal.getTime()});

    cal.setTime(new Date());
    cal.add(dateToAdd, secondVal);
    bl.addRow(new Object[] {"label", new Integer(-1100), "Active", cal.getTime()});

    return grabIntegers(bl.getData());
  }