import org.junit.rules.TemporaryFolder;
import org.sonarqube.qa.util.Tester;
+import static com.sonar.orchestrator.util.ZipUtils.unzip;
import static org.apache.commons.io.FileUtils.copyDirectory;
import static org.apache.commons.io.FileUtils.moveFile;
import static org.assertj.core.api.Assertions.assertThat;
import static org.sonarqube.tests.source.SourceSuite.ORCHESTRATOR;
-import static org.sonarqube.tests.source.ZipUtils.unzip;
import static util.ItUtils.projectDir;
public class NoScmThenScmTest {
assertThat(scmData.get(1).date).isInSameMinuteWindowAs(new Date());
// Restore SCM Repository
- unzip(new File(source, "scm-repository.zip"), source.getAbsolutePath());
+ unzip(new File(source, "scm-repository.zip"), source);
// 2nd run
orchestrator.executeBuild(newScannerWithSCM(source));
assertThat(scmData.get(1).date).isInSameMinuteWindowAs(new Date());
// Restore SCM Repository
- unzip(new File(source, "scm-repository.zip"), source.getAbsolutePath());
+ unzip(new File(source, "scm-repository.zip"), source);
// Swap analysed fo to a modified one
File sample = new File(source, PATH_TO_SAMPLE);
assertThat(scmData.get(1).date).isInSameMinuteWindowAs(new Date());
// Restore SCM Repository
- unzip(new File(source, "scm-repository.zip"), source.getAbsolutePath());
+ unzip(new File(source, "scm-repository.zip"), source);
// Swap analysed fo to a modified one
File sample = new File(source, PATH_TO_SAMPLE);
import org.junit.rules.TemporaryFolder;
import org.sonarqube.qa.util.Tester;
+import static com.sonar.orchestrator.util.ZipUtils.unzip;
import static org.apache.commons.io.FileUtils.copyDirectory;
import static org.apache.commons.io.FileUtils.deleteDirectory;
import static org.apache.commons.io.FileUtils.moveFile;
import static org.assertj.core.api.Assertions.assertThat;
import static org.sonarqube.tests.source.SourceSuite.ORCHESTRATOR;
-import static org.sonarqube.tests.source.ZipUtils.unzip;
import static util.ItUtils.projectDir;
public class ScmThenNoScmTest {
public void with_and_then_without_scm_on_same_file() throws ParseException, IOException {
File source = disposableWorkspaceFor("xoo-sample-with-then-without-scm");
- unzip(new File(source, "scm-repository.zip"), source.getAbsolutePath());
+ unzip(new File(source, "scm-repository.zip"), source);
// First run
SonarScanner scanner = SonarScanner.create(source)
public void with_and_then_without_scm_on_modified_file() throws ParseException, IOException {
File source = disposableWorkspaceFor("xoo-sample-with-then-without-scm");
- unzip(new File(source, "scm-repository.zip"), source.getAbsolutePath());
+ unzip(new File(source, "scm-repository.zip"), source);
// First run
SonarScanner scanner = SonarScanner.create(source)
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2018 SonarSource SA
- * mailto:info 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 org.sonarqube.tests.source;
-
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipInputStream;
-
-public class ZipUtils {
-
- // I see that we have apache commons compress in the path so it should be possible to reduce the boiler plate
- // -- but nothing out of the box : still have to walk the tree and uncompress file by file.
-
- static void unzip(File archive, String directory) throws IOException {
- try (ZipInputStream zis = new ZipInputStream(new FileInputStream(archive))) {
-
- ZipEntry entry = zis.getNextEntry();
- while (entry != null) {
-
- File file = new File(directory, entry.getName());
-
- if (entry.isDirectory()) {
- file.mkdirs();
- } else {
-
- File parent = file.getParentFile();
- if (!parent.exists()) {
- parent.mkdirs();
- }
-
- try (BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file))) {
- long size = entry.getSize();
- byte[] buffer = new byte[Math.toIntExact(size)];
- if (size > 0) {
- int location;
- while ((location = zis.read(buffer)) != -1) {
- bos.write(buffer, 0, location);
- }
- }
- }
-
- }
-
- entry = zis.getNextEntry();
- }
- }
- }
-
-}