diff options
author | Klaudio Sinani <klaudio.sinani@sonarsource.com> | 2021-11-17 22:54:06 +0100 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2021-11-19 20:03:27 +0000 |
commit | a3d88ea27c35921647d7602755828ca73e15e865 (patch) | |
tree | 5626c38afab1ea00ab9897da431476c17b478bbe /server/sonar-main/src/test | |
parent | 92f482f2aa43e4aa36e0fda377d13b9dc3282ff9 (diff) | |
download | sonarqube-a3d88ea27c35921647d7602755828ca73e15e865.tar.gz sonarqube-a3d88ea27c35921647d7602755828ca73e15e865.zip |
SONAR-15631 - Refactor UTs to stop using ExpectedException
Diffstat (limited to 'server/sonar-main/src/test')
18 files changed, 168 insertions, 249 deletions
diff --git a/server/sonar-main/src/test/java/org/sonar/application/AppFileSystemTest.java b/server/sonar-main/src/test/java/org/sonar/application/AppFileSystemTest.java index b4c69fdfa56..d432962458d 100644 --- a/server/sonar-main/src/test/java/org/sonar/application/AppFileSystemTest.java +++ b/server/sonar-main/src/test/java/org/sonar/application/AppFileSystemTest.java @@ -30,12 +30,12 @@ import org.apache.commons.io.FileUtils; import org.junit.Before; import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.junit.rules.TemporaryFolder; import org.sonar.application.config.TestAppSettings; import org.sonar.process.sharedmemoryfile.AllProcessesCommands; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.sonar.process.ProcessProperties.Property.PATH_DATA; import static org.sonar.process.ProcessProperties.Property.PATH_HOME; import static org.sonar.process.ProcessProperties.Property.PATH_LOGS; @@ -47,8 +47,6 @@ public class AppFileSystemTest { @Rule public TemporaryFolder temp = new TemporaryFolder(); - @Rule - public ExpectedException expectedException = ExpectedException.none(); private File homeDir; private File dataDir; @@ -179,10 +177,9 @@ public class AppFileSystemTest { assertThat(file.createNewFile()).isTrue(); settings.getProps().set(property, file.getAbsolutePath()); - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Property '" + property + "' is not valid, not a directory: " + file.getAbsolutePath()); - - underTest.reset(); + assertThatThrownBy(() -> underTest.reset()) + .isInstanceOf(IllegalStateException.class) + .hasMessage("Property '" + property + "' is not valid, not a directory: " + file.getAbsolutePath()); } @Test @@ -192,10 +189,9 @@ public class AppFileSystemTest { FileUtils.forceMkdir(logsDir); FileUtils.touch(dataDir); - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Property 'sonar.path.data' is not valid, not a directory: " + dataDir.getAbsolutePath()); - - underTest.reset(); + assertThatThrownBy(() -> underTest.reset()) + .isInstanceOf(IllegalStateException.class) + .hasMessage("Property 'sonar.path.data' is not valid, not a directory: " + dataDir.getAbsolutePath()); } } diff --git a/server/sonar-main/src/test/java/org/sonar/application/AppLoggingTest.java b/server/sonar-main/src/test/java/org/sonar/application/AppLoggingTest.java index 9da2b90899c..1e153ea4be0 100644 --- a/server/sonar-main/src/test/java/org/sonar/application/AppLoggingTest.java +++ b/server/sonar-main/src/test/java/org/sonar/application/AppLoggingTest.java @@ -36,7 +36,6 @@ import org.junit.AfterClass; import org.junit.Before; import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.junit.rules.TemporaryFolder; import org.slf4j.LoggerFactory; import org.sonar.application.config.AppSettings; @@ -46,6 +45,7 @@ import org.sonar.process.logging.LogbackJsonLayout; import org.sonar.process.logging.PatternLayoutEncoder; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.slf4j.Logger.ROOT_LOGGER_NAME; import static org.sonar.application.process.StreamGobbler.LOGGER_GOBBLER; import static org.sonar.process.ProcessProperties.Property.CLUSTER_ENABLED; @@ -55,8 +55,6 @@ public class AppLoggingTest { @Rule public TemporaryFolder temp = new TemporaryFolder(); - @Rule - public ExpectedException expectedException = ExpectedException.none(); private File logDir; @@ -232,20 +230,18 @@ public class AppLoggingTest { public void fail_with_IAE_if_global_property_unsupported_level() { settings.getProps().set("sonar.log.level", "ERROR"); - expectedException.expect(IllegalArgumentException.class); - expectedException.expectMessage("log level ERROR in property sonar.log.level is not a supported value (allowed levels are [TRACE, DEBUG, INFO])"); - - underTest.configure(); + assertThatThrownBy(() -> underTest.configure()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessage("log level ERROR in property sonar.log.level is not a supported value (allowed levels are [TRACE, DEBUG, INFO])"); } @Test public void fail_with_IAE_if_app_property_unsupported_level() { settings.getProps().set("sonar.log.level.app", "ERROR"); - expectedException.expect(IllegalArgumentException.class); - expectedException.expectMessage("log level ERROR in property sonar.log.level.app is not a supported value (allowed levels are [TRACE, DEBUG, INFO])"); - - underTest.configure(); + assertThatThrownBy(() -> underTest.configure()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessage("log level ERROR in property sonar.log.level.app is not a supported value (allowed levels are [TRACE, DEBUG, INFO])"); } @Test diff --git a/server/sonar-main/src/test/java/org/sonar/application/AppReloaderImplTest.java b/server/sonar-main/src/test/java/org/sonar/application/AppReloaderImplTest.java index ecab4a40801..6c15a43240f 100644 --- a/server/sonar-main/src/test/java/org/sonar/application/AppReloaderImplTest.java +++ b/server/sonar-main/src/test/java/org/sonar/application/AppReloaderImplTest.java @@ -21,15 +21,14 @@ package org.sonar.application; import com.google.common.collect.ImmutableMap; import java.io.IOException; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.sonar.application.config.AppSettings; import org.sonar.application.config.AppSettingsLoader; import org.sonar.application.config.TestAppSettings; import org.sonar.process.MessageException; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.assertj.core.data.MapEntry.entry; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; @@ -43,8 +42,6 @@ import static org.sonar.process.ProcessProperties.Property.PATH_WEB; public class AppReloaderImplTest { - @Rule - public ExpectedException expectedException = ExpectedException.none(); private final AppSettingsLoader settingsLoader = mock(AppSettingsLoader.class); private final FileSystem fs = mock(FileSystem.class); @@ -72,14 +69,15 @@ public class AppReloaderImplTest { public void throw_ISE_if_cluster_is_enabled() throws IOException { AppSettings settings = new TestAppSettings(ImmutableMap.of(CLUSTER_ENABLED.getKey(), "true")); - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Restart is not possible with cluster mode"); + assertThatThrownBy(() -> { + underTest.reload(settings); - underTest.reload(settings); - - verifyZeroInteractions(logging); - verifyZeroInteractions(state); - verifyZeroInteractions(fs); + verifyZeroInteractions(logging); + verifyZeroInteractions(state); + verifyZeroInteractions(fs); + }) + .isInstanceOf(IllegalStateException.class) + .hasMessage("Restart is not possible with cluster mode"); } @Test @@ -100,13 +98,14 @@ public class AppReloaderImplTest { AppSettings newSettings = new TestAppSettings(ImmutableMap.of(propertyKey, "val2")); when(settingsLoader.load()).thenReturn(newSettings); - expectedException.expect(MessageException.class); - expectedException.expectMessage("Property [" + propertyKey + "] cannot be changed on restart: [val1] => [val2]"); - - underTest.reload(settings); + assertThatThrownBy(() -> { + underTest.reload(settings); - verifyZeroInteractions(logging); - verifyZeroInteractions(state); - verifyZeroInteractions(fs); + verifyZeroInteractions(logging); + verifyZeroInteractions(state); + verifyZeroInteractions(fs); + }) + .isInstanceOf(MessageException.class) + .hasMessage("Property [" + propertyKey + "] cannot be changed on restart: [val1] => [val2]"); } } diff --git a/server/sonar-main/src/test/java/org/sonar/application/SchedulerImplTest.java b/server/sonar-main/src/test/java/org/sonar/application/SchedulerImplTest.java index 34600dc7bdc..0d71b51b67f 100644 --- a/server/sonar-main/src/test/java/org/sonar/application/SchedulerImplTest.java +++ b/server/sonar-main/src/test/java/org/sonar/application/SchedulerImplTest.java @@ -28,7 +28,6 @@ import java.io.InputStream; import java.util.ArrayList; import java.util.EnumMap; import java.util.List; -import java.util.Properties; import java.util.Random; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; @@ -37,7 +36,6 @@ import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.DisableOnDebug; -import org.junit.rules.ExpectedException; import org.junit.rules.TemporaryFolder; import org.junit.rules.TestRule; import org.junit.rules.Timeout; @@ -73,8 +71,6 @@ public class SchedulerImplTest { @Rule public TestRule safeguardTimeout = new DisableOnDebug(Timeout.seconds(60)); @Rule - public ExpectedException expectedException = ExpectedException.none(); - @Rule public TemporaryFolder temporaryFolder = new TemporaryFolder(); private Level initialLevel; diff --git a/server/sonar-main/src/test/java/org/sonar/application/cluster/AppNodesClusterHostsConsistencyTest.java b/server/sonar-main/src/test/java/org/sonar/application/cluster/AppNodesClusterHostsConsistencyTest.java index 0107499267a..42a8c2e6332 100644 --- a/server/sonar-main/src/test/java/org/sonar/application/cluster/AppNodesClusterHostsConsistencyTest.java +++ b/server/sonar-main/src/test/java/org/sonar/application/cluster/AppNodesClusterHostsConsistencyTest.java @@ -38,15 +38,14 @@ import java.util.concurrent.locks.Lock; import java.util.function.Consumer; import org.junit.After; import org.junit.Before; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.sonar.application.config.TestAppSettings; import org.sonar.process.cluster.hz.DistributedAnswer; import org.sonar.process.cluster.hz.DistributedCall; import org.sonar.process.cluster.hz.DistributedCallback; import org.sonar.process.cluster.hz.HazelcastMember; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; @@ -54,8 +53,6 @@ import static org.mockito.Mockito.when; import static org.sonar.process.ProcessProperties.Property.CLUSTER_HZ_HOSTS; public class AppNodesClusterHostsConsistencyTest { - @Rule - public ExpectedException expectedException = ExpectedException.none(); @SuppressWarnings("unchecked") private final Consumer<String> logger = mock(Consumer.class); @@ -115,10 +112,9 @@ public class AppNodesClusterHostsConsistencyTest { TestAppSettings settings = new TestAppSettings(); AppNodesClusterHostsConsistency.setInstance(member, settings); - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Instance is already set"); - - AppNodesClusterHostsConsistency.setInstance(member, settings); + assertThatThrownBy(() -> AppNodesClusterHostsConsistency.setInstance(member, settings)) + .isInstanceOf(IllegalStateException.class) + .hasMessage("Instance is already set"); } @Test @@ -127,10 +123,9 @@ public class AppNodesClusterHostsConsistencyTest { TestHazelcastMember member2 = new TestHazelcastMember(Collections.emptyMap(), newLocalHostMember(2, true)); AppNodesClusterHostsConsistency.setInstance(member1, new TestAppSettings()); - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Instance is already set"); - - AppNodesClusterHostsConsistency.setInstance(member2, new TestAppSettings()); + assertThatThrownBy(() -> AppNodesClusterHostsConsistency.setInstance(member2, new TestAppSettings())) + .isInstanceOf(IllegalStateException.class) + .hasMessage("Instance is already set"); } private Member newLocalHostMember(int port) throws UnknownHostException { diff --git a/server/sonar-main/src/test/java/org/sonar/application/cluster/health/SearchNodeHealthProviderTest.java b/server/sonar-main/src/test/java/org/sonar/application/cluster/health/SearchNodeHealthProviderTest.java index 681bd2769a7..8e6fa5c55b8 100644 --- a/server/sonar-main/src/test/java/org/sonar/application/cluster/health/SearchNodeHealthProviderTest.java +++ b/server/sonar-main/src/test/java/org/sonar/application/cluster/health/SearchNodeHealthProviderTest.java @@ -22,9 +22,7 @@ package org.sonar.application.cluster.health; import java.util.Properties; import java.util.Random; import javax.annotation.Nullable; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.sonar.application.cluster.ClusterAppState; import org.sonar.process.NetworkUtils; import org.sonar.process.ProcessId; @@ -34,16 +32,15 @@ import org.sonar.process.cluster.health.NodeHealth; import static java.lang.String.valueOf; import static org.apache.commons.lang.RandomStringUtils.randomAlphabetic; import static org.apache.commons.lang.RandomStringUtils.randomAlphanumeric; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import static org.sonar.process.ProcessProperties.Property.CLUSTER_NODE_HOST; -import static org.sonar.process.ProcessProperties.Property.CLUSTER_NODE_NAME; import static org.sonar.process.ProcessProperties.Property.CLUSTER_NODE_HZ_PORT; +import static org.sonar.process.ProcessProperties.Property.CLUSTER_NODE_NAME; public class SearchNodeHealthProviderTest { - @Rule - public ExpectedException expectedException = ExpectedException.none(); private final Random random = new Random(); private SearchNodeHealthProvider.Clock clock = mock(SearchNodeHealthProvider.Clock.class); @@ -54,10 +51,9 @@ public class SearchNodeHealthProviderTest { public void constructor_throws_IAE_if_property_node_name_is_not_set() { Props props = new Props(new Properties()); - expectedException.expect(IllegalArgumentException.class); - expectedException.expectMessage("Missing property: sonar.cluster.node.name"); - - new SearchNodeHealthProvider(props, clusterAppState, networkUtils); + assertThatThrownBy(() -> new SearchNodeHealthProvider(props, clusterAppState, networkUtils)) + .isInstanceOf(IllegalArgumentException.class) + .hasMessage("Missing property: sonar.cluster.node.name"); } @Test @@ -66,9 +62,8 @@ public class SearchNodeHealthProviderTest { properties.put(CLUSTER_NODE_NAME.getKey(), randomAlphanumeric(3)); Props props = new Props(properties); - expectedException.expect(NullPointerException.class); - - new SearchNodeHealthProvider(props, clusterAppState, networkUtils, clock); + assertThatThrownBy(() -> new SearchNodeHealthProvider(props, clusterAppState, networkUtils, clock)) + .isInstanceOf(NullPointerException.class); } @Test @@ -78,10 +73,9 @@ public class SearchNodeHealthProviderTest { when(networkUtils.getHostname()).thenReturn(randomAlphanumeric(34)); Props props = new Props(properties); - expectedException.expect(IllegalArgumentException.class); - expectedException.expectMessage("Missing property: sonar.cluster.node.port"); - - new SearchNodeHealthProvider(props, clusterAppState, networkUtils, clock); + assertThatThrownBy(() -> new SearchNodeHealthProvider(props, clusterAppState, networkUtils, clock)) + .isInstanceOf(IllegalArgumentException.class) + .hasMessage("Missing property: sonar.cluster.node.port"); } @Test @@ -93,10 +87,9 @@ public class SearchNodeHealthProviderTest { when(networkUtils.getHostname()).thenReturn(randomAlphanumeric(34)); Props props = new Props(properties); - expectedException.expect(NumberFormatException.class); - expectedException.expectMessage("For input string: \"" + port + "\""); - - new SearchNodeHealthProvider(props, clusterAppState, networkUtils, clock); + assertThatThrownBy(() -> new SearchNodeHealthProvider(props, clusterAppState, networkUtils, clock)) + .isInstanceOf(NumberFormatException.class) + .hasMessage("For input string: \"" + port + "\""); } @Test diff --git a/server/sonar-main/src/test/java/org/sonar/application/command/AbstractCommandTest.java b/server/sonar-main/src/test/java/org/sonar/application/command/AbstractCommandTest.java index be553fc9a67..da6ac85da04 100644 --- a/server/sonar-main/src/test/java/org/sonar/application/command/AbstractCommandTest.java +++ b/server/sonar-main/src/test/java/org/sonar/application/command/AbstractCommandTest.java @@ -28,7 +28,6 @@ import java.util.stream.Collectors; import java.util.stream.IntStream; import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.junit.rules.TemporaryFolder; import org.mockito.Mockito; import org.sonar.process.ProcessId; @@ -36,33 +35,34 @@ import org.sonar.process.System2; import static org.apache.commons.lang.RandomStringUtils.randomAlphanumeric; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.mockito.Mockito.when; public class AbstractCommandTest { @Rule public TemporaryFolder temp = new TemporaryFolder(); - @Rule - public ExpectedException expectedException = ExpectedException.none(); @Test public void constructor_throws_NPE_of_ProcessId_is_null() throws IOException { - expectedException.expect(NullPointerException.class); - expectedException.expectMessage("ProcessId can't be null"); - - new AbstractCommand<AbstractCommand>(null, temp.newFolder(), System2.INSTANCE) { + assertThatThrownBy(() -> { + new AbstractCommand<AbstractCommand>(null, temp.newFolder(), System2.INSTANCE) { - }; + }; + }) + .isInstanceOf(NullPointerException.class) + .hasMessage("ProcessId can't be null"); } @Test public void constructor_throws_NPE_of_workDir_is_null() { - expectedException.expect(NullPointerException.class); - expectedException.expectMessage("workDir can't be null"); - - new AbstractCommand<AbstractCommand>(ProcessId.WEB_SERVER, null, System2.INSTANCE) { + assertThatThrownBy(() -> { + new AbstractCommand<AbstractCommand>(ProcessId.WEB_SERVER, null, System2.INSTANCE) { - }; + }; + }) + .isInstanceOf(NullPointerException.class) + .hasMessage("workDir can't be null"); } @Test @@ -72,10 +72,9 @@ public class AbstractCommandTest { }; - expectedException.expect(NullPointerException.class); - expectedException.expectMessage("key can't be null"); - - underTest.setEnvVariable(null, randomAlphanumeric(30)); + assertThatThrownBy(() -> underTest.setEnvVariable(null, randomAlphanumeric(30))) + .isInstanceOf(NullPointerException.class) + .hasMessage("key can't be null"); } @Test @@ -85,10 +84,9 @@ public class AbstractCommandTest { }; - expectedException.expect(NullPointerException.class); - expectedException.expectMessage("value can't be null"); - - underTest.setEnvVariable(randomAlphanumeric(30), null); + assertThatThrownBy(() -> underTest.setEnvVariable(randomAlphanumeric(30), null)) + .isInstanceOf(NullPointerException.class) + .hasMessage("value can't be null"); } @Test diff --git a/server/sonar-main/src/test/java/org/sonar/application/command/CommandFactoryImplTest.java b/server/sonar-main/src/test/java/org/sonar/application/command/CommandFactoryImplTest.java index 637f472bcdb..d73d9d0b2ec 100644 --- a/server/sonar-main/src/test/java/org/sonar/application/command/CommandFactoryImplTest.java +++ b/server/sonar-main/src/test/java/org/sonar/application/command/CommandFactoryImplTest.java @@ -29,7 +29,6 @@ import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.junit.rules.TemporaryFolder; import org.mockito.Mockito; import org.sonar.application.es.EsInstallation; @@ -41,6 +40,7 @@ import org.sonar.process.Props; import org.sonar.process.System2; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.assertj.core.api.Assertions.entry; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -48,8 +48,6 @@ import static org.mockito.Mockito.when; public class CommandFactoryImplTest { @Rule - public ExpectedException expectedException = ExpectedException.none(); - @Rule public TemporaryFolder temp = new TemporaryFolder(); private System2 system2 = Mockito.mock(System2.class); @@ -111,10 +109,9 @@ public class CommandFactoryImplTest { @Test public void createEsCommand_throws_ISE_if_es_binary_is_not_found() { - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Cannot find elasticsearch binary"); - - newFactory(new Properties()).createEsCommand(); + assertThatThrownBy(() -> newFactory(new Properties()).createEsCommand()) + .isInstanceOf(IllegalStateException.class) + .hasMessage("Cannot find elasticsearch binary"); } @Test diff --git a/server/sonar-main/src/test/java/org/sonar/application/command/EsJvmOptionsTest.java b/server/sonar-main/src/test/java/org/sonar/application/command/EsJvmOptionsTest.java index a4c7c3bcc91..b2d772c39aa 100644 --- a/server/sonar-main/src/test/java/org/sonar/application/command/EsJvmOptionsTest.java +++ b/server/sonar-main/src/test/java/org/sonar/application/command/EsJvmOptionsTest.java @@ -25,21 +25,18 @@ import java.io.IOException; import java.util.Properties; import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.junit.rules.TemporaryFolder; import org.junit.runner.RunWith; import org.sonar.process.Props; -import org.sonar.test.ExceptionCauseMatcher; import static org.apache.commons.lang.RandomStringUtils.randomAlphanumeric; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; @RunWith(DataProviderRunner.class) public class EsJvmOptionsTest { @Rule public TemporaryFolder temporaryFolder = new TemporaryFolder(); - @Rule - public ExpectedException expectedException = ExpectedException.none(); private Properties properties = new Properties(); @@ -162,10 +159,9 @@ public class EsJvmOptionsTest { File notAFile = temporaryFolder.newFolder(); EsJvmOptions underTest = new EsJvmOptions(new Props(properties), temporaryFolder.newFolder()); - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Cannot write Elasticsearch jvm options file"); - expectedException.expectCause(ExceptionCauseMatcher.hasType(IOException.class)); - - underTest.writeToJvmOptionFile(notAFile); + assertThatThrownBy(() -> underTest.writeToJvmOptionFile(notAFile)) + .isInstanceOf(IllegalStateException.class) + .hasMessage("Cannot write Elasticsearch jvm options file") + .hasRootCauseInstanceOf(IOException.class); } } diff --git a/server/sonar-main/src/test/java/org/sonar/application/command/JvmOptionsTest.java b/server/sonar-main/src/test/java/org/sonar/application/command/JvmOptionsTest.java index c045f7d1d7a..8e39f3a9463 100644 --- a/server/sonar-main/src/test/java/org/sonar/application/command/JvmOptionsTest.java +++ b/server/sonar-main/src/test/java/org/sonar/application/command/JvmOptionsTest.java @@ -33,9 +33,8 @@ import java.util.Random; import java.util.stream.Collectors; import java.util.stream.IntStream; import java.util.stream.Stream; -import org.junit.Rule; +import org.assertj.core.api.ThrowableAssert.ThrowingCallable; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.sonar.process.MessageException; import org.sonar.process.Props; @@ -44,12 +43,11 @@ import static java.lang.String.valueOf; import static org.apache.commons.lang.RandomStringUtils.randomAlphabetic; import static org.apache.commons.lang.RandomStringUtils.randomAlphanumeric; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.assertj.core.api.Assertions.fail; @RunWith(DataProviderRunner.class) public class JvmOptionsTest { - @Rule - public ExpectedException expectedException = ExpectedException.none(); private final Random random = new Random(); private final String randomPropertyName = randomAlphanumeric(3); @@ -67,9 +65,7 @@ public class JvmOptionsTest { @Test public void constructor_throws_NPE_if_argument_is_null() { - expectJvmOptionNotNullNPE(); - - new JvmOptions(null); + expectJvmOptionNotNullNPE(() -> new JvmOptions(null)); } @Test @@ -80,10 +76,9 @@ public class JvmOptionsTest { Stream.of(new Option(null, "value"))) .flatMap(s -> s)); - expectedException.expect(NullPointerException.class); - expectedException.expectMessage("JVM option prefix can't be null"); - - new JvmOptions(mandatoryJvmOptions); + assertThatThrownBy(() -> new JvmOptions(mandatoryJvmOptions)) + .isInstanceOf(NullPointerException.class) + .hasMessage("JVM option prefix can't be null"); } @Test @@ -95,10 +90,9 @@ public class JvmOptionsTest { Stream.of(new Option(emptyString, "value"))) .flatMap(s -> s)); - expectedException.expect(IllegalArgumentException.class); - expectedException.expectMessage("JVM option prefix can't be empty"); - - new JvmOptions(mandatoryJvmOptions); + assertThatThrownBy(() -> new JvmOptions(mandatoryJvmOptions)) + .isInstanceOf(IllegalArgumentException.class) + .hasMessage("JVM option prefix can't be empty"); } @Test @@ -110,9 +104,7 @@ public class JvmOptionsTest { Stream.of(new Option(invalidPrefix, "value"))) .flatMap(s -> s)); - expectJvmOptionNotEmptyAndStartByDashIAE(); - - new JvmOptions(mandatoryJvmOptions); + expectJvmOptionNotEmptyAndStartByDashIAE(() -> new JvmOptions(mandatoryJvmOptions)); } @Test @@ -123,10 +115,9 @@ public class JvmOptionsTest { Stream.of(new Option("-prefix", null))) .flatMap(s -> s)); - expectedException.expect(NullPointerException.class); - expectedException.expectMessage("JVM option value can't be null"); - - new JvmOptions(mandatoryJvmOptions); + assertThatThrownBy(() -> new JvmOptions(mandatoryJvmOptions)) + .isInstanceOf(NullPointerException.class) + .hasMessage("JVM option value can't be null"); } @Test @@ -143,24 +134,19 @@ public class JvmOptionsTest { @Test public void add_throws_NPE_if_argument_is_null() { - expectJvmOptionNotNullNPE(); - - underTest.add(null); + expectJvmOptionNotNullNPE(() -> underTest.add(null)); } @Test @UseDataProvider("variousEmptyStrings") public void add_throws_IAE_if_argument_is_empty(String emptyString) { - expectJvmOptionNotEmptyAndStartByDashIAE(); - - underTest.add(emptyString); + expectJvmOptionNotEmptyAndStartByDashIAE(() -> underTest.add(emptyString)); } @Test public void add_throws_IAE_if_argument_does_not_start_with_dash() { - expectJvmOptionNotEmptyAndStartByDashIAE(); + expectJvmOptionNotEmptyAndStartByDashIAE(() -> underTest.add(randomAlphanumeric(3))); - underTest.add(randomAlphanumeric(3)); } @Test @@ -227,16 +213,12 @@ public class JvmOptionsTest { @Test public void addFromMandatoryProperty_fails_with_IAE_if_property_does_not_exist() { - expectMissingPropertyIAE(this.randomPropertyName); - - underTest.addFromMandatoryProperty(new Props(properties), this.randomPropertyName); + expectMissingPropertyIAE(() -> underTest.addFromMandatoryProperty(new Props(properties), this.randomPropertyName), this.randomPropertyName); } @Test public void addFromMandatoryProperty_fails_with_IAE_if_property_contains_an_empty_value() { - expectMissingPropertyIAE(this.randomPropertyName); - - underTest.addFromMandatoryProperty(new Props(properties), randomPropertyName); + expectMissingPropertyIAE(() -> underTest.addFromMandatoryProperty(new Props(properties), randomPropertyName), this.randomPropertyName); } @Test @@ -254,9 +236,7 @@ public class JvmOptionsTest { public void addFromMandatoryProperty_fails_with_MessageException_if_property_does_not_start_with_dash_after_trimmed(String emptyString) { properties.put(randomPropertyName, emptyString + "foo -bar"); - expectJvmOptionNotEmptyAndStartByDashMessageException(randomPropertyName, "foo"); - - underTest.addFromMandatoryProperty(new Props(properties), randomPropertyName); + expectJvmOptionNotEmptyAndStartByDashMessageException(() -> underTest.addFromMandatoryProperty(new Props(properties), randomPropertyName), randomPropertyName, "foo"); } @Test @@ -337,12 +317,11 @@ public class JvmOptionsTest { JvmOptions underTest = new JvmOptions(ImmutableMap.of(randomPrefix, randomValue)); - expectedException.expect(MessageException.class); - expectedException.expectMessage("a JVM option can't overwrite mandatory JVM options. " + - "The following JVM options defined by property '" + randomPropertyName + "' are invalid: " + - overriding1 + " overwrites " + randomPrefix + randomValue + ", " + overriding2 + " overwrites " + randomPrefix + randomValue); - - underTest.addFromMandatoryProperty(new Props(properties), randomPropertyName); + assertThatThrownBy(() -> underTest.addFromMandatoryProperty(new Props(properties), randomPropertyName)) + .isInstanceOf(MessageException.class) + .hasMessage("a JVM option can't overwrite mandatory JVM options. " + + "The following JVM options defined by property '" + randomPropertyName + "' are invalid: " + + overriding1 + " overwrites " + randomPrefix + randomValue + ", " + overriding2 + " overwrites " + randomPrefix + randomValue); } @Test @@ -362,25 +341,29 @@ public class JvmOptionsTest { assertThat(underTest.toString()).isEqualTo("[-foo, -bar]"); } - private void expectJvmOptionNotNullNPE() { - expectedException.expect(NullPointerException.class); - expectedException.expectMessage("a JVM option can't be null"); + private void expectJvmOptionNotNullNPE(ThrowingCallable callback) { + assertThatThrownBy(callback) + .isInstanceOf(NullPointerException.class) + .hasMessage("a JVM option can't be null"); } - private void expectJvmOptionNotEmptyAndStartByDashIAE() { - expectedException.expect(IllegalArgumentException.class); - expectedException.expectMessage("a JVM option can't be empty and must start with '-'"); + private void expectJvmOptionNotEmptyAndStartByDashIAE(ThrowingCallable callback) { + assertThatThrownBy(callback) + .isInstanceOf(IllegalArgumentException.class) + .hasMessage("a JVM option can't be empty and must start with '-'"); } - private void expectJvmOptionNotEmptyAndStartByDashMessageException(String randomPropertyName, String option) { - expectedException.expect(MessageException.class); - expectedException.expectMessage("a JVM option can't be empty and must start with '-'. " + - "The following JVM options defined by property '" + randomPropertyName + "' are invalid: " + option); + private void expectJvmOptionNotEmptyAndStartByDashMessageException(ThrowingCallable callback, String randomPropertyName, String option) { + assertThatThrownBy(callback) + .isInstanceOf(MessageException.class) + .hasMessage("a JVM option can't be empty and must start with '-'. " + + "The following JVM options defined by property '" + randomPropertyName + "' are invalid: " + option); } - public void expectMissingPropertyIAE(String randomPropertyName) { - expectedException.expect(IllegalArgumentException.class); - expectedException.expectMessage("Missing property: " + randomPropertyName); + public void expectMissingPropertyIAE(ThrowingCallable callback, String randomPropertyName) { + assertThatThrownBy(callback) + .isInstanceOf(IllegalArgumentException.class) + .hasMessage("Missing property: " + randomPropertyName); } @DataProvider() diff --git a/server/sonar-main/src/test/java/org/sonar/application/config/AppSettingsLoaderImplTest.java b/server/sonar-main/src/test/java/org/sonar/application/config/AppSettingsLoaderImplTest.java index 25be8bab784..0a6a756f232 100644 --- a/server/sonar-main/src/test/java/org/sonar/application/config/AppSettingsLoaderImplTest.java +++ b/server/sonar-main/src/test/java/org/sonar/application/config/AppSettingsLoaderImplTest.java @@ -27,13 +27,13 @@ import org.apache.commons.io.FileUtils; import org.junit.Before; import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.junit.rules.TemporaryFolder; import org.sonar.core.extension.ServiceLoaderWrapper; import org.sonar.process.System2; import static java.nio.charset.StandardCharsets.UTF_8; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.assertj.core.data.MapEntry.entry; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -41,8 +41,6 @@ import static org.mockito.Mockito.when; public class AppSettingsLoaderImplTest { @Rule - public ExpectedException expectedException = ExpectedException.none(); - @Rule public TemporaryFolder temp = new TemporaryFolder(); private ServiceLoaderWrapper serviceLoaderWrapper = mock(ServiceLoaderWrapper.class); @@ -115,10 +113,9 @@ public class AppSettingsLoaderImplTest { FileUtils.forceMkdir(propsFileAsDir); AppSettingsLoaderImpl underTest = new AppSettingsLoaderImpl(system, new String[0], homeDir, serviceLoaderWrapper); - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Cannot open file " + propsFileAsDir.getAbsolutePath()); - - underTest.load(); + assertThatThrownBy(() -> underTest.load()) + .isInstanceOf(IllegalStateException.class) + .hasMessage("Cannot open file " + propsFileAsDir.getAbsolutePath()); } @Test diff --git a/server/sonar-main/src/test/java/org/sonar/application/config/CommandLineParserTest.java b/server/sonar-main/src/test/java/org/sonar/application/config/CommandLineParserTest.java index 0b2dbfa9e1b..5995ed90606 100644 --- a/server/sonar-main/src/test/java/org/sonar/application/config/CommandLineParserTest.java +++ b/server/sonar-main/src/test/java/org/sonar/application/config/CommandLineParserTest.java @@ -20,17 +20,12 @@ package org.sonar.application.config; import java.util.Properties; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; public class CommandLineParserTest { - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - @Test public void parseArguments() { System.setProperty("CommandLineParserTest.unused", "unused"); @@ -53,9 +48,8 @@ public class CommandLineParserTest { assertThat(p.getProperty("sonar.foo")).isEqualTo("bar"); assertThat(p.getProperty("sonar.whitespace")).isEqualTo("foo bar"); - expectedException.expect(IllegalArgumentException.class); - expectedException.expectMessage("Command-line argument must start with -D, for example -Dsonar.jdbc.username=sonar. Got: sonar.bad=true"); - - CommandLineParser.argumentsToProperties(new String[] {"-Dsonar.foo=bar", "sonar.bad=true"}); + assertThatThrownBy(() -> CommandLineParser.argumentsToProperties(new String[] {"-Dsonar.foo=bar", "sonar.bad=true"})) + .isInstanceOf(IllegalArgumentException.class) + .hasMessage("Command-line argument must start with -D, for example -Dsonar.jdbc.username=sonar. Got: sonar.bad=true"); } } diff --git a/server/sonar-main/src/test/java/org/sonar/application/config/FileSystemSettingsTest.java b/server/sonar-main/src/test/java/org/sonar/application/config/FileSystemSettingsTest.java index 06de61a000e..95cfbe80344 100644 --- a/server/sonar-main/src/test/java/org/sonar/application/config/FileSystemSettingsTest.java +++ b/server/sonar-main/src/test/java/org/sonar/application/config/FileSystemSettingsTest.java @@ -24,7 +24,6 @@ import java.util.Properties; import org.junit.Before; import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.junit.rules.TemporaryFolder; import org.sonar.process.Props; @@ -39,8 +38,6 @@ public class FileSystemSettingsTest { @Rule public TemporaryFolder temp = new TemporaryFolder(); - @Rule - public ExpectedException expectedException = ExpectedException.none(); private FileSystemSettings underTest = new FileSystemSettings(); private File homeDir; diff --git a/server/sonar-main/src/test/java/org/sonar/application/config/JdbcSettingsTest.java b/server/sonar-main/src/test/java/org/sonar/application/config/JdbcSettingsTest.java index e7fabff08ca..64b8b3f98c7 100644 --- a/server/sonar-main/src/test/java/org/sonar/application/config/JdbcSettingsTest.java +++ b/server/sonar-main/src/test/java/org/sonar/application/config/JdbcSettingsTest.java @@ -26,12 +26,12 @@ import org.apache.commons.io.FileUtils; import org.junit.Before; import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.junit.rules.TemporaryFolder; import org.sonar.process.MessageException; import org.sonar.process.Props; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.sonar.application.config.JdbcSettings.Provider; import static org.sonar.process.ProcessProperties.Property.JDBC_DRIVER_PATH; import static org.sonar.process.ProcessProperties.Property.JDBC_URL; @@ -40,8 +40,6 @@ import static org.sonar.process.ProcessProperties.Property.PATH_HOME; public class JdbcSettingsTest { @Rule - public ExpectedException expectedException = ExpectedException.none(); - @Rule public TemporaryFolder temp = new TemporaryFolder(); private JdbcSettings underTest = new JdbcSettings(); @@ -92,20 +90,18 @@ public class JdbcSettingsTest { public void fail_with_MessageException_when_provider_is_not_supported() { Props props = newProps(JDBC_URL.getKey(), "jdbc:microsoft:sqlserver://localhost"); - expectedException.expect(MessageException.class); - expectedException.expectMessage("Unsupported JDBC driver provider: microsoft"); - - underTest.resolveProviderAndEnforceNonnullJdbcUrl(props); + assertThatThrownBy(() -> underTest.resolveProviderAndEnforceNonnullJdbcUrl(props)) + .isInstanceOf(MessageException.class) + .hasMessage("Unsupported JDBC driver provider: microsoft"); } @Test public void fail_with_MessageException_when_url_does_not_have_jdbc_prefix() { Props props = newProps(JDBC_URL.getKey(), "oracle:thin:@localhost/XE"); - expectedException.expect(MessageException.class); - expectedException.expectMessage("Bad format of JDBC URL: oracle:thin:@localhost/XE"); - - underTest.resolveProviderAndEnforceNonnullJdbcUrl(props); + assertThatThrownBy(() -> underTest.resolveProviderAndEnforceNonnullJdbcUrl(props)) + .isInstanceOf(MessageException.class) + .hasMessage("Bad format of JDBC URL: oracle:thin:@localhost/XE"); } @Test @@ -159,20 +155,18 @@ public class JdbcSettingsTest { @Test public void driver_dir_does_not_exist() { - expectedException.expect(MessageException.class); - expectedException.expectMessage("Directory does not exist: extensions/jdbc-driver/oracle"); - - underTest.driverPath(homeDir, Provider.ORACLE); + assertThatThrownBy(() -> underTest.driverPath(homeDir, Provider.ORACLE)) + .isInstanceOf(MessageException.class) + .hasMessage("Directory does not exist: extensions/jdbc-driver/oracle"); } @Test public void no_files_in_driver_dir() throws Exception { FileUtils.forceMkdir(new File(homeDir, "extensions/jdbc-driver/oracle")); - expectedException.expect(MessageException.class); - expectedException.expectMessage("Directory does not contain JDBC driver: extensions/jdbc-driver/oracle"); - - underTest.driverPath(homeDir, Provider.ORACLE); + assertThatThrownBy(() -> underTest.driverPath(homeDir, Provider.ORACLE)) + .isInstanceOf(MessageException.class) + .hasMessage("Directory does not contain JDBC driver: extensions/jdbc-driver/oracle"); } @Test @@ -180,10 +174,9 @@ public class JdbcSettingsTest { FileUtils.touch(new File(homeDir, "extensions/jdbc-driver/oracle/ojdbc5.jar")); FileUtils.touch(new File(homeDir, "extensions/jdbc-driver/oracle/ojdbc6.jar")); - expectedException.expect(MessageException.class); - expectedException.expectMessage("Directory must contain only one JAR file: extensions/jdbc-driver/oracle"); - - underTest.driverPath(homeDir, Provider.ORACLE); + assertThatThrownBy(() -> underTest.driverPath(homeDir, Provider.ORACLE)) + .isInstanceOf(MessageException.class) + .hasMessage("Directory must contain only one JAR file: extensions/jdbc-driver/oracle"); } private Props newProps(String... params) { diff --git a/server/sonar-main/src/test/java/org/sonar/application/es/EsInstallationTest.java b/server/sonar-main/src/test/java/org/sonar/application/es/EsInstallationTest.java index bb1f4006a60..891563fc180 100644 --- a/server/sonar-main/src/test/java/org/sonar/application/es/EsInstallationTest.java +++ b/server/sonar-main/src/test/java/org/sonar/application/es/EsInstallationTest.java @@ -24,11 +24,11 @@ import java.io.IOException; import java.util.Properties; import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.junit.rules.TemporaryFolder; import org.sonar.process.Props; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.sonar.process.ProcessProperties.Property.PATH_DATA; import static org.sonar.process.ProcessProperties.Property.PATH_HOME; import static org.sonar.process.ProcessProperties.Property.PATH_LOGS; @@ -38,17 +38,14 @@ public class EsInstallationTest { @Rule public TemporaryFolder temp = new TemporaryFolder(); - @Rule - public ExpectedException expectedException = ExpectedException.none(); @Test public void constructor_fails_with_IAE_if_sq_home_property_is_not_defined() { Props props = new Props(new Properties()); - expectedException.expect(IllegalArgumentException.class); - expectedException.expectMessage("Property sonar.path.home is not set"); - - new EsInstallation(props); + assertThatThrownBy(() -> new EsInstallation(props)) + .isInstanceOf(IllegalArgumentException.class) + .hasMessage("Property sonar.path.home is not set"); } @Test @@ -57,10 +54,9 @@ public class EsInstallationTest { props.set(PATH_DATA.getKey(), temp.newFolder().getAbsolutePath()); props.set(PATH_HOME.getKey(), temp.newFolder().getAbsolutePath()); - expectedException.expect(IllegalArgumentException.class); - expectedException.expectMessage("Property sonar.path.temp is not set"); - - new EsInstallation(props); + assertThatThrownBy(() -> new EsInstallation(props)) + .isInstanceOf(IllegalArgumentException.class) + .hasMessage("Property sonar.path.temp is not set"); } @Test @@ -68,10 +64,9 @@ public class EsInstallationTest { Props props = new Props(new Properties()); props.set(PATH_HOME.getKey(), temp.newFolder().getAbsolutePath()); - expectedException.expect(IllegalArgumentException.class); - expectedException.expectMessage("Missing property: sonar.path.data"); - - new EsInstallation(props); + assertThatThrownBy(() -> new EsInstallation(props)) + .isInstanceOf(IllegalArgumentException.class) + .hasMessage("Missing property: sonar.path.data"); } @Test diff --git a/server/sonar-main/src/test/java/org/sonar/application/es/EsYmlSettingsTest.java b/server/sonar-main/src/test/java/org/sonar/application/es/EsYmlSettingsTest.java index 7001fa4a6be..021f985629e 100644 --- a/server/sonar-main/src/test/java/org/sonar/application/es/EsYmlSettingsTest.java +++ b/server/sonar-main/src/test/java/org/sonar/application/es/EsYmlSettingsTest.java @@ -24,17 +24,15 @@ import java.io.IOException; import java.util.HashMap; import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.junit.rules.TemporaryFolder; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; public class EsYmlSettingsTest { @Rule public TemporaryFolder temp = new TemporaryFolder(); - @Rule - public ExpectedException expectedException = ExpectedException.none(); @Test public void test_generation_of_file() throws IOException { @@ -55,9 +53,8 @@ public class EsYmlSettingsTest { File yamlFile = temp.newFile(); yamlFile.setReadOnly(); - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Cannot write Elasticsearch yml settings file"); - - new EsYmlSettings(new HashMap<>()).writeToYmlSettingsFile(yamlFile); + assertThatThrownBy(() -> new EsYmlSettings(new HashMap<>()).writeToYmlSettingsFile(yamlFile)) + .isInstanceOf(IllegalStateException.class) + .hasMessage("Cannot write Elasticsearch yml settings file"); } } diff --git a/server/sonar-main/src/test/java/org/sonar/application/process/ManagedProcessHandlerTest.java b/server/sonar-main/src/test/java/org/sonar/application/process/ManagedProcessHandlerTest.java index 31a296352b4..ef49a2b407b 100644 --- a/server/sonar-main/src/test/java/org/sonar/application/process/ManagedProcessHandlerTest.java +++ b/server/sonar-main/src/test/java/org/sonar/application/process/ManagedProcessHandlerTest.java @@ -26,13 +26,13 @@ import org.awaitility.Awaitility; import org.junit.Rule; import org.junit.Test; import org.junit.rules.DisableOnDebug; -import org.junit.rules.ExpectedException; import org.junit.rules.TestRule; import org.junit.rules.Timeout; import org.mockito.Mockito; import org.sonar.process.ProcessId; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.timeout; import static org.mockito.Mockito.verify; @@ -44,8 +44,6 @@ public class ManagedProcessHandlerTest { private static final ProcessId A_PROCESS_ID = ProcessId.ELASTICSEARCH; @Rule - public ExpectedException expectedException = ExpectedException.none(); - @Rule public TestRule safeguardTimeout = new DisableOnDebug(Timeout.seconds(60)); @Test @@ -105,13 +103,14 @@ public class ManagedProcessHandlerTest { public void start_throws_exception_and_move_to_state_STOPPED_if_execution_of_command_fails() { ManagedProcessHandler underTest = newHanderBuilder(A_PROCESS_ID).build(); - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("error"); - - underTest.start(() -> { - throw new IllegalStateException("error"); - }); - assertThat(underTest.getState()).isEqualTo(ManagedProcessLifecycle.State.STOPPED); + assertThatThrownBy(() -> { + underTest.start(() -> { + throw new IllegalStateException("error"); + }); + assertThat(underTest.getState()).isEqualTo(ManagedProcessLifecycle.State.STOPPED); + }) + .isInstanceOf(IllegalStateException.class) + .hasMessage("error"); } @Test diff --git a/server/sonar-main/src/test/java/org/sonar/application/process/ProcessCommandsManagedProcessTest.java b/server/sonar-main/src/test/java/org/sonar/application/process/ProcessCommandsManagedProcessTest.java index 6e414ad7fc4..082e775d91c 100644 --- a/server/sonar-main/src/test/java/org/sonar/application/process/ProcessCommandsManagedProcessTest.java +++ b/server/sonar-main/src/test/java/org/sonar/application/process/ProcessCommandsManagedProcessTest.java @@ -24,8 +24,8 @@ import java.io.InputStream; import java.util.concurrent.TimeUnit; import org.junit.Test; import org.mockito.Mockito; -import org.sonar.process.sharedmemoryfile.ProcessCommands; import org.sonar.process.ProcessId; +import org.sonar.process.sharedmemoryfile.ProcessCommands; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.RETURNS_DEEP_STUBS; @@ -33,8 +33,6 @@ import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; - - public class ProcessCommandsManagedProcessTest { @Test |