use of org.apache.ignite.client.IgniteClient in project ignite by apache.
the class JavaThinCompatibilityTest method testCacheApi.
/**
*/
private void testCacheApi() throws Exception {
X.println(">>>> Testing cache API");
try (IgniteClient client = Ignition.startClient(new ClientConfiguration().setAddresses(ADDR))) {
ClientCache<Object, Object> cache = client.getOrCreateCache("testCacheApi");
cache.put(1, 1);
assertEquals(1, cache.get(1));
Person person = new Person(2, "name");
cache.put(2, person);
assertEquals(person, cache.get(2));
}
}
use of org.apache.ignite.client.IgniteClient in project ignite by apache.
the class WarningOnBigQueryResultsTest method testThinClient.
/**
*/
@Test
public void testThinClient() throws Exception {
try (IgniteClient cli = Ignition.startClient(new ClientConfiguration().setAddresses(THIN_CLI_ADDR))) {
assertEquals(KEYS_PER_NODE * 2, cli.query(new SqlFieldsQueryEx("SELECT * FROM TEST0", true).setSchema("TEST0")).getAll().size());
checkStateAfterQuery0("TEST0");
}
}
use of org.apache.ignite.client.IgniteClient in project ignite by apache.
the class ThinClientPermissionCheckTest method testCacheEntryEviction.
/**
* Tests that the eviction of a cache entry does not require any special permissions from the user who adds the
* entry.
*/
@Test
public void testCacheEntryEviction() throws Exception {
try (IgniteClient client = startClient(CLIENT_PUT)) {
ClientCache<Object, Object> cache = client.cache(EVICTION_TEST_CACHE);
int entrySize = 4 * (1 << 10);
int entriesCnt = 2 * EVICTION_TEST_DATA_REGION_SIZE / entrySize;
for (int i = 0; i < entriesCnt; i++) cache.put(i, new TestObject(entrySize / 4));
for (Ignite ignite : G.allGrids()) {
Set<Integer> insertedKeys = IntStream.range(0, entriesCnt).boxed().collect(Collectors.toSet());
assertTrue(ignite.cache(EVICTION_TEST_CACHE).getAll(insertedKeys).size() < entriesCnt);
}
}
}
use of org.apache.ignite.client.IgniteClient in project ignite by apache.
the class ThinClientSslPermissionCheckTest method testSysOperation.
/**
*/
@Test
public void testSysOperation() throws Exception {
try (IgniteClient sysPrmClnt = startClient(CLIENT_SYS_PERM)) {
sysPrmClnt.createCache(DYNAMIC_CACHE);
assertTrue(sysPrmClnt.cacheNames().contains(DYNAMIC_CACHE));
sysPrmClnt.destroyCache(DYNAMIC_CACHE);
assertFalse(sysPrmClnt.cacheNames().contains(DYNAMIC_CACHE));
}
List<IgniteBiTuple<Consumer<IgniteClient>, String>> ops = Arrays.asList(t(c -> c.createCache(DYNAMIC_CACHE), "createCache"), t(c -> c.destroyCache(CACHE), "destroyCache"));
for (IgniteBiTuple<Consumer<IgniteClient>, String> op : ops) assertThrowsWithCause(() -> runOperation(CLIENT, op), ClientAuthorizationException.class);
}
use of org.apache.ignite.client.IgniteClient in project ignite by apache.
the class BinaryArraySelfTest method testArrayValue.
/**
*/
@Test
public void testArrayValue() {
doTestValue(srvCache, arr -> arr, false, false);
doTestValue(cliCache, arr -> arr, false, false);
doTestValue(srvCache, arr -> arr, true, false);
doTestValue(cliCache, arr -> arr, true, false);
try (IgniteClient thinClient = thinClient()) {
ClientCacheAdapter<Object, Object> c = new ClientCacheAdapter<>(thinClient.getOrCreateCache(DEFAULT_CACHE_NAME));
doTestValue(c, arr -> arr, false, false);
doTestValue(c, arr -> arr, true, false);
}
}
Aggregations