use of no.stelar7.api.r4j.impl.lol.builders.summoner.SummonerBuilder in project L4J8 by stelar7.
the class RatelimitTest method testRateLimitThreaded.
@Test
@Disabled
public void testRateLimitThreaded() {
try {
String name = new SpectatorBuilder().withPlatform(LeagueShard.EUW1).getFeaturedGames().get(0).getParticipants().get(0).getSummonerName();
Summoner s = new SummonerBuilder().withPlatform(LeagueShard.EUW1).withName(name).get();
ExecutorService pool = Executors.newFixedThreadPool(8);
for (int i2 = 0; i2 < 130; i2++) {
pool.execute(() -> new SummonerBuilder().withPlatform(LeagueShard.EUW1).withSummonerId(s.getSummonerId()).get());
}
pool.shutdown();
pool.awaitTermination(Long.MAX_VALUE, TimeUnit.DAYS);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
use of no.stelar7.api.r4j.impl.lol.builders.summoner.SummonerBuilder in project L4J8 by stelar7.
the class RatelimitTest method testRateLimitWithSleep.
@Test
@Disabled
public void testRateLimitWithSleep() throws InterruptedException {
String id = new SpectatorBuilder().withPlatform(LeagueShard.EUW1).getFeaturedGames().get(0).getParticipants().get(0).getSummonerName();
Summoner s = new SummonerBuilder().withPlatform(LeagueShard.EUW1).withName(id).get();
new SummonerBuilder().withPlatform(LeagueShard.EUW1).withSummonerId(id).get();
TimeUnit.SECONDS.sleep(10);
new SummonerBuilder().withPlatform(LeagueShard.EUW1).withSummonerId(id).get();
}
use of no.stelar7.api.r4j.impl.lol.builders.summoner.SummonerBuilder in project L4J8 by stelar7.
the class CacheTest method testCacheStuff.
@Test
@Disabled
public void testCacheStuff() throws InterruptedException {
Logger root = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
root.setLevel(Level.INFO);
System.out.println("Fetching summoner for the first time");
DataCall.setCacheProvider(fileCache.get());
String id = new SpectatorBuilder().withPlatform(LeagueShard.EUW1).getFeaturedGames().get(0).getParticipants().get(0).getSummonerName();
new SummonerBuilder().withPlatform(LeagueShard.EUW1).withName(id).get();
new SummonerBuilder().withPlatform(LeagueShard.EUW1).withName(id).get();
Thread.sleep(6000);
System.out.println("Fetching summoner after cache timeout");
new SummonerBuilder().withPlatform(LeagueShard.EUW1).withName(id).get();
new SummonerBuilder().withPlatform(LeagueShard.EUW1).withName(id).get();
Map<String, Object> data = new TreeMap<>();
data.put("platform", LeagueShard.EUW1);
data.put("name", id);
DataCall.getCacheProvider().clear(URLEndpoint.V4_SUMMONER_BY_NAME, data);
System.out.println("Fetching summoner after deleting entry");
new SummonerBuilder().withPlatform(LeagueShard.EUW1).withName(id).get();
new SummonerBuilder().withPlatform(LeagueShard.EUW1).withName(id).get();
CacheLifetimeHint defaults = CacheLifetimeHint.DEFAULTS;
defaults.add(URLEndpoint.V4_SUMMONER_BY_NAME, TimeUnit.SECONDS.toMillis(1));
DataCall.getCacheProvider().setTimeToLive(defaults);
Thread.sleep(1000);
System.out.println("Fetching summoner after setting lifetime to a lower limit");
new SummonerBuilder().withPlatform(LeagueShard.EUW1).withName(id).get();
new SummonerBuilder().withPlatform(LeagueShard.EUW1).withName(id).get();
}
Aggregations