use of org.codice.ddf.configuration.persistence.PersistenceStrategy in project ddf by codice.
the class ConfigurationFileFactoryTest method testCreateConfigurationFileFromProperties.
@Test
public void testCreateConfigurationFileFromProperties() throws Exception {
// Setup
Dictionary<String, Object> properties = new Hashtable<>(1);
properties.put(Constants.SERVICE_PID, PID);
PersistenceStrategy mockPersistenceStrategy = getMockPersistenceStrategy(mockInputStream, properties);
ConfigurationFileFactory factory = new ConfigurationFileFactoryUnderTest(mockPersistenceStrategy, configAdmin);
// Perform Test
ConfigurationFile configFile = factory.createConfigurationFile(properties);
// Verify
assertThat(configFile, instanceOf(ManagedServiceConfigurationFile.class));
}
use of org.codice.ddf.configuration.persistence.PersistenceStrategy 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.persistence.PersistenceStrategy in project ddf by codice.
the class ConfigurationFileFactoryTest method testCreateConfigurationFileWhenConfigFileReadThrowsIOException.
@Test(expected = ConfigurationFileException.class)
public void testCreateConfigurationFileWhenConfigFileReadThrowsIOException() throws Exception {
// Setup
PersistenceStrategy mockPersistenceStrategy = mock(PersistenceStrategy.class);
when(mockPersistenceStrategy.read(mockInputStream)).thenThrow(new IOException());
ConfigurationFileFactory factory = new ConfigurationFileFactoryUnderTest(mockPersistenceStrategy, configAdmin);
// Perform Test
factory.createConfigurationFile(mockPath);
}
use of org.codice.ddf.configuration.persistence.PersistenceStrategy in project ddf by codice.
the class ConfigurationFileFactoryTest method testCreateConfigurationFileNoServicePidOrFactoryPid.
@Test(expected = ConfigurationFileException.class)
public void testCreateConfigurationFileNoServicePidOrFactoryPid() throws Exception {
// Setup
Dictionary<String, Object> properties = new Hashtable<>(1);
properties.put("prop1", "value1");
PersistenceStrategy mockPersistenceStrategy = getMockPersistenceStrategy(mockInputStream, properties);
ConfigurationFileFactory factory = new ConfigurationFileFactoryUnderTest(mockPersistenceStrategy, configAdmin);
// Perform Test
factory.createConfigurationFile(mockPath);
}
use of org.codice.ddf.configuration.persistence.PersistenceStrategy in project ddf by codice.
the class ConfigurationFileFactoryTest method testCreateConfigurationFileFileNotFoundExceptionOnGetInputStream.
@Test(expected = ConfigurationFileException.class)
public void testCreateConfigurationFileFileNotFoundExceptionOnGetInputStream() throws Exception {
// Setup
Dictionary<String, Object> properties = new Hashtable<>(1);
properties.put(Constants.SERVICE_PID, PID);
PersistenceStrategy mockPersistenceStrategy = getMockPersistenceStrategy(mockInputStream, properties);
ConfigurationFileFactory factory = new ConfigurationFileFactory(mockPersistenceStrategy, configAdmin) {
@Override
InputStream getInputStream(Path path) throws FileNotFoundException {
throw new FileNotFoundException();
}
};
// Perform Test
factory.createConfigurationFile(mockPath);
}
Aggregations