Ejemplo n.º 1
0
  @Test
  @WithRunningServer({@RunningServer(name = "standalone-customtask")})
  public void shouldThrowExceptionInViaTask() throws Exception {
    RemoteCacheManager rcm = ITestUtils.createCacheManager(server);

    exceptionRule.expect(HotRodClientException.class);
    exceptionRule.expectMessage(LocalExceptionalServerTask.EXCEPTION_MESSAGE);

    rcm.getCache().execute(LocalExceptionalServerTask.NAME, Collections.emptyMap());
  }
Ejemplo n.º 2
0
  @Test
  @WithRunningServer({@RunningServer(name = "standalone-customtask")})
  public void shouldWorkWithCustomMojo() throws Exception {
    RemoteCacheManager rcm = ITestUtils.createCacheManager(server);
    RemoteCache remoteCache = rcm.getCache();

    Map params = new HashMap();
    params.put("greeting", toBytes(new Greeting("hello, good morning :)")));

    String result = (String) remoteCache.execute(GreetingServerTask.NAME, params);
    assertEquals("hello, good morning :)", result);
  }
Ejemplo n.º 3
0
  @Test
  @WithRunningServer({@RunningServer(name = "standalone-customtask")})
  public void shouldModifyCacheInViaTask() throws Exception {
    RemoteCacheManager rcm = ITestUtils.createCacheManager(server);

    String value = "value";
    rcm.getCache().put(LocalTestServerTask.TASK_EXECUTED, value);
    rcm.getCache().execute(LocalTestServerTask.NAME, Collections.emptyMap());

    assertEquals(
        LocalTestServerTask.MODIFIED_PREFIX + value,
        rcm.getCache().get(LocalTestServerTask.TASK_EXECUTED));
    assertEquals(
        LocalTestServerTask.MODIFIED_PREFIX + value,
        rcm.getCache(LocalTestServerTask.CACHE_NAME).get(LocalTestServerTask.TASK_EXECUTED));
  }
Ejemplo n.º 4
0
  @Test
  @WithRunningServer({@RunningServer(name = "standalone-customtask")})
  public void shouldExecuteMapReduceViaJavaScriptInTask() throws Exception {
    RemoteCacheManager rcm = ITestUtils.createCacheManager(server);
    RemoteCache remoteCache = rcm.getCache();
    remoteCache.put(1, "word1 word2 word3");
    remoteCache.put(2, "word1 word2");
    remoteCache.put(3, "word1");

    Map<String, Long> result =
        (Map<String, Long>) remoteCache.execute(JSExecutingServerTask.NAME, Collections.emptyMap());
    assertEquals(3, result.size());
    assertEquals(3, result.get("word1").intValue());
    assertEquals(2, result.get("word2").intValue());
    assertEquals(1, result.get("word3").intValue());
  }