@Test
  public void testAddToEmptyCursorWhenTempStoreIsFull() throws Exception {
    createBrokerWithTempStoreLimit();
    SystemUsage usage = brokerService.getSystemUsage();

    PList dud = brokerService.getTempDataStore().getPList("dud");
    // fill the temp store
    int id = 0;
    ByteSequence payload = new ByteSequence(new byte[1024]);
    while (!usage.getTempUsage().isFull()) {
      dud.addFirst("A-" + (++id), payload);
    }

    assertTrue(
        "temp store is full: %" + usage.getTempUsage().getPercentUsage(),
        usage.getTempUsage().isFull());

    underTest = new FilePendingMessageCursor(brokerService.getBroker(), "test", false);
    underTest.setSystemUsage(usage);

    // ok to add
    underTest.addMessageLast(QueueMessageReference.NULL_MESSAGE);

    assertFalse("cursor is not full", underTest.isFull());
  }
  private void createBrokerWithTempStoreLimit() throws Exception {
    brokerService = new BrokerService();
    brokerService.setUseJmx(false);
    SystemUsage usage = brokerService.getSystemUsage();
    usage.getTempUsage().setLimit(1025 * 1024 * 15);
    brokerService.start();

    // put something in the temp store to on demand initialise it
    PList dud = brokerService.getTempDataStore().getPList("dud");
    dud.addFirst("A", new ByteSequence("A".getBytes()));
  }
 protected boolean isDiskListEmpty() {
   return diskList == null || diskList.isEmpty();
 }