-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
81 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 18 additions & 12 deletions
30
...t/java/es/moki/ratelimitj/hazelcast/HazelcastSlidingWindowSyncRequestRateLimiterTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,49 @@ | ||
package es.moki.ratelimitj.hazelcast; | ||
|
||
import com.hazelcast.core.Hazelcast; | ||
import com.hazelcast.core.DistributedObject; | ||
import com.hazelcast.core.HazelcastInstance; | ||
import es.moki.ratelimitj.core.limiter.request.RequestLimitRule; | ||
import es.moki.ratelimitj.core.limiter.request.RequestRateLimiter; | ||
import es.moki.ratelimitj.core.time.TimeSupplier; | ||
import es.moki.ratelimitj.test.limiter.request.AbstractSyncRequestRateLimiterTest; | ||
import org.junit.jupiter.api.AfterAll; | ||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.Disabled; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.Set; | ||
|
||
import static es.moki.ratelimitj.hazelcast.HazelcastTestFactory.newStandaloneHazelcastInstance; | ||
|
||
|
||
public class HazelcastSlidingWindowSyncRequestRateLimiterTest extends AbstractSyncRequestRateLimiterTest { | ||
|
||
private static HazelcastInstance hz; | ||
|
||
@BeforeAll | ||
public static void before() { | ||
hz = Hazelcast.newHazelcastInstance(); | ||
public static void beforeAll() { | ||
hz = newStandaloneHazelcastInstance(); | ||
} | ||
|
||
@AfterAll | ||
public static void after() { | ||
public static void afterAll() { | ||
hz.shutdown(); | ||
} | ||
|
||
@AfterEach | ||
public void afterEach() { | ||
hz.getDistributedObjects().forEach(DistributedObject::destroy); | ||
} | ||
|
||
@Override | ||
protected RequestRateLimiter getRateLimiter(Set<RequestLimitRule> rules, TimeSupplier timeSupplier) { | ||
return new HazelcastSlidingWindowRequestRateLimiter(hz, rules, timeSupplier); | ||
} | ||
|
||
@Override | ||
@Test | ||
@Disabled | ||
public void shouldResetLimit() { | ||
|
||
} | ||
// @Override | ||
// @Test | ||
// @Disabled | ||
// public void shouldResetLimit() { | ||
// | ||
// } | ||
|
||
} |
16 changes: 12 additions & 4 deletions
16
...elimitj/hazelcast/HazelcastSlidingWindowSyncRequestRequestRateLimiterPerformanceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
ratelimitj-hazelcast/src/test/java/es/moki/ratelimitj/hazelcast/HazelcastTestFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package es.moki.ratelimitj.hazelcast; | ||
|
||
import com.hazelcast.config.Config; | ||
import com.hazelcast.config.NetworkConfig; | ||
import com.hazelcast.core.Hazelcast; | ||
import com.hazelcast.core.HazelcastInstance; | ||
|
||
public class HazelcastTestFactory { | ||
|
||
public static HazelcastInstance newStandaloneHazelcastInstance() { | ||
Config config = new Config(); | ||
config.setProperty("hazelcast.logging.type", "slf4j"); | ||
config.setProperty("hazelcast.shutdownhook.enabled", "false"); | ||
NetworkConfig network = config.getNetworkConfig(); | ||
network.getJoin().getTcpIpConfig().setEnabled(false); | ||
network.getJoin().getMulticastConfig().setEnabled(false); | ||
return Hazelcast.newHazelcastInstance(config); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters