Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.m2e.core.tests/resources/projects/emptyPom/pom.xml1
-rw-r--r--org.eclipse.m2e.core.tests/resources/projects/simplePomOK/pom.xml6
-rw-r--r--org.eclipse.m2e.core.tests/src/org/eclipse/m2e/core/tests/AllTests.java23
-rw-r--r--org.eclipse.m2e.core.tests/src/org/eclipse/m2e/core/tests/MavenBugsTest.java12
-rw-r--r--org.eclipse.m2e.core.tests/src/org/eclipse/m2e/core/tests/RegistryTest.java46
-rw-r--r--org.eclipse.m2e.tests.common/src/org/eclipse/m2e/tests/common/AbstractMavenProjectTestCase.java22
6 files changed, 96 insertions, 14 deletions
diff --git a/org.eclipse.m2e.core.tests/resources/projects/emptyPom/pom.xml b/org.eclipse.m2e.core.tests/resources/projects/emptyPom/pom.xml
new file mode 100644
index 00000000..0013f207
--- /dev/null
+++ b/org.eclipse.m2e.core.tests/resources/projects/emptyPom/pom.xml
@@ -0,0 +1 @@
+<project/> \ No newline at end of file
diff --git a/org.eclipse.m2e.core.tests/resources/projects/simplePomOK/pom.xml b/org.eclipse.m2e.core.tests/resources/projects/simplePomOK/pom.xml
new file mode 100644
index 00000000..bee4952a
--- /dev/null
+++ b/org.eclipse.m2e.core.tests/resources/projects/simplePomOK/pom.xml
@@ -0,0 +1,6 @@
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.eclipse.m2e.tests.projects</groupId>
+ <artifactId>simplePomOK</artifactId>
+ <version>1</version>
+</project> \ No newline at end of file
diff --git a/org.eclipse.m2e.core.tests/src/org/eclipse/m2e/core/tests/AllTests.java b/org.eclipse.m2e.core.tests/src/org/eclipse/m2e/core/tests/AllTests.java
new file mode 100644
index 00000000..3c1a3c87
--- /dev/null
+++ b/org.eclipse.m2e.core.tests/src/org/eclipse/m2e/core/tests/AllTests.java
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2019 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * - Mickael Istria (Red Hat Inc.) - Initial implementation
+ *******************************************************************************/
+
+package org.eclipse.m2e.core.tests;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
+
+
+@RunWith(Suite.class)
+@SuiteClasses({MavenBugsTest.class, RegistryTest.class})
+public class AllTests {
+
+}
diff --git a/org.eclipse.m2e.core.tests/src/org/eclipse/m2e/core/tests/MavenBugsTest.java b/org.eclipse.m2e.core.tests/src/org/eclipse/m2e/core/tests/MavenBugsTest.java
index af121f17..41598fcd 100644
--- a/org.eclipse.m2e.core.tests/src/org/eclipse/m2e/core/tests/MavenBugsTest.java
+++ b/org.eclipse.m2e.core.tests/src/org/eclipse/m2e/core/tests/MavenBugsTest.java
@@ -8,8 +8,6 @@
package org.eclipse.m2e.core.tests;
-import static org.junit.Assert.assertEquals;
-
import java.io.ByteArrayInputStream;
import java.io.File;
import java.nio.file.Files;
@@ -31,10 +29,10 @@ import org.eclipse.m2e.core.MavenPlugin;
import org.eclipse.m2e.core.project.IMavenProjectFacade;
import org.eclipse.m2e.core.project.MavenProjectInfo;
import org.eclipse.m2e.core.project.ProjectImportConfiguration;
-import org.eclipse.m2e.tests.common.JobHelpers;
+import org.eclipse.m2e.tests.common.AbstractMavenProjectTestCase;
-public class MavenBugsTest {
+public class MavenBugsTest extends AbstractMavenProjectTestCase {
@Test
public void testMNG6530() throws Exception {
@@ -48,7 +46,6 @@ public class MavenBugsTest {
toImport.add(new MavenProjectInfo("", new File(tempDirectory, "child/pom.xml"), null, null));
MavenPlugin.getProjectConfigurationManager().importProjects(toImport, new ProjectImportConfiguration(), null,
new NullProgressMonitor());
- JobHelpers.waitForJobsToComplete();
IProject parent = ResourcesPlugin.getWorkspace().getRoot().getProject("testMNG6530");
IProject child = ResourcesPlugin.getWorkspace().getRoot().getProject("child");
@@ -58,8 +55,9 @@ public class MavenBugsTest {
assertEquals("bar", mavenProject.getProperties().get("foo"));
String content = IOUtil.toString(parent.getFile("pom.xml").getContents()).replaceAll("bar", "lol");
parent.getFile("pom.xml").setContents(new ByteArrayInputStream(content.getBytes()), true, false, null);
- JobHelpers.waitForJobsToComplete(); // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=542461
- mavenProject = facade.getMavenProject(new NullProgressMonitor());
+ MavenPlugin.getProjectConfigurationManager().updateProjectConfiguration(child, monitor);
+ waitForJobsToComplete();
+ mavenProject = facade.getMavenProject(monitor);
assertEquals("lol", mavenProject.getProperties().get("foo"));
} finally {
parent.delete(true, null);
diff --git a/org.eclipse.m2e.core.tests/src/org/eclipse/m2e/core/tests/RegistryTest.java b/org.eclipse.m2e.core.tests/src/org/eclipse/m2e/core/tests/RegistryTest.java
new file mode 100644
index 00000000..80b77d4e
--- /dev/null
+++ b/org.eclipse.m2e.core.tests/src/org/eclipse/m2e/core/tests/RegistryTest.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2019 Red Hat Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * - Mickael Istria (Red Hat, Inc.) - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.m2e.core.tests;
+
+import java.io.IOException;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+
+import org.eclipse.m2e.core.internal.MavenPluginActivator;
+import org.eclipse.m2e.core.project.IMavenProjectFacade;
+import org.eclipse.m2e.tests.common.AbstractMavenProjectTestCase;
+
+
+public class RegistryTest extends AbstractMavenProjectTestCase {
+
+ @Test
+ public void testDeletedFacadeIsRemoved() throws IOException, CoreException, InterruptedException {
+ IProject project = createExisting(getClass().getSimpleName(), "resources/projects/simplePomOK", true);
+ waitForJobsToComplete(monitor);
+ IMavenProjectFacade facade = MavenPluginActivator.getDefault().getMavenProjectManagerImpl().create(project,
+ monitor);
+ Assert.assertNotNull(facade);
+ project.delete(true, monitor);
+ waitForJobsToComplete(new NullProgressMonitor());
+ Assert.assertTrue(facade.isStale());
+ project = createExisting(getClass().getSimpleName(), "resources/projects/emptyPom", true);
+ waitForJobsToComplete(monitor);
+ facade = MavenPluginActivator.getDefault().getMavenProjectManagerImpl().create(project, monitor);
+ Assert.assertNull(facade);
+ }
+
+}
diff --git a/org.eclipse.m2e.tests.common/src/org/eclipse/m2e/tests/common/AbstractMavenProjectTestCase.java b/org.eclipse.m2e.tests.common/src/org/eclipse/m2e/tests/common/AbstractMavenProjectTestCase.java
index 5d8dc703..31f9cdbe 100644
--- a/org.eclipse.m2e.tests.common/src/org/eclipse/m2e/tests/common/AbstractMavenProjectTestCase.java
+++ b/org.eclipse.m2e.tests.common/src/org/eclipse/m2e/tests/common/AbstractMavenProjectTestCase.java
@@ -282,6 +282,11 @@ public abstract class AbstractMavenProjectTestCase extends TestCase {
}
protected IProject createExisting(String projectName, String projectLocation) throws IOException, CoreException {
+ return createExisting(projectName, projectLocation, false);
+ }
+
+ protected IProject createExisting(String projectName, String projectLocation, boolean addNature)
+ throws IOException, CoreException {
File dir = new File(workspace.getRoot().getLocation().toFile(), projectName);
copyDir(new File(projectLocation), dir);
@@ -291,6 +296,9 @@ public abstract class AbstractMavenProjectTestCase extends TestCase {
public void run(IProgressMonitor monitor) throws CoreException {
if(!project.exists()) {
IProjectDescription projectDescription = workspace.newProjectDescription(project.getName());
+ if(addNature) {
+ projectDescription.setNatureIds(new String[] {IMavenConstants.NATURE_ID});
+ }
projectDescription.setLocation(null);
project.create(projectDescription, monitor);
project.open(IResource.NONE, monitor);
@@ -321,7 +329,7 @@ public abstract class AbstractMavenProjectTestCase extends TestCase {
/**
* Import a test project into the Eclipse workspace
*
- * @param pomLocation - a relative location of the pom file for the project to import
+ * @param pomLocation - a relative location of the pom file for the project to import
* @param configuration - a resolver configuration to be used to configure imported project
* @return created project
*/
@@ -333,9 +341,9 @@ public abstract class AbstractMavenProjectTestCase extends TestCase {
/**
* Import a test project into the Eclipse workspace
*
- * @param pomLocation - a relative location of the pom file for the project to import
+ * @param pomLocation - a relative location of the pom file for the project to import
* @param configuration - a resolver configuration to be used to configure imported project
- * @param listener - listener which will get notified of the raw project creation
+ * @param listener - listener which will get notified of the raw project creation
* @return created project
*/
protected IProject importProject(String pomLocation, ResolverConfiguration configuration,
@@ -348,8 +356,8 @@ public abstract class AbstractMavenProjectTestCase extends TestCase {
/**
* Import test projects into the Eclipse workspace
*
- * @param basedir - a base directory for all projects to import
- * @param pomNames - a relative locations of the pom files for the projects to import
+ * @param basedir - a base directory for all projects to import
+ * @param pomNames - a relative locations of the pom files for the projects to import
* @param configuration - a resolver configuration to be used to configure imported projects
* @return created projects
*/
@@ -361,8 +369,8 @@ public abstract class AbstractMavenProjectTestCase extends TestCase {
/**
* Import test projects into the Eclipse workspace
*
- * @param basedir - a base directory for all projects to import
- * @param pomNames - a relative locations of the pom files for the projects to import
+ * @param basedir - a base directory for all projects to import
+ * @param pomNames - a relative locations of the pom files for the projects to import
* @param configuration - a resolver configuration to be used to configure imported projects
* @return created projects
*/

Back to the top