### Question:
CappedLogger { public CappedLogger setTimeLimit( long time, @Nonnull TimeUnit unit, @Nonnull Clock clock ) { if ( time < 1 ) { throw new IllegalArgumentException( "The time limit must be positive" ); } if ( unit == null ) { throw new IllegalArgumentException( "The time unit cannot be null" ); } if ( clock == null ) { throw new IllegalArgumentException( "The clock used for time limiting cannot be null" ); } filter = filter.setTimeLimit( time, unit, clock ); return this; } CappedLogger( @Nonnull Log delegate ); void debug( @Nonnull String msg ); void debug( @Nonnull String msg, @Nonnull Throwable cause ); void info( @Nonnull String msg ); void info( @Nonnull String msg, @Nonnull Throwable cause ); void warn( @Nonnull String msg ); void warn( @Nonnull String msg, @Nonnull Throwable cause ); void error( @Nonnull String msg ); void error( @Nonnull String msg, @Nonnull Throwable cause ); void reset(); CappedLogger setCountLimit( int limit ); CappedLogger unsetCountLimit(); CappedLogger setTimeLimit( long time, @Nonnull TimeUnit unit, @Nonnull Clock clock ); CappedLogger unsetTimeLimit(); CappedLogger setDuplicateFilterEnabled( boolean enabled );  }### Answer:
@Test( expected = IllegalArgumentException.class ) public void mustThrowOnZeroTimeLimit() { logger.setTimeLimit( 0, MILLISECONDS, Clocks.systemClock() ); }
@Test( expected = IllegalArgumentException.class ) public void mustThrowOnNegativeTimeLimit() { logger.setTimeLimit( -1, MILLISECONDS, Clocks.systemClock() ); }
@Test( expected = IllegalArgumentException.class ) public void mustThrowOnNullTimeUnit() { logger.setTimeLimit( 10, null, Clocks.systemClock() ); }
@Test( expected = IllegalArgumentException.class ) public void mustThrowOnNullClock() { logger.setTimeLimit( 10, TimeUnit.MILLISECONDS, null ); }
@Test public void mustNotLogMessagesWithinConfiguredTimeLimit() { FakeClock clock = getDefaultFakeClock(); logger.setTimeLimit( 1, TimeUnit.MILLISECONDS, clock ); logMethod.log( logger, "### AAA ###" ); logMethod.log( logger, "### BBB ###" ); clock.forward( 1, TimeUnit.MILLISECONDS ); logMethod.log( logger, "### CCC ###" ); logProvider.rawMessageMatcher().assertContains( containsString( "### AAA ###" ) ); logProvider.assertNone( currentLog( inLog( CappedLogger.class ), containsString( "### BBB ###" ) ) ); logProvider.rawMessageMatcher().assertContains( containsString( "### CCC ###" ) ); }