Make conversion tests more resilient to plugin version changes

Change-Id: I27f155915e182435ae63f7db9edeb57584cb2127
Signed-off-by: Fred Bricon <fbricon@gmail.com>
diff --git a/org.eclipse.m2e.wtp.jsf/src/org/eclipse/m2e/wtp/jsf/internal/configurators/JSFProjectConfigurator.java b/org.eclipse.m2e.wtp.jsf/src/org/eclipse/m2e/wtp/jsf/internal/configurators/JSFProjectConfigurator.java
index 57f4652..f916c8a 100644
--- a/org.eclipse.m2e.wtp.jsf/src/org/eclipse/m2e/wtp/jsf/internal/configurators/JSFProjectConfigurator.java
+++ b/org.eclipse.m2e.wtp.jsf/src/org/eclipse/m2e/wtp/jsf/internal/configurators/JSFProjectConfigurator.java
@@ -91,7 +91,7 @@
 			
 			FacetDetectorManager facetDetectorManager = FacetDetectorManager.getInstance();
 			IProjectFacetVersion jsfVersion = facetDetectorManager.findFacetVersion(mavenProjectFacade, JSF_FACET.getId(), monitor);
-			if (fproj != null && jsfVersion != null) { 
+			if (jsfVersion != null) { 
 				installJSFFacet(fproj, mavenProject, jsfVersion, monitor);
 			}
 		}
diff --git a/org.eclipse.m2e.wtp/src/org/eclipse/m2e/wtp/internal/conversion/EarProjectConverter.java b/org.eclipse.m2e.wtp/src/org/eclipse/m2e/wtp/internal/conversion/EarProjectConverter.java
index 63f5017..aaa5750 100644
--- a/org.eclipse.m2e.wtp/src/org/eclipse/m2e/wtp/internal/conversion/EarProjectConverter.java
+++ b/org.eclipse.m2e.wtp/src/org/eclipse/m2e/wtp/internal/conversion/EarProjectConverter.java
@@ -63,7 +63,7 @@
 
   private void setEarPlugin(IVirtualComponent component, Model model) throws CoreException {
     Build build = getCloneOrCreateBuild(model);
-    String pluginVersion = MavenPluginUtils.getMostRecentPluginVersion("org.apache.maven.plugins", "maven-ear-plugin", "2.9"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+    String pluginVersion = getEarPluginVersion();
     Plugin earPlugin = setPlugin(build, "org.apache.maven.plugins", "maven-ear-plugin", pluginVersion); //$NON-NLS-1$ //$NON-NLS-2$
   
     // Set  <earSourceDirectory>EarContent</earSourceDirectory>
@@ -142,4 +142,12 @@
     return WTPProjectsUtil.EAR_FACET;
   }
 
+  private String getEarPluginVersion() {
+	 //For test purposes only, must not be considered API behavior.
+	 String version = System.getProperty("org.eclipse.m2e.wtp.conversion.earplugin.version");//$NON-NLS-1$
+	 if(version != null) {
+	   return version;
+	 }
+	 return MavenPluginUtils.getMostRecentPluginVersion("org.apache.maven.plugins", "maven-ear-plugin", "2.9.1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+  }
 }
diff --git a/org.eclipse.m2e.wtp/src/org/eclipse/m2e/wtp/internal/conversion/WebProjectConverter.java b/org.eclipse.m2e.wtp/src/org/eclipse/m2e/wtp/internal/conversion/WebProjectConverter.java
index 49b0881..d31f301 100644
--- a/org.eclipse.m2e.wtp/src/org/eclipse/m2e/wtp/internal/conversion/WebProjectConverter.java
+++ b/org.eclipse.m2e.wtp/src/org/eclipse/m2e/wtp/internal/conversion/WebProjectConverter.java
@@ -55,7 +55,7 @@
 
   private void setWarPlugin(IVirtualComponent component, Model model) throws CoreException {
     Build build = getCloneOrCreateBuild(model);
-    String warPluginVersion = MavenPluginUtils.getMostRecentPluginVersion("org.apache.maven.plugins", "maven-war-plugin", "2.5"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+    String warPluginVersion = getWarPluginVersion();
     Plugin warPlugin = setPlugin(build, "org.apache.maven.plugins", "maven-war-plugin", warPluginVersion); //$NON-NLS-1$ //$NON-NLS-2$
   
     // Set  <warSourceDirectory>WebContent</warSourceDirectory>
@@ -93,4 +93,15 @@
     return WebFacetUtils.WEB_FACET;
   }
 
+  private String getWarPluginVersion() {
+	 //For test purposes only, must not be considered API behavior.
+	 String version = System.getProperty("org.eclipse.m2e.wtp.conversion.warplugin.version");//$NON-NLS-1$
+	 if(version != null) {
+	   return version;
+	 }
+	 return MavenPluginUtils.getMostRecentPluginVersion("org.apache.maven.plugins", "maven-war-plugin", "2.5"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+  }
+
+  
+  
 }