Search in sources :

Example 11 with RBatchRx

use of org.redisson.api.RBatchRx in project redisson by redisson.

the class RedissonBatchRxTest method testBatchNPE.

@ParameterizedTest
@MethodSource("data")
public void testBatchNPE(BatchOptions batchOptions) {
    RBatchRx batch = redisson.createBatch(batchOptions);
    batch.getBucket("A1").set("001");
    batch.getBucket("A2").set("001");
    batch.getBucket("A3").set("001");
    batch.getKeys().delete("A1");
    batch.getKeys().delete("A2");
    sync(batch.execute());
}
Also used : RBatchRx(org.redisson.api.RBatchRx) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 12 with RBatchRx

use of org.redisson.api.RBatchRx in project redisson by redisson.

the class RedissonBatchRxTest method testDifferentCodecsAtomic.

@ParameterizedTest
@MethodSource("data")
public void testDifferentCodecsAtomic(BatchOptions batchOptions) {
    RBatchRx b = redisson.createBatch(batchOptions.executionMode(ExecutionMode.IN_MEMORY_ATOMIC));
    b.getMap("test1").put("1", "2");
    b.getMap("test2", StringCodec.INSTANCE).put("21", "3");
    Maybe<Object> val1 = b.getMap("test1").get("1");
    Maybe<Object> val2 = b.getMap("test2", StringCodec.INSTANCE).get("21");
    sync(b.execute());
    Assertions.assertEquals("2", sync(val1));
    Assertions.assertEquals("3", sync(val2));
}
Also used : RBatchRx(org.redisson.api.RBatchRx) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 13 with RBatchRx

use of org.redisson.api.RBatchRx in project redisson by redisson.

the class RedissonBatchRxTest method testConnectionLeakAfterError.

@Test
public void testConnectionLeakAfterError() {
    Config config = BaseTest.createConfig();
    config.useSingleServer().setRetryInterval(100).setTimeout(200).setConnectionMinimumIdleSize(1).setConnectionPoolSize(1);
    RedissonRxClient redisson = Redisson.create(config).rxJava();
    BatchOptions batchOptions = BatchOptions.defaults().executionMode(ExecutionMode.REDIS_WRITE_ATOMIC);
    RBatchRx batch = redisson.createBatch(batchOptions);
    for (int i = 0; i < 25000; i++) {
        batch.getBucket("test").set(123);
    }
    try {
        sync(batch.execute());
        Assertions.fail();
    } catch (Exception e) {
    // skip
    }
    sync(redisson.getBucket("test3").set(4));
    assertThat(sync(redisson.getBucket("test3").get())).isEqualTo(4);
    batch = redisson.createBatch(batchOptions);
    batch.getBucket("test1").set(1);
    batch.getBucket("test2").set(2);
    sync(batch.execute());
    assertThat(sync(redisson.getBucket("test1").get())).isEqualTo(1);
    assertThat(sync(redisson.getBucket("test2").get())).isEqualTo(2);
    redisson.shutdown();
}
Also used : Config(org.redisson.config.Config) RBatchRx(org.redisson.api.RBatchRx) RedisException(org.redisson.client.RedisException) FailedToStartRedisException(org.redisson.RedisRunner.FailedToStartRedisException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) RedissonRxClient(org.redisson.api.RedissonRxClient) BatchOptions(org.redisson.api.BatchOptions) BaseTest(org.redisson.BaseTest) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 14 with RBatchRx

use of org.redisson.api.RBatchRx in project redisson by redisson.

the class RedissonBatchRxTest method testEmpty.

@ParameterizedTest
@MethodSource("data")
public void testEmpty(BatchOptions batchOptions) {
    RBatchRx batch = redisson.createBatch(batchOptions);
    sync(batch.execute());
}
Also used : RBatchRx(org.redisson.api.RBatchRx) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 15 with RBatchRx

use of org.redisson.api.RBatchRx in project redisson by redisson.

the class RedissonBatchRxTest method testExceptionHandling.

@ParameterizedTest
@MethodSource("data")
public void testExceptionHandling(BatchOptions batchOptions) {
    Assertions.assertThrows(RedisException.class, () -> {
        RBatchRx batch = redisson.createBatch(batchOptions);
        batch.getMap("test").put("1", "2");
        batch.getScript().eval(Mode.READ_WRITE, "wrong_code", RScript.ReturnType.VALUE);
        sync(batch.execute());
    });
}
Also used : RBatchRx(org.redisson.api.RBatchRx) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Aggregations

RBatchRx (org.redisson.api.RBatchRx)20 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)19 MethodSource (org.junit.jupiter.params.provider.MethodSource)18 RedissonRxClient (org.redisson.api.RedissonRxClient)5 Config (org.redisson.config.Config)5 AtomicLong (java.util.concurrent.atomic.AtomicLong)3 HashMap (java.util.HashMap)2 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)2 ClusterRunner (org.redisson.ClusterRunner)2 ClusterProcesses (org.redisson.ClusterRunner.ClusterProcesses)2 RedisRunner (org.redisson.RedisRunner)2 Completable (io.reactivex.rxjava3.core.Completable)1 Single (io.reactivex.rxjava3.core.Single)1 IOException (java.io.IOException)1 List (java.util.List)1 Map (java.util.Map)1 ExecutionException (java.util.concurrent.ExecutionException)1 ExecutorService (java.util.concurrent.ExecutorService)1 Test (org.junit.jupiter.api.Test)1 BaseTest (org.redisson.BaseTest)1