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.

IsolatedLauncherTest.java 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * SonarQube Runner - Batch
  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.batch;
  21. import java.util.Collections;
  22. import java.util.Properties;
  23. import org.junit.Test;
  24. import org.sonar.batch.bootstrapper.Batch;
  25. import static org.fest.assertions.Assertions.assertThat;
  26. public class IsolatedLauncherTest {
  27. Properties props = new Properties();
  28. BatchIsolatedLauncher launcher = new BatchIsolatedLauncher();
  29. @Test
  30. public void should_create_batch() {
  31. props.setProperty("sonar.projectBaseDir", "src/test/java_sample");
  32. props.setProperty("sonar.projectKey", "sample");
  33. props.setProperty("sonar.projectName", "Sample");
  34. props.setProperty("sonar.projectVersion", "1.0");
  35. props.setProperty("sonar.sources", "src");
  36. Batch batch = launcher.createBatch(props, Collections.emptyList());
  37. assertThat(batch).isNotNull();
  38. }
  39. @Test
  40. public void testGetSqlLevel() throws Exception {
  41. assertThat(BatchIsolatedLauncher.getSqlLevel(props)).isEqualTo("WARN");
  42. props.setProperty("sonar.showSql", "true");
  43. assertThat(BatchIsolatedLauncher.getSqlLevel(props)).isEqualTo("DEBUG");
  44. props.setProperty("sonar.showSql", "false");
  45. assertThat(BatchIsolatedLauncher.getSqlLevel(props)).isEqualTo("WARN");
  46. }
  47. @Test
  48. public void testGetSqlResultsLevel() throws Exception {
  49. assertThat(BatchIsolatedLauncher.getSqlResultsLevel(props)).isEqualTo("WARN");
  50. props.setProperty("sonar.showSqlResults", "true");
  51. assertThat(BatchIsolatedLauncher.getSqlResultsLevel(props)).isEqualTo("DEBUG");
  52. props.setProperty("sonar.showSqlResults", "false");
  53. assertThat(BatchIsolatedLauncher.getSqlResultsLevel(props)).isEqualTo("WARN");
  54. }
  55. @Test
  56. public void shouldDetermineVerboseMode() {
  57. assertThat(launcher.isDebug(props)).isFalse();
  58. props.setProperty("sonar.verbose", "true");
  59. assertThat(launcher.isDebug(props)).isTrue();
  60. }
  61. }