Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMickael Istria2019-01-18 03:29:13 -0500
committerMickael Istria2019-01-18 03:29:53 -0500
commiteb4d0d5e0fbf8941e0af16fdcffe7693965b442b (patch)
treed781fd11f9544f560d87b4300a993028f62d0fdd
parent4ebbcc3164c96eb8e1b965bac0eefc2d8e7eab52 (diff)
downloadm2e-core-eb4d0d5e0fbf8941e0af16fdcffe7693965b442b.tar.gz
m2e-core-eb4d0d5e0fbf8941e0af16fdcffe7693965b442b.tar.xz
m2e-core-eb4d0d5e0fbf8941e0af16fdcffe7693965b442b.zip
Make Importer test more stable
Change-Id: I23ac0d8747d5d743bf7ad3a20b11e88a749c1eb0 Signed-off-by: Mickael Istria <mistria@redhat.com>
-rw-r--r--org.eclipse.m2e.importer.tests/src/org/eclipse/m2e/importer/tests/MavenImporterTest.java33
1 files changed, 10 insertions, 23 deletions
diff --git a/org.eclipse.m2e.importer.tests/src/org/eclipse/m2e/importer/tests/MavenImporterTest.java b/org.eclipse.m2e.importer.tests/src/org/eclipse/m2e/importer/tests/MavenImporterTest.java
index e268cfdd..e88e8426 100644
--- a/org.eclipse.m2e.importer.tests/src/org/eclipse/m2e/importer/tests/MavenImporterTest.java
+++ b/org.eclipse.m2e.importer.tests/src/org/eclipse/m2e/importer/tests/MavenImporterTest.java
@@ -28,7 +28,6 @@ import org.apache.commons.io.FileUtils;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.ui.internal.wizards.datatransfer.SmartImportJob;
import org.eclipse.ui.wizards.datatransfer.ProjectConfigurator;
@@ -36,8 +35,6 @@ import org.eclipse.m2e.core.MavenPlugin;
import org.eclipse.m2e.core.project.IMavenProjectFacade;
import org.eclipse.m2e.importer.internal.MavenProjectConfigurator;
import org.eclipse.m2e.tests.common.AbstractMavenProjectTestCase;
-import org.eclipse.m2e.tests.common.JobHelpers;
-import org.eclipse.m2e.tests.common.JobHelpers.IJobMatcher;
public class MavenImporterTest extends AbstractMavenProjectTestCase {
@@ -69,13 +66,13 @@ public class MavenImporterTest extends AbstractMavenProjectTestCase {
Map<File, List<ProjectConfigurator>> proposals = job.getImportProposals(monitor);
Assert.assertEquals("Expected 2 projects to import", 2, proposals.size()); //$NON-NLS-1$
- boolean thymConfiguratorFound = false;
+ boolean mavenConfiguratorFound = false;
for(ProjectConfigurator configurator : proposals.values().iterator().next()) {
if(configurator instanceof MavenProjectConfigurator) {
- thymConfiguratorFound = true;
+ mavenConfiguratorFound = true;
}
}
- Assert.assertTrue("Maven configurator not found while checking directory", thymConfiguratorFound); //$NON-NLS-1$
+ Assert.assertTrue("Maven configurator not found while checking directory", mavenConfiguratorFound); //$NON-NLS-1$
// accept proposals
job.setDirectoriesToImport(proposals.keySet());
@@ -87,16 +84,11 @@ public class MavenImporterTest extends AbstractMavenProjectTestCase {
newProjects = new HashSet<>(Arrays.asList(wsRoot.getProjects()));
newProjects.removeAll(beforeImport);
Assert.assertEquals("Expected only 2 new projects", 2, newProjects.size()); //$NON-NLS-1$
-
- JobHelpers.waitForJobs(new IJobMatcher() {
- public boolean matches(Job job) {
- return MavenProjectConfigurator.UPDATE_MAVEN_CONFIGURATION_JOB_NAME.equals(job.getName());
- }
- }, 30_000);
-
for(IProject project : newProjects) {
Assert.assertTrue(
project.getLocation().toFile().getCanonicalPath().startsWith(projectDirectory.getCanonicalPath()));
+ refreshMavenProject(project);
+ waitForJobsToComplete();
IMavenProjectFacade mavenProject = MavenPlugin.getMavenProjectRegistry().getProject(project);
Assert.assertNotNull("Project not configured as Maven", mavenProject); //$NON-NLS-1$
}
@@ -110,13 +102,13 @@ public class MavenImporterTest extends AbstractMavenProjectTestCase {
Map<File, List<ProjectConfigurator>> proposals = job.getImportProposals(monitor);
Assert.assertEquals("Expected 2 projects to import", 2, proposals.size()); //$NON-NLS-1$
- boolean thymConfiguratorFound = false;
+ boolean mavenConfiguratorFound = false;
for(ProjectConfigurator configurator : proposals.values().iterator().next()) {
if(configurator instanceof MavenProjectConfigurator) {
- thymConfiguratorFound = true;
+ mavenConfiguratorFound = true;
}
}
- Assert.assertTrue("Maven configurator not found while checking directory", thymConfiguratorFound); //$NON-NLS-1$
+ Assert.assertTrue("Maven configurator not found while checking directory", mavenConfiguratorFound); //$NON-NLS-1$
// accept proposals
job.setDirectoriesToImport(proposals.keySet());
@@ -128,16 +120,11 @@ public class MavenImporterTest extends AbstractMavenProjectTestCase {
newProjects = new HashSet<>(Arrays.asList(wsRoot.getProjects()));
newProjects.removeAll(beforeImport);
Assert.assertEquals("Expected only 2 new projects", 2, newProjects.size()); //$NON-NLS-1$
-
- JobHelpers.waitForJobs(new IJobMatcher() {
- public boolean matches(Job job) {
- return MavenProjectConfigurator.UPDATE_MAVEN_CONFIGURATION_JOB_NAME.equals(job.getName());
- }
- }, 30_000);
-
for(IProject project : newProjects) {
Assert.assertTrue(
project.getLocation().toFile().getCanonicalPath().startsWith(projectDirectory.getCanonicalPath()));
+ refreshMavenProject(project);
+ waitForJobsToComplete();
IMavenProjectFacade mavenProject = MavenPlugin.getMavenProjectRegistry().getProject(project);
Assert.assertNotNull("Project not configured as Maven", mavenProject); //$NON-NLS-1$
}

Back to the top