Browse Source

Migrate batch ITs

tags/5.2-RC1
Duarte Meneses 8 years ago
parent
commit
2a5eea17c2
100 changed files with 1421 additions and 0 deletions
  1. 1
    0
      .travis.yml
  2. 38
    0
      it/it-plugins/access-secured-props-plugin/pom.xml
  3. 12
    0
      it/it-plugins/access-secured-props-plugin/src/main/java/AccessSecuredPropsPlugin.java
  4. 31
    0
      it/it-plugins/access-secured-props-plugin/src/main/java/AccessSecuredPropsSensor.java
  5. 28
    0
      it/it-plugins/access-secured-props-plugin/src/main/java/AccessSecuredPropsTaskExtension.java
  6. 38
    0
      it/it-plugins/batch-plugin/pom.xml
  7. 17
    0
      it/it-plugins/batch-plugin/src/main/java/com/sonarsource/BatchPlugin.java
  8. 43
    0
      it/it-plugins/batch-plugin/src/main/java/com/sonarsource/DumpSettingsInitializer.java
  9. 26
    0
      it/it-plugins/batch-plugin/src/main/java/com/sonarsource/RaiseMessageException.java
  10. 41
    0
      it/it-plugins/batch-plugin/src/main/java/com/sonarsource/TempFolderExtension.java
  11. 38
    0
      it/it-plugins/crash-plugin/pom.xml
  12. 12
    0
      it/it-plugins/crash-plugin/src/main/java/CrashPlugin.java
  13. 31
    0
      it/it-plugins/crash-plugin/src/main/java/CrashSensor.java
  14. 36
    0
      it/it-plugins/extension-lifecycle-plugin/pom.xml
  15. 53
    0
      it/it-plugins/extension-lifecycle-plugin/src/main/java/BatchService.java
  16. 10
    0
      it/it-plugins/extension-lifecycle-plugin/src/main/java/ExtensionLifecyclePlugin.java
  17. 39
    0
      it/it-plugins/extension-lifecycle-plugin/src/main/java/ProjectService.java
  18. 4
    0
      it/it-plugins/extension-lifecycle-plugin/src/main/java/ServerService.java
  19. 6
    0
      it/it-plugins/pom.xml
  20. 36
    0
      it/it-plugins/project-builder-plugin/pom.xml
  21. 58
    0
      it/it-plugins/project-builder-plugin/src/main/java/CreateSubProjects.java
  22. 10
    0
      it/it-plugins/project-builder-plugin/src/main/java/ProjectBuilderPlugin.java
  23. 28
    0
      it/it-plugins/project-builder-plugin/src/main/java/RenameProject.java
  24. 36
    0
      it/it-plugins/settings-encryption-plugin/pom.xml
  25. 21
    0
      it/it-plugins/settings-encryption-plugin/src/main/java/EncryptionVerifier.java
  26. 10
    0
      it/it-plugins/settings-encryption-plugin/src/main/java/SettingsEncryptionPlugin.java
  27. 5
    0
      it/it-projects/batch/case-sensitive-file-extensions/sonar-project.properties
  28. 2
    0
      it/it-projects/batch/case-sensitive-file-extensions/src/UPPER.XOO
  29. 1
    0
      it/it-projects/batch/case-sensitive-file-extensions/src/UPPER.XOO.measures
  30. 10
    0
      it/it-projects/batch/case-sensitive-file-extensions/src/lower.xoo
  31. 1
    0
      it/it-projects/batch/case-sensitive-file-extensions/src/lower.xoo.measures
  32. 2
    0
      it/it-projects/batch/custom-module-key/module_a/sonar-project.properties
  33. 16
    0
      it/it-projects/batch/custom-module-key/module_a/src/main/xoo/com/sonar/it/samples/modules/a1/HelloA1.xoo
  34. 2
    0
      it/it-projects/batch/custom-module-key/module_a/src/main/xoo/com/sonar/it/samples/modules/a1/HelloA1.xoo.measures
  35. 2
    0
      it/it-projects/batch/custom-module-key/module_b/sonar-project.properties
  36. 12
    0
      it/it-projects/batch/custom-module-key/module_b/src/main/xoo/com/sonar/it/samples/modules/a2/HelloA2.xoo
  37. 2
    0
      it/it-projects/batch/custom-module-key/module_b/src/main/xoo/com/sonar/it/samples/modules/a2/HelloA2.xoo.measures
  38. 12
    0
      it/it-projects/batch/custom-module-key/sonar-project.properties
  39. 6
    0
      it/it-projects/batch/duplicate-source/sonar-project.properties
  40. 5
    0
      it/it-projects/batch/duplicate-source/src/main/xoo/org/sonar/tests/ClassOne.xoo
  41. 5
    0
      it/it-projects/batch/duplicate-source/src/main/xoo2/org/sonar/tests/ClassOne.xoo
  42. 5
    0
      it/it-projects/batch/duplicate-source/src/test/xoo/org/sonar/tests/ClassOne.xoo
  43. 14
    0
      it/it-projects/batch/extension-lifecycle/module_a/pom.xml
  44. 10
    0
      it/it-projects/batch/extension-lifecycle/module_a/src/main/java/HelloA.java
  45. 13
    0
      it/it-projects/batch/extension-lifecycle/module_b/pom.xml
  46. 10
    0
      it/it-projects/batch/extension-lifecycle/module_b/src/main/java/HelloB.java
  47. 13
    0
      it/it-projects/batch/extension-lifecycle/pom.xml
  48. 31
    0
      it/it-projects/batch/links-project/pom.xml
  49. 11
    0
      it/it-projects/batch/links-project/sonar-project.properties
  50. 12
    0
      it/it-projects/batch/links-project/src/main/java/sample/Sample.java
  51. 15
    0
      it/it-projects/batch/multi-languages/java-module/pom.xml
  52. 10
    0
      it/it-projects/batch/multi-languages/java-module/src/main/java/HelloJava.java
  53. 20
    0
      it/it-projects/batch/multi-languages/javascript-module/pom.xml
  54. 14
    0
      it/it-projects/batch/multi-languages/javascript-module/src/Person.js
  55. 16
    0
      it/it-projects/batch/multi-languages/pom.xml
  56. 19
    0
      it/it-projects/batch/multi-languages/python-module/pom.xml
  57. 0
    0
      it/it-projects/batch/multi-languages/python-module/src/__init__.py
  58. 92
    0
      it/it-projects/batch/multi-languages/python-module/src/badfortune.py
  59. 19
    0
      it/it-projects/batch/multi-languages/sonar-project.properties
  60. 2
    0
      it/it-projects/batch/prevent-common-module/projectAB/module_a/sonar-project.properties
  61. 16
    0
      it/it-projects/batch/prevent-common-module/projectAB/module_a/src/main/xoo/com/sonar/it/samples/modules/a1/HelloA1.xoo
  62. 2
    0
      it/it-projects/batch/prevent-common-module/projectAB/module_a/src/main/xoo/com/sonar/it/samples/modules/a1/HelloA1.xoo.measures
  63. 2
    0
      it/it-projects/batch/prevent-common-module/projectAB/module_b/sonar-project.properties
  64. 12
    0
      it/it-projects/batch/prevent-common-module/projectAB/module_b/src/main/xoo/com/sonar/it/samples/modules/a2/HelloA2.xoo
  65. 2
    0
      it/it-projects/batch/prevent-common-module/projectAB/module_b/src/main/xoo/com/sonar/it/samples/modules/a2/HelloA2.xoo.measures
  66. 12
    0
      it/it-projects/batch/prevent-common-module/projectAB/sonar-project.properties
  67. 2
    0
      it/it-projects/batch/prevent-common-module/projectAC/module_a/sonar-project.properties
  68. 16
    0
      it/it-projects/batch/prevent-common-module/projectAC/module_a/src/main/xoo/com/sonar/it/samples/modules/a1/HelloA1.xoo
  69. 2
    0
      it/it-projects/batch/prevent-common-module/projectAC/module_a/src/main/xoo/com/sonar/it/samples/modules/a1/HelloA1.xoo.measures
  70. 2
    0
      it/it-projects/batch/prevent-common-module/projectAC/module_c/sonar-project.properties
  71. 12
    0
      it/it-projects/batch/prevent-common-module/projectAC/module_c/src/main/xoo/com/sonar/it/samples/modules/a2/HelloA2.xoo
  72. 2
    0
      it/it-projects/batch/prevent-common-module/projectAC/module_c/src/main/xoo/com/sonar/it/samples/modules/a2/HelloA2.xoo.measures
  73. 12
    0
      it/it-projects/batch/prevent-common-module/projectAC/sonar-project.properties
  74. 10
    0
      it/it-projects/batch/project-builder/module_a/src/HelloA.java
  75. 10
    0
      it/it-projects/batch/project-builder/module_b/src/HelloB.java
  76. 1
    0
      it/it-projects/batch/project-builder/module_b/src/IgnoredFile.java
  77. 15
    0
      it/it-projects/batch/project-builder/pom.xml
  78. 5
    0
      it/it-projects/batch/tracking/v1/sonar-project.properties
  79. 12
    0
      it/it-projects/batch/tracking/v1/src/main/xoo/sample/Sample.xoo
  80. 1
    0
      it/it-projects/batch/tracking/v1/src/main/xoo/sample/Sample.xoo.measures
  81. 5
    0
      it/it-projects/batch/tracking/v2/sonar-project.properties
  82. 14
    0
      it/it-projects/batch/tracking/v2/src/main/xoo/sample/Sample.xoo
  83. 1
    0
      it/it-projects/batch/tracking/v2/src/main/xoo/sample/Sample.xoo.measures
  84. 5
    0
      it/it-projects/batch/xoo-history-v2/sonar-project.properties
  85. 12
    0
      it/it-projects/batch/xoo-history-v2/src/main/xoo/sample/ClassAdded.xoo
  86. 3
    0
      it/it-projects/batch/xoo-history-v2/src/main/xoo/sample/ClassAdded.xoo.measures
  87. 16
    0
      it/it-projects/batch/xoo-history-v2/src/main/xoo/sample/ClassToModify.xoo
  88. 3
    0
      it/it-projects/batch/xoo-history-v2/src/main/xoo/sample/ClassToModify.xoo.measures
  89. 12
    0
      it/it-projects/batch/xoo-history-v2/src/main/xoo/sample/UnchangedClass.xoo
  90. 2
    0
      it/it-projects/batch/xoo-history-v2/src/main/xoo/sample/UnchangedClass.xoo.measures
  91. 4
    0
      it/it-projects/batch/xoo-multi-languages/sonar-project.properties
  92. 12
    0
      it/it-projects/batch/xoo-multi-languages/src/sample/Sample.xoo
  93. 10
    0
      it/it-projects/batch/xoo-multi-languages/src/sample/Sample.xoo.measures
  94. 12
    0
      it/it-projects/batch/xoo-multi-languages/src/sample/Sample.xoo2
  95. 10
    0
      it/it-projects/batch/xoo-multi-languages/src/sample/Sample.xoo2.measures
  96. 12
    0
      it/it-projects/batch/xoo-sample-with-spaces/v1/my sources/main/xoo/sample/My Sample.xoo
  97. 11
    0
      it/it-projects/batch/xoo-sample-with-spaces/v1/my sources/main/xoo/sample/My Sample.xoo.measures
  98. 5
    0
      it/it-projects/batch/xoo-sample-with-spaces/v1/sonar-project.properties
  99. 12
    0
      it/it-projects/batch/xoo-sample-with-spaces/v2/my sources/main/xoo/sample/My Sample.xoo
  100. 0
    0
      it/it-projects/batch/xoo-sample-with-spaces/v2/my sources/main/xoo/sample/My Sample.xoo.measures

+ 1
- 0
.travis.yml View File

@@ -13,6 +13,7 @@ env:
- JOB=ITS IT_CATEGORY=issue
- JOB=ITS IT_CATEGORY=analysis
- JOB=ITS IT_CATEGORY=administration
- JOB=ITS IT_CATEGORY=batch
- JOB=ITS IT_CATEGORY=server
- JOB=ITS IT_CATEGORY=plugins
- JOB=ITS IT_CATEGORY=qualitygate

+ 38
- 0
it/it-plugins/access-secured-props-plugin/pom.xml View File

@@ -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>
<parent>
<groupId>org.sonarsource.it</groupId>
<artifactId>it-plugins</artifactId>
<version>5.2-SNAPSHOT</version>
</parent>

<artifactId>access-secured-props-plugin</artifactId>
<packaging>sonar-plugin</packaging>
<name>Plugins :: Access Secured Properties</name>
<version>1.0-SNAPSHOT</version>
<description>Access .secured properties</description>

<dependencies>
<dependency>
<groupId>org.codehaus.sonar</groupId>
<artifactId>sonar-plugin-api</artifactId>
<version>${apiVersion}</version>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.codehaus.sonar</groupId>
<artifactId>sonar-packaging-maven-plugin</artifactId>
<version>1.12.1</version>
<extensions>true</extensions>
<configuration>
<pluginClass>AccessSecuredPropsPlugin</pluginClass>
</configuration>
</plugin>
</plugins>
</build>
</project>

+ 12
- 0
it/it-plugins/access-secured-props-plugin/src/main/java/AccessSecuredPropsPlugin.java View File

@@ -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);
}

}

+ 31
- 0
it/it-plugins/access-secured-props-plugin/src/main/java/AccessSecuredPropsSensor.java View File

@@ -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");
}
}
}

+ 28
- 0
it/it-plugins/access-secured-props-plugin/src/main/java/AccessSecuredPropsTaskExtension.java View File

@@ -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");
}
}
}

+ 38
- 0
it/it-plugins/batch-plugin/pom.xml View File

@@ -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>
<parent>
<groupId>org.sonarsource.it</groupId>
<artifactId>it-plugins</artifactId>
<version>5.2-SNAPSHOT</version>
</parent>

<artifactId>batch-plugin</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>sonar-plugin</packaging>
<name>SonarQube Integration Tests :: Plugins :: Batch</name>
<description>Main plugin for batch tests</description>

<dependencies>
<dependency>
<groupId>org.codehaus.sonar</groupId>
<artifactId>sonar-plugin-api</artifactId>
<version>${apiVersion}</version>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.codehaus.sonar</groupId>
<artifactId>sonar-packaging-maven-plugin</artifactId>
<version>1.12.1</version>
<extensions>true</extensions>
<configuration>
<pluginClass>com.sonarsource.BatchPlugin</pluginClass>
</configuration>
</plugin>
</plugins>
</build>
</project>

+ 17
- 0
it/it-plugins/batch-plugin/src/main/java/com/sonarsource/BatchPlugin.java View File

@@ -0,0 +1,17 @@
package com.sonarsource;

import java.util.Arrays;
import java.util.List;
import org.sonar.api.SonarPlugin;

public class BatchPlugin extends SonarPlugin {

public List getExtensions() {
return Arrays.asList(
DumpSettingsInitializer.class,
RaiseMessageException.class,
TempFolderExtension.class
);
}

}

+ 43
- 0
it/it-plugins/batch-plugin/src/main/java/com/sonarsource/DumpSettingsInitializer.java View File

@@ -0,0 +1,43 @@
package com.sonarsource;

import org.sonar.api.Properties;
import org.sonar.api.Property;
import org.sonar.api.PropertyType;
import org.sonar.api.batch.Initializer;
import org.sonar.api.config.Settings;
import org.sonar.api.resources.Project;

import java.util.Map.Entry;
import java.util.TreeMap;

@Properties({
@Property(
key = DumpSettingsInitializer.SONAR_SHOW_SETTINGS,
type = PropertyType.BOOLEAN,
name = "Property to decide if it should output settings",
defaultValue = "false")
})
public class DumpSettingsInitializer extends Initializer {

public static final String SONAR_SHOW_SETTINGS = "sonar.showSettings";
private Settings settings;

public DumpSettingsInitializer(Settings settings) {
this.settings = settings;
}

@Override
public boolean shouldExecuteOnProject(Project project) {
return true;
}

@Override
public void execute(Project project) {
if (settings.getBoolean(SONAR_SHOW_SETTINGS)) {
TreeMap<String, String> treemap = new TreeMap<String, String>(settings.getProperties());
for (Entry<String, String> prop : treemap.entrySet()) {
System.out.println(" o " + project.getKey() + ":" + prop.getKey() + " = " + prop.getValue());
}
}
}
}

+ 26
- 0
it/it-plugins/batch-plugin/src/main/java/com/sonarsource/RaiseMessageException.java View File

@@ -0,0 +1,26 @@
package com.sonarsource;

import org.sonar.api.batch.Sensor;
import org.sonar.api.batch.SensorContext;
import org.sonar.api.config.Settings;
import org.sonar.api.resources.Project;
import org.sonar.api.utils.MessageException;

public class RaiseMessageException implements Sensor {

private final Settings settings;

public RaiseMessageException(Settings settings) {
this.settings = settings;
}

@Override
public boolean shouldExecuteOnProject(Project project) {
return settings.getBoolean("raiseMessageException");
}

@Override
public void analyse(Project project, SensorContext sensorContext) {
throw MessageException.of("Error message from plugin");
}
}

+ 41
- 0
it/it-plugins/batch-plugin/src/main/java/com/sonarsource/TempFolderExtension.java View File

@@ -0,0 +1,41 @@
package com.sonarsource;

import org.sonar.api.Properties;
import org.sonar.api.Property;
import org.sonar.api.PropertyType;
import org.sonar.api.batch.Initializer;
import org.sonar.api.config.Settings;
import org.sonar.api.resources.Project;
import org.sonar.api.utils.TempFolder;

@Properties({
@Property(
key = TempFolderExtension.CREATE_TEMP_FILES,
type = PropertyType.BOOLEAN,
name = "Property to decide if it should create temp files",
defaultValue = "false")
})
public class TempFolderExtension extends Initializer {

public static final String CREATE_TEMP_FILES = "sonar.createTempFiles";
private Settings settings;
private TempFolder tempFolder;

public TempFolderExtension(Settings settings, TempFolder tempFolder) {
this.settings = settings;
this.tempFolder = tempFolder;
}

@Override
public boolean shouldExecuteOnProject(Project project) {
return true;
}

@Override
public void execute(Project project) {
if (settings.getBoolean(CREATE_TEMP_FILES)) {
System.out.println("Creating temp directory: " + tempFolder.newDir("sonar-it").getAbsolutePath());
System.out.println("Creating temp file: " + tempFolder.newFile("sonar-it", ".txt").getAbsolutePath());
}
}
}

+ 38
- 0
it/it-plugins/crash-plugin/pom.xml View File

@@ -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>
<parent>
<groupId>org.sonarsource.it</groupId>
<artifactId>it-plugins</artifactId>
<version>5.2-SNAPSHOT</version>
</parent>

<artifactId>crash-plugin</artifactId>
<packaging>sonar-plugin</packaging>
<name>Plugins :: Crash</name>
<version>1.0-SNAPSHOT</version>
<description>Crash on demand</description>

<dependencies>
<dependency>
<groupId>org.codehaus.sonar</groupId>
<artifactId>sonar-plugin-api</artifactId>
<version>${apiVersion}</version>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.codehaus.sonar</groupId>
<artifactId>sonar-packaging-maven-plugin</artifactId>
<version>1.12.1</version>
<extensions>true</extensions>
<configuration>
<pluginClass>CrashPlugin</pluginClass>
</configuration>
</plugin>
</plugins>
</build>
</project>

+ 12
- 0
it/it-plugins/crash-plugin/src/main/java/CrashPlugin.java View File

@@ -0,0 +1,12 @@
import org.sonar.api.SonarPlugin;

import java.util.Arrays;
import java.util.List;

public class CrashPlugin extends SonarPlugin {

public List getExtensions() {
return Arrays.asList(CrashSensor.class);
}

}

+ 31
- 0
it/it-plugins/crash-plugin/src/main/java/CrashSensor.java View File

@@ -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 = "crash",
name = "Property to decide if it crash or not",
defaultValue = "false")
})
public class CrashSensor implements Sensor {

private Settings settings;

public CrashSensor(Settings settings) {
this.settings = settings;
}

public boolean shouldExecuteOnProject(Project project) {
return true;
}

public void analyse(Project project, SensorContext sensorContext) {
if ("true".equals(settings.getString("crash"))) {
throw new RuntimeException("Crash!");
}
}
}

+ 36
- 0
it/it-plugins/extension-lifecycle-plugin/pom.xml View File

@@ -0,0 +1,36 @@
<?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>
<parent>
<groupId>org.sonarsource.it</groupId>
<artifactId>it-plugins</artifactId>
<version>5.2-SNAPSHOT</version>
</parent>
<artifactId>extension-lifecycle-plugin</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>sonar-plugin</packaging>
<description>Plugins :: Extension Lifecycle</description>

<dependencies>
<dependency>
<groupId>org.codehaus.sonar</groupId>
<artifactId>sonar-plugin-api</artifactId>
<version>${apiVersion}</version>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.codehaus.sonar</groupId>
<artifactId>sonar-packaging-maven-plugin</artifactId>
<version>1.12.1</version>
<extensions>true</extensions>
<configuration>
<pluginClass>ExtensionLifecyclePlugin</pluginClass>
</configuration>
</plugin>
</plugins>
</build>
</project>

+ 53
- 0
it/it-plugins/extension-lifecycle-plugin/src/main/java/BatchService.java View File

@@ -0,0 +1,53 @@
import org.sonar.api.BatchExtension;
import org.sonar.api.batch.InstantiationStrategy;
import org.sonar.api.config.Settings;

@InstantiationStrategy(InstantiationStrategy.PER_BATCH)
public class BatchService implements BatchExtension {
private boolean started=false;
private int projectServices=0;
private Settings settings;
public BatchService(Settings settings) {
this.settings = settings;
}

public void start() {
if (!settings.getBoolean("extension.lifecycle")) {
return;
}
System.out.println("Start BatchService");
if (started) {
throw new IllegalStateException("Already started");
}
if (projectServices>0) {
throw new IllegalStateException("BatchService must be started before ProjectServices");
}
started=true;
}

public boolean isStarted() {
return started;
}

public void stop() {
if (!settings.getBoolean("extension.lifecycle")) {
return;
}
System.out.println("Stop BatchService");
if (!started) {
System.out.println("BatchService is not started !");
System.exit(1);
}
if (projectServices!=3) {
// there are three maven modules in the project extension-lifecycle (pom + 2 modules)
System.out.println("Invalid nb of ProjectServices: " + projectServices);
System.exit(1);
}
started=false;
}

public void incrementProjectService() {
projectServices++;
}
}

+ 10
- 0
it/it-plugins/extension-lifecycle-plugin/src/main/java/ExtensionLifecyclePlugin.java View File

@@ -0,0 +1,10 @@
import org.sonar.api.SonarPlugin;

import java.util.Arrays;
import java.util.List;

public class ExtensionLifecyclePlugin extends SonarPlugin {
public List getExtensions() {
return Arrays.asList(BatchService.class, ProjectService.class, ServerService.class);
}
}

+ 39
- 0
it/it-plugins/extension-lifecycle-plugin/src/main/java/ProjectService.java View File

@@ -0,0 +1,39 @@
import org.sonar.api.BatchExtension;
import org.sonar.api.config.Settings;

/**
* As many instances as projects (maven modules)
*/
public class ProjectService implements BatchExtension {

private BatchService batchService;
private Settings settings;

public ProjectService(BatchService batchService, Settings settings) {
this.batchService = batchService;
this.settings = settings;
}

public void start() {
if (!settings.getBoolean("extension.lifecycle")) {
return;
}
System.out.println("Start ProjectService");

if (!batchService.isStarted()) {
throw new IllegalStateException("ProjectService must be started after BatchService");
}
batchService.incrementProjectService();
}

public void stop() {
if (!settings.getBoolean("extension.lifecycle")) {
return;
}
System.out.println("Stop ProjectService");
if (!batchService.isStarted()) {
System.out.println("ProjectService must be stopped before BatchService");
System.exit(1);
}
}
}

+ 4
- 0
it/it-plugins/extension-lifecycle-plugin/src/main/java/ServerService.java View File

@@ -0,0 +1,4 @@
import org.sonar.api.ServerExtension;

public class ServerService implements ServerExtension {
}

+ 6
- 0
it/it-plugins/pom.xml View File

@@ -31,12 +31,18 @@
</properties>

<modules>
<module>access-secured-props-plugin</module>
<module>batch-plugin</module>
<module>crash-plugin</module>
<module>extension-lifecycle-plugin</module>
<module>global-property-change-plugin</module>
<module>l10n-fr-pack</module>
<module>license-plugin</module>
<module>project-builder-plugin</module>
<module>property-relocation-plugin</module>
<module>property-sets-plugin</module>
<module>server-plugin</module>
<module>settings-encryption-plugin</module>
<module>settings-plugin</module>
<module>sonar-fake-plugin</module>
<module>sonar-subcategories-plugin</module>

+ 36
- 0
it/it-plugins/project-builder-plugin/pom.xml View File

@@ -0,0 +1,36 @@
<?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>
<parent>
<groupId>org.sonarsource.it</groupId>
<artifactId>it-plugins</artifactId>
<version>5.2-SNAPSHOT</version>
</parent>
<artifactId>project-builder-plugin</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>sonar-plugin</packaging>
<description>Plugins :: Project Builder</description>

<dependencies>
<dependency>
<groupId>org.codehaus.sonar</groupId>
<artifactId>sonar-plugin-api</artifactId>
<version>${apiVersion}</version>
<scope>provided</scope>
</dependency> </dependencies>

<build>
<plugins>
<plugin>
<groupId>org.codehaus.sonar</groupId>
<artifactId>sonar-packaging-maven-plugin</artifactId>
<version>1.12.1</version>
<extensions>true</extensions>
<configuration>
<pluginClass>ProjectBuilderPlugin</pluginClass>
</configuration>
</plugin>
</plugins>
</build>
</project>

+ 58
- 0
it/it-plugins/project-builder-plugin/src/main/java/CreateSubProjects.java View File

@@ -0,0 +1,58 @@
import org.sonar.api.batch.bootstrap.ProjectBuilder;
import org.sonar.api.batch.bootstrap.ProjectDefinition;
import org.sonar.api.batch.bootstrap.ProjectReactor;
import org.sonar.api.config.Settings;

import java.io.File;

/**
* This plugin relates to projects/project-builder sample
*/
public final class CreateSubProjects extends ProjectBuilder {

private Settings settings;

public CreateSubProjects(ProjectReactor reactor, Settings settings) {
super(reactor);

// A real implementation should for example use the configuration
this.settings = settings;
}

@Override
protected void build(ProjectReactor reactor) {
if (!settings.getBoolean("sonar.enableProjectBuilder")) {
return;
}
System.out.println("---> Creating sub-projects");
ProjectDefinition root = reactor.getRoot();

// add two modules
createSubProjectWithSourceDir(root);
createSubProjectWithSourceFiles(root);
}

private ProjectDefinition createSubProjectWithSourceDir(ProjectDefinition root) {
File baseDir = new File(root.getBaseDir(), "module_a");
ProjectDefinition subProject = ProjectDefinition.create();
subProject.setBaseDir(baseDir).setWorkDir(new File(baseDir, "target/.sonar"));
subProject.setKey("com.sonarsource.it.projects.batch:project-builder-module-a");
subProject.setVersion(root.getVersion());
subProject.setName("Module A");
subProject.setSourceDirs("src");
root.addSubProject(subProject);
return subProject;
}

private ProjectDefinition createSubProjectWithSourceFiles(ProjectDefinition root) {
File baseDir = new File(root.getBaseDir(), "module_b");
ProjectDefinition subProject = ProjectDefinition.create();
subProject.setBaseDir(baseDir).setWorkDir(new File(baseDir, "target/.sonar"));
subProject.setKey("com.sonarsource.it.projects.batch:project-builder-module-b");
subProject.setVersion(root.getVersion());
subProject.setName("Module B");
subProject.addSourceFiles("src/HelloB.java");
root.addSubProject(subProject);
return subProject;
}
}

+ 10
- 0
it/it-plugins/project-builder-plugin/src/main/java/ProjectBuilderPlugin.java View File

@@ -0,0 +1,10 @@
import org.sonar.api.SonarPlugin;

import java.util.Arrays;
import java.util.List;

public class ProjectBuilderPlugin extends SonarPlugin {
public List getExtensions() {
return Arrays.asList(CreateSubProjects.class, RenameProject.class);
}
}

+ 28
- 0
it/it-plugins/project-builder-plugin/src/main/java/RenameProject.java View File

@@ -0,0 +1,28 @@
import org.sonar.api.batch.bootstrap.ProjectBuilder;
import org.sonar.api.batch.bootstrap.ProjectDefinition;
import org.sonar.api.batch.bootstrap.ProjectReactor;
import org.sonar.api.config.Settings;

/**
* This plugin relates to projects/project-builder sample
*/
public final class RenameProject extends ProjectBuilder {

private Settings settings;
public RenameProject(ProjectReactor reactor, Settings settings) {
super(reactor);
this.settings = settings;
}

@Override
protected void build(ProjectReactor reactor) {
if (!settings.getBoolean("sonar.enableProjectBuilder")) {
return;
}
System.out.println("---> Renaming project");
// change name of root project
ProjectDefinition root = reactor.getRoot();
root.setName("Name changed by plugin");
}
}

+ 36
- 0
it/it-plugins/settings-encryption-plugin/pom.xml View File

@@ -0,0 +1,36 @@
<?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>
<parent>
<groupId>org.sonarsource.it</groupId>
<artifactId>it-plugins</artifactId>
<version>5.2-SNAPSHOT</version>
</parent>
<artifactId>settings-encryption-plugin</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>sonar-plugin</packaging>
<description>Plugins :: Settings Encryption</description>

<dependencies>
<dependency>
<groupId>org.codehaus.sonar</groupId>
<artifactId>sonar-plugin-api</artifactId>
<version>${apiVersion}</version>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.codehaus.sonar</groupId>
<artifactId>sonar-packaging-maven-plugin</artifactId>
<version>1.12.1</version>
<extensions>true</extensions>
<configuration>
<pluginClass>SettingsEncryptionPlugin</pluginClass>
</configuration>
</plugin>
</plugins>
</build>
</project>

+ 21
- 0
it/it-plugins/settings-encryption-plugin/src/main/java/EncryptionVerifier.java View File

@@ -0,0 +1,21 @@
import org.sonar.api.BatchExtension;
import org.sonar.api.batch.InstantiationStrategy;
import org.sonar.api.config.Settings;

@InstantiationStrategy(InstantiationStrategy.PER_BATCH)
public class EncryptionVerifier implements BatchExtension {
private Settings settings;

public EncryptionVerifier(Settings settings) {
this.settings = settings;
}

public void start() {
System.out.println("Start EncryptionVerifier");

String decryptedValue = settings.getString("encryptedProperty");
if (!"this is a secret".equals(decryptedValue)) {
throw new IllegalStateException("The property 'encryptedProperty' can not be decrypted");
}
}
}

+ 10
- 0
it/it-plugins/settings-encryption-plugin/src/main/java/SettingsEncryptionPlugin.java View File

@@ -0,0 +1,10 @@
import org.sonar.api.SonarPlugin;

import java.util.Arrays;
import java.util.List;

public class SettingsEncryptionPlugin extends SonarPlugin {
public List getExtensions() {
return Arrays.asList(EncryptionVerifier.class);
}
}

+ 5
- 0
it/it-projects/batch/case-sensitive-file-extensions/sonar-project.properties View File

@@ -0,0 +1,5 @@
sonar.projectKey=case-sensitive-file-extensions
sonar.projectName=Case Sensitive
sonar.projectVersion=1.0-SNAPSHOT
sonar.sources=src
sonar.language=xoo

+ 2
- 0
it/it-projects/batch/case-sensitive-file-extensions/src/UPPER.XOO View File

@@ -0,0 +1,2 @@
File extension is upper case.
It should not be ignored since SQ 4.0.

+ 1
- 0
it/it-projects/batch/case-sensitive-file-extensions/src/UPPER.XOO.measures View File

@@ -0,0 +1 @@
ncloc:2

+ 10
- 0
it/it-projects/batch/case-sensitive-file-extensions/src/lower.xoo View File

@@ -0,0 +1,10 @@
public class Sample {

public Sample(int i) {
int j = i++;
}

private String myMethod() {
return "hello";
}
}

+ 1
- 0
it/it-projects/batch/case-sensitive-file-extensions/src/lower.xoo.measures View File

@@ -0,0 +1 @@
ncloc:5

+ 2
- 0
it/it-projects/batch/custom-module-key/module_a/sonar-project.properties View File

@@ -0,0 +1,2 @@
sonar.projectName=Module A
sonar.moduleKey=com.sonarsource.it.samples:moduleA

+ 16
- 0
it/it-projects/batch/custom-module-key/module_a/src/main/xoo/com/sonar/it/samples/modules/a1/HelloA1.xoo View File

@@ -0,0 +1,16 @@
package com.sonar.it.samples.modules.a1;

public class HelloA1 {
private int i;
private HelloA1() {
}
public void hello() {
System.out.println("hello" + " xoo");
}
protected String getHello() {
return "hello";
}
}

+ 2
- 0
it/it-projects/batch/custom-module-key/module_a/src/main/xoo/com/sonar/it/samples/modules/a1/HelloA1.xoo.measures View File

@@ -0,0 +1,2 @@
ncloc:12
classes:1

+ 2
- 0
it/it-projects/batch/custom-module-key/module_b/sonar-project.properties View File

@@ -0,0 +1,2 @@
sonar.projectName=Module B
sonar.moduleKey=com.sonarsource.it.samples:moduleB

+ 12
- 0
it/it-projects/batch/custom-module-key/module_b/src/main/xoo/com/sonar/it/samples/modules/a2/HelloA2.xoo View File

@@ -0,0 +1,12 @@
package com.sonar.it.samples.modules.a2;

public class HelloA2 {
private int i;
private HelloA2() {
}
public void hello() {
System.out.println("hello" + " xoo");
}
}

+ 2
- 0
it/it-projects/batch/custom-module-key/module_b/src/main/xoo/com/sonar/it/samples/modules/a2/HelloA2.xoo.measures View File

@@ -0,0 +1,2 @@
ncloc:12
classes:1

+ 12
- 0
it/it-projects/batch/custom-module-key/sonar-project.properties View File

@@ -0,0 +1,12 @@
# Root project information
sonar.projectKey=com.sonarsource.it.samples:multi-modules-sample
sonar.projectName=Sonar :: Integration Tests :: Multi-modules Sample
sonar.projectVersion=1.0-SNAPSHOT

sonar.language=xoo
# Some properties that will be inherited by the modules
sonar.sources=src/main/xoo
# List of the module identifiers
sonar.modules=module_a,module_b

+ 6
- 0
it/it-projects/batch/duplicate-source/sonar-project.properties View File

@@ -0,0 +1,6 @@
sonar.projectKey=com.sonarsource.it.projects.batch:duplicate-source
sonar.projectName=exclusions
sonar.projectVersion=1.0-SNAPSHOT
sonar.sources=src/main/xoo,src/main/xoo2
sonar.tests=src/test/xoo
sonar.language=xoo

+ 5
- 0
it/it-projects/batch/duplicate-source/src/main/xoo/org/sonar/tests/ClassOne.xoo View File

@@ -0,0 +1,5 @@
package org.sonar.tests;

public class ClassOne {

}

+ 5
- 0
it/it-projects/batch/duplicate-source/src/main/xoo2/org/sonar/tests/ClassOne.xoo View File

@@ -0,0 +1,5 @@
package org.sonar.tests;

public class ClassOne {

}

+ 5
- 0
it/it-projects/batch/duplicate-source/src/test/xoo/org/sonar/tests/ClassOne.xoo View File

@@ -0,0 +1,5 @@
package org.sonar.tests;

public class ClassOne {

}

+ 14
- 0
it/it-projects/batch/extension-lifecycle/module_a/pom.xml View File

@@ -0,0 +1,14 @@
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>module_a</artifactId>
<packaging>jar</packaging>
<name>Module A</name>

<parent>
<groupId>com.sonarsource.it.projects.batch</groupId>
<artifactId>extension-lifecycle</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>

</project>

+ 10
- 0
it/it-projects/batch/extension-lifecycle/module_a/src/main/java/HelloA.java View File

@@ -0,0 +1,10 @@
public class HelloA {
private int i;
private HelloA() {
}
public void hello() {
System.out.println("hello" + " world");
}
}

+ 13
- 0
it/it-projects/batch/extension-lifecycle/module_b/pom.xml View File

@@ -0,0 +1,13 @@
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>module_b</artifactId>
<packaging>jar</packaging>
<name>Module B</name>

<parent>
<groupId>com.sonarsource.it.projects.batch</groupId>
<artifactId>extension-lifecycle</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
</project>

+ 10
- 0
it/it-projects/batch/extension-lifecycle/module_b/src/main/java/HelloB.java View File

@@ -0,0 +1,10 @@
public class HelloB {
private int i;
private HelloB() {
}
public void hello() {
System.out.println("hello" + " world");
}
}

+ 13
- 0
it/it-projects/batch/extension-lifecycle/pom.xml View File

@@ -0,0 +1,13 @@
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.sonarsource.it.projects.batch</groupId>
<artifactId>extension-lifecycle</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Sonar :: Integration Tests :: Extension Lifecycle Sample</name>
<modules>
<module>module_a</module>
<module>module_b</module>
</modules>
</project>

+ 31
- 0
it/it-projects/batch/links-project/pom.xml View File

@@ -0,0 +1,31 @@
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.sonarsource.it.samples</groupId>
<artifactId>simple-sample</artifactId>
<version>1.0-SNAPSHOT</version>
<name>Sonar :: Integration Tests :: Simple Sample</name>

<url>http://www.simplesample.org</url>

<issueManagement>
<system>jira</system>
<url>http://jira.codehaus.org/browse/SIMPLESAMPLE</url>
</issueManagement>

<scm>
<connection>scm:git:git@github.com:SonarSource/simplesample.git</connection>
<developerConnection>scm:git:git@github.com:SonarSource/simplesample.git</developerConnection>
<url>https://github.com/SonarSource/simplesample</url>
</scm>

<ciManagement>
<system>bamboo</system>
<url>http://bamboo.ci.codehaus.org/browse/SIMPLESAMPLE</url>
</ciManagement>

<properties>
<!-- The following property MUST override the <url> definition of the POM -->
<sonar.links.homepage>http://www.simplesample.org_OVERRIDDEN</sonar.links.homepage>
</properties>

</project>

+ 11
- 0
it/it-projects/batch/links-project/sonar-project.properties View File

@@ -0,0 +1,11 @@
sonar.projectKey=com.sonarsource.it.samples:simple-sample
sonar.projectVersion=1.0-SNAPSHOT
sonar.projectName=Sonar :: Integration Tests :: Simple Sample

sonar.sources=src/main/java

sonar.links.homepage=http://www.simplesample.org_OVERRIDDEN
sonar.links.ci=http://bamboo.ci.codehaus.org/browse/SIMPLESAMPLE
sonar.links.issue=http://jira.codehaus.org/browse/SIMPLESAMPLE
sonar.links.scm=https://github.com/SonarSource/simplesample
sonar.links.scm_dev=scm:git:git@github.com:SonarSource/simplesample.git

+ 12
- 0
it/it-projects/batch/links-project/src/main/java/sample/Sample.java View File

@@ -0,0 +1,12 @@
package sample;

public class Sample {
public Sample(int i) {
int j = i++;
}
private String myMethod() {
return "hello";
}
}

+ 15
- 0
it/it-projects/batch/multi-languages/java-module/pom.xml View File

@@ -0,0 +1,15 @@
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.sonarsource.it.projects.batch.multi-languages</groupId>
<artifactId>multi-languages</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>java-module</artifactId>
<name>Java Module</name>

<properties>
<sonar.language>java</sonar.language>
</properties>
</project>

+ 10
- 0
it/it-projects/batch/multi-languages/java-module/src/main/java/HelloJava.java View File

@@ -0,0 +1,10 @@
public class HelloJava {
private int i;
private HelloJava() {
}
public void hello() {
System.out.println("hello" + " java");
}
}

+ 20
- 0
it/it-projects/batch/multi-languages/javascript-module/pom.xml View File

@@ -0,0 +1,20 @@
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.sonarsource.it.projects.batch.multi-languages</groupId>
<artifactId>multi-languages</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>javascript-module</artifactId>
<name>Javascript Module</name>

<properties>
<sonar.language>js</sonar.language>
</properties>

<build>
<sourceDirectory>src</sourceDirectory>
</build>

</project>

+ 14
- 0
it/it-projects/batch/multi-languages/javascript-module/src/Person.js View File

@@ -0,0 +1,14 @@

var Person = function(first, last, middle) {
this.first = first;
this.middle = middle;
this.last = last;
};

Person.prototype = {

whoAreYou : function() {
return this.first + (this.middle ? ' ' + this.middle: '') + ' ' + this.last;
}

};

+ 16
- 0
it/it-projects/batch/multi-languages/pom.xml View File

@@ -0,0 +1,16 @@
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.sonarsource.it.projects.batch.multi-languages</groupId>
<artifactId>multi-languages</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Multi Languages</name>
<description>One language per module</description>

<modules>
<module>java-module</module>
<module>javascript-module</module>
<module>python-module</module>
</modules>
</project>

+ 19
- 0
it/it-projects/batch/multi-languages/python-module/pom.xml View File

@@ -0,0 +1,19 @@
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.sonarsource.it.projects.batch.multi-languages</groupId>
<artifactId>multi-languages</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>python-module</artifactId>
<name>Python Module</name>

<properties>
<sonar.language>py</sonar.language>
</properties>

<build>
<sourceDirectory>src</sourceDirectory>
</build>
</project>

+ 0
- 0
it/it-projects/batch/multi-languages/python-module/src/__init__.py View File


+ 92
- 0
it/it-projects/batch/multi-languages/python-module/src/badfortune.py View File

@@ -0,0 +1,92 @@

# fortune.py -- chooses a random fortune, as the fortune(8) program in
# the BSD-games package does
#
# Copyright (c) 2010, Andrew M. Kuchling
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

import struct, random, string

# C long variables are different sizes on 32-bit and 64-bit machines,
# so we have to measure how big they are on the machine where this is running.
LONG_SIZE = struct.calcsize('L')
is_64_bit = (LONG_SIZE == 8)

def get(filename):
"Select a random quotation, using a pregenerated .dat file"

# First, we open the .dat file, and read the header information.
# The C structure containing this info looks like:
## typedef struct { /* information table */
## #define VERSION 1
## unsigned long str_version; /* version number */
## unsigned long str_numstr; /* # of strings in the file */
## unsigned long str_longlen; /* length of longest string */
## unsigned long str_shortlen; /* length of shortest string */
## #define STR_RANDOM 0x1 /* randomized pointers */
## #define STR_ORDERED 0x2 /* ordered pointers */
## #define STR_ROTATED 0x4 /* rot-13'd text */
## unsigned long str_flags; /* bit field for flags */
## unsigned char stuff[4]; /* long aligned space */
## #define str_delim stuff[0] /* delimiting character */
## } STRFILE;

datfile = open(filename+'.dat', 'r')
data = datfile.read(5 * LONG_SIZE)
if is_64_bit:
v1, v2, n1, n2, l1, l2, s1, s2, f1, f2 = struct.unpack('!10L', data)
version = v1 + (v2 << 32)
numstr = n1 + (n2 << 32)
longlen = l1 + (l2 << 32)
shortlen = s1 + (s2 << 32)
flags = f1 + (f2 << 32)
else:
version, numstr, longlen, shortlen, flags = struct.unpack('5l', data)

delimiter = datfile.read(1)
datfile.read(3) # Throw away padding bytes
if is_64_bit: datfile.read(4) # 64-bit machines align to 8 bytes

# Pick a random number
r = random.randint(0, numstr)
datfile.seek(LONG_SIZE * r, 1) # Seek to the chosen pointer
data = datfile.read(LONG_SIZE * 2)

if is_64_bit:
s1, s2, e1, e2 = struct.unpack('!4L', data)
start, end = s1 + (s2 << 32), e1 + (e2 << 32)
else:
start, end = struct.unpack('!ll', data)
datfile.close()

file = open(filename, 'r')
file.seek(start)
quotation = file.read(end-start)
L=string.split(quotation, '\n')
while string.strip(L[-1]) == delimiter or string.strip(L[-1]) == "":
L=L[:-1]
return string.join(L, '\n')

if __name__ == '__main__':
import sys
if len(sys.argv) == 1:
print 'Usage: fortune.py <filename>'
sys.exit()
print get(sys.argv[1])

+ 19
- 0
it/it-projects/batch/multi-languages/sonar-project.properties View File

@@ -0,0 +1,19 @@
sonar.projectKey=multi-languages
sonar.projectName=Multi Languages
sonar.projectVersion=1.0-SNAPSHOT
sonar.modules=java-module,javascript-module,python-module

# not used but mandatory parameter because of https://jira.codehaus.org/browse/SONARPLUGINS-2297
sonar.sources=src

java-module.sonar.projectName=Java Module
java-module.sonar.sources=src/main/java
java-module.sonar.language=java

javascript-module.sonar.projectName=Javascript Module
javascript-module.sonar.sources=src
javascript-module.sonar.language=js

python-module.sonar.projectName=Python Module
python-module.sonar.sources=src
python-module.sonar.language=py

+ 2
- 0
it/it-projects/batch/prevent-common-module/projectAB/module_a/sonar-project.properties View File

@@ -0,0 +1,2 @@
sonar.projectName=Module A
sonar.moduleKey=com.sonarsource.it.samples:moduleA

+ 16
- 0
it/it-projects/batch/prevent-common-module/projectAB/module_a/src/main/xoo/com/sonar/it/samples/modules/a1/HelloA1.xoo View File

@@ -0,0 +1,16 @@
package com.sonar.it.samples.modules.a1;

public class HelloA1 {
private int i;
private HelloA1() {
}
public void hello() {
System.out.println("hello" + " xoo");
}
protected String getHello() {
return "hello";
}
}

+ 2
- 0
it/it-projects/batch/prevent-common-module/projectAB/module_a/src/main/xoo/com/sonar/it/samples/modules/a1/HelloA1.xoo.measures View File

@@ -0,0 +1,2 @@
ncloc:12
classes:1

+ 2
- 0
it/it-projects/batch/prevent-common-module/projectAB/module_b/sonar-project.properties View File

@@ -0,0 +1,2 @@
sonar.projectName=Module B
sonar.moduleKey=com.sonarsource.it.samples:moduleB

+ 12
- 0
it/it-projects/batch/prevent-common-module/projectAB/module_b/src/main/xoo/com/sonar/it/samples/modules/a2/HelloA2.xoo View File

@@ -0,0 +1,12 @@
package com.sonar.it.samples.modules.a2;

public class HelloA2 {
private int i;
private HelloA2() {
}
public void hello() {
System.out.println("hello" + " xoo");
}
}

+ 2
- 0
it/it-projects/batch/prevent-common-module/projectAB/module_b/src/main/xoo/com/sonar/it/samples/modules/a2/HelloA2.xoo.measures View File

@@ -0,0 +1,2 @@
ncloc:12
classes:1

+ 12
- 0
it/it-projects/batch/prevent-common-module/projectAB/sonar-project.properties View File

@@ -0,0 +1,12 @@
# Root project information
sonar.projectKey=projectAB
sonar.projectName=Project AB
sonar.projectVersion=1.0-SNAPSHOT

sonar.language=xoo
# Some properties that will be inherited by the modules
sonar.sources=src/main/xoo
# List of the module identifiers
sonar.modules=module_a,module_b

+ 2
- 0
it/it-projects/batch/prevent-common-module/projectAC/module_a/sonar-project.properties View File

@@ -0,0 +1,2 @@
sonar.projectName=Module A
sonar.moduleKey=com.sonarsource.it.samples:moduleA

+ 16
- 0
it/it-projects/batch/prevent-common-module/projectAC/module_a/src/main/xoo/com/sonar/it/samples/modules/a1/HelloA1.xoo View File

@@ -0,0 +1,16 @@
package com.sonar.it.samples.modules.a1;

public class HelloA1 {
private int i;
private HelloA1() {
}
public void hello() {
System.out.println("hello" + " xoo");
}
protected String getHello() {
return "hello";
}
}

+ 2
- 0
it/it-projects/batch/prevent-common-module/projectAC/module_a/src/main/xoo/com/sonar/it/samples/modules/a1/HelloA1.xoo.measures View File

@@ -0,0 +1,2 @@
ncloc:12
classes:1

+ 2
- 0
it/it-projects/batch/prevent-common-module/projectAC/module_c/sonar-project.properties View File

@@ -0,0 +1,2 @@
sonar.projectName=Module C
sonar.moduleKey=com.sonarsource.it.samples:moduleC

+ 12
- 0
it/it-projects/batch/prevent-common-module/projectAC/module_c/src/main/xoo/com/sonar/it/samples/modules/a2/HelloA2.xoo View File

@@ -0,0 +1,12 @@
package com.sonar.it.samples.modules.a2;

public class HelloA2 {
private int i;
private HelloA2() {
}
public void hello() {
System.out.println("hello" + " xoo");
}
}

+ 2
- 0
it/it-projects/batch/prevent-common-module/projectAC/module_c/src/main/xoo/com/sonar/it/samples/modules/a2/HelloA2.xoo.measures View File

@@ -0,0 +1,2 @@
ncloc:12
classes:1

+ 12
- 0
it/it-projects/batch/prevent-common-module/projectAC/sonar-project.properties View File

@@ -0,0 +1,12 @@
# Root project information
sonar.projectKey=projectAC
sonar.projectName=Project AC
sonar.projectVersion=1.0-SNAPSHOT

sonar.language=xoo
# Some properties that will be inherited by the modules
sonar.sources=src/main/xoo
# List of the module identifiers
sonar.modules=module_a,module_c

+ 10
- 0
it/it-projects/batch/project-builder/module_a/src/HelloA.java View File

@@ -0,0 +1,10 @@
public class HelloA {
private int i;
private HelloA() {
}
public void hello() {
System.out.println("hello" + " world");
}
}

+ 10
- 0
it/it-projects/batch/project-builder/module_b/src/HelloB.java View File

@@ -0,0 +1,10 @@
public class HelloB {
private int i;
private HelloB() {
}
public void hello() {
System.out.println("hello" + " world");
}
}

+ 1
- 0
it/it-projects/batch/project-builder/module_b/src/IgnoredFile.java View File

@@ -0,0 +1 @@
this file has been selected by the extension CreateSubProjects.

+ 15
- 0
it/it-projects/batch/project-builder/pom.xml View File

@@ -0,0 +1,15 @@
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.sonarsource.it.projects.batch</groupId>
<artifactId>project-builder</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Sonar :: Integration Tests :: Project Builder Sample</name>

<!-- modules are not defined in pom but in sonar plugin -->
<!-- <modules>
<module>module_a</module>
<module>module_b</module>
</modules>-->
</project>

+ 5
- 0
it/it-projects/batch/tracking/v1/sonar-project.properties View File

@@ -0,0 +1,5 @@
sonar.projectKey=sample
sonar.projectName=Sample
sonar.projectVersion=1.0-SNAPSHOT
sonar.sources=src/main/xoo
sonar.language=xoo

+ 12
- 0
it/it-projects/batch/tracking/v1/src/main/xoo/sample/Sample.xoo View File

@@ -0,0 +1,12 @@
package sample;

public class Sample {
public Sample(int i) {
int j = i++;
}
private String myMethod() {
return "hello";
}
}

+ 1
- 0
it/it-projects/batch/tracking/v1/src/main/xoo/sample/Sample.xoo.measures View File

@@ -0,0 +1 @@
ncloc:8

+ 5
- 0
it/it-projects/batch/tracking/v2/sonar-project.properties View File

@@ -0,0 +1,5 @@
sonar.projectKey=sample
sonar.projectName=Sample
sonar.projectVersion=1.0-SNAPSHOT
sonar.sources=src/main/xoo
sonar.language=xoo

+ 14
- 0
it/it-projects/batch/tracking/v2/src/main/xoo/sample/Sample.xoo View File

@@ -0,0 +1,14 @@
package sample;

public class Sample {
public Sample(int i) {
int j = i++;
System.out.println("foo");
}
private String myMethod() {
System.out.println("foo");
return "hello";
}
}

+ 1
- 0
it/it-projects/batch/tracking/v2/src/main/xoo/sample/Sample.xoo.measures View File

@@ -0,0 +1 @@
ncloc:10

+ 5
- 0
it/it-projects/batch/xoo-history-v2/sonar-project.properties View File

@@ -0,0 +1,5 @@
sonar.projectKey=sample
sonar.projectName=Sample
sonar.projectVersion=1.0-SNAPSHOT
sonar.sources=src/main/xoo
sonar.language=xoo

+ 12
- 0
it/it-projects/batch/xoo-history-v2/src/main/xoo/sample/ClassAdded.xoo View File

@@ -0,0 +1,12 @@
package sample;

public class ClassAdded {
public ClassAdded(int i) {
int j = i++;
}

private String myMethod() {
return "hello";
}
}

+ 3
- 0
it/it-projects/batch/xoo-history-v2/src/main/xoo/sample/ClassAdded.xoo.measures View File

@@ -0,0 +1,3 @@
ncloc:12
classes:1


+ 16
- 0
it/it-projects/batch/xoo-history-v2/src/main/xoo/sample/ClassToModify.xoo View File

@@ -0,0 +1,16 @@
package sample;

public class ClassToModify {
public ClassToModify(int i) {
int j = i++;
}

public String addedMethod() {
return "This method was added in v2";
}

private String myMethod() {
return "hello";
}
}

+ 3
- 0
it/it-projects/batch/xoo-history-v2/src/main/xoo/sample/ClassToModify.xoo.measures View File

@@ -0,0 +1,3 @@
ncloc:16
classes:1


+ 12
- 0
it/it-projects/batch/xoo-history-v2/src/main/xoo/sample/UnchangedClass.xoo View File

@@ -0,0 +1,12 @@
package sample;

public class ClassToModify {
public ClassToModify(int i) {
int j = i++;
}
private String myMethod() {
return "hello";
}
}

+ 2
- 0
it/it-projects/batch/xoo-history-v2/src/main/xoo/sample/UnchangedClass.xoo.measures View File

@@ -0,0 +1,2 @@
ncloc:12
classes:1

+ 4
- 0
it/it-projects/batch/xoo-multi-languages/sonar-project.properties View File

@@ -0,0 +1,4 @@
sonar.projectKey=multi-language-sample
sonar.projectName=Multi-Language Sample
sonar.projectVersion=1.0-SNAPSHOT
sonar.sources=src

+ 12
- 0
it/it-projects/batch/xoo-multi-languages/src/sample/Sample.xoo View File

@@ -0,0 +1,12 @@
package sample;

public class Sample {
public Sample(int i) {
int j = i++;
}
private String myMethod() {
return "hello";
}
}

+ 10
- 0
it/it-projects/batch/xoo-multi-languages/src/sample/Sample.xoo.measures View File

@@ -0,0 +1,10 @@
ncloc:13
#Used by dashboard/widgets tests
complexity_in_classes:3
classes:1
comment_lines:3
public_api:5
public_undocumented_api:2
duplicated_files:1
duplicated_blocks:2
duplicated_lines:3

+ 12
- 0
it/it-projects/batch/xoo-multi-languages/src/sample/Sample.xoo2 View File

@@ -0,0 +1,12 @@
package sample;

public class Sample {
public Sample(int i) {
int j = i++;
}
private String myMethod() {
return "hello";
}
}

+ 10
- 0
it/it-projects/batch/xoo-multi-languages/src/sample/Sample.xoo2.measures View File

@@ -0,0 +1,10 @@
ncloc:13
#Used by dashboard/widgets tests
complexity_in_classes:3
classes:1
comment_lines:3
public_api:5
public_undocumented_api:2
duplicated_files:1
duplicated_blocks:2
duplicated_lines:3

+ 12
- 0
it/it-projects/batch/xoo-sample-with-spaces/v1/my sources/main/xoo/sample/My Sample.xoo View File

@@ -0,0 +1,12 @@
package sample;

public class Sample {
public Sample(int i) {
int j = i++;
}
private String myMethod() {
return "hello";
}
}

+ 11
- 0
it/it-projects/batch/xoo-sample-with-spaces/v1/my sources/main/xoo/sample/My Sample.xoo.measures View File

@@ -0,0 +1,11 @@
ncloc:13
#Used by dashboard/widgets tests
complexity:3
complexity_in_classes:3
classes:1
comment_lines:3
public_api:5
public_undocumented_api:2
duplicated_files:1
duplicated_blocks:2
duplicated_lines:3

+ 5
- 0
it/it-projects/batch/xoo-sample-with-spaces/v1/sonar-project.properties View File

@@ -0,0 +1,5 @@
sonar.projectKey=sample
sonar.projectName=Sample
sonar.projectVersion=1.0-SNAPSHOT
sonar.sources=my sources/main/xoo
sonar.language=xoo

+ 12
- 0
it/it-projects/batch/xoo-sample-with-spaces/v2/my sources/main/xoo/sample/My Sample.xoo View File

@@ -0,0 +1,12 @@
package sample;

public class Sample {
public Sample(int i) {
int j = i++;
}
private String myMethod_modified() {
return "hello";
}
}

+ 0
- 0
it/it-projects/batch/xoo-sample-with-spaces/v2/my sources/main/xoo/sample/My Sample.xoo.measures View File


Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save