Package org.sonar.api.platform

Examples of org.sonar.api.platform.PluginMetadata


public class PluginReferentialMetadataConverterTest {

  @Test
  public void should_convert_metadata_to_plugin_referential() {
    PluginMetadata metadata = mock(DefaultPluginMetadata.class);
    when(metadata.getKey()).thenReturn("foo");

    PluginReferential pluginReferential = PluginReferentialMetadataConverter.getInstalledPluginReferential(newArrayList(metadata));
    assertThat(pluginReferential).isNotNull();
    assertThat(pluginReferential.getPlugins()).hasSize(1);
    assertThat(pluginReferential.getPlugins().get(0).getKey()).isEqualTo("foo");
View Full Code Here


    assertThat(pluginReferential.getPlugins().get(0).getKey()).isEqualTo("foo");
  }

  @Test
  public void should_not_add_core_plugin() {
    PluginMetadata metadata = mock(DefaultPluginMetadata.class);
    when(metadata.getKey()).thenReturn("foo");
    when(metadata.isCore()).thenReturn(true);

    PluginReferential pluginReferential = PluginReferentialMetadataConverter.getInstalledPluginReferential(newArrayList(metadata));
    assertThat(pluginReferential).isNotNull();
    assertThat(pluginReferential.getPlugins()).hasSize(0);
  }
View Full Code Here

public class InstalledPluginReferentialFactoryTest {

  @Test
  public void should_create_plugin_referential() {
    PluginMetadata metadata = mock(DefaultPluginMetadata.class);
    when(metadata.getKey()).thenReturn("foo");
    PluginRepository pluginRepository = mock(PluginRepository.class);
    when(pluginRepository.getMetadata()).thenReturn(newArrayList(metadata));
    InstalledPluginReferentialFactory installedPluginReferentialFactory = new InstalledPluginReferentialFactory(pluginRepository);

    assertThat(installedPluginReferentialFactory.getInstalledPluginReferential()).isNull();
View Full Code Here

  }

  @Test
  public void shouldWriteIndex() throws IOException {
    PluginRepository repository = mock(PluginRepository.class);
    PluginMetadata sqale = newMetadata("sqale");
    PluginMetadata checkstyle = newMetadata("checkstyle");
    when(repository.getMetadata()).thenReturn(Arrays.asList(sqale, checkstyle));

    new GeneratePluginIndex(fileSystem, repository).start();

    List<String> lines = FileUtils.readLines(index);
View Full Code Here

    assertThat(lines.get(0), containsString("sqale"));
    assertThat(lines.get(1), containsString("checkstyle"));
  }

  private PluginMetadata newMetadata(String pluginKey) throws IOException {
    PluginMetadata plugin = mock(DefaultPluginMetadata.class);
    when(plugin.getKey()).thenReturn(pluginKey);
    File pluginFile = temp.newFile(pluginKey + ".jar");
    when(plugin.getFile()).thenReturn(pluginFile);
    return plugin;
  }
View Full Code Here

  @Test
  public void testStart() throws Exception {
    ServerPluginJarsInstaller deployer = mock(ServerPluginJarsInstaller.class);
    File pluginFile = new File(Resources.getResource("org/sonar/server/plugins/ServerPluginRepositoryTest/sonar-artifact-size-plugin-0.2.jar").toURI());
    PluginMetadata plugin = DefaultPluginMetadata.create(pluginFile)
      .setKey("artifactsize")
      .setMainClass("org.sonar.plugins.artifactsize.ArtifactSizePlugin")
      .addDeployedFile(pluginFile);
    when(deployer.getMetadata()).thenReturn(Arrays.asList(plugin));
View Full Code Here

    jarsInstaller.install();

    assertThat(FileUtils.listFiles(pluginsDir, new String[] {"jar"}, false)).hasSize(1);
    assertThat(new File(pluginsDir, "foo-plugin-1.0.jar")).exists().isFile();
    PluginMetadata plugin = jarsInstaller.getMetadata("foo");
    assertThat(plugin.getName()).isEqualTo("Foo");
    assertThat(plugin.getDeployedFiles()).hasSize(1);
    assertThat(plugin.isCore()).isFalse();
    assertThat(plugin.isUseChildFirstClassLoader()).isFalse();
  }
View Full Code Here

    // do not copy foo 1.0
    assertThat(FileUtils.listFiles(pluginsDir, new String[] {"jar"}, false)).hasSize(2);
    assertThat(new File(pluginsDir, "foo-plugin-2.0.jar")).exists().isFile();
    assertThat(new File(pluginsDir, "bar-plugin-1.0.jar")).exists().isFile();
    PluginMetadata plugin = jarsInstaller.getMetadata("foo");
    assertThat(plugin.getVersion()).isEqualTo("2.0");
  }
View Full Code Here

    jarsInstaller.install();

    // check that the plugin is registered
    assertThat(jarsInstaller.getMetadata()).hasSize(1);
    PluginMetadata plugin = jarsInstaller.getMetadata("foo");
    assertThat(plugin.getName()).isEqualTo("Foo");
    assertThat(plugin.getDeployedFiles()).hasSize(1);
    assertThat(plugin.isCore()).isFalse();
    assertThat(plugin.isUseChildFirstClassLoader()).isFalse();

    // check that the file is still present in extensions/plugins
    assertThat(FileUtils.listFiles(pluginsDir, new String[] {"jar"}, false)).hasSize(1);
    assertThat(new File(pluginsDir, "foo-plugin-1.0.jar")).exists().isFile();
  }
View Full Code Here

      doInstall(container, matcher, null, o);
    }

    // plugin extensions
    for (Map.Entry<PluginMetadata, Plugin> entry : pluginRepository.getPluginsByMetadata().entrySet()) {
      PluginMetadata metadata = entry.getKey();
      Plugin plugin = entry.getValue();
      for (Object extension : plugin.getExtensions()) {
        doInstall(container, matcher, metadata, extension);
      }
    }
View Full Code Here

TOP

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

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.