aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-db-core
diff options
context:
space:
mode:
authorJeremy Davis <jeremy.davis@sonarsource.com>2023-04-04 10:20:33 +0200
committersonartech <sonartech@sonarsource.com>2023-04-11 20:03:15 +0000
commitba00face3dc7fbab07c4526b8035a6f42ce2dc2d (patch)
tree7540208b6b81f7f58501712d760298a05a6b931a /server/sonar-db-core
parent5e6f30d7c4989a683ba0e45fa39ed7dfa3b0252f (diff)
downloadsonarqube-ba00face3dc7fbab07c4526b8035a6f42ce2dc2d.tar.gz
sonarqube-ba00face3dc7fbab07c4526b8035a6f42ce2dc2d.zip
SONAR-19015 Use new log test fixtures in the sonar-plugin-api
Diffstat (limited to 'server/sonar-db-core')
-rw-r--r--server/sonar-db-core/build.gradle1
-rw-r--r--server/sonar-db-core/src/it/java/org/sonar/db/DatabaseUtilsIT.java8
-rw-r--r--server/sonar-db-core/src/test/java/org/sonar/db/DefaultDatabaseTest.java2
-rw-r--r--server/sonar-db-core/src/test/java/org/sonar/db/dialect/H2Test.java6
-rw-r--r--server/sonar-db-core/src/test/java/org/sonar/db/dialect/PostgreSqlTest.java8
-rw-r--r--server/sonar-db-core/src/test/java/org/sonar/db/profiling/ProfiledDataSourceTest.java15
6 files changed, 21 insertions, 19 deletions
diff --git a/server/sonar-db-core/build.gradle b/server/sonar-db-core/build.gradle
index 5413fef01b0..cc70946e9fd 100644
--- a/server/sonar-db-core/build.gradle
+++ b/server/sonar-db-core/build.gradle
@@ -28,6 +28,7 @@ dependencies {
testImplementation 'com.tngtech.java:junit-dataprovider'
testImplementation 'org.mockito:mockito-core'
testImplementation 'org.postgresql:postgresql'
+ testImplementation 'org.sonarsource.api.plugin:sonar-plugin-api-test-fixtures'
testImplementation project(':sonar-testing-harness')
diff --git a/server/sonar-db-core/src/it/java/org/sonar/db/DatabaseUtilsIT.java b/server/sonar-db-core/src/it/java/org/sonar/db/DatabaseUtilsIT.java
index 5fd95eb47e1..91763ab314e 100644
--- a/server/sonar-db-core/src/it/java/org/sonar/db/DatabaseUtilsIT.java
+++ b/server/sonar-db-core/src/it/java/org/sonar/db/DatabaseUtilsIT.java
@@ -36,8 +36,8 @@ import java.util.function.Function;
import javax.annotation.Nullable;
import org.junit.Rule;
import org.junit.Test;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
+import org.slf4j.event.Level;
+import org.sonar.api.testfixtures.log.LogTester;
import org.sonar.api.utils.log.Loggers;
import org.sonar.core.util.stream.MoreCollectors;
import org.sonar.db.dialect.Oracle;
@@ -253,7 +253,7 @@ public class DatabaseUtilsIT {
getDriver(connection);
- assertThat(logTester.logs(LoggerLevel.WARN)).contains("Fail to determine database driver.");
+ assertThat(logTester.logs(Level.WARN)).contains("Fail to determine database driver.");
}
@Test
@@ -394,7 +394,7 @@ public class DatabaseUtilsIT {
log(Loggers.get(getClass()), root);
- assertThat(logTester.logs(LoggerLevel.ERROR)).contains("SQL error: 456. Message: this is next");
+ assertThat(logTester.logs(Level.ERROR)).contains("SQL error: 456. Message: this is next");
}
@Test
diff --git a/server/sonar-db-core/src/test/java/org/sonar/db/DefaultDatabaseTest.java b/server/sonar-db-core/src/test/java/org/sonar/db/DefaultDatabaseTest.java
index 7093513823c..068bc3ee00c 100644
--- a/server/sonar-db-core/src/test/java/org/sonar/db/DefaultDatabaseTest.java
+++ b/server/sonar-db-core/src/test/java/org/sonar/db/DefaultDatabaseTest.java
@@ -28,7 +28,7 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.sonar.api.config.internal.MapSettings;
-import org.sonar.api.utils.log.LogTester;
+import org.sonar.api.testfixtures.log.LogTester;
import org.sonar.db.dialect.PostgreSql;
import org.sonar.process.logging.LogbackHelper;
diff --git a/server/sonar-db-core/src/test/java/org/sonar/db/dialect/H2Test.java b/server/sonar-db-core/src/test/java/org/sonar/db/dialect/H2Test.java
index 75de6af28dc..71ed8ac7693 100644
--- a/server/sonar-db-core/src/test/java/org/sonar/db/dialect/H2Test.java
+++ b/server/sonar-db-core/src/test/java/org/sonar/db/dialect/H2Test.java
@@ -22,8 +22,8 @@ package org.sonar.db.dialect;
import java.sql.DatabaseMetaData;
import org.junit.Rule;
import org.junit.Test;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
+import org.slf4j.event.Level;
+import org.sonar.api.testfixtures.log.LogTester;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
@@ -73,7 +73,7 @@ public class H2Test {
public void init_logs_warning() {
underTest.init(mock(DatabaseMetaData.class));
- assertThat(logs.logs(LoggerLevel.WARN)).contains("H2 database should be used for evaluation purpose only.");
+ assertThat(logs.logs(Level.WARN)).contains("H2 database should be used for evaluation purpose only.");
}
@Test
diff --git a/server/sonar-db-core/src/test/java/org/sonar/db/dialect/PostgreSqlTest.java b/server/sonar-db-core/src/test/java/org/sonar/db/dialect/PostgreSqlTest.java
index e8450a657ff..ac6553a4173 100644
--- a/server/sonar-db-core/src/test/java/org/sonar/db/dialect/PostgreSqlTest.java
+++ b/server/sonar-db-core/src/test/java/org/sonar/db/dialect/PostgreSqlTest.java
@@ -24,9 +24,9 @@ import java.sql.SQLException;
import org.junit.Rule;
import org.junit.Test;
import org.mockito.Mockito;
+import org.slf4j.event.Level;
+import org.sonar.api.testfixtures.log.LogTester;
import org.sonar.api.utils.MessageException;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
@@ -95,7 +95,7 @@ public class PostgreSqlTest {
underTest.init(metadata);
assertThat(underTest.supportsUpsert()).isFalse();
- assertThat(logs.logs(LoggerLevel.WARN)).contains("Upgrading PostgreSQL to 9.5 or greater is recommended for better performances");
+ assertThat(logs.logs(Level.WARN)).contains("Upgrading PostgreSQL to 9.5 or greater is recommended for better performances");
}
@Test
@@ -104,7 +104,7 @@ public class PostgreSqlTest {
underTest.init(metadata);
assertThat(underTest.supportsUpsert()).isTrue();
- assertThat(logs.logs(LoggerLevel.WARN)).isEmpty();
+ assertThat(logs.logs(Level.WARN)).isEmpty();
}
@Test
diff --git a/server/sonar-db-core/src/test/java/org/sonar/db/profiling/ProfiledDataSourceTest.java b/server/sonar-db-core/src/test/java/org/sonar/db/profiling/ProfiledDataSourceTest.java
index d7bac5f94ca..6ac3a99ca8e 100644
--- a/server/sonar-db-core/src/test/java/org/sonar/db/profiling/ProfiledDataSourceTest.java
+++ b/server/sonar-db-core/src/test/java/org/sonar/db/profiling/ProfiledDataSourceTest.java
@@ -34,7 +34,8 @@ import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ThreadFactory;
import org.junit.Rule;
import org.junit.Test;
-import org.sonar.api.utils.log.LogTester;
+import org.slf4j.event.Level;
+import org.sonar.api.testfixtures.log.LogTester;
import org.sonar.api.utils.log.LoggerLevel;
import static java.nio.charset.StandardCharsets.UTF_8;
@@ -70,8 +71,8 @@ public class ProfiledDataSourceTest {
assertThat(statementProxy.getConnection()).isNull();
assertThat(statementProxy.execute(sql)).isTrue();
- assertThat(logTester.logs(LoggerLevel.TRACE)).hasSize(1);
- assertThat(logTester.logs(LoggerLevel.TRACE).get(0))
+ assertThat(logTester.logs(Level.TRACE)).hasSize(1);
+ assertThat(logTester.logs(Level.TRACE).get(0))
.contains("sql=select from dual");
}
@@ -106,8 +107,8 @@ public class ProfiledDataSourceTest {
assertThat(preparedStatementProxy.getConnection()).isNull();
assertThat(preparedStatementProxy.execute()).isTrue();
- assertThat(logTester.logs(LoggerLevel.TRACE)).hasSize(1);
- assertThat(logTester.logs(LoggerLevel.TRACE).get(0))
+ assertThat(logTester.logs(Level.TRACE)).hasSize(1);
+ assertThat(logTester.logs(Level.TRACE).get(0))
.contains("sql=insert into polop (col1, col2, col3, col4) values (?, ?, ?, ?, ?)")
.contains("params=42, plouf");
}
@@ -132,8 +133,8 @@ public class ProfiledDataSourceTest {
assertThat(preparedStatementProxy.getConnection()).isNull();
assertThat(preparedStatementProxy.execute()).isTrue();
- assertThat(logTester.logs(LoggerLevel.TRACE)).hasSize(1);
- assertThat(logTester.logs(LoggerLevel.TRACE).get(0))
+ assertThat(logTester.logs(Level.TRACE)).hasSize(1);
+ assertThat(logTester.logs(Level.TRACE).get(0))
.contains("sql=select from dual")
.doesNotContain("params=");
}