protected Archiver( String id, int maxWorkQueueSize, Duration maxPurgeInterval, Duration gracePeriod )
    {
        if ( maxWorkQueueSize < 1 )
        {
            throw new IllegalArgumentException( "Argument 'maxWorkQueueSize' must be a positive integer." );
        }

        if ( gracePeriod.compareTo( maxPurgeInterval ) > 0 )
        {
            throw new IllegalArgumentException( "Value for argument 'gracePeriod' cannot be larger than 'maxPurgeInterval'." );
        }

        this.id = id;
        this.maxWorkQueueSize = maxWorkQueueSize;
        this.maxPurgeInterval = maxPurgeInterval;
        this.gracePeriod = gracePeriod;
    }
@Test
    public void testArchiver() throws Exception
    {
        // Setup fixture.
        final int maxWorkQueueSize = 100;
        final Duration maxPurgeInterval = Duration.ofMillis( 5000 );
        final Duration gracePeriod = Duration.ofMillis( 50 );
        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 );
            assertTrue( timeUntilLogged.compareTo( maxPurgeInterval ) < 0 ); // this needs not be entirely true (due to garbage collection, etc), but is a fair assumption.
        }
        finally
        {
            // Teardown fixture.
            archiver.stop();
        }
    }