use of org.apache.geode.cache.client.ClientCache in project geode by apache.
the class NoShowValue1PostProcessorDUnitTest method testPostProcess.
@Test
public void testPostProcess() {
List<String> keys = new ArrayList<>();
keys.add("key1");
keys.add("key2");
client1.invoke(() -> {
ClientCache cache = createClientCache("super-user", "1234567", server.getPort());
Region region = createProxyRegion(cache, REGION_NAME);
// post process for get
assertEquals("value3", region.get("key3"));
assertNull(region.get("key1"));
// post processs for getAll
Map values = region.getAll(keys);
assertEquals(2, values.size());
assertEquals("value2", values.get("key2"));
assertNull(values.get("key1"));
// post process for query
String query = "select * from /AuthRegion";
SelectResults result = region.query(query);
System.out.println("query result: " + result);
assertEquals(5, result.size());
assertTrue(result.contains("value0"));
assertFalse(result.contains("value1"));
assertTrue(result.contains("value2"));
assertTrue(result.contains("value3"));
assertTrue(result.contains("value4"));
Pool pool = PoolManager.find(region);
result = (SelectResults) pool.getQueryService().newQuery(query).execute();
System.out.println("query result: " + result);
assertTrue(result.contains("value0"));
assertFalse(result.contains("value1"));
assertTrue(result.contains("value2"));
assertTrue(result.contains("value3"));
assertTrue(result.contains("value4"));
});
}
use of org.apache.geode.cache.client.ClientCache in project geode by apache.
the class PDXPostProcessorDUnitTest method testQuery.
@Test
public void testQuery() {
client2.invoke(() -> {
ClientCache cache = createClientCache("super-user", "1234567", server.getPort());
Region region = createProxyRegion(cache, REGION_NAME);
// put in a value that's a domain object
region.put("key1", new SimpleClass(1, (byte) 1));
region.put("key2", BYTES);
});
client1.invoke(() -> {
ClientCache cache = createClientCache("super-user", "1234567", server.getPort());
Region region = createProxyRegion(cache, REGION_NAME);
// post process for query
String query = "select * from /AuthRegion";
SelectResults result = region.query(query);
Iterator itr = result.iterator();
while (itr.hasNext()) {
Object obj = itr.next();
if (obj instanceof byte[]) {
assertTrue(Arrays.equals(BYTES, (byte[]) obj));
} else {
assertTrue(obj instanceof SimpleClass);
}
}
});
// this makes sure PostProcessor is getting called
PDXPostProcessor pp = (PDXPostProcessor) SecurityService.getSecurityService().getPostProcessor();
assertEquals(pp.getCount(), 2);
}
use of org.apache.geode.cache.client.ClientCache in project geode by apache.
the class PDXPostProcessorDUnitTest method testRegionGet.
@Test
public void testRegionGet() {
client2.invoke(() -> {
ClientCache cache = createClientCache("super-user", "1234567", server.getPort());
Region region = createProxyRegion(cache, REGION_NAME);
// put in a value that's a domain object
region.put("key1", new SimpleClass(1, (byte) 1));
// put in a byte value
region.put("key2", BYTES);
});
client1.invoke(() -> {
ClientCache cache = createClientCache("super-user", "1234567", server.getPort());
Region region = createProxyRegion(cache, REGION_NAME);
// post process for get the client domain object
Object value = region.get("key1");
assertTrue(value instanceof SimpleClass);
// post process for get the raw byte value
value = region.get("key2");
assertTrue(Arrays.equals(BYTES, (byte[]) value));
});
// this makes sure PostProcessor is getting called
PDXPostProcessor pp = (PDXPostProcessor) SecurityService.getSecurityService().getPostProcessor();
assertEquals(pp.getCount(), 2);
}
use of org.apache.geode.cache.client.ClientCache in project geode by apache.
the class PostProcessorDUnitTest method testPostProcessRegionGet.
@Test
public void testPostProcessRegionGet() {
List<String> keys = new ArrayList<>();
keys.add("key1");
keys.add("key2");
client1.invoke(() -> {
ClientCache cache = createClientCache("super-user", "1234567", server.getPort());
Region region = createProxyRegion(cache, REGION_NAME);
// post process for get
Object value = region.get("key3");
assertEquals("super-user/AuthRegion/key3/value3", value);
// post processs for getAll
Map values = region.getAll(keys);
assertEquals(2, values.size());
assertEquals("super-user/AuthRegion/key1/value1", values.get("key1"));
assertEquals("super-user/AuthRegion/key2/value2", values.get("key2"));
});
}
use of org.apache.geode.cache.client.ClientCache in project geode by apache.
the class PostProcessorDUnitTest method testPostProcessQuery.
@Test
public void testPostProcessQuery() {
client1.invoke(() -> {
ClientCache cache = createClientCache("super-user", "1234567", server.getPort());
Region region = createProxyRegion(cache, REGION_NAME);
// post process for query
String query = "select * from /AuthRegion";
SelectResults result = region.query(query);
assertEquals(5, result.size());
assertTrue(result.contains("super-user/null/null/value0"));
assertTrue(result.contains("super-user/null/null/value1"));
assertTrue(result.contains("super-user/null/null/value2"));
assertTrue(result.contains("super-user/null/null/value3"));
assertTrue(result.contains("super-user/null/null/value4"));
Pool pool = PoolManager.find(region);
result = (SelectResults) pool.getQueryService().newQuery(query).execute();
assertTrue(result.contains("super-user/null/null/value0"));
assertTrue(result.contains("super-user/null/null/value1"));
assertTrue(result.contains("super-user/null/null/value2"));
assertTrue(result.contains("super-user/null/null/value3"));
assertTrue(result.contains("super-user/null/null/value4"));
});
}
Aggregations