@Test public void getWrongCachedObject() throws IOException { MemcachedConnection.connect(host, port); MemcachedClient client = MemcachedConnection.getConnection(); // set in memcached String key = UUID.randomUUID().toString(); String content = "slok_" + UUID.randomUUID().toString(); int seconds = 2; client.set(key, seconds, content); // get from memcached and check String result = (String) client.get("notAKey"); assertNull(result); }
@Test public void getExpiredCachedObject() throws IOException, InterruptedException { MemcachedConnection.connect(host, port); MemcachedClient client = MemcachedConnection.getConnection(); // set in memcached String key = UUID.randomUUID().toString(); String content = "slok_" + UUID.randomUUID().toString(); int seconds = 1; client.set(key, seconds, content); Thread.sleep(1001); // get from memcached and check String result = (String) client.get(key); assertNull(result); }
@Test public void getConnection() throws IOException { MemcachedConnection.connect(host, port); MemcachedConnection.getConnection(); }
@Test(expected = IllegalStateException.class) public void getWrongConnection() { MemcachedConnection.getConnection(); }