You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

LauncherTest.java 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * Sonar Runner - Implementation
  3. * Copyright (C) 2011 SonarSource
  4. * dev@sonar.codehaus.org
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 3 of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
  19. */
  20. package org.sonar.runner.internal.batch;
  21. import com.google.common.collect.Lists;
  22. import org.junit.Test;
  23. import org.sonar.runner.Runner;
  24. import java.util.Properties;
  25. import static org.fest.assertions.Assertions.assertThat;
  26. public class LauncherTest {
  27. @Test
  28. public void testGetSqlLevel() throws Exception {
  29. Properties conf = new Properties();
  30. assertThat(Launcher.getSqlLevel(conf)).isEqualTo("WARN");
  31. conf.setProperty("sonar.showSql", "true");
  32. assertThat(Launcher.getSqlLevel(conf)).isEqualTo("DEBUG");
  33. conf.setProperty("sonar.showSql", "false");
  34. assertThat(Launcher.getSqlLevel(conf)).isEqualTo("WARN");
  35. }
  36. @Test
  37. public void testGetSqlResultsLevel() throws Exception {
  38. Properties conf = new Properties();
  39. assertThat(Launcher.getSqlResultsLevel(conf)).isEqualTo("WARN");
  40. conf.setProperty("sonar.showSqlResults", "true");
  41. assertThat(Launcher.getSqlResultsLevel(conf)).isEqualTo("DEBUG");
  42. conf.setProperty("sonar.showSqlResults", "false");
  43. assertThat(Launcher.getSqlResultsLevel(conf)).isEqualTo("WARN");
  44. }
  45. @Test
  46. public void shouldDetermineVerboseMode() {
  47. Properties properties = new Properties();
  48. Launcher launcher = new Launcher(properties, Lists.newArrayList());
  49. assertThat(launcher.isDebug()).isFalse();
  50. properties.setProperty(Runner.PROPERTY_VERBOSE, "true");
  51. assertThat(launcher.isDebug()).isTrue();
  52. }
  53. @Test
  54. public void shouldSupportDeprecatedDebugProperty() {
  55. Properties properties = new Properties();
  56. Launcher launcher = new Launcher(properties, Lists.newArrayList());
  57. properties.setProperty(Runner.PROPERTY_OLD_DEBUG_MODE, "true");
  58. assertThat(launcher.isDebug()).isTrue();
  59. }
  60. }