Search in sources :

Example 1 with PersonBinarylizable

use of org.apache.ignite.client.PersonBinarylizable in project ignite by apache.

the class CacheAsyncTest method testPutAsyncThrowsExceptionOnFailedSerialization.

/**
 * Tests that request encode errors are handled correctly.
 */
@Test
public void testPutAsyncThrowsExceptionOnFailedSerialization() {
    ClientCache<Integer, PersonBinarylizable> cache = client.createCache(TMP_CACHE_NAME);
    IgniteClientFuture<Void> fut = cache.putAsync(1, new PersonBinarylizable("1", true, false, false));
    GridTestUtils.assertThrowsAnyCause(null, fut::get, BinaryObjectException.class, "Failed to serialize object [typeName=org.apache.ignite.client.PersonBinarylizable]");
}
Also used : PersonBinarylizable(org.apache.ignite.client.PersonBinarylizable) Test(org.junit.Test)

Example 2 with PersonBinarylizable

use of org.apache.ignite.client.PersonBinarylizable in project ignite by apache.

the class CacheAsyncTest method testGetAsyncThrowsExceptionOnFailedDeserialization.

/**
 * Tests that response decode errors are handled correctly.
 */
@Test
public void testGetAsyncThrowsExceptionOnFailedDeserialization() throws Exception {
    ClientCache<Integer, PersonBinarylizable> cache = client.createCache(TMP_CACHE_NAME);
    cache.put(1, new PersonBinarylizable("1", false, true, false));
    Throwable t = cache.getAsync(1).handle((res, err) -> err).toCompletableFuture().get();
    assertTrue(t.getMessage().contains("Failed to deserialize object"));
    assertTrue(X.hasCause(t, "Failed to deserialize object", ClientException.class));
    assertTrue(X.hasCause(t, "_read_", ArithmeticException.class));
}
Also used : ClientException(org.apache.ignite.client.ClientException) PersonBinarylizable(org.apache.ignite.client.PersonBinarylizable) Test(org.junit.Test)

Example 3 with PersonBinarylizable

use of org.apache.ignite.client.PersonBinarylizable in project ignite by apache.

the class IgniteCacheContinuousQueryClientTest method testFailedSerializationAfterNodeLeaves.

/**
 * Checks that deserialization error after client node leaves does not fail server node.
 */
@Test
public void testFailedSerializationAfterNodeLeaves() throws Exception {
    startGrids(1);
    final int CLIENT_ID = 1;
    Ignite clientNode = startClientGrid(CLIENT_ID);
    IgniteCache<Integer, PersonBinarylizable> cache = clientNode.cache(DEFAULT_CACHE_NAME);
    PersonBinarylizable bin = new PersonBinarylizable("1", false, true, true);
    cache.query(new ScanQuery<>((k, v) -> !v.equals(bin)));
    stopGrid(1);
    Thread.sleep(1100);
    assertNotNull(grid(0).cache(DEFAULT_CACHE_NAME));
    assertFalse(failure.get());
    stopGrid(0);
}
Also used : CacheAtomicityMode(org.apache.ignite.cache.CacheAtomicityMode) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) IgniteLogger(org.apache.ignite.IgniteLogger) AbstractFailureHandler(org.apache.ignite.failure.AbstractFailureHandler) FailureContext(org.apache.ignite.failure.FailureContext) GridAbsPredicate(org.apache.ignite.internal.util.lang.GridAbsPredicate) CacheEntryUpdatedListener(javax.cache.event.CacheEntryUpdatedListener) PARTITIONED(org.apache.ignite.cache.CacheMode.PARTITIONED) LoggerResource(org.apache.ignite.resources.LoggerResource) IgniteClientDisconnectedException(org.apache.ignite.IgniteClientDisconnectedException) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) IgniteOutClosure(org.apache.ignite.lang.IgniteOutClosure) Test(org.junit.Test) Ignite(org.apache.ignite.Ignite) ContinuousQuery(org.apache.ignite.cache.query.ContinuousQuery) FULL_SYNC(org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC) IgniteCache(org.apache.ignite.IgniteCache) GridTestUtils(org.apache.ignite.testframework.GridTestUtils) CountDownLatch(java.util.concurrent.CountDownLatch) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) CacheEntryEvent(javax.cache.event.CacheEntryEvent) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) PersonBinarylizable(org.apache.ignite.client.PersonBinarylizable) QueryCursor(org.apache.ignite.cache.query.QueryCursor) ATOMIC(org.apache.ignite.cache.CacheAtomicityMode.ATOMIC) ScanQuery(org.apache.ignite.cache.query.ScanQuery) SECONDS(java.util.concurrent.TimeUnit.SECONDS) Ignite(org.apache.ignite.Ignite) PersonBinarylizable(org.apache.ignite.client.PersonBinarylizable) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Aggregations

PersonBinarylizable (org.apache.ignite.client.PersonBinarylizable)3 Test (org.junit.Test)3 CountDownLatch (java.util.concurrent.CountDownLatch)1 SECONDS (java.util.concurrent.TimeUnit.SECONDS)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 CacheEntryEvent (javax.cache.event.CacheEntryEvent)1 CacheEntryUpdatedListener (javax.cache.event.CacheEntryUpdatedListener)1 Ignite (org.apache.ignite.Ignite)1 IgniteCache (org.apache.ignite.IgniteCache)1 IgniteClientDisconnectedException (org.apache.ignite.IgniteClientDisconnectedException)1 IgniteLogger (org.apache.ignite.IgniteLogger)1 CacheAtomicityMode (org.apache.ignite.cache.CacheAtomicityMode)1 ATOMIC (org.apache.ignite.cache.CacheAtomicityMode.ATOMIC)1 PARTITIONED (org.apache.ignite.cache.CacheMode.PARTITIONED)1 FULL_SYNC (org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC)1 ContinuousQuery (org.apache.ignite.cache.query.ContinuousQuery)1 QueryCursor (org.apache.ignite.cache.query.QueryCursor)1 ScanQuery (org.apache.ignite.cache.query.ScanQuery)1 ClientException (org.apache.ignite.client.ClientException)1 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)1