aboutsummaryrefslogtreecommitdiffstats
path: root/subprojects/sonar-update-center
diff options
context:
space:
mode:
authorsimonbrandhof <simon.brandhof@gmail.com>2010-11-08 13:38:15 +0000
committersimonbrandhof <simon.brandhof@gmail.com>2010-11-08 13:38:15 +0000
commita0172bcd669bc80265d35ba1033041c75e659c6d (patch)
tree60eff14342f1efb6fbbb750a58eee6b5c41703ab /subprojects/sonar-update-center
parent77f14b5d770d088dcd5fe43f1359f90cbba5c513 (diff)
downloadsonarqube-a0172bcd669bc80265d35ba1033041c75e659c6d.tar.gz
sonarqube-a0172bcd669bc80265d35ba1033041c75e659c6d.zip
sonar-update-center subproject: add an integration test to test extraction of plugin key from maven artifact id
Diffstat (limited to 'subprojects/sonar-update-center')
-rw-r--r--subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/extractPluginKeyFromArtifactId/pom.xml38
-rw-r--r--subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/extractPluginKeyFromArtifactId/src/main/java/org/sonar/plugins/sample/SamplePlugin.java30
-rw-r--r--subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/extractPluginKeyFromArtifactId/verify.bsh23
3 files changed, 91 insertions, 0 deletions
diff --git a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/extractPluginKeyFromArtifactId/pom.xml b/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/extractPluginKeyFromArtifactId/pom.xml
new file mode 100644
index 00000000000..1ea50bd814c
--- /dev/null
+++ b/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/extractPluginKeyFromArtifactId/pom.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.codehaus.sonar</groupId>
+ <artifactId>sonar-it-extract-plugin-key-plugin</artifactId>
+ <version>1.0</version>
+ <packaging>sonar-plugin</packaging>
+ <name>Package dependencies</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.codehaus.sonar</groupId>
+ <artifactId>sonar-plugin-api</artifactId>
+ <version>@sonar.version@</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>@project.groupId@</groupId>
+ <artifactId>@project.artifactId@</artifactId>
+ <version>@project.version@</version>
+ <extensions>true</extensions>
+ <configuration>
+ <pluginClass>org.sonar.plugins.sample.SamplePlugin</pluginClass>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.3.1</version>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/extractPluginKeyFromArtifactId/src/main/java/org/sonar/plugins/sample/SamplePlugin.java b/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/extractPluginKeyFromArtifactId/src/main/java/org/sonar/plugins/sample/SamplePlugin.java
new file mode 100644
index 00000000000..31710c3a0e6
--- /dev/null
+++ b/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/extractPluginKeyFromArtifactId/src/main/java/org/sonar/plugins/sample/SamplePlugin.java
@@ -0,0 +1,30 @@
+package org.sonar.plugins.sample;
+
+import org.sonar.api.Extension;
+import org.sonar.api.Plugin;
+
+import java.util.Collections;
+import java.util.List;
+
+public class SamplePlugin implements Plugin {
+ public String getKey() {
+ return "sample";
+ }
+
+ public String getName() {
+ return "My first Sonar plugin";
+ }
+
+ public String getDescription() {
+ return "You shouldn't expect too much from this plugin.";
+ }
+
+ public List<Class<? extends Extension>> getExtensions() {
+ return Collections.emptyList();
+ }
+
+ @Override
+ public String toString() {
+ return getKey();
+ }
+}
diff --git a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/extractPluginKeyFromArtifactId/verify.bsh b/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/extractPluginKeyFromArtifactId/verify.bsh
new file mode 100644
index 00000000000..683a784d2c7
--- /dev/null
+++ b/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/extractPluginKeyFromArtifactId/verify.bsh
@@ -0,0 +1,23 @@
+import java.io.*;
+import java.util.zip.*;
+import java.util.jar.Manifest;
+
+File file = new File( basedir, "target/sonar-it-extract-plugin-key-plugin-1.0.jar" );
+if ( !file.isFile() )
+{
+ throw new FileNotFoundException( "Could not find generated JAR: " + file );
+}
+
+ZipFile zipFile = new ZipFile(file);
+InputStream input = null;
+try {
+ input = zipFile.getInputStream(zipFile.getEntry("META-INF/MANIFEST.MF"));
+ Manifest manifest = new Manifest(input);
+ String key = manifest.getMainAttributes().getValue("Plugin-Key");
+ if (!key.equals("itextractpluginkey")) {
+ throw new Exception("Plugin key is not valid: " + key);
+ }
+} finally {
+ zipFile.close();
+ input.close();
+}