use of org.sonar.core.platform.ExplodedPlugin in project sonarqube by SonarSource.
the class CePluginJarExploderTest method explode_jar_to_temp_directory.
@Test
public void explode_jar_to_temp_directory() throws Exception {
PluginInfo info = PluginInfo.create(plugin1Jar());
ExplodedPlugin exploded = underTest.explode(info);
// all the files loaded by classloaders (JAR + META-INF/libs/*.jar) are copied to a dedicated temp directory
File copiedJar = exploded.getMain();
assertThat(exploded.getKey()).isEqualTo("test");
assertThat(copiedJar).isFile().exists();
assertThat(copiedJar.getParentFile()).isDirectory().hasName("test");
assertThat(copiedJar.getParentFile().getParentFile()).isDirectory().hasName("ce-exploded-plugins");
}
use of org.sonar.core.platform.ExplodedPlugin in project sonarqube by SonarSource.
the class CePluginJarExploderTest method explode_is_reentrant.
@Test
public void explode_is_reentrant() throws Exception {
PluginInfo info = PluginInfo.create(plugin1Jar());
ExplodedPlugin exploded1 = underTest.explode(info);
long dirSize1 = sizeOfDirectory(exploded1.getMain().getParentFile());
ExplodedPlugin exploded2 = underTest.explode(info);
long dirSize2 = sizeOfDirectory(exploded2.getMain().getParentFile());
assertThat(exploded2.getMain().getCanonicalPath()).isEqualTo(exploded1.getMain().getCanonicalPath());
assertThat(dirSize1).isEqualTo(dirSize2);
}
use of org.sonar.core.platform.ExplodedPlugin in project sonarqube by SonarSource.
the class ScannerPluginJarExploderTest method copy_and_extract_libs.
@Test
public void copy_and_extract_libs() throws IOException {
File fileFromCache = getFileFromCache("sonar-checkstyle-plugin-2.8.jar");
ExplodedPlugin exploded = underTest.explode(PluginInfo.create(fileFromCache));
assertThat(exploded.getKey()).isEqualTo("checkstyle");
assertThat(exploded.getMain()).isFile().exists();
assertThat(exploded.getLibs()).extracting("name").containsOnly("antlr-2.7.6.jar", "checkstyle-5.1.jar", "commons-cli-1.0.jar");
assertThat(new File(fileFromCache.getParent(), "sonar-checkstyle-plugin-2.8.jar")).exists();
assertThat(new File(fileFromCache.getParent(), "sonar-checkstyle-plugin-2.8.jar_unzip/META-INF/lib/checkstyle-5.1.jar")).exists();
}
use of org.sonar.core.platform.ExplodedPlugin in project sonarqube by SonarSource.
the class CePluginJarExploderTest method plugins_do_not_overlap.
@Test
public void plugins_do_not_overlap() throws Exception {
PluginInfo info1 = PluginInfo.create(plugin1Jar());
PluginInfo info2 = PluginInfo.create(plugin2Jar());
ExplodedPlugin exploded1 = underTest.explode(info1);
ExplodedPlugin exploded2 = underTest.explode(info2);
assertThat(exploded1.getKey()).isEqualTo("test");
assertThat(exploded1.getMain()).isFile().exists().hasName("sonar-test-plugin-0.1-SNAPSHOT.jar");
assertThat(exploded2.getKey()).isEqualTo("test2");
assertThat(exploded2.getMain()).isFile().exists().hasName("sonar-test2-plugin-0.1-SNAPSHOT.jar");
}
use of org.sonar.core.platform.ExplodedPlugin in project sonarqube by SonarSource.
the class ServerPluginJarExploderTest method copy_all_classloader_files_to_dedicated_directory.
@Test
public void copy_all_classloader_files_to_dedicated_directory() throws Exception {
File deployDir = temp.newFolder();
when(fs.getDeployedPluginsDir()).thenReturn(deployDir);
File jar = TestProjectUtils.jarOf("test-libs-plugin");
PluginInfo info = PluginInfo.create(jar);
ExplodedPlugin exploded = underTest.explode(info);
// all the files loaded by classloaders (JAR + META-INF/libs/*.jar) are copied to the dedicated directory
// web/deploy/{pluginKey}
File pluginDeployDir = new File(deployDir, "testlibs");
assertThat(exploded.getKey()).isEqualTo("testlibs");
assertThat(exploded.getMain()).isFile().exists().hasParent(pluginDeployDir);
assertThat(exploded.getLibs()).extracting("name").containsOnly("commons-daemon-1.0.15.jar", "commons-email-20030310.165926.jar");
for (File lib : exploded.getLibs()) {
assertThat(lib).exists().isFile();
assertThat(lib.getCanonicalPath()).startsWith(pluginDeployDir.getCanonicalPath());
}
}
Aggregations