public void testWorkspaceResolutionOfInterModuleDependenciesDuringImport() throws Exception { String oldSettings = mavenConfiguration.getUserSettingsFile(); try { injectFilexWagon(); FilexWagon.setRequestFilterPattern("test/.*", true); IJobChangeListener jobChangeListener = new JobChangeAdapter() { public void scheduled(IJobChangeEvent event) { if (event.getJob() instanceof ProjectRegistryRefreshJob) { // cancel all those concurrent refresh jobs, we want to monitor the main thread only event.getJob().cancel(); } } }; Job.getJobManager().addJobChangeListener(jobChangeListener); mavenConfiguration.setUserSettingsFile( new File("projects/MNGECLIPSE-1990/settings.xml").getAbsolutePath()); List<String> requests; try { importProjects( "projects/MNGECLIPSE-1990", new String[] {"pom.xml", "dependent/pom.xml", "dependency/pom.xml", "parent/pom.xml"}, new ResolverConfiguration()); requests = FilexWagon.getRequests(); } finally { Job.getJobManager().removeJobChangeListener(jobChangeListener); } assertTrue( "Dependency resolution was attempted from remote repository: " + requests, requests.isEmpty()); } finally { mavenConfiguration.setUserSettingsFile(oldSettings); } }
public void testRepositoryMetadataCacheUsed() throws Exception { String oldSettings = mavenConfiguration.getUserSettingsFile(); try { injectFilexWagon(); IJobChangeListener jobChangeListener = new JobChangeAdapter() { public void scheduled(IJobChangeEvent event) { if (event.getJob() instanceof ProjectRegistryRefreshJob) { // cancel all those concurrent refresh jobs, we want to monitor the main thread only event.getJob().cancel(); System.out.println(getName() + ": ProjectRegistryRefreshJob was cancelled"); } } }; Job.getJobManager().addJobChangeListener(jobChangeListener); mavenConfiguration.setUserSettingsFile( new File("projects/MNGECLIPSE-1996/settings.xml").getAbsolutePath()); waitForJobsToComplete(); FilexWagon.setRequestFilterPattern("mngeclipse1996/.*xml", true); List<String> requests; try { importProjects( "projects/MNGECLIPSE-1996", new String[] { "pom.xml", "mod-a/pom.xml", "mod-b/pom.xml", "mod-c/pom.xml", "mod-d/pom.xml", "mod-e/pom.xml" }, new ResolverConfiguration()); requests = FilexWagon.getRequests(); } finally { Job.getJobManager().removeJobChangeListener(jobChangeListener); } // up to 2 requests (for POM and JAR) are allowed, more would indicate an issue with the cache assertTrue( "Accessed metadata " + requests.size() + " times: " + requests, requests.size() == 1 || requests.size() == 2 || requests.size() == 3); } finally { mavenConfiguration.setUserSettingsFile(oldSettings); } }