Skip to content

Commit

Permalink
artifact builder tests: duplicated method removed
Browse files Browse the repository at this point in the history
  • Loading branch information
chashnikov committed Jul 30, 2015
1 parent e86e125 commit 534894a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -416,8 +416,4 @@ public void testRepackNonExistentJarFile() {
buildAll();
assertOutput(a, fs().archive("a.jar").file("a.txt"));
}

private static void createFileInArtifactOutput(JpsArtifact a, final String fileName) throws IOException {
assertTrue(new File(a.getOutputPath(), fileName).createNewFile());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,15 @@
import org.jetbrains.jps.model.artifact.DirectoryArtifactType;
import org.jetbrains.jps.model.artifact.JpsArtifact;
import org.jetbrains.jps.model.artifact.JpsArtifactService;
import org.jetbrains.jps.model.java.JpsJavaExtensionService;
import org.jetbrains.jps.model.java.JpsJavaLibraryType;
import org.jetbrains.jps.model.library.JpsLibrary;
import org.jetbrains.jps.model.library.JpsOrderRootType;
import org.jetbrains.jps.model.module.JpsModule;
import org.jetbrains.jps.util.JpsPathUtil;

import java.io.File;
import java.io.IOException;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
Expand All @@ -42,6 +45,26 @@
* @author nik
*/
public abstract class ArtifactBuilderTestCase extends JpsBuildTestCase {
protected static void createFileInArtifactOutput(JpsArtifact a, final String relativePath) {
createFileInOutputDir(a.getOutputPath(), relativePath);
}

protected static void createFileInModuleOutput(JpsModule m, final String relativePath) {
File outputDirectory = JpsJavaExtensionService.getInstance().getOutputDirectory(m, false);
assertNotNull(outputDirectory);
createFileInOutputDir(outputDirectory.getAbsolutePath(), relativePath);
}

private static void createFileInOutputDir(final String outputPath, final String relativePath) {
try {
boolean created = new File(outputPath, relativePath).createNewFile();
assertTrue(created);
}
catch (IOException e) {
throw new RuntimeException(e);
}
}

@Override
protected void tearDown() throws Exception {
for (JpsArtifact artifact : JpsArtifactService.getInstance().getArtifacts(myProject)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@
import org.jetbrains.jps.model.module.JpsModule;
import org.jetbrains.jps.util.JpsPathUtil;

import java.io.File;
import java.io.IOException;

import static com.intellij.util.io.TestFileSystemBuilder.fs;
import static org.jetbrains.jps.incremental.artifacts.LayoutElementTestUtil.root;

Expand Down Expand Up @@ -95,24 +92,4 @@ public void testCleanModuleOutputIfItIsIncludedInArtifact() {
rebuildAll();
assertOutput(m, fs().file("A.class"));
}

private static void createFileInArtifactOutput(JpsArtifact a, final String name) {
createFileInOutputDir(a.getOutputPath(), name);
}

private static void createFileInModuleOutput(JpsModule m, final String name) {
File outputDirectory = JpsJavaExtensionService.getInstance().getOutputDirectory(m, false);
assertNotNull(outputDirectory);
createFileInOutputDir(outputDirectory.getAbsolutePath(), name);
}

private static void createFileInOutputDir(final String outputPath, final String fileName) {
try {
boolean created = new File(outputPath, fileName).createNewFile();
assertTrue(created);
}
catch (IOException e) {
throw new RuntimeException(e);
}
}
}

0 comments on commit 534894a

Please sign in to comment.