SonarScannerInstaller { public File install(Version scannerVersion, File toDir, boolean useOldScript) { return install(scannerVersion, null, toDir, useOldScript); } SonarScannerInstaller(Locators locators); File install(Version scannerVersion, File toDir, boolean useOldScript); File install(Version scannerVersion, @Nullable String classifier, File toDir, boolean useOldScript);  }
@Test public void unsupported_version() throws Exception { thrown.expect(IllegalArgumentException.class); thrown.expectMessage("Unsupported sonar-scanner version: 1.0"); installer.install(Version.create("1.0"), temp.newFolder(), true); }
@Test public void install_embedded_version() throws Exception { File toDir = temp.newFolder(); File script = installer.install(Version.create(SonarRunner.DEFAULT_SCANNER_VERSION), toDir, false); assertThat(script).isFile().exists(); assertThat(script.getName()).contains("sonar-scanner"); assertThat(script.getParentFile().getName()).isEqualTo("bin"); assertThat(script.getParentFile().getParentFile().getName()).isEqualTo("sonar-scanner-" + SonarRunner.DEFAULT_SCANNER_VERSION); verify(locators, never()).locate(any(MavenLocation.class)); }
@Test public void install_self_contained() throws Exception { File toDir = temp.newFolder(); String classifier = "linux"; String versionString = "2.9"; Version version = Version.create(versionString); File script = installer.install(version, classifier, toDir, false); assertThat(script).isFile().exists(); assertThat(script.getName()).contains("sonar-scanner"); assertThat(script.getParentFile().getName()).isEqualTo("bin"); assertThat(script.getParentFile().getParentFile().getName()).isEqualTo("sonar-scanner-" + versionString + "-linux"); Path javaPath = script.toPath().getParent().resolve("../lib/jre/bin/java"); assertThat(javaPath).isRegularFile(); verify(locators, never()).locate(any(MavenLocation.class)); }