Search in sources :

Example 6 with PersistenceStrategy

use of org.codice.ddf.configuration.persistence.PersistenceStrategy in project ddf by codice.

the class ConfigurationFileFactoryTest method testCreateConfigurationFileNullInput.

@Test(expected = IllegalArgumentException.class)
public void testCreateConfigurationFileNullInput() throws Exception {
    // Setup
    PersistenceStrategy mockPersistenceStrategy = mock(PersistenceStrategy.class);
    ConfigurationFileFactory factory = new ConfigurationFileFactory(mockPersistenceStrategy, configAdmin);
    // Perform Test
    factory.createConfigurationFile((Path) null);
}
Also used : PersistenceStrategy(org.codice.ddf.configuration.persistence.PersistenceStrategy) Test(org.junit.Test)

Example 7 with PersistenceStrategy

use of org.codice.ddf.configuration.persistence.PersistenceStrategy in project ddf by codice.

the class ConfigurationFileFactoryTest method testCreateConfigurationFileForManagedServiceFactory.

@Test
public void testCreateConfigurationFileForManagedServiceFactory() throws Exception {
    // Setup
    Dictionary<String, Object> properties = new Hashtable<>(1);
    properties.put(ConfigurationAdmin.SERVICE_FACTORYPID, FACTORY_PID);
    PersistenceStrategy mockPersistenceStrategy = getMockPersistenceStrategy(mockInputStream, properties);
    ConfigurationFileFactory factory = new ConfigurationFileFactoryUnderTest(mockPersistenceStrategy, configAdmin);
    // Perform Test
    ConfigurationFile configFile = factory.createConfigurationFile(mockPath);
    // Verify
    assertThat(configFile, instanceOf(ManagedServiceFactoryConfigurationFile.class));
    verify(mockPersistenceStrategy).read(mockInputStream);
}
Also used : PersistenceStrategy(org.codice.ddf.configuration.persistence.PersistenceStrategy) Hashtable(java.util.Hashtable) Test(org.junit.Test)

Example 8 with PersistenceStrategy

use of org.codice.ddf.configuration.persistence.PersistenceStrategy in project ddf by codice.

the class ConfigurationFileFactoryTest method testCreateConfigurationFileForManagedService.

@Test
public void testCreateConfigurationFileForManagedService() 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(mockPath);
    // Verify
    assertThat(configFile, instanceOf(ManagedServiceConfigurationFile.class));
    verify(mockPersistenceStrategy).read(mockInputStream);
}
Also used : PersistenceStrategy(org.codice.ddf.configuration.persistence.PersistenceStrategy) Hashtable(java.util.Hashtable) Test(org.junit.Test)

Example 9 with PersistenceStrategy

use of org.codice.ddf.configuration.persistence.PersistenceStrategy in project ddf by codice.

the class ConfigurationFileFactoryTest method getMockPersistenceStrategy.

private PersistenceStrategy getMockPersistenceStrategy(InputStream mockInputStream, Dictionary<String, Object> properties) throws Exception {
    PersistenceStrategy mockPersistenceStrategy = mock(PersistenceStrategy.class);
    when(mockPersistenceStrategy.read(mockInputStream)).thenReturn(properties);
    return mockPersistenceStrategy;
}
Also used : PersistenceStrategy(org.codice.ddf.configuration.persistence.PersistenceStrategy)

Aggregations

PersistenceStrategy (org.codice.ddf.configuration.persistence.PersistenceStrategy)9 Test (org.junit.Test)8 Hashtable (java.util.Hashtable)5 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 Path (java.nio.file.Path)1 ConfigurationFileException (org.codice.ddf.configuration.status.ConfigurationFileException)1