use of org.apache.ignite.configuration.ClientConfiguration in project ignite by apache.
the class JavaThinCompatibilityTest method testServicesWithCallerContextThrows.
/**
*/
private void testServicesWithCallerContextThrows() {
X.println(">>>> Testing services with caller context throws");
try (IgniteClient client = Ignition.startClient(new ClientConfiguration().setAddresses(ADDR))) {
ServiceCallContext callCtx = ServiceCallContext.builder().put("key", "value").build();
EchoServiceInterface svc = client.services().serviceProxy("test_service", EchoServiceInterface.class, callCtx);
Throwable err = assertThrowsWithCause(() -> svc.echo(1), ClientFeatureNotSupportedByServerException.class);
assertEquals("Feature " + SERVICE_INVOKE_CALLCTX.name() + " is not supported by the server", err.getMessage());
}
}
use of org.apache.ignite.configuration.ClientConfiguration 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.configuration.ClientConfiguration 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.configuration.ClientConfiguration 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.configuration.ClientConfiguration in project ignite by apache.
the class FunctionalQueryTest method testSqlParameterValidation.
/**
* Tests {@link SqlFieldsQuery} parameter validation.
*/
@Test
public void testSqlParameterValidation() throws Exception {
try (Ignite ignored = Ignition.start(Config.getServerConfiguration());
IgniteClient client = Ignition.startClient(new ClientConfiguration().setAddresses(Config.SERVER))) {
// Set fields with reflection to bypass client-side validation and verify server-side check.
SqlFieldsQuery qry = new SqlFieldsQuery("SELECT * FROM Person");
Field updateBatchSize = SqlFieldsQuery.class.getDeclaredField("updateBatchSize");
updateBatchSize.setAccessible(true);
updateBatchSize.setInt(qry, -1);
GridTestUtils.assertThrowsAnyCause(null, () -> client.query(qry).getAll(), ClientException.class, "updateBatchSize cannot be lower than 1");
Field parts = SqlFieldsQuery.class.getDeclaredField("parts");
parts.setAccessible(true);
parts.set(qry, new int[] { -1 });
qry.setUpdateBatchSize(2);
GridTestUtils.assertThrowsAnyCause(null, () -> client.query(qry).getAll(), ClientException.class, "Illegal partition");
}
}
Aggregations