Fixed test.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/8389a7a6 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/8389a7a6 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/8389a7a6 Branch: refs/heads/ignite-1093-2 Commit: 8389a7a6f4cebf722c74a163ebdc80b373f42d79 Parents: b295bc5 Author: sboikov <[email protected]> Authored: Wed Sep 9 09:57:47 2015 +0300 Committer: sboikov <[email protected]> Committed: Wed Sep 9 09:57:47 2015 +0300 ---------------------------------------------------------------------- .../processors/cache/GridCacheStopSelfTest.java | 49 ++++++++++---------- 1 file changed, 24 insertions(+), 25 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/8389a7a6/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheStopSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheStopSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheStopSelfTest.java index 6054fbc..59c899d 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheStopSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheStopSelfTest.java @@ -21,8 +21,9 @@ import java.util.ArrayList; import java.util.Collection; import java.util.concurrent.Callable; import java.util.concurrent.CountDownLatch; +import javax.cache.CacheException; import org.apache.ignite.IgniteCache; -import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.IgniteException; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteInternalFuture; @@ -43,12 +44,11 @@ import static org.apache.ignite.cache.CacheMode.REPLICATED; public class GridCacheStopSelfTest extends GridCommonAbstractTest { /** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { - fail("https://issues.apache.org/jira/browse/IGNITE-257"); + fail("https://issues.apache.org/jira/browse/IGNITE-1393"); } /** */ - private static final String EXPECTED_MSG = "Grid is in invalid state to perform this operation. " + - "It either not started yet or has already being or have stopped"; + private static final String EXPECTED_MSG = "Cache has been closed or destroyed"; /** */ private boolean atomic; @@ -153,23 +153,31 @@ public class GridCacheStopSelfTest extends GridCommonAbstractTest { putFuts.add(GridTestUtils.runAsync(new Callable<Void>() { @Override public Void call() throws Exception { - if (startTx) { - try (Transaction tx = grid(0).transactions().txStart()) { - cache.put(key, key); + try { + if (startTx) { + try (Transaction tx = grid(0).transactions().txStart()) { + cache.put(key, key); + + readyLatch.countDown(); + + stopLatch.await(); + tx.commit(); + } + } + else { readyLatch.countDown(); stopLatch.await(); - tx.commit(); + cache.put(key, key); } } - else { - readyLatch.countDown(); - - stopLatch.await(); - - cache.put(key, key); + catch (CacheException | IgniteException e) { + log.info("Ignore error: " + e); + } + catch (IllegalStateException e) { + assertTrue(e.getMessage().startsWith(EXPECTED_MSG)); } return null; @@ -183,17 +191,8 @@ public class GridCacheStopSelfTest extends GridCommonAbstractTest { stopGrid(0); - for (IgniteInternalFuture<?> fut : putFuts) { - try { - fut.get(); - } - catch (IgniteCheckedException e) { - if (!e.getMessage().startsWith(EXPECTED_MSG)) - e.printStackTrace(); - - assertTrue("Unexpected error message: " + e.getMessage(), e.getMessage().startsWith(EXPECTED_MSG)); - } - } + for (IgniteInternalFuture<?> fut : putFuts) + fut.get(); try { cache.put(1, 1);
