|
|
|
@ -7,9 +7,35 @@ import java.util.Map;
|
|
|
|
|
import org.junit.Assert;
|
|
|
|
|
import org.junit.Test;
|
|
|
|
|
import org.redisson.core.RBatch;
|
|
|
|
|
import org.redisson.core.RListAsync;
|
|
|
|
|
|
|
|
|
|
public class RedissonBatchTest extends BaseTest {
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testBatchList() {
|
|
|
|
|
RBatch b = redisson.createBatch();
|
|
|
|
|
RListAsync<Integer> listAsync = b.getList("list");
|
|
|
|
|
for (int i = 1; i < 540; i++) {
|
|
|
|
|
listAsync.addAsync(i);
|
|
|
|
|
}
|
|
|
|
|
List<?> res = b.execute();
|
|
|
|
|
Assert.assertEquals(539, res.size());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testBatchBigRequest() {
|
|
|
|
|
RBatch batch = redisson.createBatch();
|
|
|
|
|
for (int i = 0; i < 210; i++) {
|
|
|
|
|
batch.getMap("test").fastPutAsync("1", "2");
|
|
|
|
|
batch.getMap("test").fastPutAsync("2", "3");
|
|
|
|
|
batch.getMap("test").putAsync("2", "5");
|
|
|
|
|
batch.getAtomicLongAsync("counter").incrementAndGetAsync();
|
|
|
|
|
batch.getAtomicLongAsync("counter").incrementAndGetAsync();
|
|
|
|
|
}
|
|
|
|
|
List<?> res = batch.execute();
|
|
|
|
|
Assert.assertEquals(210*5, res.size());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test(expected=IllegalStateException.class)
|
|
|
|
|
public void testTwice() {
|
|
|
|
|
RBatch batch = redisson.createBatch();
|
|
|
|
|