Search in sources :

Example 26 with PerpetualCache

use of org.apache.ibatis.cache.impl.PerpetualCache in project mybatis-3 by mybatis.

the class SqlSessionTest method shouldFailToAddDueToNameConflict.

@Test
public void shouldFailToAddDueToNameConflict() {
    Configuration c = new Configuration();
    final String fullName = "com.mycache.MyCache";
    final PerpetualCache cache = new PerpetualCache(fullName);
    try {
        c.addCache(cache);
        c.addCache(cache);
        fail("Exception expected.");
    } catch (Exception e) {
        assertTrue(e.getMessage().contains("already contains value"));
    }
}
Also used : PerpetualCache(org.apache.ibatis.cache.impl.PerpetualCache) TooManyResultsException(org.apache.ibatis.exceptions.TooManyResultsException) BindingException(org.apache.ibatis.binding.BindingException) BaseDataTest(org.apache.ibatis.BaseDataTest) Test(org.junit.Test)

Example 27 with PerpetualCache

use of org.apache.ibatis.cache.impl.PerpetualCache in project mybatis-3 by mybatis.

the class SqlSessionTest method shouldFailOverToMostApplicableSimpleName.

@Test(expected = IllegalArgumentException.class)
public void shouldFailOverToMostApplicableSimpleName() {
    Configuration c = new Configuration();
    final String fullName = "com.mycache.MyCache";
    final String invalidName = "unknown.namespace.MyCache";
    final PerpetualCache cache = new PerpetualCache(fullName);
    c.addCache(cache);
    assertEquals(cache, c.getCache(fullName));
    assertEquals(cache, c.getCache(invalidName));
}
Also used : PerpetualCache(org.apache.ibatis.cache.impl.PerpetualCache) BaseDataTest(org.apache.ibatis.BaseDataTest) Test(org.junit.Test)

Aggregations

PerpetualCache (org.apache.ibatis.cache.impl.PerpetualCache)27 Test (org.junit.Test)27 SerializedCache (org.apache.ibatis.cache.decorators.SerializedCache)9 SynchronizedCache (org.apache.ibatis.cache.decorators.SynchronizedCache)5 BaseDataTest (org.apache.ibatis.BaseDataTest)4 LoggingCache (org.apache.ibatis.cache.decorators.LoggingCache)4 ScheduledCache (org.apache.ibatis.cache.decorators.ScheduledCache)4 SoftCache (org.apache.ibatis.cache.decorators.SoftCache)4 WeakCache (org.apache.ibatis.cache.decorators.WeakCache)4 FifoCache (org.apache.ibatis.cache.decorators.FifoCache)3 LruCache (org.apache.ibatis.cache.decorators.LruCache)3 BindingException (org.apache.ibatis.binding.BindingException)2 TooManyResultsException (org.apache.ibatis.exceptions.TooManyResultsException)2 HashSet (java.util.HashSet)1