]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-9734 add integration test
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Fri, 18 Aug 2017 20:46:59 +0000 (22:46 +0200)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Mon, 21 Aug 2017 19:39:49 +0000 (21:39 +0200)
tests/src/test/java/org/sonarqube/tests/Category4Suite.java
tests/src/test/java/org/sonarqube/tests/ce/CeTempDirTest.java [new file with mode: 0644]

index 1f8c23c0f0bdb8ee2a1c13e068346188eaf3e287..f7ab6e9a49948fcc90d60c73a23c13217cf04461 100644 (file)
@@ -25,6 +25,7 @@ import org.junit.runner.RunWith;
 import org.junit.runners.Suite;
 import org.sonarqube.tests.analysis.FileExclusionsTest;
 import org.sonarqube.tests.analysis.IssueExclusionsTest;
+import org.sonarqube.tests.ce.CeTempDirTest;
 import org.sonarqube.tests.ce.CeWsTest;
 import org.sonarqube.tests.component.ComponentsWsTest;
 import org.sonarqube.tests.component.ProjectsWsTest;
@@ -100,7 +101,8 @@ import static util.ItUtils.xooPlugin;
   QualityProfilesUiTest.class,
   LogsTest.class,
   // ce
-  CeWsTest.class
+  CeWsTest.class,
+  CeTempDirTest.class
 })
 public class Category4Suite {
 
diff --git a/tests/src/test/java/org/sonarqube/tests/ce/CeTempDirTest.java b/tests/src/test/java/org/sonarqube/tests/ce/CeTempDirTest.java
new file mode 100644 (file)
index 0000000..c68980d
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * 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  02110-1301, USA.
+ */
+package org.sonarqube.tests.ce;
+
+import com.sonar.orchestrator.Orchestrator;
+import com.sonar.orchestrator.build.SonarScanner;
+import java.io.File;
+import org.apache.commons.io.FileUtils;
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonarqube.tests.Category4Suite;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static util.ItUtils.projectDir;
+
+public class CeTempDirTest {
+  @Rule
+  public Orchestrator orchestrator = Category4Suite.ORCHESTRATOR;
+
+  @Test
+  public void temp_files_are_deleted_when_processing_analysis_report() {
+    File ceTempDir = new File(orchestrator.getServer().getHome(), "temp/ce");
+    assertThatDirIsEmpty(ceTempDir);
+
+    orchestrator.executeBuild(SonarScanner.create(projectDir("shared/xoo-sample")));
+
+    assertThat(ceTempDir).isDirectory().exists();
+    assertThatDirIsEmpty(ceTempDir);
+  }
+
+  private void assertThatDirIsEmpty(File dir) {
+    if (dir.exists()) {
+      assertThat(FileUtils.listFiles(dir, null, true).size()).isEqualTo(0);
+    }
+  }
+}