use of org.motechproject.config.core.domain.BootstrapConfig in project motech by motech.
the class SqlDBManagerTest method shouldARemoveSlash.
@Test
public void shouldARemoveSlash() 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}dbname?useSSL=true");
SqlDBManager sqlDBManager = new SqlDBManagerImpl(coreConfigurationService);
Properties propertiesAfterUpdate = sqlDBManager.getSqlProperties(propertiesToUpdate);
assertEquals("jdbc:mysql://localhost:3306/dbname?useSSL=true", propertiesAfterUpdate.getProperty("javax.jdo.option.ConnectionURL"));
propertiesToUpdate = new Properties();
propertiesToUpdate.put("javax.jdo.option.ConnectionURL", "${sql.url}/dbname?useSSL=true");
propertiesAfterUpdate = sqlDBManager.getSqlProperties(propertiesToUpdate);
assertEquals("jdbc:mysql://localhost:3306/dbname?useSSL=true", propertiesAfterUpdate.getProperty("javax.jdo.option.ConnectionURL"));
}
use of org.motechproject.config.core.domain.BootstrapConfig in project motech by motech.
the class OsgiListener method start.
private static void start() {
LOGGER.debug("Starting OSGi framework...");
BootstrapConfig bootstrapConfig = null;
try {
bootstrapConfig = bootstrapManager.loadBootstrapConfig();
bootstrapPresent = bootstrapConfig != null;
} catch (RuntimeException e) {
LOGGER.info("Unable to load bootstrap config: " + e.getMessage());
}
if (bootstrapPresent) {
service = getOsgiService();
service.init(bootstrapConfig);
service.start();
try {
// reinitialize the servlet, in case we only just started the http bundle
// will happen if the user provided bootstrap configuration through the UI
ProxyServlet proxyServlet = ProxyServlet.getInstance();
if (proxyServlet != null) {
proxyServlet.reInit();
}
} catch (ServletException e) {
LOGGER.error("Error while configuring the Proxy Servlet", e);
}
}
}
use of org.motechproject.config.core.domain.BootstrapConfig in project motech by motech.
the class ConfigFileMonitor method init.
/**
* Initializes the configuration file monitor. This method will be automatically called after creation and
* dependency injection. It is done to make sure that injected dependencies are set and ready to use.
*/
@PostConstruct
public void init() throws IOException {
BootstrapConfig bootstrapConfig = configurationService.loadBootstrapConfig();
if (bootstrapConfig != null && bootstrapConfig.getConfigSource() == ConfigSource.FILE) {
// allow custom monitors to be injected
if (fileMonitor == null) {
fileMonitor = new DefaultFileMonitor(this);
// allow raw configs, which are one directory down, under /raw/, to be monitored
fileMonitor.setRecursive(true);
}
fileMonitor.setDelay(DELAY);
final List<File> files = new ArrayList<>();
try {
files.addAll(configLoader.findExistingConfigs());
} catch (MotechConfigurationException ex) {
LOGGER.error(ex.getMessage(), ex);
return;
}
configurationService.processExistingConfigs(files);
startFileMonitor();
}
}
use of org.motechproject.config.core.domain.BootstrapConfig in project motech by motech.
the class ConfigurationServiceTest method shouldIndicateThatConfigFilesAreNotRequiredWhenPlatformConfigurationFileIsPresent.
@Test
public void shouldIndicateThatConfigFilesAreNotRequiredWhenPlatformConfigurationFileIsPresent() 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");
when(coreConfigurationService.loadBootstrapConfig()).thenReturn(bootstrapConfig);
ConfigLocation configLocation = mock(ConfigLocation.class);
when(configLocation.hasPlatformConfigurationFile()).thenReturn(true);
when(coreConfigurationService.getConfigLocation()).thenReturn(configLocation);
assertFalse(configurationService.requiresConfigurationFiles());
}
use of org.motechproject.config.core.domain.BootstrapConfig in project motech by motech.
the class ConfigurationServiceTest method shouldIndicateThatConfigFilesAreRequiredWhenPlatformConfigurationFileIsMissing.
@Test
public void shouldIndicateThatConfigFilesAreRequiredWhenPlatformConfigurationFileIsMissing() 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");
when(coreConfigurationService.loadBootstrapConfig()).thenReturn(bootstrapConfig);
ConfigLocation configLocation = mock(ConfigLocation.class);
when(configLocation.hasPlatformConfigurationFile()).thenReturn(false);
when(coreConfigurationService.getConfigLocation()).thenReturn(configLocation);
assertTrue(configurationService.requiresConfigurationFiles());
}
Aggregations