private void testPutTwice(boolean batching, boolean inTran) throws Exception { testPutOperation(batching, inTran); testPutOperation(batching, inTran); }
@BeforeClass public void setUp() { recreateCacheManager(); }
@Test public void testPutSearchablePersistentWithoutBatchingWithoutTran() throws Exception { testPutTwice(false, false); }
public void testPreloadIndexingAfterAddingNewNode() throws Exception { loadCacheEntries(this.<String, Person>caches().get(0)); for (CacheLoader cs: TestingUtil.cachestores(this.<String, Person>caches())) { assert cs.contains(persons[0].getName()) : "Cache misconfigured, maybe cache store not pointing to same place, maybe passivation on...etc"; DummyInMemoryStore dimcs = (DummyInMemoryStore) cs; assert dimcs.stats().get("clear") == 0: "Cache store should not be cleared, purgeOnStartup is false"; assert dimcs.stats().get("write") == 4: "Cache store should have been written to 4 times, but was written to " + dimcs.stats().get("write") + " times"; } // Before adding a node, verify that the query resolves properly executeSimpleQuery(this.<String, Person>caches().get(0)); addNodeCheckingContentsAndQuery(); }
public void testPersistence() throws PersistenceException, ParseException { verifyFullTextHasMatches(0); Country italy = new Country(); italy.countryName = "Italy"; City rome = new City(); rome.name = "Rome"; italy.cities.add(rome); cache.put("IT", italy); assert ! store.contains("IT"); verifyFullTextHasMatches(1); cache.evict("IT"); assert store.contains("IT"); InternalCacheEntry internalCacheEntry = cache.getAdvancedCache().getDataContainer().get("IT"); assert internalCacheEntry==null; verifyFullTextHasMatches(1); Country country = cache.get("IT"); assert country != null; assert "Italy".equals(country.countryName); verifyFullTextHasMatches(1); cache.stop(); assert search.unwrap(SearchIntegrator.class).isStopped(); TestingUtil.killCacheManagers(cm); // Now let's check the entry is not re-indexed during data preloading: recreateCacheManager(); // People should generally use a persistent index; we use RAMDirectory for // test cleanup, so for our configuration it needs now to contain zero // matches: on filesystem it would be exactly one as expected (two when ISPN-1179 was open) verifyFullTextHasMatches(0); }
private void testPutOperation(boolean batching, final boolean inTran) throws Exception { withCacheManager(new CacheManagerCallable(getCacheManager(batching)) { @Override public void call() throws Exception { Cache<Object, Object> c = cm.getCache(); if (inTran) c.getAdvancedCache().getTransactionManager().begin(); c.put("key1", new SEntity(1, "name1", "surname1")); if (inTran) c.getAdvancedCache().getTransactionManager().commit(); assertEquals(searchByName("name1", c).size(), 1, "should be 1, even repeating this"); } }); }
@Override public void call() throws Exception { Cache<Object, Object> c = cm.getCache(); if (inTran) c.getAdvancedCache().getTransactionManager().begin(); c.put("key1", new SEntity(1, "name1", "surname1")); if (inTran) c.getAdvancedCache().getTransactionManager().commit(); assertEquals(searchByName("name1", c).size(), 1, "should be 1, even repeating this"); } });
private List searchByName(String name, Cache c) { SearchManager sm = Search.getSearchManager(c); CacheQuery<?> q = sm.getQuery(SEntity.searchByName(name), SEntity.class); int resultSize = q.getResultSize(); List<?> l = q.list(); assert l.size() == resultSize; return q.list(); }
@Override protected void configureCache(ConfigurationBuilder builder) { super.configureCache(builder); builder.indexing().index(Index.PRIMARY_OWNER) .addProperty("default.directory_provider", "infinispan") .addProperty("default.indexmanager", "org.infinispan.query.indexmanager.InfinispanIndexManager") .addProperty("lucene_version", "LUCENE_CURRENT"); } }
@Test public void testPutSearchablePersistentWithBatchingWithoutTran() throws Exception { testPutTwice(true, false); }
@Test public void testPutSearchablePersistentWithBatchingInTran() throws Exception { testPutTwice(true, true); }