@Test
    public void testArchiverWaitForGrace() throws Exception
    {
        // Setup fixture.
        final int maxWorkQueueSize = 100;
        final Duration maxPurgeInterval = Duration.ofMillis( 5000 );
        final Duration gracePeriod = Duration.ofMillis( 250 );
        final DummyArchiver archiver = new DummyArchiver( "test", maxWorkQueueSize, maxPurgeInterval, gracePeriod );
        final Thread thread = new Thread( archiver );

        try
        {
            // Execute system under test.
            thread.start();
            archiver.archive( 1 );

            // Verify result.
            waitUntilArchivingIsDone( archiver, 1 );

            assertFalse( archiver.store.isEmpty() );
            final Duration timeUntilLogged = Duration.between( archiver.getStarted(), archiver.store.get( 1 ) );
            assertTrue( timeUntilLogged.compareTo( gracePeriod ) >= 0 );
        }
        finally
        {
            // Teardown fixture.
            archiver.stop();
        }
    }
The archiver is expected to wait for a certain amount of time, before
writing data to the store (this is intended to allow the archiver to batch
work). This test verifies that the data is written to the storage only
after the 'grace period' has ended.
xmppserver/src/test/java/org/jivesoftware/openfire/archive/ArchiverTest.java