Search in sources :

Example 1 with PropertyCreateQuery

use of org.sonar.wsclient.services.PropertyCreateQuery in project sonarlint-core by SonarSource.

the class LicenseTest method prepare.

@BeforeClass
public static void prepare() throws Exception {
    OrchestratorBuilder builder = Orchestrator.builderEnv().restoreProfileAtStartup(FileLocation.ofClasspath("/cobol-sonarlint.xml"));
    if (Version.create(builder.getSonarVersion().get()).isGreaterThanOrEquals("6.7")) {
        builder.addPlugin(MavenLocation.of("com.sonarsource.license", "sonar-dev-license-plugin", "3.2.0.1163"));
    }
    builder.addPlugin("cobol");
    ORCHESTRATOR = builder.build();
    ORCHESTRATOR.start();
    adminWsClient = ConnectedModeTest.newAdminWsClient(ORCHESTRATOR);
    ORCHESTRATOR.getServer().getAdminWsClient().create(new PropertyCreateQuery("sonar.forceAuthentication", "true"));
    sonarUserHome = temp.newFolder().toPath();
    removeGroupPermission("anyone", "scan");
    ORCHESTRATOR.getServer().adminWsClient().userClient().create(UserParameters.create().login(SONARLINT_USER).password(SONARLINT_PWD).passwordConfirmation(SONARLINT_PWD).name("SonarLint"));
    // addUserPermission("sonarlint", "dryRunScan");
    ORCHESTRATOR.getServer().provisionProject(PROJECT_KEY_COBOL, "Sample Cobol");
    ORCHESTRATOR.getServer().associateProjectToQualityProfile(PROJECT_KEY_COBOL, "cobol", "SonarLint IT Cobol");
}
Also used : PropertyCreateQuery(org.sonar.wsclient.services.PropertyCreateQuery) OrchestratorBuilder(com.sonar.orchestrator.OrchestratorBuilder) BeforeClass(org.junit.BeforeClass)

Example 2 with PropertyCreateQuery

use of org.sonar.wsclient.services.PropertyCreateQuery in project sonarlint-core by SonarSource.

the class ConnectedDaemonTest method prepare.

@BeforeClass
public static void prepare() throws Exception {
    adminWsClient = ConnectedModeTest.newAdminWsClient(ORCHESTRATOR);
    ORCHESTRATOR.getServer().getAdminWsClient().create(new PropertyCreateQuery("sonar.forceAuthentication", "true"));
    sonarUserHome = temp.newFolder().toPath();
    removeGroupPermission("anyone", "scan");
    ORCHESTRATOR.getServer().adminWsClient().userClient().create(UserParameters.create().login(SONARLINT_USER).password(SONARLINT_PWD).passwordConfirmation(SONARLINT_PWD).name("SonarLint"));
    // addUserPermission("sonarlint", "dryRunScan");
    ORCHESTRATOR.getServer().provisionProject(PROJECT_KEY_JAVA, "Sample Java");
    ORCHESTRATOR.getServer().associateProjectToQualityProfile(PROJECT_KEY_JAVA, "java", "SonarLint IT Java");
    // Build project to have bytecode
    ORCHESTRATOR.executeBuild(MavenBuild.create(new File("projects/sample-java/pom.xml")).setGoals("clean package"));
}
Also used : PropertyCreateQuery(org.sonar.wsclient.services.PropertyCreateQuery) InputFile(org.sonarsource.sonarlint.daemon.proto.SonarlintDaemon.InputFile) File(java.io.File) BeforeClass(org.junit.BeforeClass)

Example 3 with PropertyCreateQuery

use of org.sonar.wsclient.services.PropertyCreateQuery in project sonarqube by SonarSource.

the class MemoryTest method analyzeProjectWithManyModulesAndBigProperties.

// Property on root module is duplicated in each module so it may be big
@Test
public void analyzeProjectWithManyModulesAndBigProperties() throws IOException {
    File baseDir = temp.newFolder();
    prepareModule(baseDir, "moduleA", 1);
    prepareModule(baseDir, "moduleB", 1);
    prepareModule(baseDir, "moduleC", 1);
    FileUtils.write(new File(baseDir, "sonar-project.properties"), "sonar.modules=moduleA,moduleB,moduleC\n", true);
    FileUtils.write(new File(baseDir, "sonar-project.properties"), "sonar.myBigProp=" + Strings.repeat("A", 10000), true);
    SonarScanner scanner = SonarScanner.create().setProperties("sonar.projectKey", "big-module-tree", "sonar.projectName", "Big Module Tree", "sonar.projectVersion", "1.0", "sonar.sources", "", "sonar.showProfiling", "true");
    scanner.setEnvironmentVariable("SONAR_RUNNER_OPTS", "-Xmx512m -server").setProjectDir(baseDir);
    BuildResult result = orchestrator.executeBuild(scanner);
    perfRule.assertDurationAround(MavenLogs.extractTotalTime(result.getLogs()), 4847L);
    // Second execution with a property on server side
    orchestrator.getServer().getAdminWsClient().create(new PropertyCreateQuery("sonar.anotherBigProp", Strings.repeat("B", 1000), "big-module-tree"));
    result = orchestrator.executeBuild(scanner);
    perfRule.assertDurationAround(MavenLogs.extractTotalTime(result.getLogs()), 4620L);
}
Also used : BuildResult(com.sonar.orchestrator.build.BuildResult) PropertyCreateQuery(org.sonar.wsclient.services.PropertyCreateQuery) File(java.io.File) SonarScanner(com.sonar.orchestrator.build.SonarScanner) Test(org.junit.Test)

Aggregations

PropertyCreateQuery (org.sonar.wsclient.services.PropertyCreateQuery)3 File (java.io.File)2 BeforeClass (org.junit.BeforeClass)2 OrchestratorBuilder (com.sonar.orchestrator.OrchestratorBuilder)1 BuildResult (com.sonar.orchestrator.build.BuildResult)1 SonarScanner (com.sonar.orchestrator.build.SonarScanner)1 Test (org.junit.Test)1 InputFile (org.sonarsource.sonarlint.daemon.proto.SonarlintDaemon.InputFile)1