From 2a5eea17c29c46566a13f84eead54b202a9bae83 Mon Sep 17 00:00:00 2001 From: Duarte Meneses Date: Fri, 14 Aug 2015 14:49:49 +0200 Subject: Migrate batch ITs --- it/it-plugins/access-secured-props-plugin/pom.xml | 38 ++++++++++++++++++++++ .../src/main/java/AccessSecuredPropsPlugin.java | 12 +++++++ .../src/main/java/AccessSecuredPropsSensor.java | 31 ++++++++++++++++++ .../main/java/AccessSecuredPropsTaskExtension.java | 28 ++++++++++++++++ 4 files changed, 109 insertions(+) create mode 100644 it/it-plugins/access-secured-props-plugin/pom.xml create mode 100644 it/it-plugins/access-secured-props-plugin/src/main/java/AccessSecuredPropsPlugin.java create mode 100644 it/it-plugins/access-secured-props-plugin/src/main/java/AccessSecuredPropsSensor.java create mode 100644 it/it-plugins/access-secured-props-plugin/src/main/java/AccessSecuredPropsTaskExtension.java (limited to 'it/it-plugins/access-secured-props-plugin') diff --git a/it/it-plugins/access-secured-props-plugin/pom.xml b/it/it-plugins/access-secured-props-plugin/pom.xml new file mode 100644 index 00000000000..61adaec8c60 --- /dev/null +++ b/it/it-plugins/access-secured-props-plugin/pom.xml @@ -0,0 +1,38 @@ + + + 4.0.0 + + org.sonarsource.it + it-plugins + 5.2-SNAPSHOT + + + access-secured-props-plugin + sonar-plugin + Plugins :: Access Secured Properties + 1.0-SNAPSHOT + Access .secured properties + + + + org.codehaus.sonar + sonar-plugin-api + ${apiVersion} + provided + + + + + + + org.codehaus.sonar + sonar-packaging-maven-plugin + 1.12.1 + true + + AccessSecuredPropsPlugin + + + + + diff --git a/it/it-plugins/access-secured-props-plugin/src/main/java/AccessSecuredPropsPlugin.java b/it/it-plugins/access-secured-props-plugin/src/main/java/AccessSecuredPropsPlugin.java new file mode 100644 index 00000000000..a32191e86b1 --- /dev/null +++ b/it/it-plugins/access-secured-props-plugin/src/main/java/AccessSecuredPropsPlugin.java @@ -0,0 +1,12 @@ +import org.sonar.api.SonarPlugin; + +import java.util.Arrays; +import java.util.List; + +public class AccessSecuredPropsPlugin extends SonarPlugin { + + public List getExtensions() { + return Arrays.asList(AccessSecuredPropsSensor.class, AccessSecuredPropsTaskExtension.class); + } + +} diff --git a/it/it-plugins/access-secured-props-plugin/src/main/java/AccessSecuredPropsSensor.java b/it/it-plugins/access-secured-props-plugin/src/main/java/AccessSecuredPropsSensor.java new file mode 100644 index 00000000000..bb0eb46b68c --- /dev/null +++ b/it/it-plugins/access-secured-props-plugin/src/main/java/AccessSecuredPropsSensor.java @@ -0,0 +1,31 @@ +import org.sonar.api.Properties; +import org.sonar.api.Property; +import org.sonar.api.batch.Sensor; +import org.sonar.api.batch.SensorContext; +import org.sonar.api.config.Settings; +import org.sonar.api.resources.Project; + +@Properties({ + @Property( + key = "accessSecuredFromSensor", + name = "Property to decide if sensor should access secured properties", + defaultValue = "false") +}) +public class AccessSecuredPropsSensor implements Sensor { + + private Settings settings; + + public AccessSecuredPropsSensor(Settings settings) { + this.settings = settings; + } + + public boolean shouldExecuteOnProject(Project project) { + return true; + } + + public void analyse(Project project, SensorContext sensorContext) { + if ("true".equals(settings.getString("accessSecuredFromSensor"))) { + settings.getString("foo.bar.secured"); + } + } +} diff --git a/it/it-plugins/access-secured-props-plugin/src/main/java/AccessSecuredPropsTaskExtension.java b/it/it-plugins/access-secured-props-plugin/src/main/java/AccessSecuredPropsTaskExtension.java new file mode 100644 index 00000000000..5ff17200580 --- /dev/null +++ b/it/it-plugins/access-secured-props-plugin/src/main/java/AccessSecuredPropsTaskExtension.java @@ -0,0 +1,28 @@ +import org.sonar.api.Properties; +import org.sonar.api.Property; +import org.sonar.api.batch.Sensor; +import org.sonar.api.batch.SensorContext; +import org.sonar.api.config.Settings; +import org.sonar.api.task.TaskExtension; +import org.sonar.api.resources.Project; + +@Properties({ + @Property( + key = "accessSecuredFromTask", + name = "Property to decide if task extension should access secured properties", + defaultValue = "false") +}) +public class AccessSecuredPropsTaskExtension implements TaskExtension { + + private Settings settings; + + public AccessSecuredPropsTaskExtension(Settings settings) { + this.settings = settings; + } + + public void start() { + if ("true".equals(settings.getString("accessSecuredFromTask"))) { + settings.getString("foo.bar.secured"); + } + } +} -- cgit v1.2.3