@Test public void testLoadConfigurationFromFileNoDefault() throws Exception { File file = new File(TEST_CONFIG_DIR + "ehcache-nodefault.xml"); Configuration configuration = ConfigurationFactory.parseConfiguration(file); 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()); try { Ehcache defaultCache = configurationHelper.createDefaultCache(); Assert.assertNull(defaultCache); } catch (CacheException e) { fail("Calling create default cache when no default cache config specified should return null and not fail"); } assertEquals(4, configurationHelper.createCaches().size()); Ehcache sampleCache1 = configurationHelper.createCacheFromName("sampleCache1"); Ehcache sampleCache4 = configurationHelper.createCacheFromName("sampleCache4"); assertEquals("net.sf.ehcache.transaction.manager.DefaultTransactionManagerLookup", configuration.getTransactionManagerLookupConfiguration().getFullyQualifiedClassPath()); assertEquals("sampleCache1", sampleCache1.getName()); assertEquals(false, sampleCache1.getCacheConfiguration().isEternal()); assertEquals(300, sampleCache1.getCacheConfiguration().getTimeToIdleSeconds()); assertEquals(600, sampleCache1.getCacheConfiguration().getTimeToLiveSeconds()); assertEquals(true, sampleCache1.getCacheConfiguration().isOverflowToDisk()); assertEquals(CacheConfiguration.TransactionalMode.OFF, sampleCache1.getCacheConfiguration().getTransactionalMode()); assertEquals(false, sampleCache1.getCacheConfiguration().isXaStrictTransactional()); assertEquals("sampleCache4", sampleCache4.getName()); assertEquals(CacheConfiguration.TransactionalMode.XA_STRICT, sampleCache4.getCacheConfiguration().getTransactionalMode()); assertEquals(true, sampleCache4.getCacheConfiguration().isXaStrictTransactional()); }
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()); } } configuration.setSource(ConfigurationSource.getConfigurationSource(file)); 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()); } } configuration.setSource(ConfigurationSource.getConfigurationSource(file)); 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()); } } configuration.setSource(ConfigurationSource.getConfigurationSource(file)); 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()); } } configuration.setSource(ConfigurationSource.getConfigurationSource(file)); 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); static CacheConfiguration parseCacheConfiguration(String xmlString); }
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()); } } configuration.setSource(ConfigurationSource.getConfigurationSource(file)); 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); static CacheConfiguration parseCacheConfiguration(String xmlString);  }