Search in sources :

Example 1 with InfinispanBaseRegion

use of org.infinispan.hibernate.cache.commons.InfinispanBaseRegion in project infinispan by infinispan.

the class EntityRegionImplTest method supportedAccessTypeTest.

@Override
protected void supportedAccessTypeTest(TestRegionFactory regionFactory, Properties properties) {
    InfinispanBaseRegion region = regionFactory.buildEntityRegion("test", accessType);
    assertNotNull(TEST_SESSION_ACCESS.entityAccess(region, accessType));
    regionFactory.getCacheManager().administration().removeCache(CACHE_NAME);
}
Also used : InfinispanBaseRegion(org.infinispan.hibernate.cache.commons.InfinispanBaseRegion)

Example 2 with InfinispanBaseRegion

use of org.infinispan.hibernate.cache.commons.InfinispanBaseRegion in project infinispan by infinispan.

the class QualifierTest method testRegionNamesQualified.

@Test
public void testRegionNamesQualified() {
    TestRegionFactory factory = TestRegionFactoryProvider.INSTANCE.findRegionFactory(sessionFactory().getCache());
    EmbeddedCacheManager cacheManager = factory.getCacheManager();
    for (String cacheName : cacheManager.getCacheNames()) {
        assertTrue(cacheName.startsWith(FOO_BAR));
    }
    // In Hibernate < 5.3 the region factory got qualified names and couldn't use any unqualified form
    if (!TestRegionFactoryProvider.INSTANCE.getRegionFactoryClass().getName().contains(".v51.")) {
        for (InfinispanBaseRegion region : TestSessionAccess.findTestSessionAccess().getAllRegions(sessionFactory())) {
            assertFalse(region.getName().startsWith(FOO_BAR));
        }
    }
}
Also used : InfinispanBaseRegion(org.infinispan.hibernate.cache.commons.InfinispanBaseRegion) TestRegionFactory(org.infinispan.test.hibernate.cache.commons.util.TestRegionFactory) EmbeddedCacheManager(org.infinispan.manager.EmbeddedCacheManager) Test(org.junit.Test)

Example 3 with InfinispanBaseRegion

use of org.infinispan.hibernate.cache.commons.InfinispanBaseRegion in project infinispan by infinispan.

the class ReadOnlyTest method testEmptySecondLevelCacheEntry.

@Test
public void testEmptySecondLevelCacheEntry() {
    sessionFactory().getCache().evictCollectionRegion(Item.class.getName() + ".items");
    Statistics stats = sessionFactory().getStatistics();
    stats.clear();
    InfinispanBaseRegion region = TEST_SESSION_ACCESS.getRegion(sessionFactory(), Item.class.getName() + ".items");
    assertEquals(0, region.getElementCountInMemory());
}
Also used : InfinispanBaseRegion(org.infinispan.hibernate.cache.commons.InfinispanBaseRegion) Statistics(org.hibernate.stat.Statistics) Test(org.junit.Test)

Example 4 with InfinispanBaseRegion

use of org.infinispan.hibernate.cache.commons.InfinispanBaseRegion in project infinispan by infinispan.

the class InfinispanRegionFactoryTestCase method testBuildEntityCollectionRegionOverridesOnly.

@Test
public void testBuildEntityCollectionRegionOverridesOnly() {
    final String address = "com.acme.Address";
    final String personAddressses = "com.acme.Person.addresses";
    AdvancedCache cache;
    Properties p = createProperties();
    p.setProperty("hibernate.cache.infinispan.entity.memory.eviction.type", "MEMORY");
    p.setProperty("hibernate.cache.infinispan.entity.memory.size", "30000");
    p.setProperty("hibernate.cache.infinispan.entity.expiration.wake_up_interval", "3000");
    p.setProperty("hibernate.cache.infinispan.collection.memory.eviction.type", "MEMORY");
    p.setProperty("hibernate.cache.infinispan.collection.memory.size", "35000");
    p.setProperty("hibernate.cache.infinispan.collection.expiration.wake_up_interval", "3500");
    TestRegionFactory factory = createRegionFactory(p);
    try {
        factory.getCacheManager();
        InfinispanBaseRegion region = factory.buildEntityRegion(address, AccessType.TRANSACTIONAL);
        assertNull(factory.getBaseConfiguration(address));
        cache = region.getCache();
        Configuration cacheCfg = cache.getCacheConfiguration();
        assertEquals(EvictionType.COUNT, cacheCfg.memory().evictionType());
        assertEquals(3000, cacheCfg.expiration().wakeUpInterval());
        assertEquals(30000, cacheCfg.memory().maxCount());
        // Max idle value comes from base XML configuration
        assertEquals(100000, cacheCfg.expiration().maxIdle());
        InfinispanBaseRegion collectionRegion = factory.buildCollectionRegion(personAddressses, AccessType.TRANSACTIONAL);
        assertNull(factory.getBaseConfiguration(personAddressses));
        cache = collectionRegion.getCache();
        cacheCfg = cache.getCacheConfiguration();
        assertEquals(EvictionType.COUNT, cacheCfg.memory().evictionType());
        assertEquals(3500, cacheCfg.expiration().wakeUpInterval());
        assertEquals(35000, cacheCfg.memory().size());
        assertEquals(100000, cacheCfg.expiration().maxIdle());
    } finally {
        factory.stop();
    }
}
Also used : InfinispanBaseRegion(org.infinispan.hibernate.cache.commons.InfinispanBaseRegion) Configuration(org.infinispan.configuration.cache.Configuration) TestRegionFactory(org.infinispan.test.hibernate.cache.commons.util.TestRegionFactory) AdvancedCache(org.infinispan.AdvancedCache) InfinispanProperties(org.infinispan.hibernate.cache.spi.InfinispanProperties) Properties(java.util.Properties) Test(org.junit.Test)

Example 5 with InfinispanBaseRegion

use of org.infinispan.hibernate.cache.commons.InfinispanBaseRegion in project infinispan by infinispan.

the class InfinispanRegionFactoryTestCase method testBuildTimestampsRegionWithCacheNameOverride.

@Test
public void testBuildTimestampsRegionWithCacheNameOverride() {
    final String timestamps = "org.hibernate.cache.spi.UpdateTimestampsCache";
    final String myTimestampsCache = "mytimestamps-cache";
    Properties p = createProperties();
    p.setProperty(TIMESTAMPS_CACHE_RESOURCE_PROP, myTimestampsCache);
    TestRegionFactory factory = createRegionFactory(p, m -> {
        ClusteringConfigurationBuilder builder = new ConfigurationBuilder().clustering().cacheMode(CacheMode.LOCAL);
        m.defineConfiguration(myTimestampsCache, builder.build());
    });
    try {
        InfinispanBaseRegion region = factory.buildTimestampsRegion(timestamps);
        assertTrue(isDefinedCache(factory, timestamps));
        // default timestamps cache is async replicated
        assertEquals(CacheMode.LOCAL, region.getCache().getCacheConfiguration().clustering().cacheMode());
    } finally {
        factory.stop();
    }
}
Also used : ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) ClusteringConfigurationBuilder(org.infinispan.configuration.cache.ClusteringConfigurationBuilder) InfinispanBaseRegion(org.infinispan.hibernate.cache.commons.InfinispanBaseRegion) ClusteringConfigurationBuilder(org.infinispan.configuration.cache.ClusteringConfigurationBuilder) TestRegionFactory(org.infinispan.test.hibernate.cache.commons.util.TestRegionFactory) InfinispanProperties(org.infinispan.hibernate.cache.spi.InfinispanProperties) Properties(java.util.Properties) Test(org.junit.Test)

Aggregations

InfinispanBaseRegion (org.infinispan.hibernate.cache.commons.InfinispanBaseRegion)33 Test (org.junit.Test)22 TestRegionFactory (org.infinispan.test.hibernate.cache.commons.util.TestRegionFactory)17 AdvancedCache (org.infinispan.AdvancedCache)16 Properties (java.util.Properties)15 InfinispanProperties (org.infinispan.hibernate.cache.spi.InfinispanProperties)12 Configuration (org.infinispan.configuration.cache.Configuration)8 Session (org.hibernate.Session)5 List (java.util.List)4 SessionFactory (org.hibernate.SessionFactory)4 StandardServiceRegistryBuilder (org.hibernate.boot.registry.StandardServiceRegistryBuilder)4 RegionFactory (org.hibernate.cache.spi.RegionFactory)4 AccessType (org.hibernate.cache.spi.access.AccessType)4 TestSessionAccess (org.infinispan.test.hibernate.cache.commons.util.TestSessionAccess)4 ArrayList (java.util.ArrayList)3 CountDownLatch (java.util.concurrent.CountDownLatch)3 Collectors (java.util.stream.Collectors)3 Transaction (org.hibernate.Transaction)3 Connection (java.sql.Connection)2 SQLException (java.sql.SQLException)2