This commit is contained in:
Vladimir Krivosheev
2015-08-12 11:20:04 +02:00
parent 8f3e06d9cc
commit 5a133ce97f
4 changed files with 28 additions and 32 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,17 +21,14 @@
package org.jetbrains.idea.eclipse;
import com.intellij.openapi.application.PluginPathManager;
import com.intellij.openapi.command.WriteCommandAction;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.testFramework.IdeaTestCase;
import com.intellij.testFramework.PsiTestUtil;
import junit.framework.Assert;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.io.IOException;
@@ -46,14 +43,15 @@ public abstract class Eclipse2ModulesTest extends IdeaTestCase {
@Override
protected void setUpModule() {
super.setUpModule();
final File testRoot = new File(PluginPathManager.getPluginHomePath("eclipse") + "/testData", getTestPath());
File testRoot = new File(PluginPathManager.getPluginHomePath("eclipse") + "/testData", getTestPath());
assertTrue(testRoot.getAbsolutePath(), testRoot.isDirectory());
final File currentTestRoot = new File(testRoot, getTestName(true));
File currentTestRoot = new File(testRoot, getTestName(true));
assertTrue(currentTestRoot.getAbsolutePath(), currentTestRoot.isDirectory());
try {
final VirtualFile baseDir = getProject().getBaseDir();
VirtualFile baseDir = getProject().getBaseDir();
assert baseDir != null;
FileUtil.copyDir(currentTestRoot, new File(baseDir.getPath()));
}
@@ -63,28 +61,19 @@ public abstract class Eclipse2ModulesTest extends IdeaTestCase {
}
@Override
protected Module createMainModule() throws IOException {
protected Module createMainModule() {
return createModule(DEPEND_MODULE_NAME);
}
protected void doTest(final String workspaceRoot, final String projectRoot) throws Exception {
final VirtualFile file =
WriteCommandAction.runWriteCommandAction(null, new Computable<VirtualFile>() {
@Override
@Nullable
public VirtualFile compute() {
final VirtualFile baseDir = getProject().getBaseDir();
assert baseDir != null;
return LocalFileSystem.getInstance()
.refreshAndFindFileByPath(baseDir.getPath() + "/" + workspaceRoot + "/" + myDependantModulePath);
}
});
if (file != null) {
PsiTestUtil.addContentRoot(getModule(), file);
}
else {
Assert.assertTrue("File not found", false);
protected void doTest(@NotNull String workspaceRoot, @NotNull String projectRoot) throws Exception {
VirtualFile baseDir = getProject().getBaseDir();
assert baseDir != null;
VirtualFile file = LocalFileSystem.getInstance().refreshAndFindFileByPath(baseDir.getPath() + "/" + workspaceRoot + "/" + myDependantModulePath);
if (file == null) {
throw new AssertionError("File not found");
}
PsiTestUtil.addContentRoot(getModule(), file);
}
public void setDependantModulePath(String dependantModulePath) {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2010 JetBrains s.r.o.
* Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,6 +20,8 @@
*/
package org.jetbrains.idea.eclipse;
import org.jetbrains.annotations.NotNull;
public class EclipseClasspath2ModulesTest extends Eclipse2ModulesTest {
@Override
protected String getTestPath() {
@@ -43,8 +45,9 @@ public class EclipseClasspath2ModulesTest extends Eclipse2ModulesTest {
}
@Override
protected void doTest(final String workspaceRoot, final String projectRoot) throws Exception {
protected void doTest(@NotNull final String workspaceRoot, @NotNull final String projectRoot) throws Exception {
super.doTest(workspaceRoot, projectRoot);
EclipseClasspathTest.doTest("/" + workspaceRoot + "/" + projectRoot, getProject());
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2010 JetBrains s.r.o.
* Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,6 +20,8 @@
*/
package org.jetbrains.idea.eclipse;
import org.jetbrains.annotations.NotNull;
public class EclipseEml2ModulesTest extends Eclipse2ModulesTest{
@Override
protected String getTestPath() {
@@ -27,7 +29,7 @@ public class EclipseEml2ModulesTest extends Eclipse2ModulesTest{
}
@Override
protected void doTest(String workspaceRoot, String projectRoot) throws Exception {
protected void doTest(@NotNull String workspaceRoot, @NotNull String projectRoot) throws Exception {
super.doTest(workspaceRoot, projectRoot);
EclipseEmlTest.doTest("/" + workspaceRoot + "/" + projectRoot, getProject());
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2010 JetBrains s.r.o.
* Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,6 +20,8 @@
*/
package org.jetbrains.idea.eclipse;
import org.jetbrains.annotations.NotNull;
public class EclipseIml2ModulesTest extends Eclipse2ModulesTest {
@Override
@@ -36,7 +38,7 @@ public class EclipseIml2ModulesTest extends Eclipse2ModulesTest {
}
@Override
protected void doTest(final String workspaceRoot, final String projectRoot) throws Exception {
protected void doTest(@NotNull final String workspaceRoot, @NotNull final String projectRoot) throws Exception {
super.doTest(workspaceRoot, projectRoot);
EclipseImlTest.doTest("/" + workspaceRoot + "/" + projectRoot, getProject());
}