diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2016-01-11 16:14:39 +0100 |
---|---|---|
committer | Julien HENRY <julien.henry@sonarsource.com> | 2016-01-11 16:14:39 +0100 |
commit | 5e187f8dc1099ce63c00b9185b9a8a8d9ce92f92 (patch) | |
tree | c976e3ce1b391dd4d74ce2c2c6522ae1a0e16e2e /src/test/java/org/sonarsource/scanner/cli/LogsTest.java | |
parent | ef4271a905f1a14f0f87c555e685e0744dec7d32 (diff) | |
download | sonar-scanner-cli-5e187f8dc1099ce63c00b9185b9a8a8d9ce92f92.tar.gz sonar-scanner-cli-5e187f8dc1099ce63c00b9185b9a8a8d9ce92f92.zip |
Update groupId, artifactId and packages
Diffstat (limited to 'src/test/java/org/sonarsource/scanner/cli/LogsTest.java')
-rw-r--r-- | src/test/java/org/sonarsource/scanner/cli/LogsTest.java | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/src/test/java/org/sonarsource/scanner/cli/LogsTest.java b/src/test/java/org/sonarsource/scanner/cli/LogsTest.java new file mode 100644 index 0000000..39bedff --- /dev/null +++ b/src/test/java/org/sonarsource/scanner/cli/LogsTest.java @@ -0,0 +1,83 @@ +/* + * SonarQube Scanner + * Copyright (C) 2011 SonarSource + * sonarqube@googlegroups.com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 + */ +package org.sonarsource.scanner.cli; + +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.sonarsource.scanner.cli.Logs; +import java.io.PrintStream; + +import static org.mockito.Mockito.verifyNoMoreInteractions; +import static org.mockito.Mockito.verify; + +public class LogsTest { + @Mock + private PrintStream stdOut; + + @Mock + private PrintStream stdErr; + + private Logs logs; + + @Before + public void setUp() { + MockitoAnnotations.initMocks(this); + logs = new Logs(stdOut, stdErr); + } + + @Test + public void testInfo() { + logs.info("info"); + verify(stdOut).println("INFO: info"); + verifyNoMoreInteractions(stdOut, stdErr); + } + + @Test + public void testError() { + Exception e = new NullPointerException("exception"); + logs.setDisplayStackTrace(false); + logs.error("error1"); + verify(stdErr).println("ERROR: error1"); + + logs.error("error2", e); + verify(stdErr).println("ERROR: error2"); + + verifyNoMoreInteractions(stdOut, stdErr); + + logs.setDisplayStackTrace(true); + logs.error("error3", e); + verify(stdErr).println("ERROR: error3"); + // other interactions to print the exception.. + } + + @Test + public void testDebug() { + logs.setDebugEnabled(true); + + logs.debug("debug"); + verify(stdOut).println("DEBUG: debug"); + + logs.setDebugEnabled(false); + logs.debug("debug"); + verifyNoMoreInteractions(stdOut, stdErr); + } +} |