Search in sources :

Example 1 with CachingProvider

use of javax.cache.spi.CachingProvider in project requery by requery.

the class EntityCacheTest method testSerializeGetPut.

@Test
public void testSerializeGetPut() {
    CachingProvider provider = Caching.getCachingProvider();
    CacheManager cacheManager = provider.getCacheManager();
    EntityCache cache = new EntityCacheBuilder(Models.DEFAULT).useReferenceCache(false).useSerializableCache(true).useCacheManager(cacheManager).build();
    Person p = new Person();
    p.setName("Alice");
    p.setUUID(UUID.randomUUID());
    p.setAddress(new Address());
    p.getAddress().setType(AddressType.HOME);
    int id = 100;
    cache.put(Person.class, id, p);
    Person d = cache.get(Person.class, id);
    Assert.assertNotNull(d);
    Assert.assertNotSame(p, d);
    Assert.assertEquals(p.getName(), d.getName());
    Assert.assertEquals(p.getUUID(), d.getUUID());
}
Also used : EntityCache(io.requery.EntityCache) Address(io.requery.test.model.Address) CacheManager(javax.cache.CacheManager) EntityCacheBuilder(io.requery.cache.EntityCacheBuilder) Person(io.requery.test.model.Person) CachingProvider(javax.cache.spi.CachingProvider) Test(org.junit.Test)

Example 2 with CachingProvider

use of javax.cache.spi.CachingProvider in project requery by requery.

the class JPAModelTest method setup.

@Before
public void setup() throws SQLException {
    CommonDataSource dataSource = DatabaseType.getDataSource(new H2());
    EntityModel model = Models.JPA;
    CachingProvider provider = Caching.getCachingProvider();
    CacheManager cacheManager = provider.getCacheManager();
    Configuration configuration = new ConfigurationBuilder(dataSource, model).useDefaultLogging().setEntityCache(new EntityCacheBuilder(model).useReferenceCache(true).useSerializableCache(true).useCacheManager(cacheManager).build()).build();
    data = new EntityDataStore<>(configuration);
    SchemaModifier tables = new SchemaModifier(configuration);
    tables.dropTables();
    TableCreationMode mode = TableCreationMode.CREATE;
    System.out.println(tables.createTablesString(mode));
    tables.createTables(mode);
}
Also used : ConfigurationBuilder(io.requery.sql.ConfigurationBuilder) Configuration(io.requery.sql.Configuration) TableCreationMode(io.requery.sql.TableCreationMode) EntityModel(io.requery.meta.EntityModel) CacheManager(javax.cache.CacheManager) H2(io.requery.sql.platform.H2) EntityCacheBuilder(io.requery.cache.EntityCacheBuilder) CommonDataSource(javax.sql.CommonDataSource) CachingProvider(javax.cache.spi.CachingProvider) SchemaModifier(io.requery.sql.SchemaModifier) Before(org.junit.Before)

Example 3 with CachingProvider

use of javax.cache.spi.CachingProvider in project requery by requery.

the class ParameterizedFunctionalTest method setup.

@Before
public void setup() throws SQLException {
    CommonDataSource dataSource = DatabaseType.getDataSource(platform);
    EntityModel model = Models.DEFAULT;
    CachingProvider provider = Caching.getCachingProvider();
    CacheManager cacheManager = provider.getCacheManager();
    Configuration configuration = new ConfigurationBuilder(dataSource, model).useDefaultLogging().setStatementCacheSize(platform instanceof SQLite ? 0 : 10).setBatchUpdateSize(50).setEntityCache(new EntityCacheBuilder(model).useReferenceCache(true).useSerializableCache(true).useCacheManager(cacheManager).build()).build();
    data = new EntityDataStore<>(configuration);
    SchemaModifier tables = new SchemaModifier(configuration);
    try {
        tables.dropTables();
    } catch (Exception e) {
        // expected if 'drop if exists' not supported (so ignore in that case)
        if (!platform.supportsIfExists()) {
            throw e;
        }
    }
    TableCreationMode mode = TableCreationMode.CREATE;
    System.out.println(tables.createTablesString(mode));
    tables.createTables(mode);
}
Also used : ConfigurationBuilder(io.requery.sql.ConfigurationBuilder) Configuration(io.requery.sql.Configuration) TableCreationMode(io.requery.sql.TableCreationMode) SQLite(io.requery.sql.platform.SQLite) EntityModel(io.requery.meta.EntityModel) CacheManager(javax.cache.CacheManager) EntityCacheBuilder(io.requery.cache.EntityCacheBuilder) CommonDataSource(javax.sql.CommonDataSource) SQLException(java.sql.SQLException) CachingProvider(javax.cache.spi.CachingProvider) SchemaModifier(io.requery.sql.SchemaModifier) Before(org.junit.Before)

Example 4 with CachingProvider

use of javax.cache.spi.CachingProvider in project requery by requery.

the class RxTest method setup.

@Before
public void setup() throws SQLException {
    Platform platform = new HSQL();
    CommonDataSource dataSource = DatabaseType.getDataSource(platform);
    EntityModel model = io.requery.test.model.Models.DEFAULT;
    CachingProvider provider = Caching.getCachingProvider();
    CacheManager cacheManager = provider.getCacheManager();
    Configuration configuration = new ConfigurationBuilder(dataSource, model).useDefaultLogging().setWriteExecutor(Executors.newSingleThreadExecutor()).setEntityCache(new EntityCacheBuilder(model).useReferenceCache(true).useSerializableCache(true).useCacheManager(cacheManager).build()).build();
    SchemaModifier tables = new SchemaModifier(configuration);
    tables.createTables(TableCreationMode.DROP_CREATE);
    data = RxSupport.toReactiveStore(new EntityDataStore<Persistable>(configuration));
}
Also used : ConfigurationBuilder(io.requery.sql.ConfigurationBuilder) Platform(io.requery.sql.Platform) Configuration(io.requery.sql.Configuration) HSQL(io.requery.sql.platform.HSQL) EntityDataStore(io.requery.sql.EntityDataStore) EntityModel(io.requery.meta.EntityModel) CacheManager(javax.cache.CacheManager) EntityCacheBuilder(io.requery.cache.EntityCacheBuilder) CommonDataSource(javax.sql.CommonDataSource) CachingProvider(javax.cache.spi.CachingProvider) SchemaModifier(io.requery.sql.SchemaModifier) Before(org.junit.Before)

Example 5 with CachingProvider

use of javax.cache.spi.CachingProvider in project requery by requery.

the class ReactorTest method setup.

@Before
public void setup() throws SQLException {
    Platform platform = new HSQL();
    CommonDataSource dataSource = DatabaseType.getDataSource(platform);
    EntityModel model = io.requery.test.model.Models.DEFAULT;
    CachingProvider provider = Caching.getCachingProvider();
    CacheManager cacheManager = provider.getCacheManager();
    Configuration configuration = new ConfigurationBuilder(dataSource, model).useDefaultLogging().setWriteExecutor(Executors.newSingleThreadExecutor()).setEntityCache(new EntityCacheBuilder(model).useReferenceCache(true).useSerializableCache(true).useCacheManager(cacheManager).build()).build();
    SchemaModifier tables = new SchemaModifier(configuration);
    tables.createTables(TableCreationMode.DROP_CREATE);
    data = new ReactorEntityStore<>(new EntityDataStore<Persistable>(configuration));
}
Also used : ConfigurationBuilder(io.requery.sql.ConfigurationBuilder) Platform(io.requery.sql.Platform) Configuration(io.requery.sql.Configuration) HSQL(io.requery.sql.platform.HSQL) EntityDataStore(io.requery.sql.EntityDataStore) EntityModel(io.requery.meta.EntityModel) CacheManager(javax.cache.CacheManager) EntityCacheBuilder(io.requery.cache.EntityCacheBuilder) CommonDataSource(javax.sql.CommonDataSource) CachingProvider(javax.cache.spi.CachingProvider) SchemaModifier(io.requery.sql.SchemaModifier) Before(org.junit.Before)

Aggregations

CachingProvider (javax.cache.spi.CachingProvider)66 CacheManager (javax.cache.CacheManager)48 HazelcastServerCachingProvider (com.hazelcast.cache.impl.HazelcastServerCachingProvider)42 Test (org.junit.Test)33 QuickTest (com.hazelcast.test.annotation.QuickTest)28 HazelcastInstance (com.hazelcast.core.HazelcastInstance)24 ParallelTest (com.hazelcast.test.annotation.ParallelTest)24 CacheConfig (com.hazelcast.config.CacheConfig)21 HazelcastClientCachingProvider (com.hazelcast.client.cache.impl.HazelcastClientCachingProvider)18 ClientConfig (com.hazelcast.client.config.ClientConfig)14 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)12 MutableConfiguration (javax.cache.configuration.MutableConfiguration)12 ICache (com.hazelcast.cache.ICache)10 HazelcastClientProxy (com.hazelcast.client.impl.HazelcastClientProxy)10 Cache (javax.cache.Cache)10 HazelcastCachingProvider (com.hazelcast.cache.HazelcastCachingProvider)9 Config (com.hazelcast.config.Config)8 Data (com.hazelcast.nio.serialization.Data)8 Before (org.junit.Before)8 HazelcastCacheManager (com.hazelcast.cache.HazelcastCacheManager)7