Browse Source

Fix ITs after the drop of modules

tags/3.4.0.1729
Julien HENRY 5 years ago
parent
commit
2e23725e04

+ 4
- 10
it/pom.xml View File

</organization> </organization>


<properties> <properties>
<sonar.buildVersion>5.6</sonar.buildVersion>
<sonar.buildVersion>6.7</sonar.buildVersion>
<!-- following properties must be set in command-line : sonar.runtimeVersion and sonarRunner.version --> <!-- following properties must be set in command-line : sonar.runtimeVersion and sonarRunner.version -->
</properties> </properties>


<dependency> <dependency>
<groupId>org.sonarsource.orchestrator</groupId> <groupId>org.sonarsource.orchestrator</groupId>
<artifactId>sonar-orchestrator</artifactId> <artifactId>sonar-orchestrator</artifactId>
<version>3.15.1.1274</version>
<version>3.22.0.1791</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<dependency> <dependency>
<groupId>org.sonarsource.sonarqube</groupId> <groupId>org.sonarsource.sonarqube</groupId>
<artifactId>sonar-ws</artifactId> <artifactId>sonar-ws</artifactId>
<version>5.6</version>
</dependency>
<dependency>
<groupId>org.easytesting</groupId>
<artifactId>fest-assert</artifactId>
<version>1.4</version>
<scope>test</scope>
<version>6.7</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.assertj</groupId> <groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId> <artifactId>assertj-core</artifactId>
<version>2.1.0</version>
<version>3.11.1</version>
</dependency> </dependency>
</dependencies> </dependencies>



+ 58
- 28
it/src/test/java/com/sonarsource/scanner/it/MultimoduleTest.java View File

import org.junit.Test; import org.junit.Test;
import org.sonarqube.ws.WsComponents.Component; import org.sonarqube.ws.WsComponents.Component;


import static org.fest.assertions.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThat;


public class MultimoduleTest extends ScannerTestCase { public class MultimoduleTest extends ScannerTestCase {




assertThat(getComponent("simplest-with-props-on-root").getName()).isEqualTo("Simplest multi-module project with all properties set on the root project"); assertThat(getComponent("simplest-with-props-on-root").getName()).isEqualTo("Simplest multi-module project with all properties set on the root project");


// Verify that we have the modules
assertThat(getComponent("simplest-with-props-on-root:module1").getName()).isEqualTo("module1");

assertThat(getComponent("simplest-with-props-on-root:module2").getName()).isEqualTo("module2");
if (noMoreModules()) {
// Verify that we have the folders
assertThat(getComponent("simplest-with-props-on-root:module1/src").getName()).isEqualTo("module1/src");
assertThat(getComponent("simplest-with-props-on-root:module2/src").getName()).isEqualTo("module2/src");
} else {
// Verify that we have the modules
assertThat(getComponent("simplest-with-props-on-root:module1").getName()).isEqualTo("module1");
assertThat(getComponent("simplest-with-props-on-root:module2").getName()).isEqualTo("module2");
}


// And verify that the working directories are all located in the root folder // And verify that the working directories are all located in the root folder
File workDir = new File("projects/multi-module/simplest/simplest-with-props-on-root/.scannerwork"); File workDir = new File("projects/multi-module/simplest/simplest-with-props-on-root/.scannerwork");


assertThat(getComponent("simplest-with-props-each-module").getName()).isEqualTo("Simplest multi-module project with properties set on each module"); assertThat(getComponent("simplest-with-props-each-module").getName()).isEqualTo("Simplest multi-module project with properties set on each module");


// Verify that we have the modules
assertThat(getComponent("simplest-with-props-each-module:module1").getName()).isEqualTo("module1");

assertThat(getComponent("simplest-with-props-each-module:overridden-key-for-module2").getName()).isEqualTo("Module 2");
if (noMoreModules()) {
assertThat(getComponent("simplest-with-props-each-module:module1/src").getName()).isEqualTo("module1/src");
assertThat(getComponent("simplest-with-props-each-module:module2/src").getName()).isEqualTo("module2/src");
} else {
// Verify that we have the modules
assertThat(getComponent("simplest-with-props-each-module:module1").getName()).isEqualTo("module1");
assertThat(getComponent("simplest-with-props-each-module:overridden-key-for-module2").getName()).isEqualTo("Module 2");
}
} }


/** /**


assertThat(getComponent("deep-path-for-modules").getName()).isEqualTo("Project with deep path for modules"); assertThat(getComponent("deep-path-for-modules").getName()).isEqualTo("Project with deep path for modules");


// Verify that we have the modules
assertThat(getComponent("deep-path-for-modules:mod1").getName()).isEqualTo("Module 1");

assertThat(getComponent("deep-path-for-modules:mod2").getName()).isEqualTo("Module 2");
if (noMoreModules()) {
assertThat(getComponent("deep-path-for-modules:modules/module1/src").getName()).isEqualTo("module1/src");
assertThat(getComponent("deep-path-for-modules:modules/module2/src").getName()).isEqualTo("module2/src");
} else {
// Verify that we have the modules
assertThat(getComponent("deep-path-for-modules:mod1").getName()).isEqualTo("Module 1");
assertThat(getComponent("deep-path-for-modules:mod2").getName()).isEqualTo("Module 2");
}
} }


/** /**


assertThat(getComponent("module-path-with-space").getName()).isEqualTo("Project with module path that contain spaces"); assertThat(getComponent("module-path-with-space").getName()).isEqualTo("Project with module path that contain spaces");


// Verify that we have the modules
assertThat(getComponent("module-path-with-space:module1").getName()).isEqualTo("Module 1");

assertThat(getComponent("module-path-with-space:module2").getName()).isEqualTo("Module 2");
if (noMoreModules()) {
assertThat(getComponent("module-path-with-space:my module 1/src").getName()).isEqualTo("my module 1/src");
assertThat(getComponent("module-path-with-space:my module 2/src").getName()).isEqualTo("my module 2/src");
} else {
// Verify that we have the modules
assertThat(getComponent("module-path-with-space:module1").getName()).isEqualTo("Module 1");
assertThat(getComponent("module-path-with-space:module2").getName()).isEqualTo("Module 2");
}
} }


/** /**
assertThat(rootProject.getName()).isEqualTo("Project with modules that overwrite properties"); assertThat(rootProject.getName()).isEqualTo("Project with modules that overwrite properties");
assertThat(rootProject.getDescription()).isEqualTo("Description of root project"); assertThat(rootProject.getDescription()).isEqualTo("Description of root project");


// Verify that we have the modules
Component module1 = getComponent("overwriting-parent-properties:module1-new-key");
assertThat(module1.getName()).isEqualTo("Module 1");
assertThat(module1.getDescription()).isEqualTo("Description of module 1");

Component module2 = getComponent("overwriting-parent-properties:module2-new-key");
assertThat(module2.getName()).isEqualTo("Module 2");
assertThat(module2.getDescription()).isEqualTo("Description of module 2");
if (noMoreModules()) {
assertThat(getComponent("overwriting-parent-properties:module1/src1").getName()).isEqualTo("module1/src1");
assertThat(getComponent("overwriting-parent-properties:module2/src2").getName()).isEqualTo("module2/src2");
} else {
// Verify that we have the modules
Component module1 = getComponent("overwriting-parent-properties:module1-new-key");
assertThat(module1.getName()).isEqualTo("Module 1");
assertThat(module1.getDescription()).isEqualTo("Description of module 1");

Component module2 = getComponent("overwriting-parent-properties:module2-new-key");
assertThat(module2.getName()).isEqualTo("Module 2");
assertThat(module2.getDescription()).isEqualTo("Description of module 2");
}
} }


/** /**


assertThat(getComponent("using-config-file-prop").getName()).isEqualTo("Advanced use case - mostly used by the Ant task"); assertThat(getComponent("using-config-file-prop").getName()).isEqualTo("Advanced use case - mostly used by the Ant task");


// Verify that we have the modules
assertThat(getComponent("using-config-file-prop:module1").getName()).isEqualTo("Module 1");
if (noMoreModules()) {
assertThat(getComponent("using-config-file-prop:module1/src").getName()).isEqualTo("module1/src");
assertThat(getComponent("using-config-file-prop:module2/src").getName()).isEqualTo("module2/src");
} else {
// Verify that we have the modules
assertThat(getComponent("using-config-file-prop:module1").getName()).isEqualTo("Module 1");
assertThat(getComponent("using-config-file-prop:module2").getName()).isEqualTo("Module 2");
}
}


assertThat(getComponent("using-config-file-prop:module2").getName()).isEqualTo("Module 2");
private boolean noMoreModules() {
return orchestrator.getServer().version().isGreaterThanOrEquals(7, 6);
} }


/** /**

+ 3
- 3
it/src/test/java/com/sonarsource/scanner/it/ScannerTest.java View File

import java.io.IOException; import java.io.IOException;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.fest.assertions.Condition;
import org.assertj.core.api.Condition;
import org.junit.After; import org.junit.After;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.sonarqube.ws.WsMeasures.Measure; import org.sonarqube.ws.WsMeasures.Measure;


import static java.lang.Integer.parseInt; import static java.lang.Integer.parseInt;
import static org.fest.assertions.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThat;


public class ScannerTest extends ScannerTestCase { public class ScannerTest extends ScannerTestCase {


BuildResult executeBuild = orchestrator.executeBuildQuietly(build); BuildResult executeBuild = orchestrator.executeBuildQuietly(build);
assertThat(executeBuild.getStatus()).isNotEqualTo(0); assertThat(executeBuild.getStatus()).isNotEqualTo(0);
String logs = executeBuild.getLogs(); String logs = executeBuild.getLogs();
assertThat(logs).satisfies(new Condition<String>("Contain error message about OOM") {
assertThat(logs).is(new Condition<String>("Contain error message about OOM") {
@Override @Override
public boolean matches(String value) { public boolean matches(String value) {
return value.contains("java.lang.OutOfMemoryError") return value.contains("java.lang.OutOfMemoryError")

+ 3
- 2
it/src/test/java/com/sonarsource/scanner/it/SonarScannerTestSuite.java View File

package com.sonarsource.scanner.it; package com.sonarsource.scanner.it;


import com.sonar.orchestrator.Orchestrator; import com.sonar.orchestrator.Orchestrator;
import com.sonar.orchestrator.locator.MavenLocation;
import org.junit.ClassRule; import org.junit.ClassRule;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.junit.runners.Suite; import org.junit.runners.Suite;


@ClassRule @ClassRule
public static final Orchestrator ORCHESTRATOR = Orchestrator.builderEnv() public static final Orchestrator ORCHESTRATOR = Orchestrator.builderEnv()
.setOrchestratorProperty("javascriptVersion", "LATEST_RELEASE")
.addPlugin("javascript")
.setSonarVersion(System.getProperty("sonar.runtimeVersion", "LATEST_RELEASE[6.7]"))
.addPlugin(MavenLocation.of("org.sonarsource.javascript", "sonar-javascript-plugin", "LATEST_RELEASE"))
.build(); .build();


} }

Loading…
Cancel
Save