Author: brett Date: Tue Dec 20 02:26:25 2011 New Revision: 1221075 URL: http://svn.apache.org/viewvc?rev=1221075&view=rev Log: add an integration test that verifies that NPanday assemblies were built with the right version of .NET framework
Added: incubator/npanday/npanday-its/trunk/src/test/java/npanday/its/AddInInstallationTest.java (with props) Modified: incubator/npanday/npanday-its/trunk/src/test/java/npanday/its/AbstractNPandayIntegrationTestCase.java incubator/npanday/npanday-its/trunk/src/test/java/npanday/its/IntegrationTestSuite.java Modified: incubator/npanday/npanday-its/trunk/src/test/java/npanday/its/AbstractNPandayIntegrationTestCase.java URL: http://svn.apache.org/viewvc/incubator/npanday/npanday-its/trunk/src/test/java/npanday/its/AbstractNPandayIntegrationTestCase.java?rev=1221075&r1=1221074&r2=1221075&view=diff ============================================================================== --- incubator/npanday/npanday-its/trunk/src/test/java/npanday/its/AbstractNPandayIntegrationTestCase.java (original) +++ incubator/npanday/npanday-its/trunk/src/test/java/npanday/its/AbstractNPandayIntegrationTestCase.java Tue Dec 20 02:26:25 2011 @@ -62,7 +62,7 @@ public abstract class AbstractNPandayInt private static final String NPANDAY_VERSION_SYSTEM_PROPERTY = "npanday.version"; - private static DefaultArtifactVersion version = checkVersion(); + protected static DefaultArtifactVersion version = checkVersion(); private static DefaultArtifactVersion frameworkVersion = checkFrameworkVersion(); @@ -578,6 +578,42 @@ public abstract class AbstractNPandayInt return false; } + private String getAssemblyFrameworkVersion( File assembly ) + throws VerificationException + { + String output = runILDisasm( assembly.getAbsolutePath() ); + + String prefix = "// Metadata version: v"; + for ( String line : output.split( "\n" ) ) + { + line = line.trim(); + if ( line.startsWith( prefix ) ) + { + return line.substring( prefix.length() ).trim(); + } + } + return null; + } + + private boolean isAssemblyFrameworkVersion( File assembly, String versionRangeStr ) + throws VerificationException + { + String frameworkVersion = getAssemblyFrameworkVersion( assembly ); + VersionRange versionRange = createVersionRange( versionRangeStr ); + return versionRange.containsVersion( new DefaultArtifactVersion( frameworkVersion ) ); + } + + protected void assertAssemblyFrameworkVersion( File assembly, String versionRangeStr ) + throws VerificationException + { + String frameworkVersion = getAssemblyFrameworkVersion( assembly ); + VersionRange versionRange = createVersionRange( versionRangeStr ); + if ( !versionRange.containsVersion( new DefaultArtifactVersion( frameworkVersion ) ) ) + { + fail( "Framework version " + frameworkVersion + " is not in range " + versionRangeStr ); + } + } + protected static boolean checkNPandayVersion( String versionRangeStr ) { return checkNPandayVersion( createVersionRange( versionRangeStr ), version ) || forceVersion; Added: incubator/npanday/npanday-its/trunk/src/test/java/npanday/its/AddInInstallationTest.java URL: http://svn.apache.org/viewvc/incubator/npanday/npanday-its/trunk/src/test/java/npanday/its/AddInInstallationTest.java?rev=1221075&view=auto ============================================================================== --- incubator/npanday/npanday-its/trunk/src/test/java/npanday/its/AddInInstallationTest.java (added) +++ incubator/npanday/npanday-its/trunk/src/test/java/npanday/its/AddInInstallationTest.java Tue Dec 20 02:26:25 2011 @@ -0,0 +1,85 @@ +package npanday.its; + +/* + * Copyright 2010 + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import org.apache.maven.it.Verifier; +import org.apache.maven.it.util.ResourceExtractor; + +import java.io.File; +import java.util.Arrays; +import java.util.List; + +public class AddInInstallationTest + extends AbstractNPandayIntegrationTestCase +{ + public AddInInstallationTest() + { + super( "[1.0.2,)" ); + } + + public void testBootstrap() + throws Exception + { + List<String> artifacts; + String groupId; + if ( checkNPandayVersion( createVersionRange( "(,1.4.0)" ), version ) ) + { + groupId = "npanday.plugin"; + artifacts = Arrays.asList( + "npanday.model:NPanday.Model.Pom", + "npanday.plugin:NPanday.Plugin.Msbuild", + "npanday.visualstudio:NPanday.VisualStudio.Addin" + ); + } + else + { + groupId = "org.apache.npanday.plugins"; + artifacts = Arrays.asList( + "org.apache.npanday:NPanday.Model.Pom", + "org.apache.npanday.plugins:NPanday.Plugin.Msbuild", + "org.apache.npanday.visualstudio:NPanday.VisualStudio.Addin" + ); + } + + String tmpdir = System.getProperty( "maven.test.tmpdir", System.getProperty( "java.io.tmpdir" ) ); + File testDir = new File( tmpdir, "AddInInstallationTest" ); + testDir.mkdirs(); + Verifier verifier = getVerifier( testDir ); + verifier.setAutoclean( false ); + verifier.executeGoal( groupId + ":maven-vsinstaller-plugin:" + version.toString() + ":install" ); + verifier.verifyErrorFreeLog(); + verifier.resetStreams(); + + // TODO: check the AddIn files + + // check correct framework version of libraries in the local repository + for ( String artifact : artifacts ) + { + String[] parts = artifact.split( ":" ); + String classifier = parts[1].equals( "NPanday.Model.Pom" ) ? "4b435f4d76e2f0e6" : null; + File assembly = new File( verifier.getArtifactPath( parts[0], parts[1], version.toString(), "dll", + classifier ) ); + assertTrue( "Check " + assembly + " exists", assembly.exists() ); + + assertAssemblyFrameworkVersion( assembly, "[2.0.50727]" ); + } + } +} Propchange: incubator/npanday/npanday-its/trunk/src/test/java/npanday/its/AddInInstallationTest.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: incubator/npanday/npanday-its/trunk/src/test/java/npanday/its/IntegrationTestSuite.java URL: http://svn.apache.org/viewvc/incubator/npanday/npanday-its/trunk/src/test/java/npanday/its/IntegrationTestSuite.java?rev=1221075&r1=1221074&r2=1221075&view=diff ============================================================================== --- incubator/npanday/npanday-its/trunk/src/test/java/npanday/its/IntegrationTestSuite.java (original) +++ incubator/npanday/npanday-its/trunk/src/test/java/npanday/its/IntegrationTestSuite.java Tue Dec 20 02:26:25 2011 @@ -46,7 +46,7 @@ public class IntegrationTestSuite // suite.addTestSuite( NPandayIT0002NetModuleDependencyTest.class ); // issue #11729 // suite.addTestSuite( NPandayIT0003NetModuleTransitiveDependencyTest.class ); // issue #11729 - suite.addTestSuite( NPANDAY_474_AspxExcludeWorkingDirectoriesTest.class); + suite.addTestSuite( NPANDAY_474_AspxExcludeWorkingDirectoriesTest.class ); suite.addTestSuite( NPANDAY_459_MsBuildProjectReferencesTest.class ); suite.addTestSuite( NPANDAY_465_AspxDisablePrecompilationTest.class ); suite.addTestSuite( NPANDAY_488_MSDeployPackageSimpleWebApp.class ); @@ -91,6 +91,8 @@ public class IntegrationTestSuite suite.addTestSuite( NPandayIT0004NUnitTestVerificationTest.class ); suite.addTestSuite( NPandayIT0001CompilerVerificationTest.class ); + suite.addTestSuite( AddInInstallationTest.class ); + return suite; } }