1 // Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
2 // This source code is licensed under the BSD-style license found in the
3 // LICENSE file in the root directory of this source tree. An additional grant
4 // of patent rights can be found in the PATENTS file in the same directory.
7 import org
.junit
.ClassRule
;
10 import static org
.assertj
.core
.api
.Assertions
.assertThat
;
12 public class RateLimiterTest
{
15 public static final RocksMemoryResource rocksMemoryResource
=
16 new RocksMemoryResource();
19 public void setBytesPerSecond() {
20 try(final RateLimiter rateLimiter
=
21 new RateLimiter(1000, 100 * 1000, 1)) {
22 rateLimiter
.setBytesPerSecond(2000);
27 public void getSingleBurstBytes() {
28 try(final RateLimiter rateLimiter
=
29 new RateLimiter(1000, 100 * 1000, 1)) {
30 assertThat(rateLimiter
.getSingleBurstBytes()).isEqualTo(100);
35 public void getTotalBytesThrough() {
36 try(final RateLimiter rateLimiter
=
37 new RateLimiter(1000, 100 * 1000, 1)) {
38 assertThat(rateLimiter
.getTotalBytesThrough()).isEqualTo(0);
43 public void getTotalRequests() {
44 try(final RateLimiter rateLimiter
=
45 new RateLimiter(1000, 100 * 1000, 1)) {
46 assertThat(rateLimiter
.getTotalRequests()).isEqualTo(0);