Search in sources :

Example 16 with ConfigurationFileException

use of org.codice.ddf.configuration.status.ConfigurationFileException in project ddf by codice.

the class ConfigurationAdminMigrationTest method testInitProcessesAllFilesEvenIfFirstOneHasAnInvalidType.

@Test
public void testInitProcessesAllFilesEvenIfFirstOneHasAnInvalidType() throws Exception {
    setUpTwoConfigFileIterator(configurationDirectoryStream);
    when(configurationFileFactory.createConfigurationFile(CONFIG_PATH1)).thenThrow(new ConfigurationFileException(""));
    when(configurationFileFactory.createConfigurationFile(CONFIG_PATH2)).thenReturn(configFile2);
    ConfigurationAdminMigration configurationAdminMigrator = new ConfigurationAdminMigration(configurationDirectoryStream, PROCESSED_DIRECTORY_PATH, FAILED_DIRECTORY_PATH, configurationFileFactory, configurationFilePoller, configurationAdmin, CONFIGURATION_FILE_EXTENSION);
    configurationAdminMigrator.init();
    verify(configurationDirectoryStream).iterator();
    verify(configurationFileFactory).createConfigurationFile(CONFIG_PATH1);
    verify(configFile1, never()).createConfig();
    verify(configurationFileFactory).createConfigurationFile(CONFIG_PATH2);
    verify(configFile2).createConfig();
    verify(configurationDirectoryStream).close();
}
Also used : ConfigurationFileException(org.codice.ddf.configuration.status.ConfigurationFileException) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

ConfigurationFileException (org.codice.ddf.configuration.status.ConfigurationFileException)16 Test (org.junit.Test)10 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)9 IOException (java.io.IOException)4 Path (java.nio.file.Path)4 Configuration (org.osgi.service.cm.Configuration)3 BufferedReader (java.io.BufferedReader)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 InputStreamReader (java.io.InputStreamReader)1 StandardCopyOption (java.nio.file.StandardCopyOption)1 ArrayList (java.util.ArrayList)1 Dictionary (java.util.Dictionary)1 PersistenceStrategy (org.codice.ddf.configuration.persistence.PersistenceStrategy)1 ExportMigrationException (org.codice.ddf.migration.ExportMigrationException)1 UnexpectedMigrationException (org.codice.ddf.migration.UnexpectedMigrationException)1 Matchers.anyObject (org.mockito.Matchers.anyObject)1 Matchers.anyString (org.mockito.Matchers.anyString)1 InvalidSyntaxException (org.osgi.framework.InvalidSyntaxException)1