com.sonar.orchestrator.locator.FileLocation Java Examples
The following examples show how to use
com.sonar.orchestrator.locator.FileLocation.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CssTest.java From sonar-css-plugin with GNU Lesser General Public License v3.0 | 6 votes |
@Test public void test() throws Exception { File litsDifferencesFile = FileLocation.of("target/differences").getFile(); orchestrator.getServer().provisionProject("project", "project"); orchestrator.getServer().associateProjectToQualityProfile("project", "css", "rules"); orchestrator.getServer().associateProjectToQualityProfile("project", "less", "rules"); orchestrator.getServer().associateProjectToQualityProfile("project", "scss", "rules"); SonarScanner build = SonarScanner.create(FileLocation.of("../projects").getFile()) .setProjectKey("project") .setSourceDirs("./") .setSourceEncoding("UTF-8") .setProperty("sonar.import_unknown_files", "true") .setProperty("sonar.analysis.mode", "preview") .setProperty("sonar.issuesReport.html.enable", "true") .setProperty("dump.old", FileLocation.of("src/test/expected").getFile().getAbsolutePath()) .setProperty("dump.new", FileLocation.of("target/actual").getFile().getAbsolutePath()) .setProperty("lits.differences", litsDifferencesFile.getAbsolutePath()) .setProperty("sonar.cpd.skip", "true"); orchestrator.executeBuild(build); assertThat(Files.asCharSource(litsDifferencesFile, StandardCharsets.UTF_8).read()).isEmpty(); }
Example #2
Source File: RunPluginTest.java From sonar-checkstyle with GNU Lesser General Public License v3.0 | 6 votes |
@BeforeClass public static void beforeAll() { orchestrator = Orchestrator.builderEnv() .setZipFile(new File("target/temp-downloads/sonar-application-" + SONAR_APP_VERSION + ".zip")) //.setSonarVersion(System.getProperty("sonar.runtimeVersion", SONAR_APP_VERSION)) .setEdition(Edition.COMMUNITY) .addPlugin(FileLocation.byWildcardMavenFilename(new File("target"), "checkstyle-sonar-plugin-*.jar")) .addPlugin(MavenLocation.of("org.sonarsource.sonar-lits-plugin", "sonar-lits-plugin", "0.8.0.1209")) .addPlugin(MavenLocation.of("org.sonarsource.java", "sonar-java-plugin", "6.0.0.20538")) .setServerProperty("sonar.web.javaOpts", "-Xmx1G") .build(); orchestrator.start(); }
Example #3
Source File: RunPluginTest.java From sonar-checkstyle with GNU Lesser General Public License v3.0 | 6 votes |
private MavenBuild testProjectBuild() throws IOException { final File targetDir = prepareProject(); final String pomLocation = targetDir.getCanonicalPath() + "/pom.xml"; final File pomFile = FileLocation.of(pomLocation) .getFile() .getCanonicalFile(); final MavenBuild mavenBuild = MavenBuild.create() .setPom(pomFile) .setCleanPackageSonarGoals() .addArgument("-Dmaven.test.skip=true") .addArgument("-DskipTests") .addArgument("-DskipITs"); mavenBuild.setProperty("sonar.projectKey", PROJECT_KEY); return mavenBuild; }
Example #4
Source File: GherkinRulingTest.java From sonar-gherkin-plugin with GNU Lesser General Public License v3.0 | 6 votes |
@Test public void test() throws Exception { File litsDifferencesFile = FileLocation.of("target/differences").getFile(); orchestrator.getServer().provisionProject("project", "project"); orchestrator.getServer().associateProjectToQualityProfile("project", "gherkin", "rules"); SonarScanner build = SonarScanner.create(FileLocation.of("../projects").getFile()) .setProjectKey("project") .setLanguage("gherkin") .setSourceDirs("./") .setSourceEncoding("UTF-8") .setProperty("sonar.analysis.mode", "preview") .setProperty("sonar.issuesReport.html.enable", "true") .setProperty("dump.old", FileLocation.of("src/test/expected").getFile().getAbsolutePath()) .setProperty("dump.new", FileLocation.of("target/actual").getFile().getAbsolutePath()) .setProperty("lits.differences", litsDifferencesFile.getAbsolutePath()) .setProperty("sonar.cpd.skip", "true") .setProperty("sonar.exclusions", "custom/spelling/spelling-fr.feature," + "custom/indentation/indentation-custom-ok.feature," + "custom/indentation/indentation-custom-ko.feature" ); orchestrator.executeBuild(build); assertThat(Files.asCharSource(litsDifferencesFile, StandardCharsets.UTF_8).read()).isEmpty(); }
Example #5
Source File: CssTest.java From sonar-css-plugin with GNU Lesser General Public License v3.0 | 5 votes |
@Before public void setUp() { ProfileGenerator.RulesConfiguration rulesConfiguration = new ProfileGenerator.RulesConfiguration(); Set<String> excludedRules = Collections.emptySet(); File cssProfile = ProfileGenerator.generateProfile(orchestrator.getServer().getUrl(), "css", "css", rulesConfiguration, excludedRules); orchestrator.getServer().restoreProfile(FileLocation.of(cssProfile)); File lessProfile = ProfileGenerator.generateProfile(orchestrator.getServer().getUrl(), "less", "less", rulesConfiguration, excludedRules); orchestrator.getServer().restoreProfile(FileLocation.of(lessProfile)); File scssProfile = ProfileGenerator.generateProfile(orchestrator.getServer().getUrl(), "scss", "scss", rulesConfiguration, excludedRules); orchestrator.getServer().restoreProfile(FileLocation.of(scssProfile)); }
Example #6
Source File: RunPluginTest.java From sonar-checkstyle with GNU Lesser General Public License v3.0 | 5 votes |
private static void executeBuildWithCommonProperties(Build<?> build, boolean buildQuietly) throws IOException { final String dumpOldLocation = FileLocation.of("target/old/" + PROJECT_NAME) .getFile() .getAbsolutePath(); final String dumpNewLocation = FileLocation.of("target/actual/" + PROJECT_NAME) .getFile() .getAbsolutePath(); build .setProperty("sonar.login", "admin") .setProperty("sonar.password", "admin") .setProperty("sonar.cpd.exclusions", "**/*") .setProperty("sonar.import_unknown_files", TRUE) .setProperty("sonar.skipPackageDesign", TRUE) .setProperty("dump.old", dumpOldLocation) .setProperty("dump.new", dumpNewLocation) .setProperty("lits.differences", litsDifferencesPath()) .setProperty("sonar.java.xfile", TRUE) .setProperty("sonar.java.failOnException", TRUE); final BuildResult buildResult; // if build fail, job is not violently interrupted, allowing time to dump SQ logs if (buildQuietly) { buildResult = orchestrator.executeBuildQuietly(build); } else { buildResult = orchestrator.executeBuild(build); } if (buildResult.isSuccess()) { assertNoDifferences(); } else { dumpServerLogs(); fail("Build failure for project: " + PROJECT_NAME); } }
Example #7
Source File: GherkinRulingTest.java From sonar-gherkin-plugin with GNU Lesser General Public License v3.0 | 5 votes |
@Before public void setUp() { ProfileGenerator.RulesConfiguration rulesConfiguration = new ProfileGenerator.RulesConfiguration(); Set<String> excludedRules = ImmutableSet.of("spelling"); File profile = ProfileGenerator.generateProfile(orchestrator.getServer().getUrl(), "gherkin", "gherkin", rulesConfiguration, excludedRules); orchestrator.getServer().restoreProfile(FileLocation.of(profile)); }
Example #8
Source File: RunPluginTest.java From sonar-checkstyle with GNU Lesser General Public License v3.0 | 4 votes |
private static String litsDifferencesPath() { return FileLocation.of("target/" + PROJECT_NAME + "_differences") .getFile() .getAbsolutePath(); }