コード例 #1
0
  @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);
  }
コード例 #2
0
  @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);
  }
コード例 #3
0
 @Test
 public void getConnection() throws IOException {
   MemcachedConnection.connect(host, port);
   MemcachedConnection.getConnection();
 }
コード例 #4
0
 @Test(expected = IllegalStateException.class)
 public void getWrongConnection() {
   MemcachedConnection.getConnection();
 }