+++ /dev/null
-<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>inclusions_apply_to_source_dirs</artifactId>
- <version>1.0-SNAPSHOT</version>
-
- <properties>
- <sonar.inclusions>src/main/java/**/Hello2.java</sonar.inclusions>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.11</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
-</project>
+++ /dev/null
-public class Hello {
- public String hello() {
- return "hello";
- }
-}
+++ /dev/null
-public class Hello2 {
- public String hello() {
- return "hello";
- }
-}
+++ /dev/null
-<?xml version="1.0"?>
-<project>
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>com.sonarsource.it.samples.jee</groupId>
- <artifactId>parent</artifactId>
- <version>1.0-SNAPSHOT</version>
- </parent>
- <artifactId>ear-module</artifactId>
- <name>ear-module</name>
- <packaging>ear</packaging>
-
- <dependencies>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>java-module</artifactId>
- <version>${project.version}</version>
- <type>jar</type>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>ejb-module</artifactId>
- <version>${project.version}</version>
- <type>ejb</type>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>web-module</artifactId>
- <version>${project.version}</version>
- <type>war</type>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-ear-plugin</artifactId>
- <version>2.3.1</version>
- <configuration>
- <modules>
- <javaModule>
- <groupId>${project.groupId}</groupId>
- <artifactId>java-module</artifactId>
- </javaModule>
- <ejbModule>
- <groupId>${project.groupId}</groupId>
- <artifactId>ejb-module</artifactId>
- </ejbModule>
- <webModule>
- <groupId>${project.groupId}</groupId>
- <artifactId>web-module</artifactId>
- <contextRoot>jee-sample</contextRoot>
- </webModule>
- </modules>
- </configuration>
- </plugin>
-
- </plugins>
- </build>
-</project>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0"?>
-<project>
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>com.sonarsource.it.samples.jee</groupId>
- <artifactId>parent</artifactId>
- <version>1.0-SNAPSHOT</version>
- </parent>
- <artifactId>ejb-module</artifactId>
- <name>ejb-module</name>
- <packaging>ejb</packaging>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-ejb_2.1_spec</artifactId>
- <version>1.1</version>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>java-module</artifactId>
- <version>${project.version}</version>
- <scope>runtime</scope>
- </dependency>
- </dependencies>
-</project>
\ No newline at end of file
+++ /dev/null
-package org.sonar.tests;
-
-/**
- * Hello world!
- *
- */
-public class App
-{
- public static void main( String[] args )
- {
- System.out.println( "Hello World!" );
- }
-}
+++ /dev/null
-<?xml version="1.0"?>
-
-<!DOCTYPE ejb-jar PUBLIC
- '-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 1.1//EN'
- 'http://java.sun.com/j2ee/dtds/ejb-jar_1_1.dtd'>
-
-<ejb-jar>
- <enterprise-beans>
-
-
- </enterprise-beans>
- <assembly-descriptor></assembly-descriptor>
-</ejb-jar>
+++ /dev/null
-package org.sonar.tests;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-/**
- * Unit test for simple App.
- */
-public class AppTest
- extends TestCase
-{
- /**
- * Create the test case
- *
- * @param testName name of the test case
- */
- public AppTest( String testName )
- {
- super( testName );
- }
-
- /**
- * @return the suite of tests being tested
- */
- public static Test suite()
- {
- return new TestSuite( AppTest.class );
- }
-
- /**
- * Rigourous Test :-)
- */
- public void testApp()
- {
- assertTrue( true );
- }
-}
+++ /dev/null
-<?xml version="1.0"?>
-<project>
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>com.sonarsource.it.samples.jee</groupId>
- <artifactId>parent</artifactId>
- <version>1.0-SNAPSHOT</version>
- </parent>
- <artifactId>java-module</artifactId>
- <name>java-module</name>
-
-</project>
\ No newline at end of file
+++ /dev/null
-package org.sonar.tests;
-
-/**
- * Hello world!
- *
- */
-public class App
-{
- public static void main( String[] args )
- {
- System.out.println( "Hello World!" );
- }
-}
+++ /dev/null
-package org.sonar.tests;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-/**
- * Unit test for simple App.
- */
-public class AppTest
- extends TestCase
-{
- /**
- * Create the test case
- *
- * @param testName name of the test case
- */
- public AppTest( String testName )
- {
- super( testName );
- }
-
- /**
- * @return the suite of tests being tested
- */
- public static Test suite()
- {
- return new TestSuite( AppTest.class );
- }
-
- /**
- * Rigourous Test :-)
- */
- public void testApp()
- {
- assertTrue( true );
- }
-}
+++ /dev/null
-<?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>com.sonarsource.it.samples.jee</groupId>
- <artifactId>parent</artifactId>
- <packaging>pom</packaging>
- <version>1.0-SNAPSHOT</version>
- <name>JEE project</name>
- <dependencies>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.8.2</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
- <modules>
- <module>java-module</module>
- <module>ejb-module</module>
- <module>web-module</module>
- <module>ear-module</module>
- </modules>
-</project>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0"?>
-<project>
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>com.sonarsource.it.samples.jee</groupId>
- <artifactId>parent</artifactId>
- <version>1.0-SNAPSHOT</version>
- </parent>
- <artifactId>web-module</artifactId>
- <packaging>war</packaging>
- <name>web-module Maven Webapp</name>
-
- <build>
- <finalName>web-module</finalName>
- </build>
-
- <dependencies>
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- <version>2.4</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>jsp-api</artifactId>
- <version>2.0</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-ejb_2.1_spec</artifactId>
- <version>1.1</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>java-module</artifactId>
- <version>${project.version}</version>
- <scope>runtime</scope>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>ejb-module</artifactId>
- <version>${project.version}</version>
- <scope>runtime</scope>
- <type>ejb</type>
- </dependency>
- </dependencies>
-</project>
\ No newline at end of file
+++ /dev/null
-<!DOCTYPE web-app PUBLIC
- "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
- "http://java.sun.com/dtd/web-app_2_3.dtd" >
-
-<web-app>
- <display-name>Archetype Created Web Application</display-name>
-</web-app>
+++ /dev/null
-<html>
-<body>
-<h2>Hello World!</h2>
-</body>
-</html>
+++ /dev/null
-<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.samples.maven-bad-parameters</groupId>
- <artifactId>parent</artifactId>
- <version>1.0-SNAPSHOT</version>
- </parent>
-</project>
\ No newline at end of file
+++ /dev/null
-package org.sonar.tests;
-
-public class Hello {
- public static String s=null;
-
- public String toString() {
- while(true)
- s="hello";
- }
-}
\ No newline at end of file
+++ /dev/null
-<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.samples.maven-bad-parameters</groupId>
- <artifactId>parent</artifactId>
- <version>1.0-SNAPSHOT</version>
- </parent>
-</project>
\ No newline at end of file
+++ /dev/null
-package org.sonar.tests;
-
-public class Hello {
- public static String s=null;
-
- public String toString() {
- while(true)
- s="hello";
- }
-}
\ No newline at end of file
+++ /dev/null
-<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.maven-bad-parameters</groupId>
- <artifactId>parent</artifactId>
- <version>1.0-SNAPSHOT</version>
- <packaging>pom</packaging>
- <name>Sonar tests - maven-bad-parameters</name>
- <modules>
- <module>module_a</module>
- <module>module_b</module>
- </modules>
-
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-pmd-plugin</artifactId>
- <configuration>
- <aggregate>true</aggregate>
- <!-- SONAR-518 -->
- <skip>true</skip>
- <!-- SONAR-593 -->
- </configuration>
- </plugin>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-checkstyle-plugin</artifactId>
- <configuration>
- <skip>true</skip>
- <!-- SONAR-519 -->
- </configuration>
- </plugin>
-
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>findbugs-maven-plugin</artifactId>
- <configuration>
- <skip>true</skip>
- <!-- SONAR-593 -->
- </configuration>
- </plugin>
-
- </plugins>
- </build>
-
-</project>
\ No newline at end of file
+++ /dev/null
-<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>maven-bad-sources-property</artifactId>
- <version>1.0-SNAPSHOT</version>
-
- <properties>
- <sonar.sources>src/main/java2</sonar.sources>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.11</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
-</project>
+++ /dev/null
-public class Hello {
- public String hello() {
- return "hello";
- }
-}
+++ /dev/null
-<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>maven-bad-tests-property</artifactId>
- <version>1.0-SNAPSHOT</version>
-
- <properties>
- <sonar.tests>src/test/java2</sonar.tests>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.11</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
-</project>
+++ /dev/null
-public class Hello {
- public String hello() {
- return "hello";
- }
-}
+++ /dev/null
-public class HelloTest {
-
-}
+++ /dev/null
-<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>maven-extensions</artifactId>
- <version>1.0-SNAPSHOT</version>
- <packaging>jar</packaging>
- <name>Sonar tests - maven extensions</name>
- <description>http://jira.codehaus.org/browse/SONAR-222</description>
- <build>
- <extensions>
- <extension>
- <groupId>org.jvnet.wagon-svn</groupId>
- <artifactId>wagon-svn</artifactId>
- <version>1.9</version>
- </extension>
-
- <extension>
- <groupId>org.apache.maven.wagon</groupId>
- <artifactId>wagon-webdav</artifactId>
- <version>1.0-beta-2</version>
- </extension>
- </extensions>
- </build>
-</project>
\ No newline at end of file
+++ /dev/null
-package org.sonar.tests.mavenExtensions;
-
-public class Hello {
- private String hello;
-
- public Hello(String s){
- this.hello = s;
- }
-
- public String say() {
- return hello;
- }
-}
+++ /dev/null
-<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>maven-only-test-dir</artifactId>
- <version>1.0-SNAPSHOT</version>
-
- <dependencies>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.11</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
-</project>
+++ /dev/null
-import org.junit.Test;
-
-import static org.junit.Assert.assertNotSame;
-
-public class HelloTest {
- @Test
- public void hiho() {
- assertNotSame("hi", "ho");
- }
-}
+++ /dev/null
-<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>maven-override-sources</artifactId>
- <version>1.0-SNAPSHOT</version>
-
- <properties>
- <sonar.sources>src/main/java2</sonar.sources>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.11</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
-</project>
+++ /dev/null
-public class Hello {
- public String hello() {
- return "hello";
- }
-}
+++ /dev/null
-public class Hello2 {
- public String hello() {
- return "hello";
- }
-}
+++ /dev/null
-<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>org.sonar.tests.modules-declaration</groupId>
- <artifactId>root</artifactId>
- <version>1.0-SNAPSHOT</version>
- </parent>
-
- <artifactId>module_a</artifactId>
-
- <name>Module A</name>
-
-</project>
+++ /dev/null
-public class HelloA {
-}
+++ /dev/null
-<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>org.sonar.tests.modules-declaration</groupId>
- <artifactId>root</artifactId>
- <version>1.0-SNAPSHOT</version>
- </parent>
-
- <artifactId>module_b</artifactId>
-
- <name>Module B</name>
-
-</project>
+++ /dev/null
-public class HelloB {
-}
+++ /dev/null
-<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>org.sonar.tests.modules-declaration</groupId>
- <artifactId>root</artifactId>
- <version>1.0-SNAPSHOT</version>
- </parent>
-
- <artifactId>module_c</artifactId>
-
- <name>Module C</name>
-
-</project>
+++ /dev/null
-public class HelloC {
-}
+++ /dev/null
-<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>org.sonar.tests.modules-declaration</groupId>
- <artifactId>root</artifactId>
- <version>1.0-SNAPSHOT</version>
- </parent>
-
- <artifactId>module_d</artifactId>
-
- <name>Module D</name>
-
-</project>
+++ /dev/null
-public class HelloD {
-}
+++ /dev/null
-<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>org.sonar.tests.modules-declaration</groupId>
- <artifactId>root</artifactId>
- <version>1.0-SNAPSHOT</version>
- </parent>
-
- <artifactId>module_e</artifactId>
-
- <name>Module E</name>
-
-</project>
+++ /dev/null
-public class HelloE {
-}
+++ /dev/null
-<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>org.sonar.tests.modules-declaration</groupId>
- <artifactId>root</artifactId>
- <version>1.0-SNAPSHOT</version>
- <packaging>pom</packaging>
-
- <name>Root</name>
-
- <modules>
- <!-- Standard/normal way - directory name -->
- <module>module_a</module>
-
- <!-- Just in case - trailing slash in a directory name -->
- <module>module_b/</module>
-
- <!-- File with usual name -->
- <module>module_c/pom.xml</module>
-
- <!-- Strange use case, but seems valid (tested with Maven 2.0.11, 2.2.1 and 3.0.3) - file with unusual name -->
- <module>module_d/mypom.xml</module>
- <module>module_e/mypom</module>
- </modules>
-
-</project>
+++ /dev/null
-Order of modules during build would look as following :
-parent
-module_a
-module_b
-root
+++ /dev/null
-<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>org.sonar.tests.modules-order</groupId>
- <artifactId>parent</artifactId>
- <version>1.0-SNAPSHOT</version>
- <relativePath>../parent</relativePath>
- </parent>
-
- <artifactId>module_a</artifactId>
-
- <name>Module A</name>
-</project>
+++ /dev/null
-public class HelloA {
-}
+++ /dev/null
-<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>org.sonar.tests.modules-order</groupId>
- <artifactId>parent</artifactId>
- <version>1.0-SNAPSHOT</version>
- <relativePath>../parent</relativePath>
- </parent>
-
- <artifactId>module_b</artifactId>
-
- <name>Module B</name>
-</project>
+++ /dev/null
-public class HelloB {
-}
+++ /dev/null
-<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>org.sonar.tests.modules-order</groupId>
- <artifactId>parent</artifactId>
- <version>1.0-SNAPSHOT</version>
- <packaging>pom</packaging>
-
- <name>Parent</name>
-</project>
+++ /dev/null
-<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>org.sonar.tests.modules-order</groupId>
- <artifactId>root</artifactId>
- <version>1.0-SNAPSHOT</version>
- <packaging>pom</packaging>
-
- <name>Sonar tests - modules order</name>
-
- <modules>
- <module>parent</module>
- <module>module_a</module>
- <module>module_b</module>
- </modules>
-</project>
+++ /dev/null
-<?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>com.sonarsource.it.samples.project-with-module-without-sources</groupId>
- <artifactId>parent</artifactId>
- <version>1.0-SNAPSHOT</version>
- <packaging>pom</packaging>
-
- <modules>
- <module>with-sources</module>
- <module>without-sources</module>
- </modules>
-</project>
+++ /dev/null
-<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.samples.project-with-module-without-sources</groupId>
- <artifactId>parent</artifactId>
- <version>1.0-SNAPSHOT</version>
- </parent>
-
- <artifactId>with-sources</artifactId>
- <version>1.0-SNAPSHOT</version>
- <name>Module with sources</name>
-
-</project>
+++ /dev/null
-package sample;
-
-public class Sample {
-
- public Sample(int i) {
- int j = i++;
- }
-
- private String myMethod() {
- return "hello";
- }
-}
+++ /dev/null
-<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.samples.project-with-module-without-sources</groupId>
- <artifactId>parent</artifactId>
- <version>1.0-SNAPSHOT</version>
- </parent>
-
- <artifactId>without-sources</artifactId>
- <version>1.0-SNAPSHOT</version>
- <name>Module without sources</name>
-
-</project>
+++ /dev/null
-<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>org.foo.bar</groupId>
- <artifactId>parent</artifactId>
- <version>1.0-SNAPSHOT</version>
- </parent>
- <artifactId>child1</artifactId>
-
-</project>
+++ /dev/null
-<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>org.foo.bar</groupId>
- <artifactId>parent</artifactId>
- <version>1.0-SNAPSHOT</version>
- </parent>
-
- <artifactId>child2</artifactId>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-shade-plugin</artifactId>
- <version>1.7.1</version>
- <executions>
- <execution>
- <configuration>
- <shadedArtifactAttached>false</shadedArtifactAttached>
- <!-- here lies a problem, (true is the default) -->
- <createDependencyReducedPom>true</createDependencyReducedPom>
- </configuration>
- <phase>package</phase>
- <goals>
- <goal>shade</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
-
- </plugins>
- </build>
-
- <dependencies>
- <dependency>
- <groupId>org.foo.bar</groupId>
- <artifactId>child1</artifactId>
- <version>1.0-SNAPSHOT</version>
- </dependency>
- </dependencies>
-
-
-</project>
+++ /dev/null
-<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>org.foo.bar</groupId>
- <artifactId>parent</artifactId>
- <version>1.0-SNAPSHOT</version>
- <packaging>pom</packaging>
-
- <modules>
- <module>child1</module>
- <module>child2</module>
- </modules>
-
-
-
-</project>
-
package it;
import com.sonar.orchestrator.Orchestrator;
-import it.analysis.BatchTest;
+import it.analysis.ScannerTest;
import it.analysis.ExtensionLifecycleTest;
import it.analysis.IssueJsonReportTest;
import it.analysis.IssuesModeTest;
import it.analysis.LinksTest;
-import it.analysis.MavenTest;
import it.analysis.MultiLanguageTest;
import it.analysis.ProjectBuilderTest;
import it.analysis.ProjectProvisioningTest;
// analysis
ExtensionLifecycleTest.class,
LinksTest.class,
- MavenTest.class,
ProjectBuilderTest.class,
TempFolderTest.class,
MultiLanguageTest.class,
IssueJsonReportTest.class,
ProjectProvisioningTest.class,
- BatchTest.class,
+ ScannerTest.class,
IssuesModeTest.class,
SettingsEncryptionTest.class,
ReportDumpTest.class,
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package it.analysis;
-
-import com.sonar.orchestrator.Orchestrator;
-import com.sonar.orchestrator.build.BuildResult;
-import com.sonar.orchestrator.build.SonarScanner;
-import com.sonar.orchestrator.locator.FileLocation;
-import it.Category3Suite;
-import java.io.File;
-import java.io.IOException;
-import java.util.Date;
-import org.apache.commons.io.FileUtils;
-import org.junit.Assume;
-import org.junit.Before;
-import org.junit.ClassRule;
-import org.junit.Ignore;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.junit.rules.TemporaryFolder;
-import org.sonar.wsclient.Sonar;
-import org.sonar.wsclient.services.PropertyDeleteQuery;
-import org.sonar.wsclient.services.PropertyUpdateQuery;
-import org.sonar.wsclient.services.Resource;
-import org.sonar.wsclient.services.ResourceQuery;
-import org.sonarqube.ws.WsComponents.ShowWsResponse;
-import org.sonarqube.ws.client.component.ShowWsRequest;
-import org.sonarqube.ws.client.measure.ComponentWsRequest;
-
-import util.ItUtils;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class BatchTest {
-
- @ClassRule
- public static Orchestrator orchestrator = Category3Suite.ORCHESTRATOR;
-
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
- @Rule
- public TemporaryFolder temp = new TemporaryFolder();
-
- @Before
- public void deleteData() {
- orchestrator.resetData();
- orchestrator.getServer().restoreProfile(FileLocation.ofClasspath("/analysis/BatchTest/one-issue-per-line.xml"));
- }
-
- /**
- * SONAR-3718
- */
- @Test
- public void should_scan_branch_with_forward_slash() {
- scan("shared/xoo-multi-modules-sample");
- scan("shared/xoo-multi-modules-sample", "sonar.branch", "branch/0.x");
-
- Sonar sonar = orchestrator.getServer().getWsClient();
- assertThat(sonar.findAll(new ResourceQuery().setQualifiers("TRK"))).hasSize(2);
-
- Resource master = sonar.find(new ResourceQuery("com.sonarsource.it.samples:multi-modules-sample"));
- assertThat(master.getName()).isEqualTo("Sonar :: Integration Tests :: Multi-modules Sample");
-
- Resource branch = sonar.find(new ResourceQuery("com.sonarsource.it.samples:multi-modules-sample:branch/0.x"));
- assertThat(branch.getName()).isEqualTo("Sonar :: Integration Tests :: Multi-modules Sample branch/0.x");
- }
-
- @Test
- public void use_sonar_profile_without_provisioning_project() {
- scan("shared/xoo-multi-modules-sample",
- "sonar.profile", "one-issue-per-line",
- "sonar.verbose", "true");
- Resource r = orchestrator.getServer().getWsClient().find(ResourceQuery.createForMetrics("com.sonarsource.it.samples:multi-modules-sample", "violations"));
- assertThat(r.getMeasureIntValue("violations")).isEqualTo(61);
- }
-
- // SONAR-4680
- @Test
- public void module_should_load_own_settings_from_database() {
- orchestrator.getServer().provisionProject("com.sonarsource.it.samples:multi-modules-sample", "Sonar :: Integration Tests :: Multi-modules Sample");
-
- Sonar sonar = orchestrator.getServer().getAdminWsClient();
- String propKey = "myFakeProperty";
- String rootModuleKey = "com.sonarsource.it.samples:multi-modules-sample";
- String moduleBKey = rootModuleKey + ":module_b";
- sonar.delete(new PropertyDeleteQuery(propKey, rootModuleKey));
- sonar.delete(new PropertyDeleteQuery(propKey, moduleBKey));
-
- BuildResult result = scan("shared/xoo-multi-modules-sample", "sonar.showSettings", propKey);
-
- assertThat(result.getLogs()).doesNotContain(rootModuleKey + ":" + propKey);
- assertThat(result.getLogs()).doesNotContain(moduleBKey + ":" + propKey);
-
- // Set property only on root project
- sonar.update(new PropertyUpdateQuery(propKey, "project", rootModuleKey));
-
- result = scan("shared/xoo-multi-modules-sample", "sonar.showSettings", propKey);
-
- assertThat(result.getLogs()).contains(rootModuleKey + ":" + propKey + " = project");
- assertThat(result.getLogs()).contains(moduleBKey + ":" + propKey + " = project");
-
- // Override property on moduleB
- sonar.update(new PropertyUpdateQuery(propKey, "moduleB", moduleBKey));
-
- result = scan("shared/xoo-multi-modules-sample", "sonar.showSettings", propKey);
-
- assertThat(result.getLogs()).contains(rootModuleKey + ":" + propKey + " = project");
- assertThat(result.getLogs()).contains(moduleBKey + ":" + propKey + " = moduleB");
- }
-
- // SONAR-4680
- @Test
- public void module_should_load_settings_from_parent() {
- orchestrator.getServer().provisionProject("com.sonarsource.it.samples:multi-modules-sample", "Sonar :: Integration Tests :: Multi-modules Sample");
-
- Sonar sonar = orchestrator.getServer().getAdminWsClient();
- String propKey = "myFakeProperty";
- String rootModuleKey = "com.sonarsource.it.samples:multi-modules-sample";
- String moduleBKey = rootModuleKey + ":module_b";
-
- // Set property on provisionned project
- sonar.update(new PropertyUpdateQuery(propKey, "project", rootModuleKey));
- sonar.delete(new PropertyDeleteQuery(propKey, moduleBKey));
-
- BuildResult result = scan("shared/xoo-multi-modules-sample", "sonar.showSettings", propKey);
-
- assertThat(result.getLogs()).contains(rootModuleKey + ":" + propKey + " = project");
- // Module should inherit from parent
- assertThat(result.getLogs()).contains(moduleBKey + ":" + propKey + " = project");
- }
-
- /**
- * SONAR-3024
- */
- @Test
- public void should_support_source_files_with_same_deprecated_key() {
- orchestrator.getServer().provisionProject("com.sonarsource.it.projects.batch:duplicate-source", "exclusions");
- orchestrator.getServer().associateProjectToQualityProfile("com.sonarsource.it.projects.batch:duplicate-source", "xoo", "one-issue-per-line");
- scan("analysis/duplicate-source");
-
- Sonar sonar = orchestrator.getServer().getAdminWsClient();
- Resource project = sonar.find(new ResourceQuery("com.sonarsource.it.projects.batch:duplicate-source").setMetrics("files", "directories"));
- // 2 main files and 1 test file all with same deprecated key
- assertThat(project.getMeasureIntValue("files")).isEqualTo(2);
- assertThat(project.getMeasureIntValue("directories")).isEqualTo(2);
- }
-
- /**
- * SONAR-3125
- */
- @Test
- public void should_display_explicit_message_when_no_plugin_language_available() {
- orchestrator.getServer().provisionProject("sample", "xoo-sample");
- orchestrator.getServer().associateProjectToQualityProfile("sample", "xoo", "one-issue-per-line");
-
- BuildResult buildResult = scanQuietly("shared/xoo-sample",
- "sonar.language", "foo",
- "sonar.profile", "");
- assertThat(buildResult.getLastStatus()).isEqualTo(1);
- assertThat(buildResult.getLogs()).contains(
- "You must install a plugin that supports the language 'foo'");
- }
-
- @Test
- public void should_display_explicit_message_when_wrong_profile() {
- orchestrator.getServer().provisionProject("sample", "xoo-sample");
- orchestrator.getServer().associateProjectToQualityProfile("sample", "xoo", "one-issue-per-line");
-
- BuildResult buildResult = scanQuietly("shared/xoo-sample",
- "sonar.profile", "unknow");
- assertThat(buildResult.getLastStatus()).isEqualTo(1);
- assertThat(buildResult.getLogs()).contains(
- "sonar.profile was set to 'unknow' but didn't match any profile for any language. Please check your configuration.");
- }
-
- @Test
- public void should_create_project_without_name_version() {
- //some of the sub-modules have a name defined, others don't
- BuildResult buildResult = scan("shared/xoo-multi-module-sample-without-project-name-version");
- assertThat(buildResult.isSuccess()).isTrue();
-
- assertNameAndVersion("com.sonarsource.it.samples:multi-modules-sample", "com.sonarsource.it.samples:multi-modules-sample", "not provided");
-
- assertNameAndVersion("com.sonarsource.it.samples:multi-modules-sample:module_b", "module_b", "not provided");
- assertNameAndVersion("com.sonarsource.it.samples:multi-modules-sample:module_b:module_b1", "module_b1", "not provided");
- assertNameAndVersion("com.sonarsource.it.samples:multi-modules-sample:module_b:module_b2", "Sub-module B2", "not provided");
-
- assertNameAndVersion("com.sonarsource.it.samples:multi-modules-sample:module_a", "Module A", "not provided");
- assertNameAndVersion("com.sonarsource.it.samples:multi-modules-sample:module_a:module_a1", "Sub-module A1", "not provided");
- assertNameAndVersion("com.sonarsource.it.samples:multi-modules-sample:module_a:module_a2", "Sub-module A2", "not provided");
- }
-
- @Test
- public void should_analyze_project_without_name_version() {
- orchestrator.getServer().provisionProject("com.sonarsource.it.samples:multi-modules-sample", "My project name");
- BuildResult buildResult = scan("shared/xoo-multi-module-sample-without-project-name-version",
- "sonar.projectName", "My project name",
- "sonar.projectVersion", "1.0");
- assertThat(buildResult.isSuccess()).isTrue();
-
- buildResult = scan("shared/xoo-multi-module-sample-without-project-name-version");
- assertThat(buildResult.isSuccess()).isTrue();
-
- assertNameAndVersion("com.sonarsource.it.samples:multi-modules-sample", "My project name", "1.0");
-
- assertNameAndVersion("com.sonarsource.it.samples:multi-modules-sample:module_b", "module_b", "1.0");
- assertNameAndVersion("com.sonarsource.it.samples:multi-modules-sample:module_b:module_b1", "module_b1", "1.0");
- assertNameAndVersion("com.sonarsource.it.samples:multi-modules-sample:module_b:module_b2", "Sub-module B2", "1.0");
-
- assertNameAndVersion("com.sonarsource.it.samples:multi-modules-sample:module_a", "Module A", "1.0");
- assertNameAndVersion("com.sonarsource.it.samples:multi-modules-sample:module_a:module_a1", "Sub-module A1", "1.0");
- assertNameAndVersion("com.sonarsource.it.samples:multi-modules-sample:module_a:module_a2", "Sub-module A2", "1.0");
- }
-
- private void assertNameAndVersion(String projectKey, String expectedProjectName, String expectedProjectVersion) {
- // new WS Client with api/components doesn't return the project version, so use the old one
- Resource resource = orchestrator.getServer().getAdminWsClient().find(new ResourceQuery(projectKey));
- assertThat(resource.getName()).isEqualTo(expectedProjectName);
- assertThat(resource.getVersion()).isEqualTo(expectedProjectVersion);
-
- }
-
- @Test
- public void should_honor_sonarUserHome() {
- File userHome = temp.getRoot();
-
- orchestrator.getServer().provisionProject("sample", "xoo-sample");
- orchestrator.getServer().associateProjectToQualityProfile("sample", "xoo", "one-issue-per-line");
-
- SonarScanner scanner = configureScanner("shared/xoo-sample",
- "sonar.verbose", "true");
- scanner.setEnvironmentVariable("SONAR_USER_HOME", "/dev/null");
- BuildResult buildResult = orchestrator.executeBuildQuietly(scanner);
- assertThat(buildResult.getLastStatus()).isEqualTo(1);
-
- buildResult = scan("shared/xoo-sample",
- "sonar.verbose", "true",
- "sonar.userHome", userHome.getAbsolutePath());
- assertThat(buildResult.isSuccess()).isTrue();
- }
-
- @Test
- public void should_authenticate_when_needed() {
- try {
- orchestrator.getServer().provisionProject("sample", "xoo-sample");
- orchestrator.getServer().associateProjectToQualityProfile("sample", "xoo", "one-issue-per-line");
-
- orchestrator.getServer().getAdminWsClient().update(new PropertyUpdateQuery("sonar.forceAuthentication", "true"));
-
- BuildResult buildResult = scanQuietly("shared/xoo-sample",
- "sonar.login", "",
- "sonar.password", "");
- assertThat(buildResult.getLastStatus()).isEqualTo(1);
- assertThat(buildResult.getLogs()).contains(
- "Not authorized. Analyzing this project requires to be authenticated. Please provide the values of the properties sonar.login and sonar.password.");
-
- // SONAR-4048
- buildResult = scanQuietly("shared/xoo-sample",
- "sonar.login", "wrong_login",
- "sonar.password", "wrong_password");
- assertThat(buildResult.getLastStatus()).isEqualTo(1);
- assertThat(buildResult.getLogs()).contains(
- "Not authorized. Please check the properties sonar.login and sonar.password.");
-
- buildResult = scan("shared/xoo-sample",
- "sonar.login", "admin",
- "sonar.password", "admin");
- assertThat(buildResult.getLastStatus()).isEqualTo(0);
-
- } finally {
- orchestrator.getServer().getAdminWsClient().update(new PropertyUpdateQuery("sonar.forceAuthentication", "false"));
- }
- }
-
- /**
- * SONAR-4211 Test Sonar Runner when server requires authentication
- */
- @Test
- public void sonar_scanner_with_secured_server() {
- try {
- orchestrator.getServer().provisionProject("sample", "xoo-sample");
- orchestrator.getServer().associateProjectToQualityProfile("sample", "xoo", "one-issue-per-line");
-
- orchestrator.getServer().getAdminWsClient().update(new PropertyUpdateQuery("sonar.forceAuthentication", "true"));
-
- BuildResult buildResult = scanQuietly("shared/xoo-sample");
- assertThat(buildResult.getLastStatus()).isEqualTo(1);
- assertThat(buildResult.getLogs()).contains(
- "Not authorized. Analyzing this project requires to be authenticated. Please provide the values of the properties sonar.login and sonar.password.");
-
- buildResult = scanQuietly("shared/xoo-sample",
- "sonar.login", "wrong_login",
- "sonar.password", "wrong_password");
- assertThat(buildResult.getLastStatus()).isEqualTo(1);
- assertThat(buildResult.getLogs()).contains(
- "Not authorized. Please check the properties sonar.login and sonar.password.");
-
- buildResult = scan("shared/xoo-sample",
- "sonar.login", "admin",
- "sonar.password", "admin");
- assertThat(buildResult.getLastStatus()).isEqualTo(0);
-
- } finally {
- orchestrator.getServer().getAdminWsClient().update(new PropertyUpdateQuery("sonar.forceAuthentication", "false"));
- }
- }
-
- /**
- * SONAR-2291
- */
- @Test
- public void batch_should_cache_plugin_jars() throws IOException {
- File userHome = temp.newFolder();
-
- BuildResult result = scan("shared/xoo-sample",
- "sonar.userHome", userHome.getAbsolutePath());
-
- File cache = new File(userHome, "cache");
- assertThat(cache).exists().isDirectory();
- int cachedFiles = FileUtils.listFiles(cache, new String[] {"jar"}, true).size();
- assertThat(cachedFiles).isGreaterThan(5);
- assertThat(result.getLogs()).contains("User cache: " + cache.getAbsolutePath());
- assertThat(result.getLogs()).contains("Download sonar-xoo-plugin-");
-
- result = scan("shared/xoo-sample",
- "sonar.userHome", userHome.getAbsolutePath());
- assertThat(cachedFiles).isEqualTo(cachedFiles);
- assertThat(result.getLogs()).contains("User cache: " + cache.getAbsolutePath());
- assertThat(result.getLogs()).doesNotContain("Download sonar-xoo-plugin-");
- }
-
- @Test
- public void batch_should_keep_report_verbose() {
- orchestrator.getServer().provisionProject("sample", "xoo-sample");
- orchestrator.getServer().associateProjectToQualityProfile("sample", "xoo", "one-issue-per-line");
-
- scanQuietly("shared/xoo-sample", "sonar.verbose", "true");
- File reportDir = new File(new File(ItUtils.projectDir("shared/xoo-sample"), ".sonar"), "batch-report");
- assertThat(reportDir).isDirectory();
- assertThat(reportDir.list()).isNotEmpty();
- }
-
- /**
- * SONAR-4239
- */
- @Test
- public void should_display_project_url_after_analysis() throws IOException {
- orchestrator.getServer().provisionProject("com.sonarsource.it.samples:multi-modules-sample", "Sonar :: Integration Tests :: Multi-modules Sample");
- orchestrator.getServer().associateProjectToQualityProfile("com.sonarsource.it.samples:multi-modules-sample", "xoo", "one-issue-per-line");
- Assume.assumeTrue(orchestrator.getServer().version().isGreaterThanOrEquals("3.6"));
-
- BuildResult result = scan("shared/xoo-multi-modules-sample");
-
- assertThat(result.getLogs()).contains("/dashboard/index/com.sonarsource.it.samples:multi-modules-sample");
-
- result = scan("shared/xoo-multi-modules-sample",
- "sonar.branch", "mybranch");
-
- assertThat(result.getLogs()).contains("/dashboard/index/com.sonarsource.it.samples:multi-modules-sample:mybranch");
-
- try {
- orchestrator.getServer().getAdminWsClient().update(new PropertyUpdateQuery("sonar.core.serverBaseURL", "http://foo:123/sonar"));
- result = scan("shared/xoo-multi-modules-sample");
- assertThat(result.getLogs()).contains("http://foo:123/sonar/dashboard/index/com.sonarsource.it.samples:multi-modules-sample");
- } finally {
- orchestrator.getServer().getAdminWsClient().update(new PropertyUpdateQuery("sonar.core.serverBaseURL", null));
- }
- }
-
- /**
- * SONAR-4188, SONAR-5178, SONAR-5915
- */
- @Test
- public void should_display_explicit_message_when_invalid_project_key_or_branch() {
- orchestrator.getServer().provisionProject("sample", "xoo-sample");
- orchestrator.getServer().associateProjectToQualityProfile("sample", "xoo", "one-issue-per-line");
-
- BuildResult buildResult = scanQuietly("shared/xoo-sample",
- "sonar.projectKey", "ar g$l:");
- assertThat(buildResult.getLastStatus()).isEqualTo(1);
- assertThat(buildResult.getLogs()).contains("\"ar g$l:\" is not a valid project or module key")
- .contains("Allowed characters");
-
- // SONAR-4629
- buildResult = scanQuietly("shared/xoo-sample",
- "sonar.projectKey", "12345");
- assertThat(buildResult.getLastStatus()).isEqualTo(1);
- assertThat(buildResult.getLogs()).contains("\"12345\" is not a valid project or module key")
- .contains("Allowed characters");
-
- buildResult = scanQuietly("shared/xoo-sample",
- "sonar.branch", "ar g$l:");
- assertThat(buildResult.getLastStatus()).isEqualTo(1);
- assertThat(buildResult.getLogs()).contains("\"ar g$l:\" is not a valid branch")
- .contains("Allowed characters");
- }
-
- /**
- * SONAR-4547
- */
- @Test
- public void display_MessageException_without_stacktrace() throws Exception {
- orchestrator.getServer().provisionProject("sample", "xoo-sample");
- orchestrator.getServer().associateProjectToQualityProfile("sample", "xoo", "one-issue-per-line");
- BuildResult result = scanQuietly("shared/xoo-sample", "raiseMessageException", "true");
- assertThat(result.getLastStatus()).isNotEqualTo(0);
- assertThat(result.getLogs())
- // message
- .contains("Error message from plugin")
-
- // but not stacktrace
- .doesNotContain("at com.sonarsource.RaiseMessageException");
- }
-
- /**
- * SONAR-4751
- */
- @Test
- public void file_extensions_are_case_insensitive() throws Exception {
- orchestrator.getServer().provisionProject("case-sensitive-file-extensions", "Case Sensitive");
- orchestrator.getServer().associateProjectToQualityProfile("case-sensitive-file-extensions", "xoo", "one-issue-per-line");
- scan("analysis/case-sensitive-file-extensions");
-
- Resource project = orchestrator.getServer().getWsClient().find(ResourceQuery.createForMetrics("case-sensitive-file-extensions", "files", "ncloc"));
- assertThat(project.getMeasureIntValue("files")).isEqualTo(2);
- assertThat(project.getMeasureIntValue("ncloc")).isEqualTo(5 + 2);
- }
-
- /**
- * SONAR-4876
- */
- @Test
- public void custom_module_key() {
- orchestrator.getServer().provisionProject("com.sonarsource.it.samples:multi-modules-sample", "Sonar :: Integration Tests :: Multi-modules Sample");
- orchestrator.getServer().associateProjectToQualityProfile("com.sonarsource.it.samples:multi-modules-sample", "xoo", "one-issue-per-line");
- scan("analysis/custom-module-key");
- assertThat(getResource("com.sonarsource.it.samples:moduleA")).isNotNull();
- assertThat(getResource("com.sonarsource.it.samples:moduleB")).isNotNull();
- }
-
- /**
- * SONAR-4692
- */
- @Test
- @Ignore("This test should be moved to a Medium test of the Compute Engine")
- public void prevent_same_module_key_in_two_projects() {
- orchestrator.getServer().provisionProject("projectAB", "project AB");
- orchestrator.getServer().associateProjectToQualityProfile("projectAB", "xoo", "one-issue-per-line");
- scan("analysis/prevent-common-module/projectAB");
- assertThat(getResource("com.sonarsource.it.samples:moduleA")).isNotNull();
- assertThat(getResource("com.sonarsource.it.samples:moduleB")).isNotNull();
-
- orchestrator.getServer().provisionProject("projectAC", "project AC");
- orchestrator.getServer().associateProjectToQualityProfile("projectAC", "xoo", "one-issue-per-line");
-
- BuildResult result = scanQuietly("analysis/prevent-common-module/projectAC");
- assertThat(result.getLastStatus()).isNotEqualTo(0);
- assertThat(result.getLogs()).contains("Module \"com.sonarsource.it.samples:moduleA\" is already part of project \"projectAB\"");
- }
-
- /**
- * SONAR-4235
- */
- @Test
- public void test_project_creation_date() {
- long before = new Date().getTime() - 2000l;
- orchestrator.getServer().provisionProject("sample", "xoo-sample");
- orchestrator.getServer().associateProjectToQualityProfile("sample", "xoo", "one-issue-per-line");
- orchestrator.executeBuild(SonarScanner.create(ItUtils.projectDir("shared/xoo-sample")));
- long after = new Date().getTime() + 2000l;
- Resource xooSample = orchestrator.getServer().getWsClient().find(new ResourceQuery().setResourceKeyOrId("sample"));
- assertThat(xooSample.getCreationDate().getTime()).isGreaterThan(before).isLessThan(after);
- }
-
- /**
- * SONAR-4334
- */
- @Test
- @Ignore("Should be move to CE IT/MT")
- public void fail_if_project_date_is_older_than_latest_snapshot() {
- orchestrator.getServer().provisionProject("sample", "xoo-sample");
- orchestrator.getServer().associateProjectToQualityProfile("sample", "xoo", "one-issue-per-line");
- SonarScanner analysis = SonarScanner.create(ItUtils.projectDir("shared/xoo-sample"));
- analysis.setProperty("sonar.projectDate", "2014-01-01");
- orchestrator.executeBuild(analysis);
-
- analysis.setProperty("sonar.projectDate", "2000-10-19");
- BuildResult result = orchestrator.executeBuildQuietly(analysis);
-
- assertThat(result.getLastStatus()).isNotEqualTo(0);
- assertThat(result.getLogs()).contains("'sonar.projectDate' property cannot be older than the date of the last known quality snapshot on this project. Value: '2000-10-19'. " +
- "Latest quality snapshot: ");
- assertThat(result.getLogs()).contains("This property may only be used to rebuild the past in a chronological order.");
- }
-
- private Resource getResource(String key) {
- return orchestrator.getServer().getWsClient().find(ResourceQuery.createForMetrics(key, "lines"));
- }
-
- private BuildResult scan(String projectPath, String... props) {
- SonarScanner scanner = configureScanner(projectPath, props);
- return orchestrator.executeBuild(scanner);
- }
-
- private BuildResult scanQuietly(String projectPath, String... props) {
- SonarScanner scanner = configureScanner(projectPath, props);
- return orchestrator.executeBuildQuietly(scanner);
- }
-
- private SonarScanner configureScanner(String projectPath, String... props) {
- SonarScanner scanner = SonarScanner.create(ItUtils.projectDir(projectPath))
- .setProperties(props);
- return scanner;
- }
-
-}
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package it.analysis;
-
-import com.sonar.orchestrator.Orchestrator;
-import com.sonar.orchestrator.build.BuildResult;
-import com.sonar.orchestrator.build.MavenBuild;
-import it.Category3Suite;
-import java.util.List;
-import org.junit.Before;
-import org.junit.ClassRule;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.sonar.wsclient.Sonar;
-import org.sonar.wsclient.services.Resource;
-import org.sonar.wsclient.services.ResourceQuery;
-import util.ItUtils;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class MavenTest {
-
- @ClassRule
- public static Orchestrator orchestrator = Category3Suite.ORCHESTRATOR;
-
- @Before
- public void deleteData() {
- orchestrator.resetData();
- }
-
- @Test
- public void shouldSupportJarWithoutSources() {
- MavenBuild build = MavenBuild.create(ItUtils.projectPom("maven/project-with-module-without-sources"))
- .setCleanSonarGoals();
- orchestrator.executeBuild(build);
-
- Resource project = orchestrator.getServer().getWsClient()
- .find(ResourceQuery.createForMetrics("com.sonarsource.it.samples.project-with-module-without-sources:parent", "files"));
- assertThat(project.getMeasureIntValue("files")).isEqualTo(1);
-
- Resource subProject = orchestrator.getServer().getWsClient().find(ResourceQuery.create("com.sonarsource.it.samples.project-with-module-without-sources:without-sources"));
- assertThat(subProject).isNotNull();
- }
-
- /**
- * See SONAR-594
- */
- @Test
- public void shouldSupportJeeProjects() {
- MavenBuild build = MavenBuild.create(ItUtils.projectPom("maven/jee"))
- .setGoals("clean install", "sonar:sonar");
- orchestrator.executeBuild(build);
-
- Resource project = orchestrator.getServer().getWsClient().find(ResourceQuery.createForMetrics("com.sonarsource.it.samples.jee:parent", "files"));
- assertThat(project.getMeasureIntValue("files")).isEqualTo(2);
-
- List<Resource> modules = orchestrator.getServer().getWsClient().findAll(ResourceQuery.create("com.sonarsource.it.samples.jee:parent").setDepth(-1).setQualifiers("BRC"));
- assertThat(modules).hasSize(4);
- }
-
- /**
- * See SONAR-222
- */
- @Test
- public void shouldSupportMavenExtensions() {
- MavenBuild build = MavenBuild.create(ItUtils.projectPom("maven/maven-extensions"))
- .setCleanSonarGoals();
- orchestrator.executeBuild(build);
-
- Resource project = orchestrator.getServer().getWsClient().find(ResourceQuery.createForMetrics("com.sonarsource.it.samples:maven-extensions", "files"));
- assertThat(project.getMeasureIntValue("files")).isEqualTo(1);
- }
-
- /**
- * This test should be splitted. It checks multiple use-cases at the same time : SONAR-518, SONAR-519 and SONAR-593
- */
- @Test
- public void testBadMavenParameters() {
- // should not fail
- MavenBuild build = MavenBuild.create(ItUtils.projectPom("maven/maven-bad-parameters"))
- .setCleanSonarGoals();
- orchestrator.executeBuild(build);
-
- Resource project = orchestrator.getServer().getWsClient().find(ResourceQuery.createForMetrics("com.sonarsource.it.samples.maven-bad-parameters:parent", "files"));
- assertThat(project.getMeasureIntValue("files")).isGreaterThan(0);
- }
-
- @Test
- public void shouldAnalyzeMultiModules() {
- MavenBuild build = MavenBuild.create(ItUtils.projectPom("maven/modules-order"))
- .setCleanSonarGoals()
- .setProperty("sonar.dynamicAnalysis", "false");
- orchestrator.executeBuild(build);
-
- Sonar sonar = orchestrator.getServer().getWsClient();
- assertThat(sonar.find(new ResourceQuery("org.sonar.tests.modules-order:root")).getName()).isEqualTo("Sonar tests - modules order");
-
- assertThat(sonar.find(new ResourceQuery("org.sonar.tests.modules-order:parent")).getName()).isEqualTo("Parent");
-
- assertThat(sonar.find(new ResourceQuery("org.sonar.tests.modules-order:module_a")).getName()).isEqualTo("Module A");
- assertThat(sonar.find(new ResourceQuery("org.sonar.tests.modules-order:module_a:src/main/java/HelloA.java")).getName()).isEqualTo("HelloA.java");
-
- assertThat(sonar.find(new ResourceQuery("org.sonar.tests.modules-order:module_b")).getName()).isEqualTo("Module B");
- assertThat(sonar.find(new ResourceQuery("org.sonar.tests.modules-order:module_b:src/main/java/HelloB.java")).getName()).isEqualTo("HelloB.java");
- }
-
- /**
- * See SONAR-2735
- */
- @Test
- public void shouldSupportDifferentDeclarationsForModules() {
- MavenBuild build = MavenBuild.create(ItUtils.projectPom("maven/modules-declaration"))
- .setCleanSonarGoals()
- .setProperty("sonar.dynamicAnalysis", "false");
- orchestrator.executeBuild(build);
- Sonar sonar = orchestrator.getServer().getWsClient();
-
- assertThat(sonar.find(new ResourceQuery("org.sonar.tests.modules-declaration:root")).getName()).isEqualTo("Root");
-
- assertThat(sonar.find(new ResourceQuery("org.sonar.tests.modules-declaration:module_a")).getName()).isEqualTo("Module A");
- assertThat(sonar.find(new ResourceQuery("org.sonar.tests.modules-declaration:module_a:src/main/java/HelloA.java")).getName()).isEqualTo("HelloA.java");
-
- assertThat(sonar.find(new ResourceQuery("org.sonar.tests.modules-declaration:module_b")).getName()).isEqualTo("Module B");
- assertThat(sonar.find(new ResourceQuery("org.sonar.tests.modules-declaration:module_b:src/main/java/HelloB.java")).getName()).isEqualTo("HelloB.java");
-
- assertThat(sonar.find(new ResourceQuery("org.sonar.tests.modules-declaration:module_c")).getName()).isEqualTo("Module C");
- assertThat(sonar.find(new ResourceQuery("org.sonar.tests.modules-declaration:module_c:src/main/java/HelloC.java")).getName()).isEqualTo("HelloC.java");
-
- assertThat(sonar.find(new ResourceQuery("org.sonar.tests.modules-declaration:module_d")).getName()).isEqualTo("Module D");
- assertThat(sonar.find(new ResourceQuery("org.sonar.tests.modules-declaration:module_d:src/main/java/HelloD.java")).getName()).isEqualTo("HelloD.java");
-
- assertThat(sonar.find(new ResourceQuery("org.sonar.tests.modules-declaration:module_e")).getName()).isEqualTo("Module E");
- assertThat(sonar.find(new ResourceQuery("org.sonar.tests.modules-declaration:module_e:src/main/java/HelloE.java")).getName()).isEqualTo("HelloE.java");
- }
-
- /**
- * See SONAR-3843
- */
- @Test
- public void should_support_shade_with_dependency_reduced_pom_with_clean_install_sonar_goals() {
- MavenBuild build = MavenBuild.create(ItUtils.projectPom("maven/shade-with-dependency-reduced-pom"))
- .setProperty("sonar.dynamicAnalysis", "false")
- .setGoals("clean", "install", "sonar:sonar");
-
- orchestrator.executeBuild(build);
- }
-
- /**
- * SONAR-4245
- */
- @Test
- @Ignore("This test should be moved to a Medium test of the Compute Engine")
- public void should_prevent_analysis_of_module_then_project() {
- MavenBuild scan = MavenBuild.create(ItUtils.projectPom("shared/multi-modules-sample/module_a"))
- .setProperty("sonar.dynamicAnalysis", "false")
- .setCleanSonarGoals();
- orchestrator.executeBuild(scan);
-
- scan = MavenBuild.create(ItUtils.projectPom("shared/multi-modules-sample"))
- .setProperty("sonar.dynamicAnalysis", "false")
- .setCleanSonarGoals();
- BuildResult result = orchestrator.executeBuildQuietly(scan);
- assertThat(result.getStatus()).isNotEqualTo(0);
- assertThat(result.getLogs()).contains("The project 'com.sonarsource.it.samples:module_a' is already defined in SonarQube "
- + "but not as a module of project 'com.sonarsource.it.samples:multi-modules-sample'. "
- + "If you really want to stop directly analysing project 'com.sonarsource.it.samples:module_a', "
- + "please first delete it from SonarQube and then relaunch the analysis of project 'com.sonarsource.it.samples:multi-modules-sample'.");
- }
-
- /**
- * src/main/java is missing
- */
- @Test
- public void maven_project_with_only_test_dir() {
- MavenBuild build = MavenBuild.create(ItUtils.projectPom("maven/maven-only-test-dir")).setCleanPackageSonarGoals();
- orchestrator.executeBuild(build);
-
- Resource project = orchestrator.getServer().getWsClient().find(ResourceQuery.createForMetrics("com.sonarsource.it.samples:maven-only-test-dir", "tests", "files"));
- assertThat(project.getMeasureIntValue("tests")).isEqualTo(1);
- assertThat(project.getMeasure("files")).isNull();
- }
-
- /**
- * The property sonar.sources overrides the source dirs as declared in Maven
- */
- @Test
- public void override_sources() {
- MavenBuild build = MavenBuild.create(ItUtils.projectPom("maven/maven-override-sources")).setGoals("sonar:sonar");
- orchestrator.executeBuild(build);
-
- Resource project = orchestrator.getServer().getWsClient().find(ResourceQuery.createForMetrics("com.sonarsource.it.samples:maven-override-sources", "files"));
- assertThat(project.getMeasureIntValue("files")).isEqualTo(1);
-
- Resource file = orchestrator.getServer().getWsClient().find(ResourceQuery.create("com.sonarsource.it.samples:maven-override-sources:src/main/java2/Hello2.java"));
- assertThat(file).isNotNull();
- }
-
- /**
- * The property sonar.inclusions overrides the property sonar.sources
- */
- @Test
- public void inclusions_apply_to_source_dirs() {
- MavenBuild build = MavenBuild.create(ItUtils.projectPom("maven/inclusions_apply_to_source_dirs")).setGoals("sonar:sonar");
- orchestrator.executeBuild(build);
-
- Resource project = orchestrator.getServer().getWsClient().find(ResourceQuery.createForMetrics("com.sonarsource.it.samples:inclusions_apply_to_source_dirs", "files"));
- assertThat(project.getMeasureIntValue("files")).isEqualTo(1);
-
- Resource file = orchestrator.getServer().getWsClient().find(ResourceQuery.create("com.sonarsource.it.samples:inclusions_apply_to_source_dirs:src/main/java/Hello2.java"));
- assertThat(file).isNotNull();
- }
-
- /**
- * The property sonar.sources has a typo -> fail, like in sonar-runner
- */
- @Test
- public void fail_if_bad_value_of_sonar_sources_property() {
- MavenBuild build = MavenBuild.create(ItUtils.projectPom("maven/maven-bad-sources-property")).setGoals("sonar:sonar");
- BuildResult result = orchestrator.executeBuildQuietly(build);
- assertThat(result.getStatus()).isNotEqualTo(0);
- assertThat(result.getLogs()).contains(
- "java2' does not exist for Maven module com.sonarsource.it.samples:maven-bad-sources-property:jar:1.0-SNAPSHOT. Please check the property sonar.sources");
- }
-
- /**
- * The property sonar.sources has a typo -> fail, like in sonar-runner
- */
- @Test
- public void fail_if_bad_value_of_sonar_tests_property() {
- MavenBuild build = MavenBuild.create(ItUtils.projectPom("maven/maven-bad-tests-property")).setGoals("sonar:sonar");
- BuildResult result = orchestrator.executeBuildQuietly(build);
- assertThat(result.getStatus()).isNotEqualTo(0);
- assertThat(result.getLogs()).contains(
- "java2' does not exist for Maven module com.sonarsource.it.samples:maven-bad-tests-property:jar:1.0-SNAPSHOT. Please check the property sonar.tests");
- }
-
-}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package it.analysis;
+
+import com.sonar.orchestrator.Orchestrator;
+import com.sonar.orchestrator.build.BuildResult;
+import com.sonar.orchestrator.build.SonarScanner;
+import com.sonar.orchestrator.locator.FileLocation;
+import it.Category3Suite;
+import java.io.File;
+import java.io.IOException;
+import java.util.Date;
+import org.apache.commons.io.FileUtils;
+import org.junit.Assume;
+import org.junit.Before;
+import org.junit.ClassRule;
+import org.junit.Ignore;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.junit.rules.TemporaryFolder;
+import org.sonar.wsclient.Sonar;
+import org.sonar.wsclient.services.PropertyDeleteQuery;
+import org.sonar.wsclient.services.PropertyUpdateQuery;
+import org.sonar.wsclient.services.Resource;
+import org.sonar.wsclient.services.ResourceQuery;
+import org.sonarqube.ws.WsComponents.ShowWsResponse;
+import org.sonarqube.ws.client.component.ShowWsRequest;
+import org.sonarqube.ws.client.measure.ComponentWsRequest;
+
+import util.ItUtils;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class ScannerTest {
+
+ @ClassRule
+ public static Orchestrator orchestrator = Category3Suite.ORCHESTRATOR;
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ @Rule
+ public TemporaryFolder temp = new TemporaryFolder();
+
+ @Before
+ public void deleteData() {
+ orchestrator.resetData();
+ orchestrator.getServer().restoreProfile(FileLocation.ofClasspath("/analysis/BatchTest/one-issue-per-line.xml"));
+ }
+
+ /**
+ * SONAR-3718
+ */
+ @Test
+ public void should_scan_branch_with_forward_slash() {
+ scan("shared/xoo-multi-modules-sample");
+ scan("shared/xoo-multi-modules-sample", "sonar.branch", "branch/0.x");
+
+ Sonar sonar = orchestrator.getServer().getWsClient();
+ assertThat(sonar.findAll(new ResourceQuery().setQualifiers("TRK"))).hasSize(2);
+
+ Resource master = sonar.find(new ResourceQuery("com.sonarsource.it.samples:multi-modules-sample"));
+ assertThat(master.getName()).isEqualTo("Sonar :: Integration Tests :: Multi-modules Sample");
+
+ Resource branch = sonar.find(new ResourceQuery("com.sonarsource.it.samples:multi-modules-sample:branch/0.x"));
+ assertThat(branch.getName()).isEqualTo("Sonar :: Integration Tests :: Multi-modules Sample branch/0.x");
+ }
+
+ @Test
+ public void use_sonar_profile_without_provisioning_project() {
+ scan("shared/xoo-multi-modules-sample",
+ "sonar.profile", "one-issue-per-line",
+ "sonar.verbose", "true");
+ Resource r = orchestrator.getServer().getWsClient().find(ResourceQuery.createForMetrics("com.sonarsource.it.samples:multi-modules-sample", "violations"));
+ assertThat(r.getMeasureIntValue("violations")).isEqualTo(61);
+ }
+
+ // SONAR-4680
+ @Test
+ public void module_should_load_own_settings_from_database() {
+ orchestrator.getServer().provisionProject("com.sonarsource.it.samples:multi-modules-sample", "Sonar :: Integration Tests :: Multi-modules Sample");
+
+ Sonar sonar = orchestrator.getServer().getAdminWsClient();
+ String propKey = "myFakeProperty";
+ String rootModuleKey = "com.sonarsource.it.samples:multi-modules-sample";
+ String moduleBKey = rootModuleKey + ":module_b";
+ sonar.delete(new PropertyDeleteQuery(propKey, rootModuleKey));
+ sonar.delete(new PropertyDeleteQuery(propKey, moduleBKey));
+
+ BuildResult result = scan("shared/xoo-multi-modules-sample", "sonar.showSettings", propKey);
+
+ assertThat(result.getLogs()).doesNotContain(rootModuleKey + ":" + propKey);
+ assertThat(result.getLogs()).doesNotContain(moduleBKey + ":" + propKey);
+
+ // Set property only on root project
+ sonar.update(new PropertyUpdateQuery(propKey, "project", rootModuleKey));
+
+ result = scan("shared/xoo-multi-modules-sample", "sonar.showSettings", propKey);
+
+ assertThat(result.getLogs()).contains(rootModuleKey + ":" + propKey + " = project");
+ assertThat(result.getLogs()).contains(moduleBKey + ":" + propKey + " = project");
+
+ // Override property on moduleB
+ sonar.update(new PropertyUpdateQuery(propKey, "moduleB", moduleBKey));
+
+ result = scan("shared/xoo-multi-modules-sample", "sonar.showSettings", propKey);
+
+ assertThat(result.getLogs()).contains(rootModuleKey + ":" + propKey + " = project");
+ assertThat(result.getLogs()).contains(moduleBKey + ":" + propKey + " = moduleB");
+ }
+
+ // SONAR-4680
+ @Test
+ public void module_should_load_settings_from_parent() {
+ orchestrator.getServer().provisionProject("com.sonarsource.it.samples:multi-modules-sample", "Sonar :: Integration Tests :: Multi-modules Sample");
+
+ Sonar sonar = orchestrator.getServer().getAdminWsClient();
+ String propKey = "myFakeProperty";
+ String rootModuleKey = "com.sonarsource.it.samples:multi-modules-sample";
+ String moduleBKey = rootModuleKey + ":module_b";
+
+ // Set property on provisionned project
+ sonar.update(new PropertyUpdateQuery(propKey, "project", rootModuleKey));
+ sonar.delete(new PropertyDeleteQuery(propKey, moduleBKey));
+
+ BuildResult result = scan("shared/xoo-multi-modules-sample", "sonar.showSettings", propKey);
+
+ assertThat(result.getLogs()).contains(rootModuleKey + ":" + propKey + " = project");
+ // Module should inherit from parent
+ assertThat(result.getLogs()).contains(moduleBKey + ":" + propKey + " = project");
+ }
+
+ /**
+ * SONAR-3024
+ */
+ @Test
+ public void should_support_source_files_with_same_deprecated_key() {
+ orchestrator.getServer().provisionProject("com.sonarsource.it.projects.batch:duplicate-source", "exclusions");
+ orchestrator.getServer().associateProjectToQualityProfile("com.sonarsource.it.projects.batch:duplicate-source", "xoo", "one-issue-per-line");
+ scan("analysis/duplicate-source");
+
+ Sonar sonar = orchestrator.getServer().getAdminWsClient();
+ Resource project = sonar.find(new ResourceQuery("com.sonarsource.it.projects.batch:duplicate-source").setMetrics("files", "directories"));
+ // 2 main files and 1 test file all with same deprecated key
+ assertThat(project.getMeasureIntValue("files")).isEqualTo(2);
+ assertThat(project.getMeasureIntValue("directories")).isEqualTo(2);
+ }
+
+ /**
+ * SONAR-3125
+ */
+ @Test
+ public void should_display_explicit_message_when_no_plugin_language_available() {
+ orchestrator.getServer().provisionProject("sample", "xoo-sample");
+ orchestrator.getServer().associateProjectToQualityProfile("sample", "xoo", "one-issue-per-line");
+
+ BuildResult buildResult = scanQuietly("shared/xoo-sample",
+ "sonar.language", "foo",
+ "sonar.profile", "");
+ assertThat(buildResult.getLastStatus()).isEqualTo(1);
+ assertThat(buildResult.getLogs()).contains(
+ "You must install a plugin that supports the language 'foo'");
+ }
+
+ @Test
+ public void should_display_explicit_message_when_wrong_profile() {
+ orchestrator.getServer().provisionProject("sample", "xoo-sample");
+ orchestrator.getServer().associateProjectToQualityProfile("sample", "xoo", "one-issue-per-line");
+
+ BuildResult buildResult = scanQuietly("shared/xoo-sample",
+ "sonar.profile", "unknow");
+ assertThat(buildResult.getLastStatus()).isEqualTo(1);
+ assertThat(buildResult.getLogs()).contains(
+ "sonar.profile was set to 'unknow' but didn't match any profile for any language. Please check your configuration.");
+ }
+
+ @Test
+ public void should_create_project_without_name_version() {
+ //some of the sub-modules have a name defined, others don't
+ BuildResult buildResult = scan("shared/xoo-multi-module-sample-without-project-name-version");
+ assertThat(buildResult.isSuccess()).isTrue();
+
+ assertNameAndVersion("com.sonarsource.it.samples:multi-modules-sample", "com.sonarsource.it.samples:multi-modules-sample", "not provided");
+
+ assertNameAndVersion("com.sonarsource.it.samples:multi-modules-sample:module_b", "module_b", "not provided");
+ assertNameAndVersion("com.sonarsource.it.samples:multi-modules-sample:module_b:module_b1", "module_b1", "not provided");
+ assertNameAndVersion("com.sonarsource.it.samples:multi-modules-sample:module_b:module_b2", "Sub-module B2", "not provided");
+
+ assertNameAndVersion("com.sonarsource.it.samples:multi-modules-sample:module_a", "Module A", "not provided");
+ assertNameAndVersion("com.sonarsource.it.samples:multi-modules-sample:module_a:module_a1", "Sub-module A1", "not provided");
+ assertNameAndVersion("com.sonarsource.it.samples:multi-modules-sample:module_a:module_a2", "Sub-module A2", "not provided");
+ }
+
+ @Test
+ public void should_analyze_project_without_name_version() {
+ orchestrator.getServer().provisionProject("com.sonarsource.it.samples:multi-modules-sample", "My project name");
+ BuildResult buildResult = scan("shared/xoo-multi-module-sample-without-project-name-version",
+ "sonar.projectName", "My project name",
+ "sonar.projectVersion", "1.0");
+ assertThat(buildResult.isSuccess()).isTrue();
+
+ buildResult = scan("shared/xoo-multi-module-sample-without-project-name-version");
+ assertThat(buildResult.isSuccess()).isTrue();
+
+ assertNameAndVersion("com.sonarsource.it.samples:multi-modules-sample", "My project name", "1.0");
+
+ assertNameAndVersion("com.sonarsource.it.samples:multi-modules-sample:module_b", "module_b", "1.0");
+ assertNameAndVersion("com.sonarsource.it.samples:multi-modules-sample:module_b:module_b1", "module_b1", "1.0");
+ assertNameAndVersion("com.sonarsource.it.samples:multi-modules-sample:module_b:module_b2", "Sub-module B2", "1.0");
+
+ assertNameAndVersion("com.sonarsource.it.samples:multi-modules-sample:module_a", "Module A", "1.0");
+ assertNameAndVersion("com.sonarsource.it.samples:multi-modules-sample:module_a:module_a1", "Sub-module A1", "1.0");
+ assertNameAndVersion("com.sonarsource.it.samples:multi-modules-sample:module_a:module_a2", "Sub-module A2", "1.0");
+ }
+
+ private void assertNameAndVersion(String projectKey, String expectedProjectName, String expectedProjectVersion) {
+ // new WS Client with api/components doesn't return the project version, so use the old one
+ Resource resource = orchestrator.getServer().getAdminWsClient().find(new ResourceQuery(projectKey));
+ assertThat(resource.getName()).isEqualTo(expectedProjectName);
+ assertThat(resource.getVersion()).isEqualTo(expectedProjectVersion);
+
+ }
+
+ @Test
+ public void should_honor_sonarUserHome() {
+ File userHome = temp.getRoot();
+
+ orchestrator.getServer().provisionProject("sample", "xoo-sample");
+ orchestrator.getServer().associateProjectToQualityProfile("sample", "xoo", "one-issue-per-line");
+
+ SonarScanner scanner = configureScanner("shared/xoo-sample",
+ "sonar.verbose", "true");
+ scanner.setEnvironmentVariable("SONAR_USER_HOME", "/dev/null");
+ BuildResult buildResult = orchestrator.executeBuildQuietly(scanner);
+ assertThat(buildResult.getLastStatus()).isEqualTo(1);
+
+ buildResult = scan("shared/xoo-sample",
+ "sonar.verbose", "true",
+ "sonar.userHome", userHome.getAbsolutePath());
+ assertThat(buildResult.isSuccess()).isTrue();
+ }
+
+ @Test
+ public void should_authenticate_when_needed() {
+ try {
+ orchestrator.getServer().provisionProject("sample", "xoo-sample");
+ orchestrator.getServer().associateProjectToQualityProfile("sample", "xoo", "one-issue-per-line");
+
+ orchestrator.getServer().getAdminWsClient().update(new PropertyUpdateQuery("sonar.forceAuthentication", "true"));
+
+ BuildResult buildResult = scanQuietly("shared/xoo-sample",
+ "sonar.login", "",
+ "sonar.password", "");
+ assertThat(buildResult.getLastStatus()).isEqualTo(1);
+ assertThat(buildResult.getLogs()).contains(
+ "Not authorized. Analyzing this project requires to be authenticated. Please provide the values of the properties sonar.login and sonar.password.");
+
+ // SONAR-4048
+ buildResult = scanQuietly("shared/xoo-sample",
+ "sonar.login", "wrong_login",
+ "sonar.password", "wrong_password");
+ assertThat(buildResult.getLastStatus()).isEqualTo(1);
+ assertThat(buildResult.getLogs()).contains(
+ "Not authorized. Please check the properties sonar.login and sonar.password.");
+
+ buildResult = scan("shared/xoo-sample",
+ "sonar.login", "admin",
+ "sonar.password", "admin");
+ assertThat(buildResult.getLastStatus()).isEqualTo(0);
+
+ } finally {
+ orchestrator.getServer().getAdminWsClient().update(new PropertyUpdateQuery("sonar.forceAuthentication", "false"));
+ }
+ }
+
+ /**
+ * SONAR-4211 Test Sonar Runner when server requires authentication
+ */
+ @Test
+ public void sonar_scanner_with_secured_server() {
+ try {
+ orchestrator.getServer().provisionProject("sample", "xoo-sample");
+ orchestrator.getServer().associateProjectToQualityProfile("sample", "xoo", "one-issue-per-line");
+
+ orchestrator.getServer().getAdminWsClient().update(new PropertyUpdateQuery("sonar.forceAuthentication", "true"));
+
+ BuildResult buildResult = scanQuietly("shared/xoo-sample");
+ assertThat(buildResult.getLastStatus()).isEqualTo(1);
+ assertThat(buildResult.getLogs()).contains(
+ "Not authorized. Analyzing this project requires to be authenticated. Please provide the values of the properties sonar.login and sonar.password.");
+
+ buildResult = scanQuietly("shared/xoo-sample",
+ "sonar.login", "wrong_login",
+ "sonar.password", "wrong_password");
+ assertThat(buildResult.getLastStatus()).isEqualTo(1);
+ assertThat(buildResult.getLogs()).contains(
+ "Not authorized. Please check the properties sonar.login and sonar.password.");
+
+ buildResult = scan("shared/xoo-sample",
+ "sonar.login", "admin",
+ "sonar.password", "admin");
+ assertThat(buildResult.getLastStatus()).isEqualTo(0);
+
+ } finally {
+ orchestrator.getServer().getAdminWsClient().update(new PropertyUpdateQuery("sonar.forceAuthentication", "false"));
+ }
+ }
+
+ /**
+ * SONAR-2291
+ */
+ @Test
+ public void batch_should_cache_plugin_jars() throws IOException {
+ File userHome = temp.newFolder();
+
+ BuildResult result = scan("shared/xoo-sample",
+ "sonar.userHome", userHome.getAbsolutePath());
+
+ File cache = new File(userHome, "cache");
+ assertThat(cache).exists().isDirectory();
+ int cachedFiles = FileUtils.listFiles(cache, new String[] {"jar"}, true).size();
+ assertThat(cachedFiles).isGreaterThan(5);
+ assertThat(result.getLogs()).contains("User cache: " + cache.getAbsolutePath());
+ assertThat(result.getLogs()).contains("Download sonar-xoo-plugin-");
+
+ result = scan("shared/xoo-sample",
+ "sonar.userHome", userHome.getAbsolutePath());
+ assertThat(cachedFiles).isEqualTo(cachedFiles);
+ assertThat(result.getLogs()).contains("User cache: " + cache.getAbsolutePath());
+ assertThat(result.getLogs()).doesNotContain("Download sonar-xoo-plugin-");
+ }
+
+ @Test
+ public void batch_should_keep_report_verbose() {
+ orchestrator.getServer().provisionProject("sample", "xoo-sample");
+ orchestrator.getServer().associateProjectToQualityProfile("sample", "xoo", "one-issue-per-line");
+
+ scanQuietly("shared/xoo-sample", "sonar.verbose", "true");
+ File reportDir = new File(new File(ItUtils.projectDir("shared/xoo-sample"), ".sonar"), "batch-report");
+ assertThat(reportDir).isDirectory();
+ assertThat(reportDir.list()).isNotEmpty();
+ }
+
+ /**
+ * SONAR-4239
+ */
+ @Test
+ public void should_display_project_url_after_analysis() throws IOException {
+ orchestrator.getServer().provisionProject("com.sonarsource.it.samples:multi-modules-sample", "Sonar :: Integration Tests :: Multi-modules Sample");
+ orchestrator.getServer().associateProjectToQualityProfile("com.sonarsource.it.samples:multi-modules-sample", "xoo", "one-issue-per-line");
+ Assume.assumeTrue(orchestrator.getServer().version().isGreaterThanOrEquals("3.6"));
+
+ BuildResult result = scan("shared/xoo-multi-modules-sample");
+
+ assertThat(result.getLogs()).contains("/dashboard/index/com.sonarsource.it.samples:multi-modules-sample");
+
+ result = scan("shared/xoo-multi-modules-sample",
+ "sonar.branch", "mybranch");
+
+ assertThat(result.getLogs()).contains("/dashboard/index/com.sonarsource.it.samples:multi-modules-sample:mybranch");
+
+ try {
+ orchestrator.getServer().getAdminWsClient().update(new PropertyUpdateQuery("sonar.core.serverBaseURL", "http://foo:123/sonar"));
+ result = scan("shared/xoo-multi-modules-sample");
+ assertThat(result.getLogs()).contains("http://foo:123/sonar/dashboard/index/com.sonarsource.it.samples:multi-modules-sample");
+ } finally {
+ orchestrator.getServer().getAdminWsClient().update(new PropertyUpdateQuery("sonar.core.serverBaseURL", null));
+ }
+ }
+
+ /**
+ * SONAR-4188, SONAR-5178, SONAR-5915
+ */
+ @Test
+ public void should_display_explicit_message_when_invalid_project_key_or_branch() {
+ orchestrator.getServer().provisionProject("sample", "xoo-sample");
+ orchestrator.getServer().associateProjectToQualityProfile("sample", "xoo", "one-issue-per-line");
+
+ BuildResult buildResult = scanQuietly("shared/xoo-sample",
+ "sonar.projectKey", "ar g$l:");
+ assertThat(buildResult.getLastStatus()).isEqualTo(1);
+ assertThat(buildResult.getLogs()).contains("\"ar g$l:\" is not a valid project or module key")
+ .contains("Allowed characters");
+
+ // SONAR-4629
+ buildResult = scanQuietly("shared/xoo-sample",
+ "sonar.projectKey", "12345");
+ assertThat(buildResult.getLastStatus()).isEqualTo(1);
+ assertThat(buildResult.getLogs()).contains("\"12345\" is not a valid project or module key")
+ .contains("Allowed characters");
+
+ buildResult = scanQuietly("shared/xoo-sample",
+ "sonar.branch", "ar g$l:");
+ assertThat(buildResult.getLastStatus()).isEqualTo(1);
+ assertThat(buildResult.getLogs()).contains("\"ar g$l:\" is not a valid branch")
+ .contains("Allowed characters");
+ }
+
+ /**
+ * SONAR-4547
+ */
+ @Test
+ public void display_MessageException_without_stacktrace() throws Exception {
+ orchestrator.getServer().provisionProject("sample", "xoo-sample");
+ orchestrator.getServer().associateProjectToQualityProfile("sample", "xoo", "one-issue-per-line");
+ BuildResult result = scanQuietly("shared/xoo-sample", "raiseMessageException", "true");
+ assertThat(result.getLastStatus()).isNotEqualTo(0);
+ assertThat(result.getLogs())
+ // message
+ .contains("Error message from plugin")
+
+ // but not stacktrace
+ .doesNotContain("at com.sonarsource.RaiseMessageException");
+ }
+
+ /**
+ * SONAR-4751
+ */
+ @Test
+ public void file_extensions_are_case_insensitive() throws Exception {
+ orchestrator.getServer().provisionProject("case-sensitive-file-extensions", "Case Sensitive");
+ orchestrator.getServer().associateProjectToQualityProfile("case-sensitive-file-extensions", "xoo", "one-issue-per-line");
+ scan("analysis/case-sensitive-file-extensions");
+
+ Resource project = orchestrator.getServer().getWsClient().find(ResourceQuery.createForMetrics("case-sensitive-file-extensions", "files", "ncloc"));
+ assertThat(project.getMeasureIntValue("files")).isEqualTo(2);
+ assertThat(project.getMeasureIntValue("ncloc")).isEqualTo(5 + 2);
+ }
+
+ /**
+ * SONAR-4876
+ */
+ @Test
+ public void custom_module_key() {
+ orchestrator.getServer().provisionProject("com.sonarsource.it.samples:multi-modules-sample", "Sonar :: Integration Tests :: Multi-modules Sample");
+ orchestrator.getServer().associateProjectToQualityProfile("com.sonarsource.it.samples:multi-modules-sample", "xoo", "one-issue-per-line");
+ scan("analysis/custom-module-key");
+ assertThat(getResource("com.sonarsource.it.samples:moduleA")).isNotNull();
+ assertThat(getResource("com.sonarsource.it.samples:moduleB")).isNotNull();
+ }
+
+ /**
+ * SONAR-4692
+ */
+ @Test
+ @Ignore("This test should be moved to a Medium test of the Compute Engine")
+ public void prevent_same_module_key_in_two_projects() {
+ orchestrator.getServer().provisionProject("projectAB", "project AB");
+ orchestrator.getServer().associateProjectToQualityProfile("projectAB", "xoo", "one-issue-per-line");
+ scan("analysis/prevent-common-module/projectAB");
+ assertThat(getResource("com.sonarsource.it.samples:moduleA")).isNotNull();
+ assertThat(getResource("com.sonarsource.it.samples:moduleB")).isNotNull();
+
+ orchestrator.getServer().provisionProject("projectAC", "project AC");
+ orchestrator.getServer().associateProjectToQualityProfile("projectAC", "xoo", "one-issue-per-line");
+
+ BuildResult result = scanQuietly("analysis/prevent-common-module/projectAC");
+ assertThat(result.getLastStatus()).isNotEqualTo(0);
+ assertThat(result.getLogs()).contains("Module \"com.sonarsource.it.samples:moduleA\" is already part of project \"projectAB\"");
+ }
+
+ /**
+ * SONAR-4235
+ */
+ @Test
+ public void test_project_creation_date() {
+ long before = new Date().getTime() - 2000l;
+ orchestrator.getServer().provisionProject("sample", "xoo-sample");
+ orchestrator.getServer().associateProjectToQualityProfile("sample", "xoo", "one-issue-per-line");
+ orchestrator.executeBuild(SonarScanner.create(ItUtils.projectDir("shared/xoo-sample")));
+ long after = new Date().getTime() + 2000l;
+ Resource xooSample = orchestrator.getServer().getWsClient().find(new ResourceQuery().setResourceKeyOrId("sample"));
+ assertThat(xooSample.getCreationDate().getTime()).isGreaterThan(before).isLessThan(after);
+ }
+
+ /**
+ * SONAR-4334
+ */
+ @Test
+ @Ignore("Should be move to CE IT/MT")
+ public void fail_if_project_date_is_older_than_latest_snapshot() {
+ orchestrator.getServer().provisionProject("sample", "xoo-sample");
+ orchestrator.getServer().associateProjectToQualityProfile("sample", "xoo", "one-issue-per-line");
+ SonarScanner analysis = SonarScanner.create(ItUtils.projectDir("shared/xoo-sample"));
+ analysis.setProperty("sonar.projectDate", "2014-01-01");
+ orchestrator.executeBuild(analysis);
+
+ analysis.setProperty("sonar.projectDate", "2000-10-19");
+ BuildResult result = orchestrator.executeBuildQuietly(analysis);
+
+ assertThat(result.getLastStatus()).isNotEqualTo(0);
+ assertThat(result.getLogs()).contains("'sonar.projectDate' property cannot be older than the date of the last known quality snapshot on this project. Value: '2000-10-19'. " +
+ "Latest quality snapshot: ");
+ assertThat(result.getLogs()).contains("This property may only be used to rebuild the past in a chronological order.");
+ }
+
+ private Resource getResource(String key) {
+ return orchestrator.getServer().getWsClient().find(ResourceQuery.createForMetrics(key, "lines"));
+ }
+
+ private BuildResult scan(String projectPath, String... props) {
+ SonarScanner scanner = configureScanner(projectPath, props);
+ return orchestrator.executeBuild(scanner);
+ }
+
+ private BuildResult scanQuietly(String projectPath, String... props) {
+ SonarScanner scanner = configureScanner(projectPath, props);
+ return orchestrator.executeBuildQuietly(scanner);
+ }
+
+ private SonarScanner configureScanner(String projectPath, String... props) {
+ SonarScanner scanner = SonarScanner.create(ItUtils.projectDir(projectPath))
+ .setProperties(props);
+ return scanner;
+ }
+
+}