예제 #1
0
  public void testSessionExpiration() throws Exception {
    Interpreter interpreter = new Interpreter();
    interpreter.initialize(this.cacheManager);
    interpreter.setSessionTimeout(500);
    interpreter.setSessionReaperWakeupInterval(1000);
    interpreter.start();

    try {
      String sessionId = interpreter.createSessionId(null);
      Thread.sleep(1500);
      Map<String, String> response = interpreter.execute(sessionId, "");
      assert response.containsKey("ERROR");
    } finally {
      interpreter.stop();
    }
  }
예제 #2
0
  public void testHotRodEncoding() throws Exception {
    Cache<byte[], byte[]> cache = cacheManager.getCache();
    RemoteCache<String, String> remoteCache = remoteCacheManager.getCache();
    remoteCache.put("k1", "v1");
    GenericJBossMarshaller marshaller = new GenericJBossMarshaller();
    byte[] k1 = marshaller.objectToByteBuffer("k1");
    assertTrue(cache.containsKey(k1));

    String sessionId = interpreter.createSessionId(BasicCacheContainer.DEFAULT_CACHE_NAME);
    interpreter.execute(sessionId, "encoding hotrod;");
    Map<String, String> response = interpreter.execute(sessionId, "get k1;");
    assertEquals("v1", response.get(ResultKeys.OUTPUT.toString()));

    assertInterpreter(interpreter.execute(sessionId, "put k2 v2;"));
    String v2 = remoteCache.get("k2");
    assertEquals("v2", v2);
  }