use of org.redisson.api.RLiveObjectService in project redisson by redisson.
the class RedissonLiveObjectServiceTest method testExpirable.
@Test
public void testExpirable() throws InterruptedException {
RLiveObjectService service = redisson.getLiveObjectService();
TestClass myObject = new TestClass();
myObject = service.persist(myObject);
myObject.setValue("123345");
assertTrue(service.asLiveObject(myObject).isExists());
service.asRExpirable(myObject).expire(1, TimeUnit.SECONDS);
Thread.sleep(2000);
assertFalse(service.asLiveObject(myObject).isExists());
}
use of org.redisson.api.RLiveObjectService in project redisson by redisson.
the class RedissonLiveObjectServiceTest method testRObject.
@Test
public void testRObject() {
RLiveObjectService service = redisson.getLiveObjectService();
TestClass myObject = new TestClass();
myObject = service.persist(myObject);
try {
((RObject) myObject).isExists();
} catch (Exception e) {
assertEquals("Please use RLiveObjectService instance for this type of functions", e.getMessage());
}
}
use of org.redisson.api.RLiveObjectService in project redisson by redisson.
the class RedissonLiveObjectServiceTest method testStoreInnerObject.
@Test
public void testStoreInnerObject() {
RLiveObjectService service = redisson.getLiveObjectService();
ObjectWithList so = new ObjectWithList();
so = service.persist(so);
SimpleObject s = new SimpleObject();
s = service.persist(s);
so.setSo(s);
assertThat(s.getId()).isNotNull();
so.getObjects().add(s);
so = redisson.getLiveObjectService().detach(so);
assertThat(so.getSo().getId()).isEqualTo(s.getId());
assertThat(so.getObjects().get(0).getId()).isEqualTo(so.getSo().getId());
}
use of org.redisson.api.RLiveObjectService in project redisson by redisson.
the class RedissonLiveObjectServiceTest method testAsLiveObject.
@Test
public void testAsLiveObject() {
RLiveObjectService service = redisson.getLiveObjectService();
TestClass instance = new TestClass(new ObjectId(100));
instance = service.persist(instance);
RLiveObject liveObject = service.asLiveObject(instance);
assertEquals(new ObjectId(100), liveObject.getLiveObjectId());
try {
service.asLiveObject(new Object());
fail("Should not be here");
} catch (Exception e) {
assertTrue(e instanceof ClassCastException);
}
}
use of org.redisson.api.RLiveObjectService in project redisson by redisson.
the class RedissonLiveObjectServiceTest method testRemoveByInstance.
@Test
public void testRemoveByInstance() {
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(persisted);
assertFalse(service.isExists(persisted));
}
Aggregations