use of org.codice.ddf.configuration.status.ConfigurationFileException in project ddf by codice.
the class ConfigurationAdminMigrationTest method testInitMovesFilesThatCannotBeReadToFailedDirectory.
@Test
public void testInitMovesFilesThatCannotBeReadToFailedDirectory() throws Exception {
setUpTwoConfigFileIterator(configurationDirectoryStream);
setUpConfigurationFileFactoryForTwoFiles();
doThrow(new ConfigurationFileException("")).when(configFile1).createConfig();
doThrow(new ConfigurationFileException("")).when(configFile2).createConfig();
when(Files.move(CONFIG_PATH1, PROCESSED_DIRECTORY_PATH, REPLACE_EXISTING)).thenReturn(FAILED_DIRECTORY_PATH);
when(Files.move(CONFIG_PATH2, PROCESSED_DIRECTORY_PATH, REPLACE_EXISTING)).thenReturn(FAILED_DIRECTORY_PATH);
ConfigurationAdminMigration configurationAdminMigrator = new ConfigurationAdminMigration(configurationDirectoryStream, PROCESSED_DIRECTORY_PATH, FAILED_DIRECTORY_PATH, configurationFileFactory, configurationFilePoller, configurationAdmin, CONFIGURATION_FILE_EXTENSION);
configurationAdminMigrator.init();
verifyStatic();
Files.move(CONFIG_PATH1, CONFIG_FILE_IN_FAILED_DIRECTORY.resolve(CONFIG_FILE_PATH1), REPLACE_EXISTING);
Files.move(CONFIG_PATH2, CONFIG_FILE_IN_FAILED_DIRECTORY.resolve(CONFIG_FILE_PATH2), REPLACE_EXISTING);
verify(configurationDirectoryStream).close();
}
use of org.codice.ddf.configuration.status.ConfigurationFileException in project ddf by codice.
the class ConfigurationAdminMigrationTest method testExportConfigurationFileException.
@Test(expected = MigrationException.class)
public void testExportConfigurationFileException() throws IOException, InvalidSyntaxException, ConfigurationFileException {
when(configurationAdmin.listConfigurations(anyString())).thenReturn(new Configuration[] { configuration });
ConfigurationAdminMigration configurationAdminMigration = createConfigurationAdminMigratorWithNoFiles();
when(configurationFileFactory.createConfigurationFile((Dictionary<String, Object>) anyObject())).thenThrow(new ConfigurationFileException(""));
configurationAdminMigration.export(EXPORTED_DIRECTORY_PATH);
}
use of org.codice.ddf.configuration.status.ConfigurationFileException in project ddf by codice.
the class ConfigurationAdminMigrationTest method testNotifyFailsToMoveFileToFailedDirectory.
@Test
public void testNotifyFailsToMoveFileToFailedDirectory() throws Exception {
doThrow(new ConfigurationFileException("")).when(configFile1).createConfig();
ConfigurationAdminMigration configurationAdminMigration = createConfigurationAdminMigratorForNotify();
configurationAdminMigration.notify(CONFIG_PATH1);
verify(configurationFileFactory).createConfigurationFile(CONFIG_PATH1);
}
use of org.codice.ddf.configuration.status.ConfigurationFileException in project ddf by codice.
the class ConfigurationFileFactoryTest method testCreateConfigurationFileWhenConfigFileReadThrowsConfigurationFileException.
@Test(expected = ConfigurationFileException.class)
public void testCreateConfigurationFileWhenConfigFileReadThrowsConfigurationFileException() throws Exception {
// Setup
PersistenceStrategy mockPersistenceStrategy = mock(PersistenceStrategy.class);
when(mockPersistenceStrategy.read(mockInputStream)).thenThrow(new ConfigurationFileException(""));
ConfigurationFileFactory factory = new ConfigurationFileFactoryUnderTest(mockPersistenceStrategy, configAdmin);
// Perform Test
factory.createConfigurationFile(mockPath);
}
use of org.codice.ddf.configuration.status.ConfigurationFileException in project ddf by codice.
the class ManagedServiceFactoryConfigurationFile method createConfig.
@Override
public void createConfig() throws ConfigurationFileException {
String factoryPid = getFactoryPid();
try {
Configuration configuration = configAdmin.createFactoryConfiguration(factoryPid, null);
configuration.update(properties);
} catch (IOException e) {
String message = String.format("Unable to get or update Configuration for factory pid [%s].", factoryPid);
LOGGER.info(message, e);
throw new ConfigurationFileException(message, e);
}
}
Aggregations