use of org.apache.ignite.client.IgniteClient in project ignite by apache.
the class JavaThinCompatibilityTest method testServicesWithCallerContext.
/**
*/
private void testServicesWithCallerContext() {
X.println(">>>> Testing services with caller context");
ServiceCallContext callCtx = ServiceCallContext.builder().put("key", "value").build();
try (IgniteClient client = Ignition.startClient(new ClientConfiguration().setAddresses(ADDR))) {
assertEquals("value", client.services().serviceProxy("ctx_service", CtxServiceInterface.class, callCtx).attribute("key"));
}
}
use of org.apache.ignite.client.IgniteClient in project ignite by apache.
the class JavaThinCompatibilityTest method testServiceDescriptors.
/**
*/
private void testServiceDescriptors() {
X.println(">>>> Testing services descriptors");
try (IgniteClient client = Ignition.startClient(new ClientConfiguration().setAddresses(ADDR))) {
assertEquals(2, client.services().serviceDescriptors().size());
ClientServiceDescriptor svc = client.services().serviceDescriptor("test_service");
assertEquals("test_service", svc.name());
assertEquals(EchoService.class.getName(), svc.serviceClass());
assertEquals(0, svc.totalCount());
assertEquals(1, svc.maxPerNodeCount());
assertNull(svc.cacheName());
assertEquals(grid(0).localNode().id(), svc.originNodeId());
assertEquals(PlatformType.JAVA, svc.platformType());
}
}
use of org.apache.ignite.client.IgniteClient in project ignite by apache.
the class JavaThinCompatibilityTest method testContinuousQueries.
/**
*/
private void testContinuousQueries() throws Exception {
X.println(">>>> Testing continuous queries");
try (IgniteClient client = Ignition.startClient(new ClientConfiguration().setAddresses(ADDR))) {
ClientCache<Object, Object> cache = client.getOrCreateCache("testContinuousQueries");
List<CacheEntryEvent<?, ?>> allEvts = new ArrayList<>();
cache.query(new ContinuousQuery<>().setLocalListener(evts -> evts.forEach(allEvts::add)));
cache.put(0, 0);
cache.put(0, 1);
cache.remove(0);
assertTrue(GridTestUtils.waitForCondition(() -> allEvts.size() == 3, 1_000L));
}
}
use of org.apache.ignite.client.IgniteClient in project ignite by apache.
the class ThinClientPermissionCheckTest method testCacheEntryExpiration.
/**
* Tests that the expiration of a cache entry does not require any special permissions from the user who adds the
* entry.
*/
@Test
public void testCacheEntryExpiration() throws Exception {
CountDownLatch cacheObjExpiredLatch = new CountDownLatch(G.allGrids().size());
for (Ignite ignite : G.allGrids()) {
ignite.events().localListen(evt -> {
if ((evt.type() == EVT_CACHE_OBJECT_EXPIRED && EXPIRATION_TEST_CACHE.equals(((CacheEvent) evt).cacheName())))
cacheObjExpiredLatch.countDown();
return true;
}, EVT_CACHE_OBJECT_EXPIRED);
}
try (IgniteClient client = startClient(CLIENT_PUT)) {
ClientCache<Object, Object> cache = client.cache(EXPIRATION_TEST_CACHE);
cache.put("key", "val");
cacheObjExpiredLatch.await(getTestTimeout(), TimeUnit.MILLISECONDS);
for (Ignite ignite : G.allGrids()) assertNull(ignite.cache(EXPIRATION_TEST_CACHE).get("key"));
}
}
use of org.apache.ignite.client.IgniteClient in project ignite by apache.
the class ThinClientPermissionCheckTest method testAllowedOperationAfterSecurityViolation.
/**
*/
@Test
public void testAllowedOperationAfterSecurityViolation() throws Exception {
try (IgniteClient client = startClient(CLIENT_READ)) {
assertThrowsWithCause(() -> client.cache(CACHE).put("key", "value"), ClientAuthorizationException.class);
assertNull(client.cache(CACHE).get("key"));
}
}
Aggregations