### Question:
CappedLogger { public CappedLogger setCountLimit( int limit ) { if ( limit < 1 ) { throw new IllegalArgumentException( "The count limit must be positive" ); } filter = filter.setCountLimit( limit ); 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 mustThrowOnSettingZeroCountLimit() { logger.setCountLimit( 0 ); }
@Test( expected = IllegalArgumentException.class ) public void mustThrowOnSettingNegativeCountLimit() { logger.setCountLimit( -1 ); }
@Test public void mustLimitByConfiguredCount() { int limit = 10; logger.setCountLimit( limit ); String[] lines = logLines( limit + 1 ); assertLoggedLines( lines, limit ); logProvider.assertNone( currentLog( inLog( CappedLogger.class ), containsString( lines[limit] ) ) ); }