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.

DefaultServerFileSystemTest.java 2.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. * SonarQube, open source software quality management tool.
  3. * Copyright (C) 2008-2014 SonarSource
  4. * mailto:contact AT sonarsource DOT com
  5. *
  6. * SonarQube 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. * SonarQube 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 License
  17. * along with this program; if not, write to the Free Software Foundation,
  18. * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  19. */
  20. package org.sonar.server.platform;
  21. import com.google.common.io.Resources;
  22. import org.junit.Rule;
  23. import org.junit.Test;
  24. import org.junit.rules.TemporaryFolder;
  25. import org.sonar.api.platform.ServerFileSystem;
  26. import java.io.File;
  27. import java.util.List;
  28. import static org.assertj.core.api.Assertions.assertThat;
  29. public class DefaultServerFileSystemTest {
  30. private static final String PATH = "org/sonar/server/platform/DefaultServerFileSystemTest/";
  31. @Rule
  32. public TemporaryFolder temp = new TemporaryFolder();
  33. @Test
  34. public void find_checkstyle_extensions() throws Exception {
  35. ServerFileSystem fs = new DefaultServerFileSystem(
  36. new File(Resources.getResource(PATH + "shouldFindCheckstyleExtensions").toURI()), temp.newFolder(), null);
  37. List<File> xmls = fs.getExtensions("checkstyle", "xml");
  38. assertThat(xmls).hasSize(1);
  39. List<File> all = fs.getExtensions("checkstyle");
  40. assertThat(all).hasSize(3);
  41. }
  42. @Test
  43. public void not_fail_if_no_checkstyle_extensions() throws Exception {
  44. ServerFileSystem fs = new DefaultServerFileSystem(
  45. new File(Resources.getResource(PATH + "shouldNotFailIfNoCheckstyleExtensions").toURI()), temp.newFolder(), null);
  46. List<File> xmls = fs.getExtensions("checkstyle", "xml");
  47. assertThat(xmls).isEmpty();
  48. List<File> jars = fs.getExtensions("checkstyle");
  49. assertThat(jars).isEmpty();
  50. }
  51. }