Search in sources :

Example 66 with IgniteClient

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));
    }
}
Also used : IgniteClient(org.apache.ignite.client.IgniteClient) BinaryObject(org.apache.ignite.binary.BinaryObject) Person(org.apache.ignite.client.Person) ClientConfiguration(org.apache.ignite.configuration.ClientConfiguration) ThinClientConfiguration(org.apache.ignite.configuration.ThinClientConfiguration)

Example 67 with IgniteClient

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");
    }
}
Also used : IgniteClient(org.apache.ignite.client.IgniteClient) SqlFieldsQueryEx(org.apache.ignite.internal.processors.cache.query.SqlFieldsQueryEx) ClientConfiguration(org.apache.ignite.configuration.ClientConfiguration) Test(org.junit.Test)

Example 68 with IgniteClient

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);
        }
    }
}
Also used : IgniteClient(org.apache.ignite.client.IgniteClient) TestObject(org.apache.ignite.internal.processors.cache.eviction.paged.TestObject) TestObject(org.apache.ignite.internal.processors.cache.eviction.paged.TestObject) Ignite(org.apache.ignite.Ignite) AbstractSecurityTest(org.apache.ignite.internal.processors.security.AbstractSecurityTest) Test(org.junit.Test)

Example 69 with IgniteClient

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);
}
Also used : Arrays(java.util.Arrays) CACHE_PUT(org.apache.ignite.plugin.security.SecurityPermission.CACHE_PUT) RunWith(org.junit.runner.RunWith) SslMode(org.apache.ignite.client.SslMode) IgniteEx(org.apache.ignite.internal.IgniteEx) CACHE_READ(org.apache.ignite.plugin.security.SecurityPermission.CACHE_READ) AbstractSecurityTest(org.apache.ignite.internal.processors.security.AbstractSecurityTest) CACHE_CREATE(org.apache.ignite.plugin.security.SecurityPermission.CACHE_CREATE) Config(org.apache.ignite.client.Config) IgniteClient(org.apache.ignite.client.IgniteClient) Collections.singletonMap(java.util.Collections.singletonMap) ClientAuthorizationException(org.apache.ignite.client.ClientAuthorizationException) G(org.apache.ignite.internal.util.typedef.G) ImmutableSet(com.google.common.collect.ImmutableSet) GridTestUtils.assertThrowsWithCause(org.apache.ignite.testframework.GridTestUtils.assertThrowsWithCause) SecurityPermissionSetBuilder(org.apache.ignite.plugin.security.SecurityPermissionSetBuilder) Collection(java.util.Collection) IgniteException(org.apache.ignite.IgniteException) TASK_EXECUTE(org.apache.ignite.plugin.security.SecurityPermission.TASK_EXECUTE) Test(org.junit.Test) JUnit4(org.junit.runners.JUnit4) CACHE_DESTROY(org.apache.ignite.plugin.security.SecurityPermission.CACHE_DESTROY) IgniteBiTuple(org.apache.ignite.lang.IgniteBiTuple) GridTestUtils(org.apache.ignite.testframework.GridTestUtils) Consumer(java.util.function.Consumer) List(java.util.List) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) Ignition(org.apache.ignite.Ignition) ClientConfiguration(org.apache.ignite.configuration.ClientConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) CACHE_REMOVE(org.apache.ignite.plugin.security.SecurityPermission.CACHE_REMOVE) TestSecurityData(org.apache.ignite.internal.processors.security.impl.TestSecurityData) TestCertificateSecurityPluginProvider(org.apache.ignite.internal.processors.security.impl.TestCertificateSecurityPluginProvider) Collections(java.util.Collections) GridFunc.t(org.apache.ignite.internal.util.lang.GridFunc.t) ClientConnectorConfiguration(org.apache.ignite.configuration.ClientConnectorConfiguration) ClientAuthorizationException(org.apache.ignite.client.ClientAuthorizationException) IgniteClient(org.apache.ignite.client.IgniteClient) Consumer(java.util.function.Consumer) IgniteBiTuple(org.apache.ignite.lang.IgniteBiTuple) AbstractSecurityTest(org.apache.ignite.internal.processors.security.AbstractSecurityTest) Test(org.junit.Test)

Example 70 with IgniteClient

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);
    }
}
Also used : IgniteClient(org.apache.ignite.client.IgniteClient) BinaryObject(org.apache.ignite.binary.BinaryObject) Test(org.junit.Test)

Aggregations

IgniteClient (org.apache.ignite.client.IgniteClient)106 Test (org.junit.Test)76 ClientConfiguration (org.apache.ignite.configuration.ClientConfiguration)43 ThinClientConfiguration (org.apache.ignite.configuration.ThinClientConfiguration)26 UUID (java.util.UUID)21 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)15 Ignite (org.apache.ignite.Ignite)14 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)14 HashSet (java.util.HashSet)13 T2 (org.apache.ignite.internal.util.typedef.T2)13 Set (java.util.Set)12 CountDownLatch (java.util.concurrent.CountDownLatch)12 ContinuousQuery (org.apache.ignite.cache.query.ContinuousQuery)12 List (java.util.List)10 BinaryObject (org.apache.ignite.binary.BinaryObject)10 GridTestUtils (org.apache.ignite.testframework.GridTestUtils)10 GridTestUtils.assertThrowsWithCause (org.apache.ignite.testframework.GridTestUtils.assertThrowsWithCause)10 Map (java.util.Map)9 Duration (javax.cache.expiry.Duration)9 ClientCacheConfiguration (org.apache.ignite.client.ClientCacheConfiguration)9