-
Notifications
You must be signed in to change notification settings - Fork 613
/
ServerTasks.java
57 lines (48 loc) · 2.03 KB
/
ServerTasks.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package org.infinispan.server.extensions;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import org.infinispan.client.hotrod.RemoteCache;
import org.infinispan.jboss.marshalling.commons.GenericJBossMarshaller;
import org.infinispan.server.test.junit4.InfinispanServerRule;
import org.infinispan.server.test.junit4.InfinispanServerTestMethodRule;
import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
/**
* @author Tristan Tarrant <tristan@infinispan.org>
* @since 10.0
**/
public class ServerTasks {
@ClassRule
public static final InfinispanServerRule SERVERS = ExtensionsIT.SERVERS;
@Rule
public InfinispanServerTestMethodRule SERVER_TEST = new InfinispanServerTestMethodRule(SERVERS);
@Test
public void testServerTaskNoParameters() {
RemoteCache<String, String> cache = SERVER_TEST.hotrod().create();
Object hello = cache.execute("hello", Collections.emptyMap());
assertEquals("Hello world", hello);
}
@Test
public void testServerTaskWithParameters() {
RemoteCache<String, String> cache = SERVER_TEST.hotrod().create();
ArrayList<String> messages = cache.execute("hello", Collections.singletonMap("greetee", new ArrayList<>(Arrays.asList("nurse", "kitty"))));
assertEquals(2, messages.size());
assertEquals("Hello nurse", messages.get(0));
assertEquals("Hello kitty", messages.get(1));
}
@Test
public void testDistributedServerTaskWithParameters() {
// We must utilise the GenericJBossMarshaller due to ISPN-8814
RemoteCache<String, String> cache = SERVER_TEST.hotrod().withMarshaller(GenericJBossMarshaller.class).create();
List<String> greetings = cache.execute("dist-hello", Collections.singletonMap("greetee", "my friend"));
assertEquals(2, greetings.size());
for(String greeting : greetings) {
assertTrue(greeting.matches("Hello my friend .*"));
}
}
}