@Test
  public void testWithoutEhcacheExplicitDependencyAndNoCodeChanges() throws Exception {
    CacheManager manager =
        cachingProvider.getCacheManager(
            getClass()
                .getResource("/org/ehcache/docs/ehcache-jsr107-template-override.xml")
                .toURI(),
            getClass().getClassLoader());

    // tag::jsr107SupplementWithTemplatesExample[]
    MutableConfiguration<Long, String> mutableConfiguration =
        new MutableConfiguration<Long, String>();
    mutableConfiguration.setTypes(Long.class, String.class); // <1>

    Cache<Long, String> anyCache = manager.createCache("anyCache", mutableConfiguration); // <2>

    CacheRuntimeConfiguration<Long, String> ehcacheConfig =
        (CacheRuntimeConfiguration<Long, String>)
            anyCache
                .getConfiguration(Eh107Configuration.class)
                .unwrap(CacheRuntimeConfiguration.class); // <3>
    ehcacheConfig.getResourcePools().getPoolForResource(ResourceType.Core.HEAP).getSize(); // <4>

    Cache<Long, String> anotherCache = manager.createCache("byRefCache", mutableConfiguration);
    assertFalse(anotherCache.getConfiguration(Configuration.class).isStoreByValue()); // <5>

    MutableConfiguration<String, String> otherConfiguration =
        new MutableConfiguration<String, String>();
    otherConfiguration.setTypes(String.class, String.class);
    otherConfiguration.setExpiryPolicyFactory(
        CreatedExpiryPolicy.factoryOf(Duration.ONE_MINUTE)); // <6>

    Cache<String, String> foosCache = manager.createCache("foos", otherConfiguration); // <7>
    CacheRuntimeConfiguration<Long, String> foosEhcacheConfig =
        (CacheRuntimeConfiguration<Long, String>)
            foosCache
                .getConfiguration(Eh107Configuration.class)
                .unwrap(CacheRuntimeConfiguration.class);
    foosEhcacheConfig.getExpiry().getExpiryForCreation(42L, "Answer!").getAmount(); // <8>

    CompleteConfiguration<String, String> foosConfig =
        foosCache.getConfiguration(CompleteConfiguration.class);

    try {
      final Factory<ExpiryPolicy> expiryPolicyFactory = foosConfig.getExpiryPolicyFactory();
      ExpiryPolicy expiryPolicy = expiryPolicyFactory.create(); // <9>
      throw new AssertionError("Expected UnsupportedOperationException");
    } catch (UnsupportedOperationException e) {
      // Expected
    }
    // end::jsr107SupplementWithTemplatesExample[]
    assertThat(
        ehcacheConfig.getResourcePools().getPoolForResource(ResourceType.Core.HEAP).getSize(),
        is(20L));
    assertThat(
        foosEhcacheConfig.getExpiry().getExpiryForCreation(42L, "Answer!"),
        is(new org.ehcache.expiry.Duration(2, TimeUnit.MINUTES)));
  }
 protected AbstractBaseCacheProxy(CacheConfig cacheConfig, CacheDistributedObject delegate) {
   this.name = cacheConfig.getName();
   this.cacheConfig = cacheConfig;
   this.delegate = delegate;
   this.nodeEngine = delegate.getNodeEngine();
   this.serializationService = this.nodeEngine.getSerializationService();
   if (cacheConfig.getCacheLoaderFactory() != null) {
     final Factory<CacheLoader> cacheLoaderFactory = cacheConfig.getCacheLoaderFactory();
     cacheLoader = cacheLoaderFactory.create();
   } else {
     cacheLoader = null;
   }
   asyncListenerRegistrations = new ConcurrentHashMap<CacheEntryListenerConfiguration, String>();
   syncListenerRegistrations = new ConcurrentHashMap<CacheEntryListenerConfiguration, String>();
   syncLocks = new ConcurrentHashMap<Integer, CountDownLatch>();
 }