use of org.motechproject.config.core.domain.BootstrapConfig in project motech by motech.
the class ConfigurationServiceTest method shouldIndicateThatConfigFilesAreNotRequiredWhenConfigSourceIsUI.
@Test
public void shouldIndicateThatConfigFilesAreNotRequiredWhenConfigSourceIsUI() throws IOException {
BootstrapConfig bootstrapConfig = new BootstrapConfig(new SQLDBConfig("jdbc:mysql://localhost:3306/", "com.mysql.jdbc.Driver", null, null), ConfigSource.UI, null, null, "tcp://localhost:61616");
when(coreConfigurationService.loadBootstrapConfig()).thenReturn(bootstrapConfig);
assertFalse(configurationService.requiresConfigurationFiles());
}
use of org.motechproject.config.core.domain.BootstrapConfig in project motech by motech.
the class ConfigurationServiceTest method shouldSaveBootstrapConfig.
@Test
public void shouldSaveBootstrapConfig() throws IOException {
BootstrapConfig bootstrapConfig = new BootstrapConfig(new SQLDBConfig("jdbc:mysql://localhost:3306/", "com.mysql.jdbc.Driver", null, null), ConfigSource.FILE, null, null, "tcp://localhost:61616");
configurationService.save(bootstrapConfig);
verify(coreConfigurationService).saveBootstrapConfig(bootstrapConfig);
}
use of org.motechproject.config.core.domain.BootstrapConfig in project motech by motech.
the class ConfigurationServiceTest method shouldLoadBootstrapDBConfiguration.
@Test
public void shouldLoadBootstrapDBConfiguration() {
BootstrapConfig expectedConfig = new BootstrapConfig(new SQLDBConfig("jdbc:mysql://localhost:3306/", "com.mysql.jdbc.Driver", null, null), null, null, null, "tcp://localhost:61616");
when(coreConfigurationService.loadBootstrapConfig()).thenReturn(expectedConfig);
BootstrapConfig bootstrapConfig = configurationService.loadBootstrapConfig();
assertNotNull(bootstrapConfig);
assertThat(bootstrapConfig, IsEqual.equalTo(bootstrapConfig));
}
use of org.motechproject.config.core.domain.BootstrapConfig in project motech by motech.
the class ConfigurationServiceBundleIT method shouldSaveBootstrapConfigToDefaultLocationAndLoadFromTheSameLocation.
@Test
public void shouldSaveBootstrapConfigToDefaultLocationAndLoadFromTheSameLocation() {
BootstrapConfig existingBootstrapConfig = configurationService.loadBootstrapConfig();
BootstrapConfig bootstrapConfig = new BootstrapConfig(existingBootstrapConfig.getSqlConfig(), existingBootstrapConfig.getConfigSource(), "./felix", motechDir, existingBootstrapConfig.getQueueUrl(), existingBootstrapConfig.getActiveMqProperties());
configurationService.save(bootstrapConfig);
assertThat(configurationService.loadBootstrapConfig(), IsEqual.equalTo(bootstrapConfig));
}
use of org.motechproject.config.core.domain.BootstrapConfig in project motech by motech.
the class BootstrapControllerTest method shouldAddErrorOnSaveAndReturnTheSameBootstrapStartupView.
@Test
public void shouldAddErrorOnSaveAndReturnTheSameBootstrapStartupView() throws Exception {
when(messageBrokerTestService.pingBroker("tcp://localhost:61616")).thenReturn(true);
when(localeResolver.resolveLocale(any(HttpServletRequest.class))).thenReturn(Locale.ENGLISH);
when(messageSource.getMessage("server.error.bootstrap.save", null, Locale.ENGLISH)).thenReturn("errMsg");
doThrow(new MotechConfigurationException("Test Exception")).when(OsgiListener.class);
OsgiListener.saveBootstrapConfig(any(BootstrapConfig.class));
MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders.post("/bootstrap/").param("sqlUrl", "jdbc:mysql://www.someurl.com:3306/").param("sqlDriver", "com.mysql.jdbc.Driver").param("sqlUsername", "some_username").param("sqlPassword", "some_password").param("configSource", "UI").param("queueUrl", "tcp://localhost:61616")).andExpect(MockMvcResultMatchers.status().isOk()).andReturn();
ModelAndView actualView = mvcResult.getModelAndView();
assertThat(actualView.getViewName(), is("bootstrapconfig"));
assertThat((String) ((List) actualView.getModel().get("errors")).get(0), is("errMsg"));
}
Aggregations