Skip to content

Commit

Permalink
SONARJAVA-3690 Update SonarQube Api to the latest 8.7 version to be c…
Browse files Browse the repository at this point in the history
…ompatible with the latest SQ (#3428)
  • Loading branch information
margarita-nedzelska-sonarsource authored Feb 22, 2021
1 parent 149242d commit 3b1ad17
Show file tree
Hide file tree
Showing 34 changed files with 142 additions and 138 deletions.
5 changes: 5 additions & 0 deletions external-reports/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
<artifactId>sonar-plugin-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.sonarsource.sonarqube</groupId>
<artifactId>sonar-plugin-api-impl</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.sonarsource.analyzer-commons</groupId>
<artifactId>sonar-analyzer-commons</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import javax.annotation.Nullable;
import org.junit.Rule;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.jupiter.migrationsupport.rules.EnableRuleMigrationSupport;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
Expand All @@ -38,7 +39,7 @@
import org.sonar.api.batch.sensor.issue.ExternalIssue;
import org.sonar.api.rules.RuleType;
import org.sonar.api.server.rule.RulesDefinition;
import org.sonar.api.utils.log.LogTester;
import org.sonar.api.utils.log.LogTesterJUnit5;
import org.sonar.api.utils.log.LoggerLevel;

import static org.assertj.core.api.Assertions.assertThat;
Expand All @@ -55,8 +56,8 @@ class CheckstyleSensorTest {
@Rule
public final TemporaryFolder tmp = new TemporaryFolder();

@Rule
public LogTester logTester = new LogTester();
@RegisterExtension
public LogTesterJUnit5 logTester = new LogTesterJUnit5();

@Test
void checkstyle_rules_definition() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.batch.fs.internal.TestInputFileBuilder;
import org.sonar.api.batch.sensor.internal.SensorContextTester;
import org.sonar.api.utils.log.LogTester;
import org.sonar.api.utils.log.LogTesterJUnit5;
import org.sonar.api.utils.log.LoggerLevel;

import static java.nio.charset.StandardCharsets.UTF_8;
Expand All @@ -42,7 +42,7 @@ private ExternalReportTestUtils() {
}


public static void assertNoErrorWarnDebugLogs(LogTester logTester) {
public static void assertNoErrorWarnDebugLogs(LogTesterJUnit5 logTester) {
assertThat(logTester.logs(LoggerLevel.ERROR)).isEmpty();
assertThat(logTester.logs(LoggerLevel.WARN)).isEmpty();
assertThat(logTester.logs(LoggerLevel.DEBUG)).isEmpty();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Nullable;
import org.junit.Rule;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.jupiter.migrationsupport.rules.EnableRuleMigrationSupport;
import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.batch.fs.TextRange;
Expand All @@ -41,23 +41,22 @@
import org.sonar.api.config.internal.MapSettings;
import org.sonar.api.rules.RuleType;
import org.sonar.api.server.rule.RulesDefinition;
import org.sonar.api.utils.log.LogTester;
import org.sonar.api.utils.log.LogTesterJUnit5;
import org.sonar.api.utils.log.LoggerLevel;

import static java.nio.charset.StandardCharsets.UTF_8;
import static org.assertj.core.api.Assertions.assertThat;
import static org.sonar.java.externalreport.ExternalReportTestUtils.onlyOneLogElement;

@EnableRuleMigrationSupport
class PmdSensorTest {

private static final Path PROJECT_DIR = Paths.get("src", "test", "resources", "pmd");
private static final String PROJECT_ID = "pmd-test";

private static final PmdSensor sensor = new PmdSensor();

@Rule
public LogTester logTester = new LogTester();
@RegisterExtension
public LogTesterJUnit5 logTester = new LogTesterJUnit5();

@Test
void test_descriptor() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import javax.annotation.Nullable;
import org.junit.Rule;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.jupiter.migrationsupport.rules.EnableRuleMigrationSupport;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
Expand All @@ -38,7 +39,7 @@
import org.sonar.api.batch.sensor.issue.ExternalIssue;
import org.sonar.api.rules.RuleType;
import org.sonar.api.server.rule.RulesDefinition;
import org.sonar.api.utils.log.LogTester;
import org.sonar.api.utils.log.LogTesterJUnit5;
import org.sonar.api.utils.log.LoggerLevel;

import static org.assertj.core.api.Assertions.assertThat;
Expand All @@ -56,8 +57,8 @@ class SpotBugsSensorTest {
@Rule
public final TemporaryFolder tmp = new TemporaryFolder();

@Rule
public LogTester logTester = new LogTester();
@RegisterExtension
public LogTesterJUnit5 logTester = new LogTesterJUnit5();

@Test
void spotbugs_rules_definition() {
Expand Down
5 changes: 5 additions & 0 deletions its/plugin/plugins/java-extension-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
<version>${sonar.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.sonarsource.sonarqube</groupId>
<artifactId>sonar-plugin-api-impl</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.sonarsource.java</groupId>
Expand Down
4 changes: 4 additions & 0 deletions java-checks-testkit/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@
<groupId>org.sonarsource.sonarqube</groupId>
<artifactId>sonar-plugin-api</artifactId>
</dependency>
<dependency>
<groupId>org.sonarsource.sonarqube</groupId>
<artifactId>sonar-plugin-api-impl</artifactId>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,8 @@
import java.util.stream.Collectors;
import org.assertj.core.api.Fail;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.migrationsupport.rules.EnableRuleMigrationSupport;
import org.sonar.api.batch.fs.internal.DefaultInputFile;
import org.sonar.api.batch.fs.internal.TestInputFileBuilder;
import org.sonar.api.utils.log.LogTester;
import org.sonar.api.utils.log.LoggerLevel;
import org.sonar.check.Rule;
import org.sonar.java.AnalyzerMessage;
import org.sonar.java.RspecKey;
Expand All @@ -48,12 +45,8 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.catchThrowable;

@EnableRuleMigrationSupport
class JavaCheckVerifierTest {

@org.junit.Rule
public LogTester logTester = new LogTester().setLevel(LoggerLevel.INFO);

private static final String FILENAME_ISSUES = "src/test/files/JavaCheckVerifier.java";
private static final String FILENAME_NO_ISSUE = "src/test/files/JavaCheckVerifierNoIssue.java";
private static final String FILENAME_PARSING_ISSUE = "src/test/files/JavaCheckVerifierParsingIssue.java";
Expand Down
5 changes: 5 additions & 0 deletions java-checks/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
<groupId>org.sonarsource.sonarqube</groupId>
<artifactId>sonar-plugin-api</artifactId>
</dependency>
<dependency>
<groupId>org.sonarsource.sonarqube</groupId>
<artifactId>sonar-plugin-api-impl</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>java-frontend</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@
import java.util.stream.Stream;
import javax.annotation.Nullable;
import org.apache.commons.lang.exception.ExceptionUtils;
import org.junit.Rule;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.migrationsupport.rules.EnableRuleMigrationSupport;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.batch.fs.internal.DefaultFileSystem;
import org.sonar.api.batch.fs.internal.DefaultInputFile;
Expand All @@ -45,7 +44,7 @@
import org.sonar.api.utils.AnnotationUtils;
import org.sonar.api.utils.Version;
import org.sonar.api.utils.log.LogAndArguments;
import org.sonar.api.utils.log.LogTester;
import org.sonar.api.utils.log.LogTesterJUnit5;
import org.sonar.api.utils.log.Logger;
import org.sonar.api.utils.log.LoggerLevel;
import org.sonar.api.utils.log.Loggers;
Expand All @@ -60,13 +59,12 @@
import static org.assertj.core.api.Assertions.fail;
import static org.sonar.java.checks.verifier.TestUtils.testSourcesPath;

@EnableRuleMigrationSupport
class RulesSanityTest {

private static final Logger LOG = Loggers.get(RulesSanityTest.class);

@Rule
public final LogTester logTester = new LogTester();
@RegisterExtension
public final LogTesterJUnit5 logTester = new LogTesterJUnit5();

private static final String TARGET_CLASSES = "target/test-classes";
private static final String TEST_FILES_DIRECTORY = "src/test/files";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,25 @@
*/
package org.sonar.java.checks.tests;

import org.junit.Rule;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.migrationsupport.rules.EnableRuleMigrationSupport;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import org.sonar.api.utils.log.LogTester;
import org.sonar.api.utils.log.LogTesterJUnit5;
import org.sonar.api.utils.log.LoggerLevel;
import org.sonar.java.checks.verifier.JavaCheckVerifier;

import static org.assertj.core.api.Assertions.assertThat;
import static org.sonar.java.checks.verifier.TestUtils.testSourcesPath;
import static org.sonar.java.checks.verifier.TestUtils.nonCompilingTestSourcesPath;
import static org.sonar.java.checks.verifier.TestUtils.testSourcesPath;

@EnableRuleMigrationSupport
class AssertionsInTestsCheckTest {

private AssertionsInTestsCheck check = new AssertionsInTestsCheck();

@Rule
public LogTester logTester = new LogTester();
@RegisterExtension
public LogTesterJUnit5 logTester = new LogTesterJUnit5();

@BeforeEach
void setup() {
Expand Down
5 changes: 5 additions & 0 deletions java-frontend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@
<groupId>org.sonarsource.sonarqube</groupId>
<artifactId>sonar-plugin-api</artifactId>
</dependency>
<dependency>
<groupId>org.sonarsource.sonarqube</groupId>
<artifactId>sonar-plugin-api-impl</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.sonarsource.sslr</groupId>
<artifactId>sslr-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,19 @@
import java.time.Instant;
import java.time.ZoneId;
import java.time.ZoneOffset;
import org.junit.Rule;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.migrationsupport.rules.EnableRuleMigrationSupport;
import org.sonar.api.utils.log.LogTester;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.api.utils.log.LogTesterJUnit5;
import org.sonar.api.utils.log.LoggerLevel;

import static org.assertj.core.api.Assertions.assertThat;

@EnableRuleMigrationSupport
class ExecutionTimeReportTest {

private static final String NL = System.lineSeparator();

@Rule
public LogTester logTester = new LogTester();
@RegisterExtension
public LogTesterJUnit5 logTester = new LogTesterJUnit5();
public UnitTestClock clock = new UnitTestClock();
public ExecutionTimeReport report = new ExecutionTimeReport(clock);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.migrationsupport.rules.EnableRuleMigrationSupport;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.junit.jupiter.MockitoExtension;
Expand All @@ -59,7 +59,7 @@
import org.sonar.api.measures.FileLinesContextFactory;
import org.sonar.api.rule.RuleKey;
import org.sonar.api.utils.Version;
import org.sonar.api.utils.log.LogTester;
import org.sonar.api.utils.log.LogTesterJUnit5;
import org.sonar.api.utils.log.LoggerLevel;
import org.sonar.check.Rule;
import org.sonar.java.classpath.ClasspathForMain;
Expand All @@ -84,7 +84,6 @@
import static org.mockito.Mockito.when;
import static org.sonar.java.TestUtils.computeLineEndOffsets;

@EnableRuleMigrationSupport
@ExtendWith(MockitoExtension.class)
class SonarComponentsTest {

Expand Down Expand Up @@ -431,13 +430,12 @@ class Logging {

private SonarComponents sonarComponents;

@org.junit.Rule
public LogTester logTester = new LogTester();
@RegisterExtension
public LogTesterJUnit5 logTester = new LogTesterJUnit5();

@BeforeEach
void beforeEach() {
sonarComponents = new SonarComponents(null, fs, javaClasspath, javaTestClasspath, null);
logTester.clear();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,16 @@
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import org.junit.Rule;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.migrationsupport.rules.EnableRuleMigrationSupport;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.mockito.Mockito;
import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.batch.fs.internal.DefaultFileSystem;
import org.sonar.api.batch.sensor.internal.SensorContextTester;
import org.sonar.api.config.internal.MapSettings;
import org.sonar.api.issue.NoSonarFilter;
import org.sonar.api.utils.log.LogTester;
import org.sonar.api.utils.log.LogTesterJUnit5;
import org.sonar.api.utils.log.LoggerLevel;
import org.sonar.java.AnalysisException;
import org.sonar.java.ExceptionHandler;
Expand All @@ -61,11 +60,10 @@
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.when;

@EnableRuleMigrationSupport
class JavaAstScannerTest {

@Rule
public LogTester logTester = new LogTester();
@RegisterExtension
public LogTesterJUnit5 logTester = new LogTesterJUnit5();
private SensorContextTester context;

@BeforeEach
Expand Down
Loading

0 comments on commit 3b1ad17

Please sign in to comment.