Skip to content

Commit

Permalink
Add missing assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
garydgregory committed Nov 24, 2024
1 parent 0523c23 commit 1ccc008
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.apache.commons.pool2.impl;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;

import java.time.Duration;

Expand All @@ -30,41 +31,44 @@ public class TestEvictionConfig {
@Test
public void testConstructor1s() {
final EvictionConfig config = new EvictionConfig(Duration.ofMillis(1), Duration.ofMillis(1), 1);

assertEquals(1, config.getIdleEvictDuration().toMillis());
assertEquals(1, config.getIdleEvictTime());
assertEquals(1, config.getIdleEvictTimeDuration().toMillis());
assertEquals(1, config.getIdleSoftEvictDuration().toMillis());
assertEquals(1, config.getIdleSoftEvictTime());
assertEquals(1, config.getIdleSoftEvictTimeDuration().toMillis());
assertEquals(1, config.getMinIdle());
// toString() should never throw
assertFalse(config.toString().isEmpty());
}

@Test
public void testConstructorZerosDurations() {
final EvictionConfig config = new EvictionConfig(Duration.ZERO, Duration.ZERO, 0);

assertEquals(Long.MAX_VALUE, config.getIdleEvictDuration().toMillis());
assertEquals(Long.MAX_VALUE, config.getIdleEvictTime());
assertEquals(Long.MAX_VALUE, config.getIdleEvictTimeDuration().toMillis());
assertEquals(Long.MAX_VALUE, config.getIdleSoftEvictDuration().toMillis());
assertEquals(Long.MAX_VALUE, config.getIdleSoftEvictTime());
assertEquals(Long.MAX_VALUE, config.getIdleSoftEvictTimeDuration().toMillis());
assertEquals(0, config.getMinIdle());
// toString() should never throw
assertFalse(config.toString().isEmpty());
}

@Test
public void testConstructorZerosMillis() {
@SuppressWarnings("deprecation")
final EvictionConfig config = new EvictionConfig(0, 0, 0);

assertEquals(Long.MAX_VALUE, config.getIdleEvictDuration().toMillis());
assertEquals(Long.MAX_VALUE, config.getIdleEvictTime());
assertEquals(Long.MAX_VALUE, config.getIdleEvictTimeDuration().toMillis());
assertEquals(Long.MAX_VALUE, config.getIdleSoftEvictDuration().toMillis());
assertEquals(Long.MAX_VALUE, config.getIdleSoftEvictTime());
assertEquals(Long.MAX_VALUE, config.getIdleSoftEvictTimeDuration().toMillis());
assertEquals(0, config.getMinIdle());
// toString() should never throw
assertFalse(config.toString().isEmpty());
}

}

0 comments on commit 1ccc008

Please sign in to comment.