Package org.sonar.api.platform

Examples of org.sonar.api.platform.ServerFileSystem


    assertEquals(repo.createRules().size(), 17);
  }

  @Test(expected = org.sonar.api.utils.SonarException.class)
  public void containsInvalidFormatInExtensionRulesNewFormat() {
    ServerFileSystem filesystem = mock(ServerFileSystem.class);
    ArrayList<File> extensionFile = new ArrayList<File>();
    extensionFile.add(TestUtils.loadResource("/org/sonar/plugins/cxx/rules-repository/CustomRulesInvalid.xml"));
    when(filesystem.getExtensions(CxxValgrindRuleRepository.KEY, "xml")).thenReturn(extensionFile);
    CxxValgrindRuleRepository repo = new CxxValgrindRuleRepository(filesystem, new XMLRuleParser(), new Settings());
    repo.createRules();
  }
View Full Code Here


    repo.createRules();
  }

  @Test(expected = org.sonar.api.utils.SonarException.class)
  public void containsEmptyExtensionRulesFile() {
    ServerFileSystem filesystem = mock(ServerFileSystem.class);
    ArrayList<File> extensionFile = new ArrayList<File>();
    extensionFile.add(TestUtils.loadResource("/org/sonar/plugins/cxx/rules-repository/CustomRulesEmptyFile.xml"));
    when(filesystem.getExtensions(CxxValgrindRuleRepository.KEY, "xml")).thenReturn(extensionFile);
    CxxValgrindRuleRepository repo = new CxxValgrindRuleRepository(filesystem, new XMLRuleParser(), new Settings());
    repo.createRules();
  }
View Full Code Here

    assertEquals(repo.createRules().size(), 16);
  }

  @Test
  public void containsValidFormatInExtensionRulesOldFormat() {
    ServerFileSystem filesystem = mock(ServerFileSystem.class);
    ArrayList<File> extensionFile = new ArrayList<File>();
    extensionFile.add(TestUtils.loadResource("/org/sonar/plugins/cxx/rules-repository/CustomRulesOldFormat.xml"));
    when(filesystem.getExtensions(CxxValgrindRuleRepository.KEY, "xml")).thenReturn(extensionFile);
    CxxValgrindRuleRepository repo = new CxxValgrindRuleRepository(filesystem, new XMLRuleParser(), new Settings());
    assertEquals(repo.createRules().size(), 18);
  }
View Full Code Here

    assertEquals(repo.createRules().size(), 18);
  }

  @Test
  public void containsValidFormatInExtensionRulesNewFormat() {
    ServerFileSystem filesystem = mock(ServerFileSystem.class);
    ArrayList<File> extensionFile = new ArrayList<File>();
    extensionFile.add(TestUtils.loadResource("/org/sonar/plugins/cxx/rules-repository/CustomRulesNewFormat.xml"));
    when(filesystem.getExtensions(CxxValgrindRuleRepository.KEY, "xml")).thenReturn(extensionFile);
    CxxValgrindRuleRepository repo = new CxxValgrindRuleRepository(filesystem, new XMLRuleParser(), new Settings());
    assertEquals(repo.createRules().size(), 17);
  }
View Full Code Here

    assertThat(new File(appDir, "app/views/fake/index.html.erb").exists(), is(true));
  }

  @Test
  public void deployRubyRailsApps_no_apps() throws Exception {
    ServerFileSystem fileSystem = mock(ServerFileSystem.class);
    File tempDir = this.temp.getRoot();
    when(fileSystem.getTempDir()).thenReturn(tempDir);

    PluginRepository pluginRepository = mock(PluginRepository.class);
    when(pluginRepository.getMetadata()).thenReturn(Collections.<PluginMetadata>emptyList());
    new RailsAppsDeployer(fileSystem, pluginRepository).start();
View Full Code Here

    assertThat(FileUtils.listFiles(appDir, null, true).size(), is(0));
  }

  @Test
  public void prepareRubyRailsRootDirectory() throws Exception {
    ServerFileSystem fileSystem = mock(ServerFileSystem.class);
    File tempDir = this.temp.getRoot();
    when(fileSystem.getTempDir()).thenReturn(tempDir);

    File dir = new RailsAppsDeployer(fileSystem, mock(PluginRepository.class)).prepareRailsDirectory();

    assertThat(dir.isDirectory(), is(true));
    assertThat(dir.exists(), is(true));
View Full Code Here

    assertThat(dir.getCanonicalPath(), is(new File(tempDir, "ror").getCanonicalPath()));
  }

  @Test
  public void prepareRubyRailsRootDirectory_delete_existing_dir() throws Exception {
    ServerFileSystem fileSystem = mock(ServerFileSystem.class);
    File tempDir = this.temp.getRoot();
    when(fileSystem.getTempDir()).thenReturn(tempDir);

    File file = new File(tempDir, "ror/foo/bar.txt");
    FileUtils.writeStringToFile(file, "foooo");

    File dir = new RailsAppsDeployer(fileSystem, mock(PluginRepository.class)).prepareRailsDirectory();
View Full Code Here

  @Rule
  public TemporaryFolder temp = new TemporaryFolder();

  @Test
  public void createTempFolder() throws Exception {
    ServerFileSystem fs = mock(ServerFileSystem.class);
    File serverTempFolder = temp.newFolder();
    when(fs.getTempDir()).thenReturn(serverTempFolder);
    TempFolderProvider tempFolderProvider = new TempFolderProvider();
    TempFolder tempUtils = tempFolderProvider.provide(fs);
    tempUtils.newDir();
    tempUtils.newFile();
    assertThat(new File(serverTempFolder, "tmp")).exists();
View Full Code Here

    assertThat(plugins).isEmpty();
  }

  @Test
  public void find_checkstyle_extensions() throws Exception {
    ServerFileSystem fs = new DefaultServerFileSystem(new File(Resources.getResource(PATH + "shouldFindCheckstyleExtensions").toURI()), null);

    List<File> xmls = fs.getExtensions("checkstyle", "xml");
    assertThat(xmls).hasSize(1);

    List<File> all = fs.getExtensions("checkstyle");
    assertThat(all).hasSize(3);
  }
View Full Code Here

    assertThat(all).hasSize(3);
  }

  @Test
  public void not_fail_if_no_checkstyle_extensions() throws Exception {
    ServerFileSystem fs = new DefaultServerFileSystem(new File(Resources.getResource(PATH + "shouldNotFailIfNoCheckstyleExtensions").toURI()), null);
    List<File> xmls = fs.getExtensions("checkstyle", "xml");
    assertThat(xmls).isEmpty();

    List<File> jars = fs.getExtensions("checkstyle");
    assertThat(jars).isEmpty();
  }
View Full Code Here

TOP

Related Classes of org.sonar.api.platform.ServerFileSystem

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.