@Override public void run() throws Exception { assertEquals(0, cache.size()); GridTestUtils.assertThrowsAnyCause(log, new Callable<Object>() { @Override public Object call() throws Exception { return cache.getAndPutIfAbsent(key1, badValue); } }, IgniteCheckedException.class, ERR_MSG); assertEquals(0, cache.size()); } });
@Override public void run() throws Exception { GridTestUtils.assertThrowsAnyCause(log, new Callable<Object>() { @Override public Object call() throws Exception { return cache.invoke(key1, new TestEntryProcessor(badValue)); } }, IgniteCheckedException.class, ERR_MSG); assertEquals(0, cache.size()); } });
@Override public void run() throws Exception { GridTestUtils.assertThrowsAnyCause(log, new Callable<Object>() { @Override public Object call() throws Exception { cache.getAndPut(key1, badValue); return null; } }, IgniteCheckedException.class, ERR_MSG); assertEquals(0, cache.size()); } });
@Override public void run() throws Exception { cache.put(key1, okValue); GridTestUtils.assertThrowsAnyCause(log, new Callable<Object>() { @Override public Object call() throws Exception { return cache.getAndReplace(key1, badValue); } }, IgniteCheckedException.class, ERR_MSG); assertEquals(1, cache.size()); assertEquals(okValue, cache.get(key1)); } });
/** * @param cache Cache instance. * @param cacheSkipStore Cache skip store projection. * @throws Exception If failed. */ private void checkEmpty(IgniteCache<String, Integer> cache, IgniteCache<String, Integer> cacheSkipStore) throws Exception { assertTrue(cache.size(ALL) == 0); assertTrue(cacheSkipStore.size(ALL) == 0); assertTrue(storeStgy.getStoreSize() == 0); }
/** * Check that there's nothing in cache. */ protected void assertCacheEmpty() { assertEquals(0, cache().size(CachePeekMode.ALL)); }
/** * @param cache Cache instance. * @param cacheSkipStore Cache skip store projection. * @throws Exception If failed. */ private void checkEmpty(IgniteCache<String, Integer> cache, IgniteCache<String, Integer> cacheSkipStore) throws Exception { assertTrue(cache.size(ALL) == 0); assertTrue(cacheSkipStore.size(ALL) == 0); assertTrue(storeStgy.getStoreSize() == 0); }
/** */ private void verifyCache(IgniteCache cache, BiFunction<String, Integer, String> generatingFunc) { int size = cache.size(CachePeekMode.PRIMARY); String cacheName = cache.getName(); for (int i = 0; i < size; i++) { String value = (String) cache.get(i); assertEquals(generatingFunc.apply(cacheName, i), value); } } }
/** * Do a {@code SELECT COUNT(*)} query to check index state correctness. * @param expSize Expected number of items in table. */ private void assertSize(long expSize) throws SQLException { assertEquals(expSize, cache().size()); try (Statement stmt = conn.createStatement()) { try (ResultSet rs = stmt.executeQuery("SELECT COUNT(*) from Person")) { assertEquals(expSize, getSingleValue(rs)); } } }
/** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { super.beforeTest(); // Clean up all caches. for (int i = 0; i < GRID_CNT; i++) { IgniteCache<Object, Object> c = grid(i).cache(DEFAULT_CACHE_NAME); assertEquals(0, c.size()); } }
/** * Do a {@code SELECT COUNT(*)} query to check index state correctness. * @param expSize Expected number of items in table. */ private void assertSize(long expSize) { assertEquals(expSize, cache().size()); assertEquals(expSize, cache().query(new SqlFieldsQuery("SELECT COUNT(*) from \"ValueClass\"")) .getAll().get(0).get(0)); }
/** * Check that data was loaded correctly. */ protected void checkCacheLoad() { IgniteCache<Object, Object> c1 = grid().cache(CACHE_NAME); c1.loadCache(null); assertEquals(ORGANIZATION_CNT + PERSON_CNT, c1.size()); }
@Override public void run() throws Exception { cache.put(key1, okValue); cache.put(key2, okValue); cache.invokeAll(F.asMap( key1, new TestEntryProcessor(null), key2, new TestEntryProcessor(null))); assertEquals(0, cache.size()); } });
/** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { IgniteCache<String, Integer> cache = jcache(); assertEquals(0, cache.localSize()); assertEquals(0, cache.size()); super.beforeTest(); assertEquals(0, cache.localSize()); assertEquals(0, cache.size()); dfltIgnite = grid(0); }
/** * @param caches Cache names to invoke a query against to. * @param node Ignite node. */ private void checkPersons(String[] caches, Ignite node) { for (String cacheName : caches) { IgniteCache<Object, Object> cache = node.cache(cacheName); for (int i = 0; i < entriesCount(); i++) assertEquals(new Person("" + i, cacheName), cache.get(i)); assertEquals(entriesCount(), cache.size()); } }
@Override public boolean applyx() throws IgniteCheckedException { jcache(fi).removeAll(); if (jcache(fi).size(CachePeekMode.ALL) > 0) { for (Cache.Entry<String, ?> k : jcache(fi).localEntries()) jcache(fi).remove(k.getKey()); } return jcache(fi).localSize(CachePeekMode.ALL) == 0; } },
/** {@inheritDoc} */ @Override protected void afterTest() throws Exception { TestIndexingSpi.forceFail(false); Transaction tx = jcache().unwrap(Ignite.class).transactions().tx(); if (tx != null) { tx.close(); fail("Cache transaction remained after test completion: " + tx); } for (int key = 0; key <= lastKey; key++) grid(0).cache(DEFAULT_CACHE_NAME).remove(key); assertEquals(0, jcache(0).size(CachePeekMode.ALL)); }
/** {@inheritDoc} */ @SuppressWarnings({"SizeReplaceableByIsEmpty"}) @Override protected void beforeTest() throws Exception { MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.NEAR_CACHE); for (int i = 0; i < GRID_CNT; i++) { assert near(grid(i)).size() == 0 : "Near cache size is not zero for grid: " + i; assert dht(grid(i)).size() == 0 : "DHT cache size is not zero for grid: " + i; assert near(grid(i)).localSize() == 0 : "Near cache is not empty for grid: " + i; assert dht(grid(i)).isEmpty() : "DHT cache is not empty for grid: " + i; } }
/** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { super.beforeTest(); if (testsCfg.awaitPartitionMapExchange()) awaitPartitionMapExchange(); assert jcache().unwrap(Ignite.class).transactions().tx() == null; assertEquals(0, jcache().localSize()); assertEquals(0, jcache().size()); }
/** {@inheritDoc} */ @Override protected void afterTest() throws Exception { store.reset(); jcache().removeAll(); assertEquals("DHT entries: " + dht().entrySet(), 0, dht().size()); assertEquals("Near entries: " + near().entrySet(), 0, near().size()); assertEquals(0, jcache().size()); }