change framework detection
ranges not always suitable - e.g. can have v4.0 installed but not v3.5
git-svn-id: https://svn.apache.org/repos/asf/incubator/npanday/npanday-its/trunk@1609666 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/test/java/npanday/its/AbstractNPandayIntegrationTestCase.java b/src/test/java/npanday/its/AbstractNPandayIntegrationTestCase.java
index 076a0eb..7a208b1 100644
--- a/src/test/java/npanday/its/AbstractNPandayIntegrationTestCase.java
+++ b/src/test/java/npanday/its/AbstractNPandayIntegrationTestCase.java
@@ -27,6 +27,7 @@
import org.apache.maven.it.VerificationException;
import org.apache.maven.it.Verifier;
import org.apache.maven.it.util.FileUtils;
+import org.apache.maven.it.util.Os;
import org.apache.maven.it.util.ResourceExtractor;
import org.apache.maven.it.util.StringUtils;
import org.apache.maven.it.util.cli.CommandLineException;
@@ -41,6 +42,7 @@
import java.io.Writer;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.regex.Matcher;
@@ -50,24 +52,27 @@
public abstract class AbstractNPandayIntegrationTestCase
extends TestCase
{
+ protected static final String FRAMEWORK_V4_0 = "v4.0.30319";
+ protected static final String FRAMEWORK_V3_5 = "v3.5";
+ protected static final String FRAMEWORK_V2_0 = "v2.0.50727";
+ protected static final String FRAMEWORK_V1_1 = "v1.1";
+
protected boolean skip;
protected String skipReason;
- private static final String NPANDAY_MAX_FRAMEWORK_VERSION_PROPERTY = "npanday.framework.version";
-
private static final String NPANDAY_VERSION_SYSTEM_PROPERTY = "npanday.version";
protected static DefaultArtifactVersion version = checkVersion();
- private static DefaultArtifactVersion frameworkVersion = checkFrameworkVersion();
-
private static boolean debugMaven = Boolean.valueOf( System.getProperty( "debug.maven", "false" ) );
private static boolean debugOutput = Boolean.valueOf( System.getProperty( "npanday.log.debug", "false" ) );
private static boolean forceVersion = Boolean.valueOf( System.getProperty( "npanday.version.force", "false" ) );
+ private static final List<String> availableFrameworkVersions = findAvailableFrameworkVersions();
+
private static final Pattern PATTERN = Pattern.compile( "(.*?)-(RC[0-9]+|SNAPSHOT)" );
private static String disasmArg;
@@ -94,16 +99,14 @@
}
}
- protected AbstractNPandayIntegrationTestCase( String versionRangeStr, String frameworkVersionStr )
+ protected AbstractNPandayIntegrationTestCase( String versionRangeStr, String frameworkVersion )
{
this( versionRangeStr );
- VersionRange versionRange = createVersionRange(frameworkVersionStr);
-
- if ( frameworkVersion != null && !versionRange.containsVersion( frameworkVersion ) && !forceVersion )
+ if ( !availableFrameworkVersions.contains(frameworkVersion) && !forceVersion )
{
skip = true;
- skipReason = "Framework version " + frameworkVersion + " not in range " + versionRange;
+ skipReason = "Framework version " + frameworkVersion + " not available";
}
}
@@ -122,6 +125,31 @@
return getVerifier(context.getTestDir());
}
+ private static List<String> findAvailableFrameworkVersions() {
+ // TODO: might need to check if framework is sufficient - might need to check actual SDK for a given tools version
+
+ List<String> keys;
+ if (!Os.isFamily( Os.FAMILY_WINDOWS )) {
+ // on Mono, assume all present until we can do better at finding them
+ System.out.println("Assuming all frameworks are available");
+ return Arrays.asList(FRAMEWORK_V1_1, FRAMEWORK_V2_0, FRAMEWORK_V3_5, FRAMEWORK_V4_0);
+ }
+ else {
+ try {
+ keys = new ArrayList<String>();
+ for (String key : WinRegistry.readStringSubKeys(WinRegistry.RegistryHKey.HKLM.getHKey(), "SOFTWARE\\Microsoft\\.NETFramework")) {
+ if (key.matches("^v[0-9.]+$")) {
+ keys.add(key);
+ }
+ }
+ } catch (Exception e) {
+ throw new RuntimeException(e.getMessage(), e);
+ }
+ }
+ System.out.println("Available frameworks: " + keys);
+ return keys;
+ }
+
protected static boolean checkNPandayVersion( VersionRange versionRange, DefaultArtifactVersion version )
{
if (version == null) {
@@ -158,58 +186,6 @@
return version;
}
- private static DefaultArtifactVersion checkFrameworkVersion()
- {
- DefaultArtifactVersion version = null;
- String v = System.getProperty( NPANDAY_MAX_FRAMEWORK_VERSION_PROPERTY );
- if ( v != null )
- {
- version = new DefaultArtifactVersion( v );
- System.out.println( "Using Framework versions <= " + version );
- }
- else
- {
- // TODO: this is not necessarily accurate. While it gets all those available, the max should actually be
- // the one in the path (which can be obtained from the output for csc, but there may be other better
- // ways such as a small C# app to interrogate it.
- // It may be best to have an NPanday plugin that can reveal it then call that first to set it,
- // reusing the vendor info
-
- File versions = new File( System.getenv( "systemroot" ) + "\\Microsoft.NET\\Framework" );
- if ( versions.exists() )
- {
- List<DefaultArtifactVersion> frameworkVersions = new ArrayList<DefaultArtifactVersion>();
- String[] list = versions.list( new java.io.FilenameFilter()
- {
- public boolean accept( File parent, String name )
- {
- File f = new File( parent, name );
- // Mscorlib.dll can be used to detect 2.0 SDK, Microsoft.CompactFramework.Build.Tasks.dll for 3.5 SDK
- // Having just the runtime (without these files) is not sufficient
- return f.isDirectory() && ( new File( f, "Mscorlib.dll" ).exists() || new File( f,
- "Microsoft.CompactFramework.Build.Tasks.dll" ).exists() );
- }
- } );
- if ( list != null && list.length > 0 )
- {
- for ( String frameworkVersion : list )
- {
- frameworkVersions.add( new DefaultArtifactVersion( frameworkVersion ) );
- }
- Collections.sort( frameworkVersions );
- System.out.println( "Available framework versions: " + frameworkVersions );
- version = frameworkVersions.get( frameworkVersions.size() - 1 );
- System.out.println( "Selected framework version: " + version );
- }
- }
- if ( version == null )
- {
- System.out.println( "No Framework version given - attempting to use all" );
- }
- }
- return version;
- }
-
protected static VersionRange createVersionRange( String versionRangeStr )
{
VersionRange versionRange;
diff --git a/src/test/java/npanday/its/Azure17Bootstrap.java b/src/test/java/npanday/its/Azure17Bootstrap.java
index a88a88f..1fa0e43 100644
--- a/src/test/java/npanday/its/Azure17Bootstrap.java
+++ b/src/test/java/npanday/its/Azure17Bootstrap.java
@@ -26,7 +26,7 @@
{
public Azure17Bootstrap()
{
- super( "[1.5.0-incubating,)", "[v4.0.30319,)" );
+ super( "[1.5.0-incubating,)" );
skipIfMissingAzureSDK("1.7");
}
diff --git a/src/test/java/npanday/its/AzureBootstrap.java b/src/test/java/npanday/its/AzureBootstrap.java
index 29ea553..a22ce11 100644
--- a/src/test/java/npanday/its/AzureBootstrap.java
+++ b/src/test/java/npanday/its/AzureBootstrap.java
@@ -26,7 +26,7 @@
{
public AzureBootstrap()
{
- super( "[1.5.0-incubating,)", "[v4.0.30319,)" );
+ super( "[1.5.0-incubating,)" );
skipIfMissingAzureSDK("1.6");
}
diff --git a/src/test/java/npanday/its/NPANDAY_196_MvcSupportTest.java b/src/test/java/npanday/its/NPANDAY_196_MvcSupportTest.java
index bdba565..d7d85e1 100644
--- a/src/test/java/npanday/its/NPANDAY_196_MvcSupportTest.java
+++ b/src/test/java/npanday/its/NPANDAY_196_MvcSupportTest.java
@@ -26,9 +26,10 @@
public class NPANDAY_196_MvcSupportTest
extends AbstractNPandayIntegrationTestCase
{
+
public NPANDAY_196_MvcSupportTest()
{
- super( "[1.2,)", "[v3.5,)" );
+ super( "[1.2,)", FRAMEWORK_V3_5 );
skipIfMissingMVC2();
}
diff --git a/src/test/java/npanday/its/NPANDAY_243_WpfGeneratedResourcesHandlingTest.java b/src/test/java/npanday/its/NPANDAY_243_WpfGeneratedResourcesHandlingTest.java
index 50937b4..34720d2 100644
--- a/src/test/java/npanday/its/NPANDAY_243_WpfGeneratedResourcesHandlingTest.java
+++ b/src/test/java/npanday/its/NPANDAY_243_WpfGeneratedResourcesHandlingTest.java
@@ -28,7 +28,7 @@
{
public NPANDAY_243_WpfGeneratedResourcesHandlingTest()
{
- super( "[1.2,)", "[v3.5,)" ); // 1.2+
+ super( "[1.2,)", FRAMEWORK_V3_5 );
}
public void testWpfProject()
diff --git a/src/test/java/npanday/its/NPANDAY_254_WebAppWithCultureResTest.java b/src/test/java/npanday/its/NPANDAY_254_WebAppWithCultureResTest.java
index 04d90f6..3c1c00d 100644
--- a/src/test/java/npanday/its/NPANDAY_254_WebAppWithCultureResTest.java
+++ b/src/test/java/npanday/its/NPANDAY_254_WebAppWithCultureResTest.java
@@ -30,7 +30,7 @@
{
public NPANDAY_254_WebAppWithCultureResTest()
{
- super( "[1.5.0-incubating,)", "[v4.0.30319,)" );
+ super( "[1.5.0-incubating,)", FRAMEWORK_V4_0 );
skipIfMissingWebDeployV2();
skipIfXdtNotPresent();
diff --git a/src/test/java/npanday/its/NPANDAY_288_Net40SupportTest.java b/src/test/java/npanday/its/NPANDAY_288_Net40SupportTest.java
index 9fa1f96..2e5e224 100644
--- a/src/test/java/npanday/its/NPANDAY_288_Net40SupportTest.java
+++ b/src/test/java/npanday/its/NPANDAY_288_Net40SupportTest.java
@@ -28,7 +28,7 @@
{
public NPANDAY_288_Net40SupportTest()
{
- super( "[1.4.0-incubating,)", "[v4.0.30319,)" );
+ super( "[1.4.0-incubating,)", FRAMEWORK_V4_0 );
}
public void testNet40Project()
diff --git a/src/test/java/npanday/its/NPANDAY_328_VS2010WpfProjectSupportTest.java b/src/test/java/npanday/its/NPANDAY_328_VS2010WpfProjectSupportTest.java
index 0d369fe..9dca3a6 100644
--- a/src/test/java/npanday/its/NPANDAY_328_VS2010WpfProjectSupportTest.java
+++ b/src/test/java/npanday/its/NPANDAY_328_VS2010WpfProjectSupportTest.java
@@ -28,7 +28,7 @@
{
public NPANDAY_328_VS2010WpfProjectSupportTest()
{
- super( "[1.4.0-incubating,)", "[v4.0.30319,)" );
+ super( "[1.4.0-incubating,)", FRAMEWORK_V4_0 );
}
public void testWPF2010Project()
diff --git a/src/test/java/npanday/its/NPANDAY_329_VS2010WcfProjectSupportTest.java b/src/test/java/npanday/its/NPANDAY_329_VS2010WcfProjectSupportTest.java
index 29a527c..1adb16f 100644
--- a/src/test/java/npanday/its/NPANDAY_329_VS2010WcfProjectSupportTest.java
+++ b/src/test/java/npanday/its/NPANDAY_329_VS2010WcfProjectSupportTest.java
@@ -28,9 +28,10 @@
public class NPANDAY_329_VS2010WcfProjectSupportTest
extends AbstractNPandayIntegrationTestCase
{
+
public NPANDAY_329_VS2010WcfProjectSupportTest()
{
- super( "[1.4.0-incubating,)", "[v4.0.30319,)" );
+ super( "[1.4.0-incubating,)", FRAMEWORK_V4_0);
}
public void testWCF2010Project()
diff --git a/src/test/java/npanday/its/NPANDAY_330_VS2010MvcProjectSupportTest.java b/src/test/java/npanday/its/NPANDAY_330_VS2010MvcProjectSupportTest.java
index 9d426d9..cfb7b1e 100644
--- a/src/test/java/npanday/its/NPANDAY_330_VS2010MvcProjectSupportTest.java
+++ b/src/test/java/npanday/its/NPANDAY_330_VS2010MvcProjectSupportTest.java
@@ -28,7 +28,7 @@
{
public NPANDAY_330_VS2010MvcProjectSupportTest()
{
- super( "[1.4.0-incubating,)", "[v4.0.30319,)" );
+ super( "[1.4.0-incubating,)", FRAMEWORK_V4_0 );
skipIfMissingMVC2();
}
diff --git a/src/test/java/npanday/its/NPANDAY_465_AspxDisablePrecompilationTest.java b/src/test/java/npanday/its/NPANDAY_465_AspxDisablePrecompilationTest.java
index a990eac..cb43806 100644
--- a/src/test/java/npanday/its/NPANDAY_465_AspxDisablePrecompilationTest.java
+++ b/src/test/java/npanday/its/NPANDAY_465_AspxDisablePrecompilationTest.java
@@ -31,7 +31,7 @@
{
public NPANDAY_465_AspxDisablePrecompilationTest()
{
- super( "[1.4.1-incubating,)", "[v3.5,)" );
+ super( "[1.4.1-incubating,)", FRAMEWORK_V3_5 );
}
public void testDisablePrecompilation()
diff --git a/src/test/java/npanday/its/NPANDAY_474_AspxExcludeWorkingDirectoriesTest.java b/src/test/java/npanday/its/NPANDAY_474_AspxExcludeWorkingDirectoriesTest.java
index 75b731b..8a0eafc 100644
--- a/src/test/java/npanday/its/NPANDAY_474_AspxExcludeWorkingDirectoriesTest.java
+++ b/src/test/java/npanday/its/NPANDAY_474_AspxExcludeWorkingDirectoriesTest.java
@@ -32,7 +32,7 @@
{
public NPANDAY_474_AspxExcludeWorkingDirectoriesTest()
{
- super( "[1.4.1-incubating,)", "[v3.5,)" );
+ super( "[1.4.1-incubating,)", FRAMEWORK_V4_0 );
}
public void testExcludeWorkingDirectories()
diff --git a/src/test/java/npanday/its/NPANDAY_480_AzureSupportOneWebRole.java b/src/test/java/npanday/its/NPANDAY_480_AzureSupportOneWebRole.java
index 0712b34..7575643 100644
--- a/src/test/java/npanday/its/NPANDAY_480_AzureSupportOneWebRole.java
+++ b/src/test/java/npanday/its/NPANDAY_480_AzureSupportOneWebRole.java
@@ -26,7 +26,7 @@
{
public NPANDAY_480_AzureSupportOneWebRole()
{
- super( "[1.5.0-incubating,)", "[v4.0.30319,)" );
+ super( "[1.5.0-incubating,)", FRAMEWORK_V4_0 );
skipIfMissingAzureSDK("1.6");
skipIfMissingWebDeployV2();
diff --git a/src/test/java/npanday/its/NPANDAY_480_CloudServiceWithMultipleRoles.java b/src/test/java/npanday/its/NPANDAY_480_CloudServiceWithMultipleRoles.java
index 6ff1496..62624c1 100644
--- a/src/test/java/npanday/its/NPANDAY_480_CloudServiceWithMultipleRoles.java
+++ b/src/test/java/npanday/its/NPANDAY_480_CloudServiceWithMultipleRoles.java
@@ -26,7 +26,7 @@
{
public NPANDAY_480_CloudServiceWithMultipleRoles()
{
- super( "[1.5.0-incubating,)", "[v4.0.30319,)" );
+ super( "[1.5.0-incubating,)", FRAMEWORK_V4_0 );
skipIfMissingAzureSDK("1.6");
skipIfMissingWebDeployV2();
diff --git a/src/test/java/npanday/its/NPANDAY_480_CloudServiceWithWorkerRole.java b/src/test/java/npanday/its/NPANDAY_480_CloudServiceWithWorkerRole.java
index 8ebdfad..9aa3836 100644
--- a/src/test/java/npanday/its/NPANDAY_480_CloudServiceWithWorkerRole.java
+++ b/src/test/java/npanday/its/NPANDAY_480_CloudServiceWithWorkerRole.java
@@ -26,7 +26,7 @@
{
public NPANDAY_480_CloudServiceWithWorkerRole()
{
- super( "[1.5.0-incubating,)", "[v4.0.30319,)" );
+ super( "[1.5.0-incubating,)", FRAMEWORK_V4_0 );
skipIfMissingAzureSDK("1.6");
}
diff --git a/src/test/java/npanday/its/NPANDAY_571_AzureSDKVersionTest.java b/src/test/java/npanday/its/NPANDAY_571_AzureSDKVersionTest.java
index 784cb4f..f7494dc 100644
--- a/src/test/java/npanday/its/NPANDAY_571_AzureSDKVersionTest.java
+++ b/src/test/java/npanday/its/NPANDAY_571_AzureSDKVersionTest.java
@@ -26,7 +26,7 @@
{
public NPANDAY_571_AzureSDKVersionTest()
{
- super( "[1.5.0-incubating,)", "[v4.0.30319,)" );
+ super( "[1.5.0-incubating,)", FRAMEWORK_V4_0 );
skipIfMissingProgramFilesDirectory( "Microsoft SDKs\\Windows Azure\\.NET SDK\\2012-06", "Azure SDK 1.7 is not installed" );
}
diff --git a/src/test/java/npanday/its/NPANDAY_580_WpfBrowserTest.java b/src/test/java/npanday/its/NPANDAY_580_WpfBrowserTest.java
index 88df4fe..b8ee918 100644
--- a/src/test/java/npanday/its/NPANDAY_580_WpfBrowserTest.java
+++ b/src/test/java/npanday/its/NPANDAY_580_WpfBrowserTest.java
@@ -28,7 +28,7 @@
{
public NPANDAY_580_WpfBrowserTest()
{
- super( "[1.5.0-incubating,)", "[v4.0.30319,)" );
+ super( "[1.5.0-incubating,)", FRAMEWORK_V4_0 );
}
public void test()
diff --git a/src/test/java/npanday/its/NPANDAY_96_GlobalAsaxPrecompiledTest.java b/src/test/java/npanday/its/NPANDAY_96_GlobalAsaxPrecompiledTest.java
index 66a843b..f4f2f73 100644
--- a/src/test/java/npanday/its/NPANDAY_96_GlobalAsaxPrecompiledTest.java
+++ b/src/test/java/npanday/its/NPANDAY_96_GlobalAsaxPrecompiledTest.java
@@ -31,7 +31,7 @@
{
public NPANDAY_96_GlobalAsaxPrecompiledTest()
{
- super( "[1.4.0-incubating,)", "[v3.5,)" );
+ super( "[1.4.0-incubating,)", FRAMEWORK_V3_5 );
}
public void testGlobalAsaxPrecompiled()
diff --git a/src/test/java/npanday/its/NPandayIT0012VBWebAppTest.java b/src/test/java/npanday/its/NPandayIT0012VBWebAppTest.java
index d0c3437..ae736d1 100644
--- a/src/test/java/npanday/its/NPandayIT0012VBWebAppTest.java
+++ b/src/test/java/npanday/its/NPandayIT0012VBWebAppTest.java
@@ -33,7 +33,7 @@
{
public NPandayIT0012VBWebAppTest()
{
- super( "[1.2,)" );
+ super( "[1.2,)", FRAMEWORK_V3_5 );
}
public void testWebAppInstall()
diff --git a/src/test/java/npanday/its/NPandayIT0013WebAppInstallTest.java b/src/test/java/npanday/its/NPandayIT0013WebAppInstallTest.java
index 9dacff1..35ff8f9 100644
--- a/src/test/java/npanday/its/NPandayIT0013WebAppInstallTest.java
+++ b/src/test/java/npanday/its/NPandayIT0013WebAppInstallTest.java
@@ -31,7 +31,7 @@
{
public NPandayIT0013WebAppInstallTest()
{
- super( "[1.0.2,)" );
+ super( "[1.0.2,)", FRAMEWORK_V3_5 );
}
public void testWebAppInstall()
diff --git a/src/test/java/npanday/its/NPandayIT0041Net35Test.java b/src/test/java/npanday/its/NPandayIT0041Net35Test.java
index 1f8640d..55d583e 100644
--- a/src/test/java/npanday/its/NPandayIT0041Net35Test.java
+++ b/src/test/java/npanday/its/NPandayIT0041Net35Test.java
@@ -29,7 +29,7 @@
{
public NPandayIT0041Net35Test()
{
- super( "[1.0.2,)", "[v3.5,)" );
+ super( "[1.0.2,)", FRAMEWORK_V3_5 );
}
public void testNet35Project()