From 1b77fb78678e2ff330035efd46e7f47d34950fc9 Mon Sep 17 00:00:00 2001 From: "Anton.Makeev" Date: Thu, 1 Oct 2009 14:48:47 +0400 Subject: [PATCH] Maven: tests fixed --- .../jetbrains/idea/maven/ArchetypesTest.java | 2 +- .../maven/DependenciesManagementTest.java | 2 +- .../jetbrains/idea/maven/MavenTestCase.java | 4 ++-- .../SnapshotDependenciesImportingTest.java | 8 +++---- .../idea/maven/StructureImportingTest.java | 2 +- .../maven/execution/MavenExecutorsTest.java | 2 +- .../idea/maven/execution/MavenRunnerTest.java | 2 +- .../maven/wizards/MavenModuleBuilderTest.java | 22 +++++++++---------- 8 files changed, 22 insertions(+), 22 deletions(-) diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/ArchetypesTest.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/ArchetypesTest.java index 2d99aac510ef..5ca80473d922 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/ArchetypesTest.java +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/ArchetypesTest.java @@ -14,7 +14,7 @@ import java.util.Map; public class ArchetypesTest extends MavenTestCase { public void testGenerating() throws Exception { - if (!hasM2Home()) return; + if (!hasMavenInstallation()) return; File dir = new File(myDir.getPath(), "generated"); dir.mkdirs(); diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/DependenciesManagementTest.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/DependenciesManagementTest.java index b53a22e7e826..cce6502977dd 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/DependenciesManagementTest.java +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/DependenciesManagementTest.java @@ -7,7 +7,7 @@ import java.util.Arrays; public class DependenciesManagementTest extends MavenImportingTestCase { public void testImportingDependencies() throws Exception { - if (!hasM2Home()) return; + if (!hasMavenInstallation()) return; setRepositoryPath(new File(myDir, "/repo").getPath()); updateSettingsXml("" + getRepositoryPath() + ""); diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/MavenTestCase.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/MavenTestCase.java index 9a7f9c8f00fd..68633572b0e2 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/MavenTestCase.java +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/MavenTestCase.java @@ -391,8 +391,8 @@ public abstract class MavenTestCase extends UsefulTestCase { return true; } - protected boolean hasM2Home() { - boolean result = System.getenv("M2_HOME") != null; + protected boolean hasMavenInstallation() { + boolean result = "true".equals(System.getProperty("idea.maven.test.has.installation")); if (!result) System.out.println("Ignored, because Maven installation not found: " + getClass().getSimpleName() + "." + getName()); return result; } diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/SnapshotDependenciesImportingTest.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/SnapshotDependenciesImportingTest.java index 616cae4e9bf7..e795885a6f17 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/SnapshotDependenciesImportingTest.java +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/SnapshotDependenciesImportingTest.java @@ -33,7 +33,7 @@ public class SnapshotDependenciesImportingTest extends MavenImportingTestCase { } private void performTestWithDependencyVersion(String version) throws Exception { - if (!hasM2Home()) return; + if (!hasMavenInstallation()) return; createProjectPom("test" + "project" + @@ -81,7 +81,7 @@ public class SnapshotDependenciesImportingTest extends MavenImportingTestCase { } public void testNamingLibraryTheSameWayRegardlessAvailableSnapshotVersion() throws Exception { - if (!hasM2Home()) return; + if (!hasMavenInstallation()) return; deployArtifact("test", "foo", "1-SNAPSHOT"); @@ -107,7 +107,7 @@ public class SnapshotDependenciesImportingTest extends MavenImportingTestCase { } public void testAttachingCorrectJavaDocsAndSources() throws Exception { - if (!hasM2Home()) return; + if (!hasMavenInstallation()) return; deployArtifact("test", "foo", "1-SNAPSHOT", "" + @@ -167,7 +167,7 @@ public class SnapshotDependenciesImportingTest extends MavenImportingTestCase { } public void testCorrectlryUpdateRootEntriesWithActualPathForSnapshotDependencies() throws Exception { - if (!hasM2Home()) return; + if (!hasMavenInstallation()) return; deployArtifact("test", "foo", "1-SNAPSHOT", "" + diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/StructureImportingTest.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/StructureImportingTest.java index e8b62b882d41..eac67f408e2b 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/StructureImportingTest.java +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/StructureImportingTest.java @@ -323,7 +323,7 @@ public class StructureImportingTest extends MavenImportingTestCase { } public void testParentInLocalRepository() throws Exception { - if (!hasM2Home()) return; + if (!hasMavenInstallation()) return; VirtualFile parent = createModulePom("parent", "test" + diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/execution/MavenExecutorsTest.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/execution/MavenExecutorsTest.java index a5834636f223..5af90a541e0a 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/execution/MavenExecutorsTest.java +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/execution/MavenExecutorsTest.java @@ -9,7 +9,7 @@ import java.util.Arrays; public class MavenExecutorsTest extends MavenTestCase { public void testExternalExecutor() throws Exception { - if (!hasM2Home()) return; + if (!hasMavenInstallation()) return; VfsUtil.saveText(createProjectSubFile("src/main/java/A.java"), "public class A {}"); diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/execution/MavenRunnerTest.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/execution/MavenRunnerTest.java index 1420dc0ea8ee..c3f1ed3f70bd 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/execution/MavenRunnerTest.java +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/execution/MavenRunnerTest.java @@ -6,7 +6,7 @@ import java.util.Arrays; public class MavenRunnerTest extends MavenImportingTestCase { public void testUpdatingExcludedFoldersAfterRun() throws Exception { - if (!hasM2Home()) return; + if (!hasMavenInstallation()) return; createStdProjectFolders(); diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/wizards/MavenModuleBuilderTest.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/wizards/MavenModuleBuilderTest.java index d5947bdab38b..a5ceba900604 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/wizards/MavenModuleBuilderTest.java +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/wizards/MavenModuleBuilderTest.java @@ -27,7 +27,7 @@ public class MavenModuleBuilderTest extends MavenImportingTestCase { } public void testCreatingBlank() throws Exception { - if (!hasM2Home()) return; + if (!hasMavenInstallation()) return; MavenId id = new MavenId("org.foo", "module", "1.0"); createNewModule(id); @@ -50,7 +50,7 @@ public class MavenModuleBuilderTest extends MavenImportingTestCase { } public void testInheritJdkFromProject() throws Exception { - if (!hasM2Home()) return; + if (!hasMavenInstallation()) return; createNewModule(new MavenId("org.foo", "module", "1.0")); ModuleRootManager manager = ModuleRootManager.getInstance(getModule("module")); @@ -58,7 +58,7 @@ public class MavenModuleBuilderTest extends MavenImportingTestCase { } public void testCreatingFromArchetype() throws Exception { - if (!hasM2Home()) return; + if (!hasMavenInstallation()) return; setArchetype(new ArchetypeInfo("org.apache.maven.archetypes", "maven-archetype-quickstart", "1.0", null, null)); MavenId id = new MavenId("org.foo", "module", "1.0"); @@ -78,7 +78,7 @@ public class MavenModuleBuilderTest extends MavenImportingTestCase { } public void testAddingNewlyCreatedModuleToTheAggregator() throws Exception { - if (!hasM2Home()) return; + if (!hasMavenInstallation()) return; importProject("test" + "project" + @@ -99,7 +99,7 @@ public class MavenModuleBuilderTest extends MavenImportingTestCase { } public void testAddingManagedProjectIfNoArrgerator() throws Exception { - if (!hasM2Home()) return; + if (!hasMavenInstallation()) return; importProject("test" + "project" + @@ -116,7 +116,7 @@ public class MavenModuleBuilderTest extends MavenImportingTestCase { } public void testDoNotAddManagedProjectIfAddingAsModuleToAggregator() throws Exception { - if (!hasM2Home()) return; + if (!hasMavenInstallation()) return; importProject("test" + "project" + @@ -133,7 +133,7 @@ public class MavenModuleBuilderTest extends MavenImportingTestCase { } public void testAddingParent() throws Exception { - if (!hasM2Home()) return; + if (!hasMavenInstallation()) return; importProject("test" + "project" + @@ -164,7 +164,7 @@ public class MavenModuleBuilderTest extends MavenImportingTestCase { } public void testAddingParentWithInheritedProperties() throws Exception { - if (!hasM2Home()) return; + if (!hasMavenInstallation()) return; importProject("test" + "project" + @@ -194,7 +194,7 @@ public class MavenModuleBuilderTest extends MavenImportingTestCase { } public void testAddingParentAndInheritWhenGeneratingFromArchetype() throws Exception { - if (!hasM2Home()) return; + if (!hasMavenInstallation()) return; importProject("test" + "project" + @@ -231,7 +231,7 @@ public class MavenModuleBuilderTest extends MavenImportingTestCase { } public void testAddingParentWithRelativePath() throws Exception { - if (!hasM2Home()) return; + if (!hasMavenInstallation()) return; importProject("test" + "project" + @@ -263,7 +263,7 @@ public class MavenModuleBuilderTest extends MavenImportingTestCase { } public void testFindingPotentialParentInNotMavenizedProject() throws Exception { - if (!hasM2Home()) return; + if (!hasMavenInstallation()) return; Module module = createModule("project"); VirtualFile dir = module.getModuleFile().getParent();