Search in sources :

Example 26 with RLiveObjectService

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

the class RedissonLiveObjectServiceTest method testRemoveById.

@Test
public void testRemoveById() {
    RLiveObjectService service = redisson.getLiveObjectService();
    TestClass ts = new TestClass(new ObjectId(100));
    ts.setCode("CODE");
    TestClass persisted = service.persist(ts);
    assertTrue(service.isExists(persisted));
    service.delete(TestClass.class, new ObjectId(100));
    assertFalse(service.isExists(persisted));
}
Also used : RLiveObjectService(org.redisson.api.RLiveObjectService) Test(org.junit.Test)

Example 27 with RLiveObjectService

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

the class RedissonLiveObjectServiceTest method testClassUnRegistration.

@Test
public void testClassUnRegistration() {
    RLiveObjectService service = redisson.getLiveObjectService();
    service.registerClass(TestClass.class);
    assertTrue(service.isClassRegistered(TestClass.class));
    RLiveObjectService newService = redisson.getLiveObjectService();
    RedissonClient newRedisson = Redisson.create(redisson.getConfig());
    newRedisson.getLiveObjectService().registerClass(TestClass.class);
    newService.unregisterClass(TestClass.class);
    assertFalse(service.isClassRegistered(TestClass.class));
    assertFalse(newService.isClassRegistered(TestClass.class));
    assertTrue(newRedisson.getLiveObjectService().isClassRegistered(TestClass.class));
    assertFalse(service.isClassRegistered(TestClass.class));
    assertFalse(newService.isClassRegistered(TestClass.class));
    newRedisson.shutdown(1, 5, TimeUnit.SECONDS);
}
Also used : RedissonClient(org.redisson.api.RedissonClient) RLiveObjectService(org.redisson.api.RLiveObjectService) Test(org.junit.Test)

Example 28 with RLiveObjectService

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

the class RedissonLiveObjectServiceTest method testIsLiveObject.

@Test
public void testIsLiveObject() {
    RLiveObjectService service = redisson.getLiveObjectService();
    TestClass ts = new TestClass(new ObjectId(100));
    assertFalse(service.isLiveObject(ts));
    TestClass persisted = service.persist(ts);
    assertFalse(service.isLiveObject(ts));
    assertTrue(service.isLiveObject(persisted));
}
Also used : RLiveObjectService(org.redisson.api.RLiveObjectService) Test(org.junit.Test)

Example 29 with RLiveObjectService

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

the class RedissonLiveObjectServiceTest method testLiveObjectWithRObject.

@Test
public void testLiveObjectWithRObject() {
    RLiveObjectService s = redisson.getLiveObjectService();
    TestREntityWithRMap t = new TestREntityWithRMap("2");
    t = s.persist(t);
    RMap<String, String> map = redisson.<String, String>getMap("testMap");
    t.setValue(map);
    map.put("field", "123");
    assertEquals("123", s.<TestREntityWithRMap, String>get(TestREntityWithRMap.class, "2").getValue().get("field"));
    t = s.get(TestREntityWithRMap.class, "2");
    t.getValue().put("field", "333");
    assertEquals("333", s.<TestREntityWithRMap, String>get(TestREntityWithRMap.class, "2").getValue().get("field"));
}
Also used : RLiveObjectService(org.redisson.api.RLiveObjectService) Test(org.junit.Test)

Example 30 with RLiveObjectService

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

the class RedissonReferenceTest method testBasic.

@Test
public void testBasic() {
    RBucket<Object> b1 = redisson.getBucket("b1");
    RBucket<Object> b2 = redisson.getBucket("b2");
    RBucket<Object> b3 = redisson.getBucket("b3");
    b2.set(b3);
    b1.set(redisson.getBucket("b2"));
    assertTrue(b1.get().getClass().equals(RedissonBucket.class));
    assertEquals("b3", ((RBucket) ((RBucket) b1.get()).get()).getName());
    RBucket<Object> b4 = redisson.getBucket("b4");
    b4.set(redisson.getMapCache("testCache"));
    assertTrue(b4.get() instanceof RedissonMapCache);
    ((RedissonMapCache) b4.get()).fastPut(b1, b2, 1, TimeUnit.MINUTES);
    assertEquals("b2", ((RBucket) ((RedissonMapCache) b4.get()).get(b1)).getName());
    RBucket<Object> b5 = redisson.getBucket("b5");
    RLiveObjectService service = redisson.getLiveObjectService();
    RedissonLiveObjectServiceTest.TestREntity rlo = new RedissonLiveObjectServiceTest.TestREntity("123");
    rlo = service.persist(rlo);
    rlo.setName("t1");
    rlo.setValue("t2");
    b5.set(rlo);
    assertTrue(redisson.getBucket("b5").get() instanceof RLiveObject);
    assertEquals("t1", ((RedissonLiveObjectServiceTest.TestREntity) redisson.getBucket("b5").get()).getName());
    assertEquals("t2", ((RedissonLiveObjectServiceTest.TestREntity) redisson.getBucket("b5").get()).getValue());
}
Also used : RBucket(org.redisson.api.RBucket) RLiveObject(org.redisson.api.RLiveObject) RLiveObject(org.redisson.api.RLiveObject) RLiveObjectService(org.redisson.api.RLiveObjectService) Test(org.junit.Test)

Aggregations

RLiveObjectService (org.redisson.api.RLiveObjectService)30 Test (org.junit.Test)29 RedisException (org.redisson.client.RedisException)8 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 LinkedList (java.util.LinkedList)3 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)3 RList (org.redisson.api.RList)3 RLiveObject (org.redisson.api.RLiveObject)3 RObject (org.redisson.api.RObject)3 HashSet (java.util.HashSet)2 TreeSet (java.util.TreeSet)2 ArrayBlockingQueue (java.util.concurrent.ArrayBlockingQueue)2 ConcurrentLinkedQueue (java.util.concurrent.ConcurrentLinkedQueue)2 LinkedBlockingDeque (java.util.concurrent.LinkedBlockingDeque)2 RBlockingDeque (org.redisson.api.RBlockingDeque)2 RBlockingQueue (org.redisson.api.RBlockingQueue)2 RDeque (org.redisson.api.RDeque)2 RMap (org.redisson.api.RMap)2 RQueue (org.redisson.api.RQueue)2