use of org.apache.geode.pdx.SimpleClass in project geode by apache.
the class PDXPostProcessorDUnitTest method testGfshCommand.
@Test
public void testGfshCommand() {
// have client2 input some domain data into the region
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(() -> {
GfshShellConnectionRule gfsh = new GfshShellConnectionRule();
gfsh.secureConnectAndVerify(server.getJmxPort(), GfshShellConnectionRule.PortType.jmxManger, "dataUser", "1234567");
// get command
CommandResult result = gfsh.executeAndVerifyCommand("get --key=key1 --region=AuthRegion");
if (pdxPersistent)
assertThat(gfsh.getGfshOutput().contains("org.apache.geode.pdx.internal.PdxInstanceImpl"));
else
assertThat(gfsh.getGfshOutput()).contains("SimpleClass");
result = gfsh.executeAndVerifyCommand("get --key=key2 --region=AuthRegion");
assertTrue(result.getContent().toString().contains("byte[]"));
gfsh.executeAndVerifyCommand("query --query=\"select * from /AuthRegion\"");
gfsh.close();
});
PDXPostProcessor pp = (PDXPostProcessor) SecurityService.getSecurityService().getPostProcessor();
assertEquals(pp.getCount(), 4);
}
use of org.apache.geode.pdx.SimpleClass in project geode by apache.
the class PDXPostProcessorDUnitTest method testRegisterInterest.
@Test
public void testRegisterInterest() {
IgnoredException.addIgnoredException("NoAvailableServersException");
client1.invoke(() -> {
ClientCache cache = createClientCache("super-user", "1234567", server.getPort());
ClientRegionFactory factory = cache.createClientRegionFactory(ClientRegionShortcut.PROXY);
factory.addCacheListener(new CacheListenerAdapter() {
@Override
public void afterUpdate(EntryEvent event) {
Object key = event.getKey();
Object value = ((EntryEventImpl) event).getDeserializedValue();
if (key.equals("key1")) {
assertTrue(value instanceof SimpleClass);
} else if (key.equals("key2")) {
assertTrue(Arrays.equals(BYTES, (byte[]) value));
}
}
});
Region region = factory.create(REGION_NAME);
region.put("key1", "value1");
region.registerInterest("key1");
region.registerInterest("key2");
});
client2.invoke(() -> {
ClientCache cache = createClientCache("dataUser", "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);
});
// wait for events to fire
Awaitility.await().atMost(1, TimeUnit.SECONDS);
PDXPostProcessor pp = (PDXPostProcessor) SecurityService.getSecurityService().getPostProcessor();
assertEquals(pp.getCount(), 2);
}
use of org.apache.geode.pdx.SimpleClass in project geode by apache.
the class WANTestBase method doPutsPDXSerializable.
public static void doPutsPDXSerializable(String regionName, int numPuts) {
Region r = cache.getRegion(Region.SEPARATOR + regionName);
assertNotNull(r);
for (int i = 0; i < numPuts; i++) {
r.put("Key_" + i, new SimpleClass(i, (byte) i));
}
}
Aggregations