@Test public void testLoadConfigurationFromClasspath() throws Exception { Configuration configuration = ConfigurationFactory.parseConfiguration(); ConfigurationHelper configurationHelper = new ConfigurationHelper(manager, configuration); assertEquals(null, configurationHelper.getConfigurationBean().getName()); assertEquals(true, configurationHelper.getConfigurationBean().getUpdateCheck()); assertEquals(Configuration.Monitoring.AUTODETECT, configurationHelper.getConfigurationBean().getMonitoring()); assertEquals(System.getProperty("java.io.tmpdir"), configurationHelper.getDiskStorePath()); Map<String, CacheManagerPeerProvider> peerProviders = configurationHelper.createCachePeerProviders(); CacheManagerPeerProvider peerProvider = peerProviders.get("RMI"); assertTrue(peerProvider instanceof MulticastRMICacheManagerPeerProvider); assertEquals(new Integer(0), ((MulticastRMICacheManagerPeerProvider) peerProvider).getHeartBeatSender().getTimeToLive()); assertEquals(null, configurationHelper.createCacheManagerEventListener()); Ehcache defaultCache = configurationHelper.createDefaultCache(); assertEquals("default", defaultCache.getName()); assertEquals(false, defaultCache.getCacheConfiguration().isEternal()); assertEquals(5, defaultCache.getCacheConfiguration().getTimeToIdleSeconds()); assertEquals(10, defaultCache.getCacheConfiguration().getTimeToLiveSeconds()); assertEquals(true, defaultCache.getCacheConfiguration().isOverflowToDisk()); assertEquals(CACHES_IN_TEST_EHCACHE, configurationHelper.createCaches().size()); Ehcache sampleCache1 = configurationHelper.createCacheFromName("sampleCache1"); assertEquals("sampleCache1", sampleCache1.getName()); assertEquals(false, sampleCache1.getCacheConfiguration().isEternal()); assertEquals(360, sampleCache1.getCacheConfiguration().getTimeToIdleSeconds()); assertEquals(1000, sampleCache1.getCacheConfiguration().getTimeToLiveSeconds()); assertEquals(true, sampleCache1.getCacheConfiguration().isOverflowToDisk()); assertEquals(1000, sampleCache1.getCacheConfiguration().getMaxElementsOnDisk()); Ehcache persistentLongExpiryIntervalCache = configurationHelper.createCacheFromName("persistentLongExpiryIntervalCache"); assertEquals("persistentLongExpiryIntervalCache", persistentLongExpiryIntervalCache.getName()); assertEquals(false, persistentLongExpiryIntervalCache.getCacheConfiguration().isEternal()); assertEquals(300, persistentLongExpiryIntervalCache.getCacheConfiguration().getTimeToIdleSeconds()); assertEquals(600, persistentLongExpiryIntervalCache.getCacheConfiguration().getTimeToLiveSeconds()); assertEquals(true, persistentLongExpiryIntervalCache.getCacheConfiguration().isOverflowToDisk()); assertEquals(true, persistentLongExpiryIntervalCache.getCacheConfiguration().isDiskPersistent()); assertEquals(600, persistentLongExpiryIntervalCache.getCacheConfiguration().getDiskExpiryThreadIntervalSeconds()); Ehcache exceptionHandlingCache = configurationHelper.createCacheFromName("exceptionHandlingCache"); assertEquals("exceptionHandlingCache", exceptionHandlingCache.getName()); assertTrue(exceptionHandlingCache.getCacheExceptionHandler() != null); assertTrue(exceptionHandlingCache.getCacheExceptionHandler() instanceof CountingExceptionHandler); assertTrue(exceptionHandlingCache.getCacheExceptionHandler() instanceof CacheExceptionHandler); }
public static Configuration parseConfiguration(final File file) throws CacheException { if (file == null) { throw new CacheException("Attempt to configure ehcache from null file."); } LOG.debug("Configuring ehcache from file: {}", file); Configuration configuration = null; InputStream input = null; try { input = new BufferedInputStream(new FileInputStream(file)); configuration = parseConfiguration(input); } catch (Exception e) { throw new CacheException("Error configuring from " + file + ". Initial cause was " + e.getMessage(), e); } finally { try { if (input != null) { input.close(); } } catch (IOException e) { LOG.error("IOException while closing configuration input stream. Error was " + e.getMessage()); } } return configuration; }
ConfigurationFactory { public static Configuration parseConfiguration(final File file) throws CacheException { if (file == null) { throw new CacheException("Attempt to configure ehcache from null file."); } LOG.debug("Configuring ehcache from file: {}", file); Configuration configuration = null; InputStream input = null; try { input = new BufferedInputStream(new FileInputStream(file)); configuration = parseConfiguration(input); } catch (Exception e) { throw new CacheException("Error configuring from " + file + ". Initial cause was " + e.getMessage(), e); } finally { try { if (input != null) { input.close(); } } catch (IOException e) { LOG.error("IOException while closing configuration input stream. Error was " + e.getMessage()); } } return configuration; } }
ConfigurationFactory { public static Configuration parseConfiguration(final File file) throws CacheException { if (file == null) { throw new CacheException("Attempt to configure ehcache from null file."); } LOG.debug("Configuring ehcache from file: {}", file); Configuration configuration = null; InputStream input = null; try { input = new BufferedInputStream(new FileInputStream(file)); configuration = parseConfiguration(input); } catch (Exception e) { throw new CacheException("Error configuring from " + file + ". Initial cause was " + e.getMessage(), e); } finally { try { if (input != null) { input.close(); } } catch (IOException e) { LOG.error("IOException while closing configuration input stream. Error was " + e.getMessage()); } } return configuration; } private  ConfigurationFactory(); }
ConfigurationFactory { public static Configuration parseConfiguration(final File file) throws CacheException { if (file == null) { throw new CacheException("Attempt to configure ehcache from null file."); } LOG.debug("Configuring ehcache from file: {}", file); Configuration configuration = null; InputStream input = null; try { input = new BufferedInputStream(new FileInputStream(file)); configuration = parseConfiguration(input); } catch (Exception e) { throw new CacheException("Error configuring from " + file + ". Initial cause was " + e.getMessage(), e); } finally { try { if (input != null) { input.close(); } } catch (IOException e) { LOG.error("IOException while closing configuration input stream. Error was " + e.getMessage()); } } return configuration; } private  ConfigurationFactory(); static Configuration parseConfiguration(final File file); static Configuration parseConfiguration(final URL url); static Configuration parseConfiguration(); static Configuration parseConfiguration(final InputStream inputStream); }
ConfigurationFactory { public static Configuration parseConfiguration(final File file) throws CacheException { if (file == null) { throw new CacheException("Attempt to configure ehcache from null file."); } LOG.debug("Configuring ehcache from file: {}", file); Configuration configuration = null; InputStream input = null; try { input = new BufferedInputStream(new FileInputStream(file)); configuration = parseConfiguration(input); } catch (Exception e) { throw new CacheException("Error configuring from " + file + ". Initial cause was " + e.getMessage(), e); } finally { try { if (input != null) { input.close(); } } catch (IOException e) { LOG.error("IOException while closing configuration input stream. Error was " + e.getMessage()); } } return configuration; } private  ConfigurationFactory(); static Configuration parseConfiguration(final File file); static Configuration parseConfiguration(final URL url); static Configuration parseConfiguration(); static Configuration parseConfiguration(final InputStream inputStream);  }