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));
}
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);
}
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));
}
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"));
}
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());
}
Aggregations