import java.io.File;
import java.io.IOException;
import java.util.Map;
-import org.junit.After;
import org.junit.Test;
import org.sonarqube.ws.Measures.Measure;
public class DistributionTest extends ScannerTestCase {
- @After
- public void cleanup() {
- orchestrator.resetData();
- }
-
@Test
public void should_succeed_with_self_contained_jre_despite_rubbish_java_home()
throws IOException, InterruptedException {
import java.util.Map;
import java.util.stream.Collectors;
import org.apache.commons.lang.StringEscapeUtils;
-import org.junit.After;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
@Rule
public TemporaryFolder temp = new TemporaryFolder();
- @After
- public void cleanup() {
- orchestrator.resetData();
- }
-
@Test
public void basedir_contains_sources() {
SonarScanner build = newScanner(new File("projects/basedir-with-source"));
import com.sonar.orchestrator.Orchestrator;
import com.sonar.orchestrator.build.SonarScanner;
+import com.sonar.orchestrator.http.HttpMethod;
import com.sonar.orchestrator.version.Version;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
+import java.time.Instant;
+import java.time.ZoneId;
+import java.time.format.DateTimeFormatter;
+import java.time.temporal.ChronoUnit;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.stream.Collectors;
import javax.annotation.CheckForNull;
import org.apache.commons.lang.StringUtils;
+import org.junit.After;
import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.rules.ExpectedException;
return artifactVersion;
}
+ @After
+ public void resetData() {
+ // We add one day to ensure that today's entries are deleted.
+ Instant instant = Instant.now().plus(1, ChronoUnit.DAYS);
+
+ // The expected format is yyyy-MM-dd.
+ String currentDateTime = DateTimeFormatter.ISO_LOCAL_DATE
+ .withZone(ZoneId.of("UTC"))
+ .format(instant);
+
+ orchestrator.getServer()
+ .newHttpCall("/api/projects/bulk_delete")
+ .setAdminCredentials()
+ .setMethod(HttpMethod.POST)
+ .setParams("analyzedBefore", currentDateTime)
+ .execute();
+ }
+
SonarScanner newScanner(File baseDir, String... keyValueProperties) {
SonarScanner scannerCli = SonarScanner.create(baseDir, keyValueProperties);
scannerCli.setScannerVersion(artifactVersion().toString());