Adding a uniform configuration for all json/yaml mapper use cases: part 1

This commit is contained in:
Sergey Skrobotov
2023-02-23 16:11:05 -08:00
parent 6ee9c6ad46
commit b9b4e3fdd8
38 changed files with 250 additions and 121 deletions

View File

@@ -15,6 +15,7 @@ import java.io.IOException;
import java.time.Duration;
import java.util.concurrent.TimeUnit;
import org.junit.jupiter.api.Test;
import org.whispersystems.textsecuregcm.util.SystemMapper;
class LeakyBucketTest {
@@ -35,7 +36,7 @@ class LeakyBucketTest {
@Test
void testLapseRate() throws IOException {
ObjectMapper mapper = new ObjectMapper();
ObjectMapper mapper = SystemMapper.jsonMapper();
String serialized = "{\"bucketSize\":2,\"leakRatePerMillis\":8.333333333333334E-6,\"spaceRemaining\":0,\"lastUpdateTimeMillis\":" + (System.currentTimeMillis() - TimeUnit.MINUTES.toMillis(2)) + "}";
LeakyBucket leakyBucket = LeakyBucket.fromSerialized(mapper, serialized);

View File

@@ -61,7 +61,7 @@ public class RateLimitedByIpTest {
Mockito.when(rl.forDescriptor(Mockito.eq(RateLimiters.For.BACKUP_AUTH_CHECK))).thenReturn(RATE_LIMITER));
private static final ResourceExtension RESOURCES = ResourceExtension.builder()
.setMapper(SystemMapper.getMapper())
.setMapper(SystemMapper.jsonMapper())
.setTestContainerFactory(new GrizzlyWebTestContainerFactory())
.addResource(new Controller())
.addProvider(new RateLimitByIpFilter(RATE_LIMITERS))