aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2015-07-16 21:41:03 +0200
committerSimon Brandhof <simon.brandhof@sonarsource.com>2015-07-16 21:41:03 +0200
commit57cb022d1b9751a1a73fcf7a2054aa1b24ab4c27 (patch)
tree316a18fb54f71039b89ea405915a397018ce8cb8 /sonar-plugin-api
parent97e740133e533f623b6a0bc774dda3804d8df62f (diff)
downloadsonarqube-57cb022d1b9751a1a73fcf7a2054aa1b24ab4c27.tar.gz
sonarqube-57cb022d1b9751a1a73fcf7a2054aa1b24ab4c27.zip
Rename variables "sut" to "underTest" in tests
Diffstat (limited to 'sonar-plugin-api')
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/utils/log/ConsoleLoggerTest.java76
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/utils/log/ConsoleLoggersTest.java10
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/utils/log/DefaultProfilerTest.java64
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/utils/log/LogbackLoggerTest.java82
4 files changed, 116 insertions, 116 deletions
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/utils/log/ConsoleLoggerTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/utils/log/ConsoleLoggerTest.java
index 7edba887086..7e4d74c684c 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/utils/log/ConsoleLoggerTest.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/utils/log/ConsoleLoggerTest.java
@@ -30,7 +30,7 @@ import static org.mockito.Mockito.*;
public class ConsoleLoggerTest {
PrintStream stream = mock(PrintStream.class);
- ConsoleLogger sut = new ConsoleLogger(stream);
+ ConsoleLogger underTest = new ConsoleLogger(stream);
@Rule
public LogTester tester = new LogTester();
@@ -38,74 +38,74 @@ public class ConsoleLoggerTest {
@Test
public void debug_enabled() {
tester.setLevel(LoggerLevel.DEBUG);
- assertThat(sut.isDebugEnabled()).isTrue();
- assertThat(sut.isTraceEnabled()).isFalse();
- sut.debug("message");
- sut.debug("message {}", "foo");
- sut.debug("message {} {}", "foo", "bar");
- sut.debug("message {} {} {}", "foo", "bar", "baz");
+ assertThat(underTest.isDebugEnabled()).isTrue();
+ assertThat(underTest.isTraceEnabled()).isFalse();
+ underTest.debug("message");
+ underTest.debug("message {}", "foo");
+ underTest.debug("message {} {}", "foo", "bar");
+ underTest.debug("message {} {} {}", "foo", "bar", "baz");
verify(stream, times(4)).println(anyString());
}
@Test
public void debug_disabled() {
tester.setLevel(LoggerLevel.INFO);
- assertThat(sut.isDebugEnabled()).isFalse();
- assertThat(sut.isTraceEnabled()).isFalse();
- sut.debug("message");
- sut.debug("message {}", "foo");
- sut.debug("message {} {}", "foo", "bar");
- sut.debug("message {} {} {}", "foo", "bar", "baz");
+ assertThat(underTest.isDebugEnabled()).isFalse();
+ assertThat(underTest.isTraceEnabled()).isFalse();
+ underTest.debug("message");
+ underTest.debug("message {}", "foo");
+ underTest.debug("message {} {}", "foo", "bar");
+ underTest.debug("message {} {} {}", "foo", "bar", "baz");
verifyZeroInteractions(stream);
}
@Test
public void trace_enabled() {
tester.setLevel(LoggerLevel.TRACE);
- assertThat(sut.isDebugEnabled()).isTrue();
- assertThat(sut.isTraceEnabled()).isTrue();
- sut.trace("message");
- sut.trace("message {}", "foo");
- sut.trace("message {} {}", "foo", "bar");
- sut.trace("message {} {} {}", "foo", "bar", "baz");
+ assertThat(underTest.isDebugEnabled()).isTrue();
+ assertThat(underTest.isTraceEnabled()).isTrue();
+ underTest.trace("message");
+ underTest.trace("message {}", "foo");
+ underTest.trace("message {} {}", "foo", "bar");
+ underTest.trace("message {} {} {}", "foo", "bar", "baz");
verify(stream, times(4)).println(anyString());
}
@Test
public void trace_disabled() {
tester.setLevel(LoggerLevel.DEBUG);
- assertThat(sut.isTraceEnabled()).isFalse();
- sut.trace("message");
- sut.trace("message {}", "foo");
- sut.trace("message {} {}", "foo", "bar");
- sut.trace("message {} {} {}", "foo", "bar", "baz");
+ assertThat(underTest.isTraceEnabled()).isFalse();
+ underTest.trace("message");
+ underTest.trace("message {}", "foo");
+ underTest.trace("message {} {}", "foo", "bar");
+ underTest.trace("message {} {} {}", "foo", "bar", "baz");
verifyZeroInteractions(stream);
}
@Test
public void log() {
- sut.info("message");
- sut.info("message {}", "foo");
- sut.info("message {} {}", "foo", "bar");
- sut.info("message {} {} {}", "foo", "bar", "baz");
+ underTest.info("message");
+ underTest.info("message {}", "foo");
+ underTest.info("message {} {}", "foo", "bar");
+ underTest.info("message {} {} {}", "foo", "bar", "baz");
verify(stream, times(4)).println(startsWith("INFO "));
- sut.warn("message");
- sut.warn("message {}", "foo");
- sut.warn("message {} {}", "foo", "bar");
- sut.warn("message {} {} {}", "foo", "bar", "baz");
+ underTest.warn("message");
+ underTest.warn("message {}", "foo");
+ underTest.warn("message {} {}", "foo", "bar");
+ underTest.warn("message {} {} {}", "foo", "bar", "baz");
verify(stream, times(4)).println(startsWith("WARN "));
- sut.error("message");
- sut.error("message {}", "foo");
- sut.error("message {} {}", "foo", "bar");
- sut.error("message {} {} {}", "foo", "bar", "baz");
- sut.error("message", new IllegalArgumentException());
+ underTest.error("message");
+ underTest.error("message {}", "foo");
+ underTest.error("message {} {}", "foo", "bar");
+ underTest.error("message {} {} {}", "foo", "bar", "baz");
+ underTest.error("message", new IllegalArgumentException());
verify(stream, times(5)).println(startsWith("ERROR "));
}
@Test
public void level_change_not_implemented_yet() {
- assertThat(sut.setLevel(LoggerLevel.DEBUG)).isFalse();
+ assertThat(underTest.setLevel(LoggerLevel.DEBUG)).isFalse();
}
}
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/utils/log/ConsoleLoggersTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/utils/log/ConsoleLoggersTest.java
index 197225cf515..b58df58be8e 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/utils/log/ConsoleLoggersTest.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/utils/log/ConsoleLoggersTest.java
@@ -25,20 +25,20 @@ import static org.assertj.core.api.Assertions.assertThat;
public class ConsoleLoggersTest {
- ConsoleLoggers sut = new ConsoleLoggers();
+ ConsoleLoggers underTest = new ConsoleLoggers();
@Test
public void newInstance() {
- Logger logger = sut.newInstance("foo");
+ Logger logger = underTest.newInstance("foo");
assertThat(logger).isInstanceOf(ConsoleLogger.class);
}
@Test
public void level() {
// INFO by default
- assertThat(sut.getLevel()).isEqualTo(LoggerLevel.INFO);
+ assertThat(underTest.getLevel()).isEqualTo(LoggerLevel.INFO);
- sut.setLevel(LoggerLevel.DEBUG);
- assertThat(sut.getLevel()).isEqualTo(LoggerLevel.DEBUG);
+ underTest.setLevel(LoggerLevel.DEBUG);
+ assertThat(underTest.getLevel()).isEqualTo(LoggerLevel.DEBUG);
}
}
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/utils/log/DefaultProfilerTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/utils/log/DefaultProfilerTest.java
index da6b46697e4..30d2e286b60 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/utils/log/DefaultProfilerTest.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/utils/log/DefaultProfilerTest.java
@@ -30,21 +30,21 @@ public class DefaultProfilerTest {
@Rule
public LogTester tester = new LogTester();
- Profiler sut = Profiler.create(Loggers.get("DefaultProfilerTest"));
+ Profiler underTest = Profiler.create(Loggers.get("DefaultProfilerTest"));
@Test
public void test_levels() throws Exception {
// trace by default
- assertThat(sut.isDebugEnabled()).isTrue();
- assertThat(sut.isTraceEnabled()).isTrue();
+ assertThat(underTest.isDebugEnabled()).isTrue();
+ assertThat(underTest.isTraceEnabled()).isTrue();
tester.setLevel(LoggerLevel.DEBUG);
- assertThat(sut.isDebugEnabled()).isTrue();
- assertThat(sut.isTraceEnabled()).isFalse();
+ assertThat(underTest.isDebugEnabled()).isTrue();
+ assertThat(underTest.isTraceEnabled()).isFalse();
tester.setLevel(LoggerLevel.INFO);
- assertThat(sut.isDebugEnabled()).isFalse();
- assertThat(sut.isTraceEnabled()).isFalse();
+ assertThat(underTest.isDebugEnabled()).isFalse();
+ assertThat(underTest.isTraceEnabled()).isFalse();
}
@Test
@@ -52,25 +52,25 @@ public class DefaultProfilerTest {
tester.setLevel(LoggerLevel.TRACE);
// trace
- sut.startTrace("Register rules");
+ underTest.startTrace("Register rules");
assertThat(tester.logs()).containsOnly("Register rules");
- sut.stopTrace();
+ underTest.stopTrace();
assertThat(tester.logs()).hasSize(2);
assertThat(tester.logs().get(1)).startsWith("Register rules (done) | time=");
tester.clear();
// debug
- sut.startDebug("Register rules");
+ underTest.startDebug("Register rules");
assertThat(tester.logs()).containsOnly("Register rules");
- sut.stopTrace();
+ underTest.stopTrace();
assertThat(tester.logs()).hasSize(2);
assertThat(tester.logs().get(1)).startsWith("Register rules (done) | time=");
tester.clear();
// info
- sut.startInfo("Register rules");
+ underTest.startInfo("Register rules");
assertThat(tester.logs()).containsOnly("Register rules");
- sut.stopTrace();
+ underTest.stopTrace();
assertThat(tester.logs()).hasSize(2);
assertThat(tester.logs().get(1)).startsWith("Register rules (done) | time=");
}
@@ -80,24 +80,24 @@ public class DefaultProfilerTest {
tester.setLevel(LoggerLevel.TRACE);
// start TRACE and stop DEBUG
- sut.startTrace("Register rules");
- sut.stopDebug("Rules registered");
+ underTest.startTrace("Register rules");
+ underTest.stopDebug("Rules registered");
assertThat(tester.logs()).hasSize(2);
assertThat(tester.logs().get(0)).contains("Register rules");
assertThat(tester.logs().get(1)).startsWith("Rules registered | time=");
tester.clear();
// start DEBUG and stop INFO
- sut.startDebug("Register rules");
- sut.stopInfo("Rules registered");
+ underTest.startDebug("Register rules");
+ underTest.stopInfo("Rules registered");
assertThat(tester.logs()).hasSize(2);
assertThat(tester.logs().get(0)).contains("Register rules");
assertThat(tester.logs().get(1)).startsWith("Rules registered | time=");
tester.clear();
// start INFO and stop TRACE
- sut.startInfo("Register rules");
- sut.stopTrace("Rules registered");
+ underTest.startInfo("Register rules");
+ underTest.stopTrace("Rules registered");
assertThat(tester.logs()).hasSize(2);
assertThat(tester.logs().get(0)).contains("Register rules");
assertThat(tester.logs().get(1)).startsWith("Rules registered | time=");
@@ -108,22 +108,22 @@ public class DefaultProfilerTest {
tester.setLevel(LoggerLevel.TRACE);
// trace
- sut.start();
- sut.stopTrace("Rules registered");
+ underTest.start();
+ underTest.stopTrace("Rules registered");
assertThat(tester.logs()).hasSize(1);
assertThat(tester.logs().get(0)).startsWith("Rules registered | time=");
tester.clear();
// debug
- sut.start();
- sut.stopDebug("Rules registered");
+ underTest.start();
+ underTest.stopDebug("Rules registered");
assertThat(tester.logs()).hasSize(1);
assertThat(tester.logs().get(0)).startsWith("Rules registered | time=");
tester.clear();
// info
- sut.start();
- sut.stopInfo("Rules registered");
+ underTest.start();
+ underTest.stopInfo("Rules registered");
assertThat(tester.logs()).hasSize(1);
assertThat(tester.logs().get(0)).startsWith("Rules registered | time=");
}
@@ -148,12 +148,12 @@ public class DefaultProfilerTest {
@Test
public void empty_message() {
- sut.addContext("foo", "bar");
- sut.startInfo("");
+ underTest.addContext("foo", "bar");
+ underTest.startInfo("");
assertThat(tester.logs()).containsOnly("foo=bar");
- sut.addContext("after_start", true);
- sut.stopInfo("");
+ underTest.addContext("after_start", true);
+ underTest.stopInfo("");
assertThat(tester.logs()).hasSize(2);
assertThat(tester.logs().get(1))
.startsWith("time=")
@@ -162,9 +162,9 @@ public class DefaultProfilerTest {
@Test
public void fail_if_stop_without_message() {
- sut.start();
+ underTest.start();
try {
- sut.stopInfo();
+ underTest.stopInfo();
fail();
} catch (IllegalStateException e) {
assertThat(e).hasMessage("Profiler#stopXXX() can't be called without any message defined in start methods");
@@ -174,7 +174,7 @@ public class DefaultProfilerTest {
@Test
public void fail_if_stop_without_start() {
try {
- sut.stopDebug("foo");
+ underTest.stopDebug("foo");
fail();
} catch (IllegalStateException e) {
assertThat(e).hasMessage("Profiler must be started before being stopped");
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/utils/log/LogbackLoggerTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/utils/log/LogbackLoggerTest.java
index 500b32b47d9..9061d429692 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/utils/log/LogbackLoggerTest.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/utils/log/LogbackLoggerTest.java
@@ -29,7 +29,7 @@ import static org.junit.Assert.fail;
public class LogbackLoggerTest {
- LogbackLogger sut = new LogbackLogger((ch.qos.logback.classic.Logger)LoggerFactory.getLogger(getClass()));
+ LogbackLogger underTest = new LogbackLogger((ch.qos.logback.classic.Logger)LoggerFactory.getLogger(getClass()));
@Rule
public LogTester tester = new LogTester();
@@ -37,55 +37,55 @@ public class LogbackLoggerTest {
@Test
public void log() {
// no assertions. Simply verify that calls do not fail.
- sut.trace("message");
- sut.trace("message {}", "foo");
- sut.trace("message {} {}", "foo", "bar");
- sut.trace("message {} {} {}", "foo", "bar", "baz");
-
- sut.debug("message");
- sut.debug("message {}", "foo");
- sut.debug("message {} {}", "foo", "bar");
- sut.debug("message {} {} {}", "foo", "bar", "baz");
-
- sut.info("message");
- sut.info("message {}", "foo");
- sut.info("message {} {}", "foo", "bar");
- sut.info("message {} {} {}", "foo", "bar", "baz");
-
- sut.warn("message");
- sut.warn("message {}", "foo");
- sut.warn("message {} {}", "foo", "bar");
- sut.warn("message {} {} {}", "foo", "bar", "baz");
-
- sut.error("message");
- sut.error("message {}", "foo");
- sut.error("message {} {}", "foo", "bar");
- sut.error("message {} {} {}", "foo", "bar", "baz");
- sut.error("message", new IllegalArgumentException(""));
+ underTest.trace("message");
+ underTest.trace("message {}", "foo");
+ underTest.trace("message {} {}", "foo", "bar");
+ underTest.trace("message {} {} {}", "foo", "bar", "baz");
+
+ underTest.debug("message");
+ underTest.debug("message {}", "foo");
+ underTest.debug("message {} {}", "foo", "bar");
+ underTest.debug("message {} {} {}", "foo", "bar", "baz");
+
+ underTest.info("message");
+ underTest.info("message {}", "foo");
+ underTest.info("message {} {}", "foo", "bar");
+ underTest.info("message {} {} {}", "foo", "bar", "baz");
+
+ underTest.warn("message");
+ underTest.warn("message {}", "foo");
+ underTest.warn("message {} {}", "foo", "bar");
+ underTest.warn("message {} {} {}", "foo", "bar", "baz");
+
+ underTest.error("message");
+ underTest.error("message {}", "foo");
+ underTest.error("message {} {}", "foo", "bar");
+ underTest.error("message {} {} {}", "foo", "bar", "baz");
+ underTest.error("message", new IllegalArgumentException(""));
}
@Test
public void change_level() {
- assertThat(sut.setLevel(LoggerLevel.INFO)).isTrue();
- assertThat(sut.logbackLogger().getLevel()).isEqualTo(Level.INFO);
- assertThat(sut.isDebugEnabled()).isFalse();
- assertThat(sut.isTraceEnabled()).isFalse();
-
- assertThat(sut.setLevel(LoggerLevel.DEBUG)).isTrue();
- assertThat(sut.isDebugEnabled()).isTrue();
- assertThat(sut.isTraceEnabled()).isFalse();
- assertThat(sut.logbackLogger().getLevel()).isEqualTo(Level.DEBUG);
-
- assertThat(sut.setLevel(LoggerLevel.TRACE)).isTrue();
- assertThat(sut.isDebugEnabled()).isTrue();
- assertThat(sut.isTraceEnabled()).isTrue();
- assertThat(sut.logbackLogger().getLevel()).isEqualTo(Level.TRACE);
+ assertThat(underTest.setLevel(LoggerLevel.INFO)).isTrue();
+ assertThat(underTest.logbackLogger().getLevel()).isEqualTo(Level.INFO);
+ assertThat(underTest.isDebugEnabled()).isFalse();
+ assertThat(underTest.isTraceEnabled()).isFalse();
+
+ assertThat(underTest.setLevel(LoggerLevel.DEBUG)).isTrue();
+ assertThat(underTest.isDebugEnabled()).isTrue();
+ assertThat(underTest.isTraceEnabled()).isFalse();
+ assertThat(underTest.logbackLogger().getLevel()).isEqualTo(Level.DEBUG);
+
+ assertThat(underTest.setLevel(LoggerLevel.TRACE)).isTrue();
+ assertThat(underTest.isDebugEnabled()).isTrue();
+ assertThat(underTest.isTraceEnabled()).isTrue();
+ assertThat(underTest.logbackLogger().getLevel()).isEqualTo(Level.TRACE);
}
@Test
public void info_level_can_not_be_disabled() {
try {
- sut.setLevel(LoggerLevel.ERROR);
+ underTest.setLevel(LoggerLevel.ERROR);
fail();
} catch (IllegalArgumentException e) {