/** * Test method for {@link * org.infinispan.spring.support.embedded.InfinispanNamedEmbeddedCacheFactoryBean#getObjectType()} * . * * @throws Exception */ @Test public final void infinispanNamedEmbeddedCacheFactoryBeanShouldReportTheMostDerivedObjectType() throws Exception { final InfinispanNamedEmbeddedCacheFactoryBean<Object, Object> objectUnderTest = new InfinispanNamedEmbeddedCacheFactoryBean<Object, Object>(); objectUnderTest.setInfinispanEmbeddedCacheManager(DEFAULT_CACHE_MANAGER); objectUnderTest.setBeanName("test.bean.Name"); objectUnderTest.afterPropertiesSet(); assertEquals( "getObjectType() should have returned the most derived class of the actual Cache " + "implementation returned from getObject(). However, it didn't.", objectUnderTest.getObject().getClass(), objectUnderTest.getObjectType()); objectUnderTest.destroy(); }
/** * Test method for {@link * org.infinispan.spring.support.embedded.InfinispanNamedEmbeddedCacheFactoryBean#getObject()} . * * @throws Exception */ @Test public final void infinispanNamedEmbeddedCacheFactoryBeanShouldProduceANonNullInfinispanCache() throws Exception { final String cacheName = "test.cache.Name"; final String beanName = "test.bean.Name"; final InfinispanNamedEmbeddedCacheFactoryBean<Object, Object> objectUnderTest = new InfinispanNamedEmbeddedCacheFactoryBean<Object, Object>(); objectUnderTest.setInfinispanEmbeddedCacheManager(DEFAULT_CACHE_MANAGER); objectUnderTest.setCacheName(cacheName); objectUnderTest.setBeanName(beanName); objectUnderTest.afterPropertiesSet(); final Cache<Object, Object> cache = objectUnderTest.getObject(); assertNotNull( "InfinispanNamedEmbeddedCacheFactoryBean should have produced a proper Infinispan cache. " + "However, it produced a null Infinispan cache.", cache); objectUnderTest.destroy(); }
/** * Test method for {@link * org.infinispan.spring.support.embedded.InfinispanNamedEmbeddedCacheFactoryBean#setBeanName(java.lang.String)} * . * * @throws Exception */ @Test public final void infinispanNamedEmbeddedCacheFactoryBeanShouldUseBeanNameAsCacheNameIfNoCacheNameHasBeenSet() throws Exception { final String beanName = "test.bean.Name"; final InfinispanNamedEmbeddedCacheFactoryBean<Object, Object> objectUnderTest = new InfinispanNamedEmbeddedCacheFactoryBean<Object, Object>(); objectUnderTest.setInfinispanEmbeddedCacheManager(DEFAULT_CACHE_MANAGER); objectUnderTest.setBeanName(beanName); objectUnderTest.afterPropertiesSet(); final Cache<Object, Object> cache = objectUnderTest.getObject(); assertEquals( "InfinispanNamedEmbeddedCacheFactoryBean should have used its bean name [" + beanName + "] as the name of the created cache. However, it didn't.", beanName, cache.getName()); objectUnderTest.destroy(); }
/** * Test method for {@link * org.infinispan.spring.support.embedded.InfinispanNamedEmbeddedCacheFactoryBean#destroy()} . * * @throws Exception */ @Test public final void infinispanNamedEmbeddedCacheFactoryBeanShouldStopTheCreatedInfinispanCacheWhenItIsDestroyed() throws Exception { final String cacheName = "test.cache.Name"; final String beanName = "test.bean.Name"; final InfinispanNamedEmbeddedCacheFactoryBean<Object, Object> objectUnderTest = new InfinispanNamedEmbeddedCacheFactoryBean<Object, Object>(); objectUnderTest.setInfinispanEmbeddedCacheManager(DEFAULT_CACHE_MANAGER); objectUnderTest.setCacheName(cacheName); objectUnderTest.setBeanName(beanName); objectUnderTest.afterPropertiesSet(); final Cache<Object, Object> cache = objectUnderTest.getObject(); objectUnderTest.destroy(); assertEquals( "InfinispanNamedEmbeddedCacheFactoryBean should have stopped the created Infinispan cache when being destroyed. " + "However, the created Infinispan is not yet terminated.", ComponentStatus.TERMINATED, cache.getStatus()); }