Maven: community tests fixes

This commit is contained in:
Anton Makeev
2010-06-04 17:41:35 +04:00
parent 4222e87c18
commit 295d6a601f
6 changed files with 117 additions and 12 deletions
+1
View File
@@ -30,6 +30,7 @@
<orderEntry type="module" module-name="idea-tests" scope="TEST" />
<orderEntry type="module" module-name="testFramework-java" exported="" scope="TEST" />
<orderEntry type="module" module-name="jetgroovy" scope="TEST" />
<orderEntry type="module" module-name="FlexSupport" scope="TEST" />
</component>
<component name="copyright">
<Base>
@@ -15,6 +15,7 @@
*/
package org.jetbrains.idea.maven;
import com.intellij.openapi.application.ApplicationInfo;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.Result;
import com.intellij.openapi.application.WriteAction;
@@ -36,6 +37,7 @@ import com.intellij.testFramework.fixtures.IdeaTestFixtureFactory;
import org.jetbrains.idea.maven.project.*;
import org.jetbrains.idea.maven.utils.MavenProgressIndicator;
import java.awt.*;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Field;
@@ -157,15 +159,28 @@ public abstract class MavenTestCase extends UsefulTestCase {
@Override
protected void runTest() throws Throwable {
if (runInWriteAction()) {
new WriteAction() {
protected void run(Result result) throws Throwable {
MavenTestCase.super.runTest();
}
}.executeSilently().throwException();
try {
if (runInWriteAction()) {
new WriteAction() {
protected void run(Result result) throws Throwable {
MavenTestCase.super.runTest();
}
}.executeSilently().throwException();
}
else {
MavenTestCase.super.runTest();
}
}
else {
MavenTestCase.super.runTest();
catch (Exception throwable) {
Throwable each = throwable;
do {
if (each instanceof HeadlessException) {
printIgnoredMessage("Doesn't work in Headless environment");
return;
}
}
while ((each = each.getCause()) != null);
throw throwable;
}
}
@@ -450,16 +465,31 @@ public abstract class MavenTestCase extends UsefulTestCase {
}
protected boolean ignore() {
System.out.println("Ignored: " + getClass().getSimpleName() + "." + getName());
printIgnoredMessage(null);
return true;
}
public boolean checkUltimate() {
if ("IU".equals(ApplicationInfo.getInstance().getBuild().getProductCode())) return true;
printIgnoredMessage("Ultimate edition is required");
return false;
}
protected boolean hasMavenInstallation() {
boolean result = getTestMavenHome() != null;
if (!result) System.out.println("Ignored, because Maven installation not found: " + getClass().getSimpleName() + "." + getName());
if (!result) printIgnoredMessage("Maven installation not found");
return result;
}
private void printIgnoredMessage(String message) {
String toPrint = "Ignored";
if (message != null) {
toPrint += ", beacuse " + message;
}
toPrint += ": " + getClass().getSimpleName() + "." + getName();
System.out.println(toPrint);
}
private String getTestMavenHome() {
return System.getProperty("idea.maven.test.home");
}
@@ -52,6 +52,7 @@ import com.intellij.usages.UsageTargetUtil;
import com.intellij.util.Function;
import com.intellij.util.containers.ContainerUtil;
import gnu.trove.THashMap;
import junit.framework.AssertionFailedError;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.idea.maven.MavenImportingTestCase;
import org.jetbrains.idea.maven.dom.model.MavenDomProjectModel;
@@ -279,7 +280,7 @@ public abstract class MavenDomTestCase extends MavenImportingTestCase {
invokeRename(context, renameHandler);
}
protected void assertCannotRename() throws IOException {
protected void assertCannotRename() throws Exception {
MapDataContext context = createRenameDataContext(myProjectPom, "new name");
RenameHandler handler = RenameHandlerRegistry.getInstance().getRenameHandler(context);
if (handler == null) return;
@@ -287,7 +288,9 @@ public abstract class MavenDomTestCase extends MavenImportingTestCase {
invokeRename(context, handler);
}
catch (Exception e) {
assertTrue(e.getMessage(), e.getMessage().startsWith("Cannot perform refactoring."));
if (!e.getMessage().startsWith("Cannot perform refactoring.")) {
throw e;
}
}
}
@@ -21,6 +21,9 @@ import com.intellij.psi.PsiManager;
import org.jetbrains.idea.maven.dom.model.MavenDomProfilesModel;
import org.jetbrains.idea.maven.dom.references.MavenPropertyPsiReference;
import java.awt.*;
import java.io.IOException;
public class MavenFilteredPropertiesCompletionAndResolutionTest extends MavenDomTestCase {
public void testBasic() throws Exception {
createProjectSubDir("res");
@@ -146,6 +146,72 @@ public class ArtifactsDownloadingTest extends MavenImportingTestCase {
assertTrue(javadoc.exists());
}
public void testCustomDocsAndSources() throws Exception {
if (!checkUltimate()) return;
String remoteRepo = FileUtil.toSystemIndependentName(myDir.getPath() + "/repo");
updateSettingsXmlFully("<settings>" +
"<mirrors>" +
" <mirror>" +
" <id>Nexus</id>" +
" <url>" + VfsUtil.pathToUrl(remoteRepo) + "</url>" +
" <mirrorOf>*</mirrorOf>" +
" </mirror>" +
"</mirrors>" +
"</settings>");
FileUtil.writeToFile(new File(remoteRepo, "/xxx/yyy/1/yyy-1-sources.jar"), "111".getBytes());
FileUtil.writeToFile(new File(remoteRepo, "/xxx/yyy/1/yyy-1-sources.jar.sha1"),
"6216f8a75fd5bb3d5f22b6f9958cdede3fc086c2 xxx/yyy/1/yyy-1-sources.jar".getBytes());
FileUtil.writeToFile(new File(remoteRepo, "/xxx/yyy/1/yyy-1-asdoc.zip"), "111".getBytes());
FileUtil.writeToFile(new File(remoteRepo, "/xxx/yyy/1/yyy-1-asdoc.zip.sha1"),
"6216f8a75fd5bb3d5f22b6f9958cdede3fc086c2 xxx/yyy/1/yyy-1-asdoc.zip".getBytes());
FileUtil.writeToFile(new File(remoteRepo, "/xxx/yyy/1/yyy-1-javadoc.jar"), "111".getBytes());
FileUtil.writeToFile(new File(remoteRepo, "/xxx/yyy/1/yyy-1-javadoc.jar.sha1"),
"6216f8a75fd5bb3d5f22b6f9958cdede3fc086c2 xxx/yyy/1/yyy-1-javadoc.jar".getBytes());
importProject("<groupId>test</groupId>" +
"<artifactId>project</artifactId>" +
"<version>1</version>" +
"<packaging>swf</packaging>" +
"<dependencies>" +
" <dependency>" +
" <groupId>xxx</groupId>" +
" <artifactId>yyy</artifactId>" +
" <version>1</version>" +
" <type>swc</type>" +
" </dependency>" +
"</dependencies>" +
"<build>" +
" <plugins>" +
" <plugin>" +
" <groupId>org.sonatype.flexmojos</groupId>" +
" <artifactId>flexmojos-maven-plugin</artifactId>" +
" <version>3.5.0</version>" +
" <extensions>true</extensions>" +
" </plugin>" +
" </plugins>" +
"</build>");
File sources = new File(getRepositoryPath(), "/xxx/yyy/1/yyy-1-sources.jar");
File asdoc = new File(getRepositoryPath(), "/xxx/yyy/1/yyy-1-asdoc.zip");
File javadoc = new File(getRepositoryPath(), "/xxx/yyy/1/yyy-1-javadoc.jar");
assertFalse(sources.exists());
assertFalse(asdoc.exists());
assertFalse(javadoc.exists());
downloadArtifacts();
assertTrue(sources.exists());
assertTrue(asdoc.exists());
assertFalse(javadoc.exists());
}
public void testDownloadingPlugins() throws Exception {
importProject("<groupId>test</groupId>" +
"<artifactId>project</artifactId>" +
@@ -1500,6 +1500,8 @@ public class DependenciesImportingTest extends MavenImportingTestCase {
}
public void testCustomSourcesAndJavadocPaths() throws Exception {
if (!checkUltimate()) return;
importProject("<groupId>test</groupId>" +
"<artifactId>project</artifactId>" +
"<version>1</version>" +