use of org.motechproject.config.core.domain.BootstrapConfig in project motech by motech.
the class CoreConfigurationBundleIT method testBootstrapConfigBundleIT.
@Test
public void testBootstrapConfigBundleIT() {
BootstrapConfig bootstrapConfig = coreConfigurationService.loadBootstrapConfig();
assertNotNull(bootstrapConfig);
assertNotNull(bootstrapConfig.getSqlConfig());
assertNotNull(bootstrapConfig.getConfigSource());
}
use of org.motechproject.config.core.domain.BootstrapConfig in project motech by motech.
the class SqlDBManagerTest method shouldProperlySetSqlProperties.
@Test
public void shouldProperlySetSqlProperties() throws IOException {
BootstrapConfig bootstrapConfig = new BootstrapConfig(new SQLDBConfig("jdbc:mysql://localhost:3306/", "com.mysql.jdbc.Driver", "root", "pass"), ConfigSource.FILE, "./felix", motechDir, "tcp://localhost:61616");
when(coreConfigurationService.loadBootstrapConfig()).thenReturn(bootstrapConfig);
Properties propertiesToUpdate = new Properties();
propertiesToUpdate.put("javax.jdo.option.ConnectionURL", "${sql.url}");
propertiesToUpdate.put("some.username", "${sql.user}");
propertiesToUpdate.put("some.password", "${sql.password}");
propertiesToUpdate.put("quartz.delegate", "${sql.quartz.delegateClass}");
SqlDBManager sqlDBManager = new SqlDBManagerImpl(coreConfigurationService);
Properties propertiesAfterUpdate = sqlDBManager.getSqlProperties(propertiesToUpdate);
assertEquals(4, propertiesAfterUpdate.size());
assertEquals("jdbc:mysql://localhost:3306/", propertiesAfterUpdate.getProperty("javax.jdo.option.ConnectionURL"));
assertEquals("root", propertiesAfterUpdate.getProperty("some.username"));
assertEquals("pass", propertiesAfterUpdate.getProperty("some.password"));
assertEquals(Drivers.QUARTZ_STD_JDBC_DELEGATE, propertiesAfterUpdate.getProperty("quartz.delegate"));
}
use of org.motechproject.config.core.domain.BootstrapConfig in project motech by motech.
the class StartupControllerTest method shouldInformViewThatConfigFilesNotRequiredWhenConfigSourceIsFileAndConfigFilesExist.
@Test
public void shouldInformViewThatConfigFilesNotRequiredWhenConfigSourceIsFileAndConfigFilesExist() throws IOException {
when(configurationService.requiresConfigurationFiles()).thenReturn(true);
when(localeService.getUserLocale(httpServletRequest)).thenReturn(new Locale("en"));
BootstrapConfig bootstrapConfig = mock(BootstrapConfig.class);
when(bootstrapConfig.getConfigSource()).thenReturn(ConfigSource.FILE);
when(configurationService.loadBootstrapConfig()).thenReturn(bootstrapConfig);
when(configurationService.requiresConfigurationFiles()).thenReturn(false);
StartupViewData startupViewData = startupController.getStartupViewData(httpServletRequest);
assertThat((startupViewData.getRequireConfigFiles()), Is.is(false));
verify(configurationService).requiresConfigurationFiles();
}
use of org.motechproject.config.core.domain.BootstrapConfig in project motech by motech.
the class StartupControllerTest method shouldInformViewThatConfigFilesRequiredWhenConfigSourceIsFileAndConfigFilesDoNotExist.
@Test
public void shouldInformViewThatConfigFilesRequiredWhenConfigSourceIsFileAndConfigFilesDoNotExist() throws IOException {
when(configurationService.requiresConfigurationFiles()).thenReturn(true);
when(localeService.getUserLocale(httpServletRequest)).thenReturn(new Locale("en"));
BootstrapConfig bootstrapConfig = mock(BootstrapConfig.class);
when(bootstrapConfig.getConfigSource()).thenReturn(ConfigSource.FILE);
when(configurationService.loadBootstrapConfig()).thenReturn(bootstrapConfig);
when(configurationService.requiresConfigurationFiles()).thenReturn(true);
StartupViewData startupViewData = startupController.getStartupViewData(httpServletRequest);
assertThat((startupViewData.getRequireConfigFiles()), Is.is(true));
verify(configurationService).requiresConfigurationFiles();
}
use of org.motechproject.config.core.domain.BootstrapConfig in project motech by motech.
the class StartupManagerTest method shouldNotTryToLoadDbSettingsIfConfigurationFilesAreStillRequired.
@Test
public void shouldNotTryToLoadDbSettingsIfConfigurationFilesAreStillRequired() {
BootstrapConfig bootstrap = mock(BootstrapConfig.class);
when(configurationService.loadBootstrapConfig()).thenReturn(bootstrap);
when(configurationService.requiresConfigurationFiles()).thenReturn(true);
startupManager.startup();
assertFalse(startupManager.isBootstrapConfigRequired());
assertTrue(startupManager.isConfigRequired());
verify(configurationService, never()).getPlatformSettings();
verify(configurationService).requiresConfigurationFiles();
}
Aggregations