diff options
author | Fabrice Bellingard <fabrice.bellingard@sonarsource.com> | 2013-02-05 12:32:13 +0100 |
---|---|---|
committer | Fabrice Bellingard <fabrice.bellingard@sonarsource.com> | 2013-02-05 14:18:48 +0100 |
commit | 9c257218ef13f071061f65081738e3b2aca6ef61 (patch) | |
tree | 48bb62e7d601b65c2bb5ad6d2d3cf28991638f8f /sonar-core | |
parent | a6216949829c8a02bcec19b856e601333a7d036a (diff) | |
download | sonarqube-9c257218ef13f071061f65081738e3b2aca6ef61.tar.gz sonarqube-9c257218ef13f071061f65081738e3b2aca6ef61.zip |
SONAR-4110 Log server ID, when it exists, at startup
Diffstat (limited to 'sonar-core')
-rw-r--r-- | sonar-core/src/main/java/org/sonar/core/properties/PropertiesDao.java | 10 | ||||
-rw-r--r-- | sonar-core/src/test/java/org/sonar/core/properties/PropertiesDaoTest.java | 13 |
2 files changed, 23 insertions, 0 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/properties/PropertiesDao.java b/sonar-core/src/main/java/org/sonar/core/properties/PropertiesDao.java index 3ee901fc9c2..84b4f3fda6f 100644 --- a/sonar-core/src/main/java/org/sonar/core/properties/PropertiesDao.java +++ b/sonar-core/src/main/java/org/sonar/core/properties/PropertiesDao.java @@ -85,6 +85,16 @@ public class PropertiesDao implements BatchComponent, ServerComponent { } } + public PropertyDto selectGlobalProperty(String propertyKey) { + SqlSession session = mybatis.openSession(); + PropertiesMapper mapper = session.getMapper(PropertiesMapper.class); + try { + return mapper.selectByKey(new PropertyDto().setKey(propertyKey)); + } finally { + MyBatis.closeQuietly(session); + } + } + public List<PropertyDto> selectProjectProperties(String resourceKey) { SqlSession session = mybatis.openSession(); PropertiesMapper mapper = session.getMapper(PropertiesMapper.class); diff --git a/sonar-core/src/test/java/org/sonar/core/properties/PropertiesDaoTest.java b/sonar-core/src/test/java/org/sonar/core/properties/PropertiesDaoTest.java index 242938e0e84..64df0517675 100644 --- a/sonar-core/src/test/java/org/sonar/core/properties/PropertiesDaoTest.java +++ b/sonar-core/src/test/java/org/sonar/core/properties/PropertiesDaoTest.java @@ -95,6 +95,19 @@ public class PropertiesDaoTest extends AbstractDaoTestCase { } @Test + public void selectGlobalProperty() { + setupData("selectGlobalProperties"); + + PropertyDto prop = dao.selectGlobalProperty("global.one"); + assertThat(prop).isNotNull(); + assertThat(prop.getValue(), is("one")); + + assertThat(dao.selectGlobalProperty("project.one")).isNull(); + assertThat(dao.selectGlobalProperty("user.one")).isNull(); + assertThat(dao.selectGlobalProperty("unexisting")).isNull(); + } + + @Test public void selectProjectProperties() { setupData("selectProjectProperties"); List<PropertyDto> properties = dao.selectProjectProperties("org.struts:struts"); |