aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre <pierre.guillot@sonarsource.com>2020-12-07 17:47:23 +0100
committersonartech <sonartech@sonarsource.com>2020-12-09 20:07:20 +0000
commit5f1b82343cb99caae29ce07f316b3b6b556c8b33 (patch)
treef381d643bb81f1644ee832edd45a532f9867f211
parent2cd3d3d4d3818df1f6c4e3ecc7b89e42ed68fc77 (diff)
downloadsonarqube-5f1b82343cb99caae29ce07f316b3b6b556c8b33.tar.gz
sonarqube-5f1b82343cb99caae29ce07f316b3b6b556c8b33.zip
fix multiple checked exceptions assertions on overall code
-rw-r--r--server/sonar-db-core/src/test/java/org/sonar/db/profiling/InvocationUtilsTest.java18
1 files changed, 6 insertions, 12 deletions
diff --git a/server/sonar-db-core/src/test/java/org/sonar/db/profiling/InvocationUtilsTest.java b/server/sonar-db-core/src/test/java/org/sonar/db/profiling/InvocationUtilsTest.java
index 45bf5a1f0e1..a7d139023e7 100644
--- a/server/sonar-db-core/src/test/java/org/sonar/db/profiling/InvocationUtilsTest.java
+++ b/server/sonar-db-core/src/test/java/org/sonar/db/profiling/InvocationUtilsTest.java
@@ -19,8 +19,10 @@
*/
package org.sonar.db.profiling;
+import java.lang.reflect.Method;
import java.sql.Connection;
import java.sql.SQLException;
+import org.junit.Assert;
import org.junit.Test;
import org.sonar.test.TestUtils;
@@ -45,13 +47,9 @@ public class InvocationUtilsTest {
Connection target = mock(Connection.class);
String failSql = "any sql";
when(target.prepareStatement(failSql)).thenThrow(new SQLException("Expected"));
+ Method prepareStatement = Connection.class.getMethod("prepareStatement", String.class);
- try {
- InvocationUtils.invokeQuietly(target, Connection.class.getMethod("prepareStatement", String.class), new Object[] {failSql});
- fail();
- } catch (Throwable t) {
- assertThat(t).isInstanceOf(SQLException.class);
- }
+ Assert.assertThrows(SQLException.class, () -> InvocationUtils.invokeQuietly(target, prepareStatement, new Object[] {failSql}));
}
@Test
@@ -59,13 +57,9 @@ public class InvocationUtilsTest {
Connection target = mock(Connection.class);
String failSql = "any sql";
when(target.prepareStatement(failSql)).thenThrow(new SQLException("Expected"));
+ Method wait = Object.class.getMethod("wait");
- try {
- InvocationUtils.invokeQuietly(target, Object.class.getMethod("wait"), new Object[0]);
- fail();
- } catch (Throwable t) {
- assertThat(t).isInstanceOf(IllegalStateException.class);
- }
+ Assert.assertThrows(IllegalStateException.class, () -> InvocationUtils.invokeQuietly(target, wait, new Object[0]));
}
@Test