Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

RunnerTest.java 2.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * Sonar Standalone Runner
  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;
  21. import org.junit.Test;
  22. import java.io.File;
  23. import java.net.URISyntaxException;
  24. import java.util.Properties;
  25. import static org.hamcrest.Matchers.*;
  26. import static org.junit.Assert.assertThat;
  27. public class RunnerTest {
  28. @Test
  29. public void shouldCheckVersion() {
  30. assertThat(Runner.isUnsupportedVersion("1.0"), is(true));
  31. assertThat(Runner.isUnsupportedVersion("2.0"), is(true));
  32. assertThat(Runner.isUnsupportedVersion("2.1"), is(true));
  33. assertThat(Runner.isUnsupportedVersion("2.2"), is(true));
  34. assertThat(Runner.isUnsupportedVersion("2.3"), is(true));
  35. assertThat(Runner.isUnsupportedVersion("2.4"), is(true));
  36. assertThat(Runner.isUnsupportedVersion("2.4.1"), is(true));
  37. assertThat(Runner.isUnsupportedVersion("2.5"), is(true));
  38. assertThat(Runner.isUnsupportedVersion("2.6"), is(false));
  39. }
  40. /**
  41. * This test can only be executed by Maven, not by IDE
  42. */
  43. @Test
  44. public void shouldGetVersion() {
  45. String version = Runner.create(new Properties()).getRunnerVersion();
  46. assertThat(version.length(), greaterThanOrEqualTo(3));
  47. assertThat(version, containsString("."));
  48. // test that version is set by Maven build
  49. assertThat(version, not(containsString("$")));
  50. }
  51. @Test
  52. public void shouldInitDirs() throws Exception {
  53. Properties props = new Properties();
  54. File home = new File(getClass().getResource("/org/sonar/runner/RunnerTest/shouldInitDirs/").toURI());
  55. props.setProperty("project.home", home.getCanonicalPath());
  56. Runner runner = Runner.create(props);
  57. assertThat(runner.getProjectDir(), is(home));
  58. assertThat(runner.getWorkDir(), is(new File(home, ".sonar")));
  59. }
  60. @Test
  61. public void shouldInitProjectDirWithCurrentDir() throws Exception {
  62. Runner runner = Runner.create(new Properties());
  63. assertThat(runner.getProjectDir().isDirectory(), is(true));
  64. assertThat(runner.getProjectDir().exists(), is(true));
  65. }
  66. }