/** * @return Cache configuration for test. * @throws Exception In case when failed to create cache configuration. */ protected CacheConfiguration cacheConfiguration() throws Exception { CacheConfiguration cc = defaultCacheConfiguration(); cc.setName(CACHE_NAME); cc.setCacheMode(PARTITIONED); cc.setAtomicityMode(transactional ? TRANSACTIONAL : ATOMIC); cc.setWriteBehindEnabled(false); cc.setStoreKeepBinary(storeKeepBinary()); CacheJdbcPojoStoreFactory<Object, Object> storeFactory = new CacheJdbcPojoStoreFactory<>(); storeFactory.setDialect(new H2Dialect()); storeFactory.setTypes(storeTypes()); storeFactory.setDataSourceFactory(new H2DataSourceFactory()); // H2 DataSource factory. storeFactory.setSqlEscapeAll(sqlEscapeAll()); storeFactory.setParallelLoadCacheMinimumThreshold(parallelLoadThreshold); cc.setCacheStoreFactory(storeFactory); cc.setReadThrough(true); cc.setWriteThrough(true); cc.setLoadPreviousValue(true); return cc; }