ConfigurationFileManager { public void initConfiguration() { if (new File(rootDirectoryAsFile, MARKER_FILE_NAME).exists()) { return; } restoreConfiguration(); } ConfigurationFileManager();   ConfigurationFileManager(final ConfigurationProvider configurationProvider, final File rootDirectory); void initConfiguration(); void restoreConfiguration(); void unzipFilesFrom(final FileItem file); void deleteFile(final String path); void saveConfiguration(final String includes, final String excludes); InputStream downloadStoredConfiguration(); File getRootDirectory();  }
@Test public void testExampleConfigurationProvidesExampleFiles() throws Exception { final ConfigurationFileManager subject = getTestJenkinsConfiguration(); subject.initConfiguration(); for (final String expectedFileName : new String[] { "example.txt", "example/example.txt", "emptyExample" }) { assertTrue(new File(tempDir.getRoot(), expectedFileName).exists()); } }
@Test public void testExampleConfigurationLeavesExistingFileAlone() throws Exception { final File existingFile = tempDir.newFile(); final ConfigurationFileManager subject = getTestJenkinsConfiguration(); subject.initConfiguration(); assertTrue(existingFile.exists()); }
@Test public void testBootstrapExtractsDefaultArchive() { final StoredOrDefaultConfigurationProvider configurationProvider = new StoredOrDefaultConfigurationProvider(StoredOrDefaultConfigurationProviderTest.setupMockStorage(null)); final ConfigurationFileManager subject = getTestJenkinsConfiguration(configurationProvider); subject.initConfiguration(); assertTrue(defaultFile.exists()); }
@Test public void testSecondBootstrapDoesNothing() { final StoredOrDefaultConfigurationProvider configurationProvider = new StoredOrDefaultConfigurationProvider(StoredOrDefaultConfigurationProviderTest.setupMockStorage(null)); final ConfigurationFileManager subject = getTestJenkinsConfiguration(configurationProvider); subject.initConfiguration(); assertTrue(defaultFile.delete()); subject.initConfiguration(); assertFalse(defaultFile.exists()); }