Return-Path: X-Original-To: apmail-ignite-commits-archive@minotaur.apache.org Delivered-To: apmail-ignite-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D66F4185D4 for ; Wed, 8 Jul 2015 14:53:19 +0000 (UTC) Received: (qmail 23901 invoked by uid 500); 8 Jul 2015 14:53:19 -0000 Delivered-To: apmail-ignite-commits-archive@ignite.apache.org Received: (qmail 23868 invoked by uid 500); 8 Jul 2015 14:53:19 -0000 Mailing-List: contact commits-help@ignite.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ignite.incubator.apache.org Delivered-To: mailing list commits@ignite.incubator.apache.org Received: (qmail 23859 invoked by uid 99); 8 Jul 2015 14:53:19 -0000 Received: from Unknown (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 08 Jul 2015 14:53:19 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 55D1D181A31 for ; Wed, 8 Jul 2015 14:53:19 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.791 X-Spam-Level: * X-Spam-Status: No, score=1.791 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, T_RP_MATCHES_RCVD=-0.01, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-eu-west.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id PRbEE2pZzX7X for ; Wed, 8 Jul 2015 14:53:07 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-eu-west.apache.org (ASF Mail Server at mx1-eu-west.apache.org) with SMTP id 7826620F19 for ; Wed, 8 Jul 2015 14:53:06 +0000 (UTC) Received: (qmail 23227 invoked by uid 99); 8 Jul 2015 14:53:05 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 08 Jul 2015 14:53:05 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id A209AE097A; Wed, 8 Jul 2015 14:53:05 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: sboikov@apache.org To: commits@ignite.incubator.apache.org Date: Wed, 08 Jul 2015 14:53:47 -0000 Message-Id: In-Reply-To: <744a6cef7cb542d98d0dcd1c6e3c351f@git.apache.org> References: <744a6cef7cb542d98d0dcd1c6e3c351f@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [46/50] incubator-ignite git commit: #ignite-1101: Add test for cache future runtime exception. #ignite-1101: Add test for cache future runtime exception. Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/94a42a48 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/94a42a48 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/94a42a48 Branch: refs/heads/ignite-929 Commit: 94a42a48530998da9895e217c99eec69db71d8c9 Parents: 44b52b4 Author: ivasilinets Authored: Wed Jul 8 14:45:49 2015 +0300 Committer: ivasilinets Committed: Wed Jul 8 14:45:49 2015 +0300 ---------------------------------------------------------------------- .../cache/CacheFutureExceptionSelfTest.java | 121 ++++--------------- 1 file changed, 26 insertions(+), 95 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/94a42a48/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheFutureExceptionSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheFutureExceptionSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheFutureExceptionSelfTest.java index 27bfe17..34d2daa 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheFutureExceptionSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheFutureExceptionSelfTest.java @@ -19,16 +19,11 @@ package org.apache.ignite.internal.processors.cache; import org.apache.ignite.*; import org.apache.ignite.configuration.*; -import org.apache.ignite.internal.util.*; -import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.lang.*; -import org.apache.ignite.spi.discovery.tcp.*; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*; import org.apache.ignite.testframework.junits.common.*; import javax.cache.*; import java.io.*; -import java.util.*; import java.util.concurrent.*; import static java.util.concurrent.TimeUnit.*; @@ -39,9 +34,11 @@ import static java.util.concurrent.TimeUnit.*; public class CacheFutureExceptionSelfTest extends GridCommonAbstractTest { /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { - IgniteConfiguration cfg = StartNode.createConfiguration(); + IgniteConfiguration cfg = new IgniteConfiguration(); + cfg.setGridName(gridName); - cfg.setClientMode(true); + if (gridName.equals(getTestGridName(1))) + cfg.setClientMode(true); return cfg; } @@ -50,68 +47,39 @@ public class CacheFutureExceptionSelfTest extends GridCommonAbstractTest { * @throws Exception If failed. */ public void testAsyncCacheFuture() throws Exception { - final CountDownLatch readyLatch = new CountDownLatch(1); + Ignite srv = startGrid(0); - GridJavaProcess node1 = null; + IgniteCache cache = srv.getOrCreateCache("CACHE"); + cache.put("key", new NotSerializableClass()); - Collection jvmArgs = Arrays.asList("-ea", "-DIGNITE_QUIET=false"); + Ignite client = startGrid(1); - try { - node1 = GridJavaProcess.exec( - StartNode.class.getName(), null, - log, - new CI1() { - @Override public void apply(String s) { - info("Server node1: " + s); + IgniteCache asyncCache = client.cache("CACHE").withAsync(); - if (s.contains("Topology snapshot")) - readyLatch.countDown(); - } - }, - null, - jvmArgs, - null - ); + System.setProperty("FAIL", "true"); - assertTrue(readyLatch.await(60, SECONDS)); + asyncCache.get("key"); - Ignite client = startGrid(0); + final CountDownLatch futLatch = new CountDownLatch(1); - IgniteCache cache = client.getOrCreateCache("CACHE"); + asyncCache.future().listen(new IgniteInClosure>() { + @Override public void apply(IgniteFuture fut) { + assertTrue(fut.isDone()); - cache.put("key", new NotSerializableClass()); + try { + fut.get(); - System.setProperty("FAIL", "true"); - - IgniteCache asyncCache = cache.withAsync(); - - asyncCache.get("key"); - - final CountDownLatch futLatch = new CountDownLatch(1); - - asyncCache.future().listen(new IgniteInClosure>() { - @Override public void apply(IgniteFuture fut) { - assertTrue(fut.isDone()); - - try { - fut.get(); - - fail(); - } - catch (CacheException e) { - log.info("Expected error: " + e); + fail(); + } + catch (CacheException e) { + log.info("Expected error: " + e); - futLatch.countDown(); - } + futLatch.countDown(); } - }); + } + }); - assertTrue(futLatch.await(60, SECONDS)); - } - finally { - if (node1 != null) - node1.killProcess(); - } + assertTrue(futLatch.await(60, SECONDS)); } /** @@ -131,41 +99,4 @@ public class CacheFutureExceptionSelfTest extends GridCommonAbstractTest { in.readObject(); } } - - /** - * Test class. - */ - public static class StartNode { - /** - * @return Configuration. - */ - public static IgniteConfiguration createConfiguration() { - IgniteConfiguration cfg = new IgniteConfiguration(); - - cfg.setPeerClassLoadingEnabled(true); - - cfg.setLocalHost("127.0.0.1"); - - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinderCleanFrequency(1000); - - TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder(); - - ipFinder.setAddresses(Collections.singletonList("127.0.0.1:47500..47509")); - - disco.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(disco); - - return cfg; - } - - /** - * @param args Main parameters. - */ - public static void main(String[] args) { - Ignition.start(createConfiguration()); - } - } -} \ No newline at end of file +} \ No newline at end of file