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.

RunnerTestCase.java 2.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * SonarSource :: IT :: SonarQube Scanner
  3. * Copyright (C) 2009 SonarSource
  4. * sonarqube@googlegroups.com
  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 com.sonar.runner.it;
  21. import com.sonar.orchestrator.version.Version;
  22. import com.sonar.orchestrator.Orchestrator;
  23. import com.sonar.orchestrator.OrchestratorBuilder;
  24. import com.sonar.orchestrator.build.SonarRunner;
  25. import org.junit.AfterClass;
  26. import org.junit.BeforeClass;
  27. import org.junit.Rule;
  28. import org.junit.rules.ExpectedException;
  29. import java.io.File;
  30. public abstract class RunnerTestCase {
  31. @Rule
  32. public ExpectedException thrown = ExpectedException.none();
  33. public static Orchestrator orchestrator = null;
  34. @BeforeClass
  35. public static void startServer() {
  36. OrchestratorBuilder builder = Orchestrator.builderEnv()
  37. // TODO Java projects should be replaced by Xoo projects
  38. .setOrchestratorProperty("javaVersion", "LATEST_RELEASE")
  39. .addPlugin("java")
  40. .setOrchestratorProperty("findbugsVersion", "LATEST_RELEASE")
  41. .addPlugin("findbugs")
  42. .setOrchestratorProperty("javascriptVersion", "LATEST_RELEASE")
  43. .addPlugin("javascript");
  44. orchestrator = builder.build();
  45. orchestrator.start();
  46. }
  47. @AfterClass
  48. public static void stopServer() {
  49. if (orchestrator != null) {
  50. orchestrator.stop();
  51. orchestrator = null;
  52. }
  53. }
  54. SonarRunner newRunner(File baseDir, String... keyValueProperties) {
  55. SonarRunner runner = SonarRunner.create(baseDir, keyValueProperties);
  56. String runnerVersion = Version.create(orchestrator.getConfiguration().getString("sonarRunner.version")).toString();
  57. runner.setRunnerVersion(runnerVersion);
  58. return runner;
  59. }
  60. }