@Test(expectedExceptions = AluminumException.class) public void tryingToObtainConfigurationElementAfterClosingConfigurationShouldCauseException() { Configuration configuration = new DefaultConfiguration(); configuration.close(); configuration.getCache(); }
@AfterMethod public void closeConfiguration() { if (configuration != null) { configuration.close(); configuration = null; } }
@Test(dependsOnMethods = "parsersInsideParserPackagesShouldBeFound") public void configurationShouldDisableParsersWhenItIsClosed() { Configuration configuration = new DefaultConfiguration(); TestParser parser = findParserOfType(configuration, TestParser.class); configuration.close(); assert parser.getConfiguration() == null; }
@Test(dependsOnMethods = "configurationShouldInitialiseSerialisers") public void configurationShouldDisableSerialisersWhenItIsClosed() { Configuration configuration = new DefaultConfiguration(); TestSerialiser serialiser = findSerialiserOfType(configuration, TestSerialiser.class); configuration.close(); assert serialiser.getConfiguration() == null; }
@Test(dependsOnMethods = "configurationShouldInitialiseLibraries") public void configurationShouldDisableLibrariesWhenItIsClosed() { Configuration configuration = new DefaultConfiguration(); TestLibrary library = findLibraryOfType(configuration, TestLibrary.class); configuration.close(); assert library.getConfiguration() == null; }
@Test(dependsOnMethods = "configurationShouldInitialiseExpressionFactories") public void configurationShouldDisableExpressionFactoriesWhenItIsClosed() { Configuration configuration = new DefaultConfiguration(); TestExpressionFactory expressionFactory = findExpressionFactoryOfType(configuration, TestExpressionFactory.class); configuration.close(); assert expressionFactory.getConfiguration() == null; }
@Test(dependsOnMethods = "configurationShouldInitialiseCache") public void configurationShouldDisableCacheWhenItIsClosed() { ConfigurationParameters parameters = new ConfigurationParameters(); parameters.addParameter(CACHE_CLASS, TestCache.class.getName()); Configuration configuration = new DefaultConfiguration(parameters); TestCache cache = (TestCache) configuration.getCache(); configuration.close(); assert cache.getConfiguration() == null; }
@Test(dependsOnMethods = "configurationShouldInitialiseTemplateFinder") public void configurationShouldDisableTemplateFinderWhenItIsClosed() { ConfigurationParameters parameters = new ConfigurationParameters(); parameters.addParameter(TEMPLATE_FINDER_CLASS, TestTemplateFinder.class.getName()); Configuration configuration = new DefaultConfiguration(parameters); TestTemplateFinder templateFinder = (TestTemplateFinder) configuration.getTemplateFinder(); configuration.close(); assert templateFinder.getConfiguration() == null; }
@Test(dependsOnMethods = "configurationShouldInitialiseConverterRegistry") public void configurationShouldDisableConverterRegistryWhenItIsClosed() { ConfigurationParameters parameters = new ConfigurationParameters(); parameters.addParameter(CONVERTER_REGISTRY_CLASS, TestConverterRegistry.class.getName()); Configuration configuration = new DefaultConfiguration(parameters); TestConverterRegistry converterRegistry = (TestConverterRegistry) configuration.getConverterRegistry(); configuration.close(); assert converterRegistry.getConfiguration() == null; }
@Test(dependsOnMethods = "configurationShouldInitialiseTemplateElementFactory") public void configurationShouldDisableTemplateElementFactoryWhenItIsClosed() { ConfigurationParameters parameters = new ConfigurationParameters(); parameters.addParameter( TEMPLATE_ELEMENT_FACTORY_CLASS, TestTemplateElementFactory.class.getName()); Configuration configuration = new DefaultConfiguration(parameters); TestTemplateElementFactory templateElementFactory = (TestTemplateElementFactory) configuration.getTemplateElementFactory(); configuration.close(); assert templateElementFactory.getConfiguration() == null; }
@Test(expectedExceptions = AluminumException.class) public void closingAlreadyClosedConfigurationShouldCauseException() { Configuration configuration = new DefaultConfiguration(); configuration.close(); configuration.close(); }