|
|
|
@ -1,23 +1,32 @@
|
|
|
|
|
package org.redisson;
|
|
|
|
|
|
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat;
|
|
|
|
|
import static org.assertj.core.api.Assertions.assertThatNoException;
|
|
|
|
|
|
|
|
|
|
import java.io.Serializable;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
import java.util.Collection;
|
|
|
|
|
import java.util.Collections;
|
|
|
|
|
import java.util.HashSet;
|
|
|
|
|
import java.util.Iterator;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Set;
|
|
|
|
|
import java.util.concurrent.ExecutionException;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
import java.util.stream.IntStream;
|
|
|
|
|
import org.junit.jupiter.api.Assertions;
|
|
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
|
import org.redisson.RedisRunner.FailedToStartRedisException;
|
|
|
|
|
import org.redisson.api.RFuture;
|
|
|
|
|
import org.redisson.api.RList;
|
|
|
|
|
import org.redisson.api.RSet;
|
|
|
|
|
import org.redisson.api.RTransaction;
|
|
|
|
|
import org.redisson.api.SortOrder;
|
|
|
|
|
import org.redisson.api.TransactionOptions;
|
|
|
|
|
import org.redisson.client.codec.IntegerCodec;
|
|
|
|
|
import org.redisson.client.codec.StringCodec;
|
|
|
|
|
|
|
|
|
|
import java.io.Serializable;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.concurrent.ExecutionException;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
import java.util.stream.IntStream;
|
|
|
|
|
|
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat;
|
|
|
|
|
|
|
|
|
|
public class RedissonSetTest extends RedisDockerTest {
|
|
|
|
|
|
|
|
|
|
public static class SimpleBean implements Serializable {
|
|
|
|
@ -890,4 +899,22 @@ public class RedissonSetTest extends RedisDockerTest {
|
|
|
|
|
assertThat(strings).containsAll(stringsOne);
|
|
|
|
|
assertThat(strings).hasSize(stringsOne.size());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testAddAndContainsInTransactionShouldNotShowResourceLeak() {
|
|
|
|
|
int arbitraryElementsCount = 1000;
|
|
|
|
|
|
|
|
|
|
RTransaction tx = redisson.createTransaction(TransactionOptions.defaults());
|
|
|
|
|
RSet<Integer> testSet = tx.getSet("testSet");
|
|
|
|
|
// Should check the log when we run this test and see if there is any resource leak error
|
|
|
|
|
assertThatNoException().isThrownBy(()->{
|
|
|
|
|
for (int index = 0; index < arbitraryElementsCount; index++) {
|
|
|
|
|
testSet.add(index);
|
|
|
|
|
if (testSet.contains(index)) {
|
|
|
|
|
System.out.println("Element " + index + " is in the set");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
tx.commit();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|