aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/java/org/sonar
diff options
context:
space:
mode:
authorFabrice Bellingard <fabrice.bellingard@sonarsource.com>2012-09-07 15:20:42 +0200
committerFabrice Bellingard <fabrice.bellingard@sonarsource.com>2012-09-07 15:20:42 +0200
commitb0ea3c75021e2325a4170749fe4b2cd5e96e0f56 (patch)
treeafdbf06acac270966f8fbca42c014bc870eb57ea /src/test/java/org/sonar
parentc8c554c3f13d8ec44926bb20f0b48dbec9bb4b83 (diff)
downloadsonar-scanner-cli-b0ea3c75021e2325a4170749fe4b2cd5e96e0f56.tar.gz
sonar-scanner-cli-b0ea3c75021e2325a4170749fe4b2cd5e96e0f56.zip
Refactor code and add some API documentation.
Diffstat (limited to 'src/test/java/org/sonar')
-rw-r--r--src/test/java/org/sonar/runner/model/SonarProjectBuilderTest.java16
-rw-r--r--src/test/java/org/sonar/runner/utils/SonarRunnerUtilsTest.java63
2 files changed, 63 insertions, 16 deletions
diff --git a/src/test/java/org/sonar/runner/model/SonarProjectBuilderTest.java b/src/test/java/org/sonar/runner/model/SonarProjectBuilderTest.java
index d27e88c..b3f91bd 100644
--- a/src/test/java/org/sonar/runner/model/SonarProjectBuilderTest.java
+++ b/src/test/java/org/sonar/runner/model/SonarProjectBuilderTest.java
@@ -233,22 +233,6 @@ public class SonarProjectBuilderTest {
}
@Test
- public void shouldGetList() {
- Properties props = new Properties();
-
- props.put("prop", " foo , bar , \n\ntoto,tutu");
- assertThat(SonarProjectBuilder.getListFromProperty(props, "prop")).containsOnly("foo", "bar", "toto", "tutu");
- }
-
- @Test
- public void shouldGetListFromFile() throws IOException {
- String filePath = "shouldGetList/foo.properties";
- Properties props = loadPropsFromFile(filePath);
-
- assertThat(SonarProjectBuilder.getListFromProperty(props, "prop")).containsOnly("foo", "bar", "toto", "tutu");
- }
-
- @Test
public void shouldGetRelativeFile() {
assertThat(SonarProjectBuilder.getFileFromPath("shouldGetFile/foo.properties", TestUtils.getResource(this.getClass(), "/")))
.isEqualTo(TestUtils.getResource("org/sonar/runner/model/SonarProjectBuilderTest/shouldGetFile/foo.properties"));
diff --git a/src/test/java/org/sonar/runner/utils/SonarRunnerUtilsTest.java b/src/test/java/org/sonar/runner/utils/SonarRunnerUtilsTest.java
new file mode 100644
index 0000000..c98c8f8
--- /dev/null
+++ b/src/test/java/org/sonar/runner/utils/SonarRunnerUtilsTest.java
@@ -0,0 +1,63 @@
+/*
+ * Sonar Standalone Runner
+ * Copyright (C) 2011 SonarSource
+ * dev@sonar.codehaus.org
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.runner.utils;
+
+import org.apache.commons.io.IOUtils;
+import org.junit.Test;
+import org.sonar.test.TestUtils;
+
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.Properties;
+
+import static org.fest.assertions.Assertions.assertThat;
+
+public class SonarRunnerUtilsTest {
+
+ @Test
+ public void shouldGetList() {
+ Properties props = new Properties();
+
+ props.put("prop", " foo , bar , \n\ntoto,tutu");
+ assertThat(SonarRunnerUtils.getListFromProperty(props, "prop")).containsOnly("foo", "bar", "toto", "tutu");
+ }
+
+ @Test
+ public void shouldGetListFromFile() throws IOException {
+ String filePath = "shouldGetList/foo.properties";
+ Properties props = loadPropsFromFile(filePath);
+
+ assertThat(SonarRunnerUtils.getListFromProperty(props, "prop")).containsOnly("foo", "bar", "toto", "tutu");
+ }
+
+ private Properties loadPropsFromFile(String filePath) throws FileNotFoundException, IOException {
+ Properties props = new Properties();
+ FileInputStream fileInputStream = null;
+ try {
+ fileInputStream = new FileInputStream(TestUtils.getResource(this.getClass(), filePath));
+ props.load(fileInputStream);
+ } finally {
+ IOUtils.closeQuietly(fileInputStream);
+ }
+ return props;
+ }
+
+}