// Path: msbuild-maven-plugin-it/src/test/java/uk/org/raje/maven/plugin/msbuild/it/MSBuildMojoITHelper.java
// static void addPropertiesToVerifier( Verifier verifier ) throws IOException
// {
//     Properties props = new Properties();
//     props.load( MSBuildMojoITHelper.class.getResourceAsStream( VERIFIER_PROPERTIES_FILE ) );
//     Properties systemProps = verifier.getSystemProperties();
//     systemProps.putAll( props );
//     verifier.setSystemProperties( systemProps );
// }
// 
// Path: msbuild-maven-plugin-it/src/test/java/uk/org/raje/maven/plugin/msbuild/it/MSBuildMojoITHelper.java
// static void assertDirectoryContents( File directory, int expectedCount, List<String> expectedFiles )
// {
//     assertTrue ( "Expected output directory missing: " + directory.getAbsolutePath(), directory.exists() );
//     List<String> dirContents = Arrays.asList( directory.list() );
//     if ( expectedCount != -1 )
//     {
//         assertEquals( expectedCount, dirContents.size() );
//     }
//     for ( String fileName: expectedFiles )
//     {
//         assertTrue( "Expected file missing: " + fileName, dirContents.contains( fileName ) );
//     }
// }
// 
// Path: msbuild-maven-plugin-it/src/test/java/uk/org/raje/maven/plugin/msbuild/it/MSBuildMojoITHelper.java
// static File calculateAndDeleteOutputDirectory( File parent, String name ) throws IOException
// {
//     File result = new File( parent, name );
//     if ( result.exists() )
//     {
//         for ( File content : result.listFiles() )
//         {
//             // NOTE: No attempt to recurse, shouldn't ever be needed!
//             if ( !content.delete() )
//             {
//                 throw new IOException( "Failed to delete " +  content.getAbsolutePath() );
//             }
//         }
//         if ( !result.delete() )
//         {
//             throw new IOException( "Failed to delete " +  result.getAbsolutePath() );
//         }
//     }
// 
//     return result;
// }
// 
// Path: msbuild-maven-plugin-it/src/test/java/uk/org/raje/maven/plugin/msbuild/it/MSBuildMojoITHelper.java
// static void checkProjectBuildOutputIsCleaned( String projectName, File outputDir )
// {
//     if ( outputDir.exists() ) // if the directory doesn't exist we're clean
//     {
//         // What is left depends on exact tool version so we aren't too strict
//         List<String> dirContents = Arrays.asList( outputDir.list( new FilenameFilter() {
//             @Override
//             public boolean accept( File path, String name )
//             {
//                 return path.isFile();
//             }
//         } ) );
//         if ( dirContents.size() != 0 ) // if the directory contains something it should just be the log file
//         {
//             assertEquals( 1, dirContents.size() );
//             assertTrue( "Unexpect files left after clean",
//                      dirContents.contains( projectName + ".Build.CppClean.log" ) // VS 2010
//                      || dirContents.contains( projectName + ".log" ) // VS 2015
//                      );
//         }
//     }
// 
// }


import static org.junit.Assert.assertEquals;
import java.io.File;
import java.util.Arrays;
import org.apache.maven.it.Verifier;
import org.apache.maven.it.util.ResourceExtractor;
import org.junit.Test;
import static uk.org.raje.maven.plugin.msbuild.it.MSBuildMojoITHelper.addPropertiesToVerifier;
import static uk.org.raje.maven.plugin.msbuild.it.MSBuildMojoITHelper.assertDirectoryContents;
import static uk.org.raje.maven.plugin.msbuild.it.MSBuildMojoITHelper.calculateAndDeleteOutputDirectory;
import static uk.org.raje.maven.plugin.msbuild.it.MSBuildMojoITHelper.checkProjectBuildOutputIsCleaned;
/*
 * Copyright 2013 Andrew Everitt, Andrew Heckford, Daniele Masato
 *
 * Licensed 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.
 */
package uk.org.raje.maven.plugin.msbuild.it;





/**
 * Integration test that runs the hello-world-lib-test
 *
 */
public class MavenITHelloWorldLibTest
{

    @Test
    public void testSolutionBuild() throws Exception
    {
        File testDir = ResourceExtractor.simpleExtractResources( getClass(),
                "/hello-world-lib-test" );
        File releaseDir = calculateAndDeleteOutputDirectory( testDir, "Release" );
        File debugDir = calculateAndDeleteOutputDirectory( testDir, "Debug" );

        Verifier verifier = new Verifier( testDir.getAbsolutePath() );
        addPropertiesToVerifier( verifier );

        // Delete any existing artifact from the local repository
        verifier.deleteArtifacts( GROUPID, SOLUTION_ARTIFACTID, VERSION );

        verifier.executeGoal( "install" );
        verifier.verifyErrorFreeLog();
// Path: msbuild-maven-plugin-it/src/test/java/uk/org/raje/maven/plugin/msbuild/it/MSBuildMojoITHelper.java
// static void addPropertiesToVerifier( Verifier verifier ) throws IOException
// {
//     Properties props = new Properties();
//     props.load( MSBuildMojoITHelper.class.getResourceAsStream( VERIFIER_PROPERTIES_FILE ) );
//     Properties systemProps = verifier.getSystemProperties();
//     systemProps.putAll( props );
//     verifier.setSystemProperties( systemProps );
// }
// 
// Path: msbuild-maven-plugin-it/src/test/java/uk/org/raje/maven/plugin/msbuild/it/MSBuildMojoITHelper.java
// static void assertDirectoryContents( File directory, int expectedCount, List<String> expectedFiles )
// {
//     assertTrue ( "Expected output directory missing: " + directory.getAbsolutePath(), directory.exists() );
//     List<String> dirContents = Arrays.asList( directory.list() );
//     if ( expectedCount != -1 )
//     {
//         assertEquals( expectedCount, dirContents.size() );
//     }
//     for ( String fileName: expectedFiles )
//     {
//         assertTrue( "Expected file missing: " + fileName, dirContents.contains( fileName ) );
//     }
// }
// 
// Path: msbuild-maven-plugin-it/src/test/java/uk/org/raje/maven/plugin/msbuild/it/MSBuildMojoITHelper.java
// static File calculateAndDeleteOutputDirectory( File parent, String name ) throws IOException
// {
//     File result = new File( parent, name );
//     if ( result.exists() )
//     {
//         for ( File content : result.listFiles() )
//         {
//             // NOTE: No attempt to recurse, shouldn't ever be needed!
//             if ( !content.delete() )
//             {
//                 throw new IOException( "Failed to delete " +  content.getAbsolutePath() );
//             }
//         }
//         if ( !result.delete() )
//         {
//             throw new IOException( "Failed to delete " +  result.getAbsolutePath() );
//         }
//     }
// 
//     return result;
// }
// 
// Path: msbuild-maven-plugin-it/src/test/java/uk/org/raje/maven/plugin/msbuild/it/MSBuildMojoITHelper.java
// static void checkProjectBuildOutputIsCleaned( String projectName, File outputDir )
// {
//     if ( outputDir.exists() ) // if the directory doesn't exist we're clean
//     {
//         // What is left depends on exact tool version so we aren't too strict
//         List<String> dirContents = Arrays.asList( outputDir.list( new FilenameFilter() {
//             @Override
//             public boolean accept( File path, String name )
//             {
//                 return path.isFile();
//             }
//         } ) );
//         if ( dirContents.size() != 0 ) // if the directory contains something it should just be the log file
//         {
//             assertEquals( 1, dirContents.size() );
//             assertTrue( "Unexpect files left after clean",
//                      dirContents.contains( projectName + ".Build.CppClean.log" ) // VS 2010
//                      || dirContents.contains( projectName + ".log" ) // VS 2015
//                      );
//         }
//     }
// 
// }


// Path: msbuild-maven-plugin-it/src/test/java/uk/org/raje/maven/plugin/msbuild/it/MavenITHelloWorldLibTest.java
import static org.junit.Assert.assertEquals;
import java.io.File;
import java.util.Arrays;
import org.apache.maven.it.Verifier;
import org.apache.maven.it.util.ResourceExtractor;
import org.junit.Test;
import static uk.org.raje.maven.plugin.msbuild.it.MSBuildMojoITHelper.addPropertiesToVerifier;
import static uk.org.raje.maven.plugin.msbuild.it.MSBuildMojoITHelper.assertDirectoryContents;
import static uk.org.raje.maven.plugin.msbuild.it.MSBuildMojoITHelper.calculateAndDeleteOutputDirectory;
import static uk.org.raje.maven.plugin.msbuild.it.MSBuildMojoITHelper.checkProjectBuildOutputIsCleaned;

/*
 * Copyright 2013 Andrew Everitt, Andrew Heckford, Daniele Masato
 *
 * Licensed 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.
 */
package uk.org.raje.maven.plugin.msbuild.it;





/**
 * Integration test that runs the hello-world-lib-test
 *
 */
public class MavenITHelloWorldLibTest
{

    @Test
    public void testSolutionBuild() throws Exception
    {
        File testDir = ResourceExtractor.simpleExtractResources( getClass(),
                "/hello-world-lib-test" );
        File releaseDir = calculateAndDeleteOutputDirectory( testDir, "Release" );
        File debugDir = calculateAndDeleteOutputDirectory( testDir, "Debug" );

        Verifier verifier = new Verifier( testDir.getAbsolutePath() );
        addPropertiesToVerifier( verifier );

        // Delete any existing artifact from the local repository
        verifier.deleteArtifacts( GROUPID, SOLUTION_ARTIFACTID, VERSION );

        verifier.executeGoal( "install" );
        verifier.verifyErrorFreeLog();
        assertDirectoryContents( releaseDir, 1, Arrays.asList(