// 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;
        verifier.deleteArtifacts( GROUPID, PROJECT_ARTIFACTID, VERSION );

        verifier.executeGoal( "install" );
        verifier.verifyErrorFreeLog();

        // We don't check all the files, just the most important ones
        // Different versions/installs of Visual Studio generate different file sets anyway!
        assertDirectoryContents( releaseDir, -1, Arrays.asList(
                new String[]{"hello-world.obj", "hello-world-lib.lib"} ) );
        assertDirectoryContents( debugDir, -1, Arrays.asList(
                new String[]{"hello-world.obj", "hello-world-lib.lib"} ) );

        File artifactsDir = new File(
                verifier.getArtifactMetadataPath( GROUPID, PROJECT_ARTIFACTID, VERSION ) ).getParentFile();
        assertDirectoryContents( artifactsDir, 5, Arrays.asList( new String[]{
                PROJECT_ARTIFACTID + "-" + VERSION + ".pom",
                PROJECT_ARTIFACTID + "-" + VERSION + ".lib",
                PROJECT_ARTIFACTID + "-" + VERSION + "-Win32-Debug.lib"} ) );


        verifier.resetStreams();

        verifier.executeGoal( "clean" );
        verifier.verifyErrorFreeLog();
        checkProjectBuildOutputIsCleaned( "hello-world-lib", releaseDir );
        checkProjectBuildOutputIsCleaned( "hello-world-lib", debugDir );
    }

    private static final String GROUPID = "uk.org.raje.maven.plugins.msbuild.it";
    private static final String SOLUTION_ARTIFACTID = "hello-world-lib-solution-test";
// 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;

        verifier.deleteArtifacts( GROUPID, PROJECT_ARTIFACTID, VERSION );

        verifier.executeGoal( "install" );
        verifier.verifyErrorFreeLog();

        // We don't check all the files, just the most important ones
        // Different versions/installs of Visual Studio generate different file sets anyway!
        assertDirectoryContents( releaseDir, -1, Arrays.asList(
                new String[]{"hello-world.obj", "hello-world-lib.lib"} ) );
        assertDirectoryContents( debugDir, -1, Arrays.asList(
                new String[]{"hello-world.obj", "hello-world-lib.lib"} ) );

        File artifactsDir = new File(
                verifier.getArtifactMetadataPath( GROUPID, PROJECT_ARTIFACTID, VERSION ) ).getParentFile();
        assertDirectoryContents( artifactsDir, 5, Arrays.asList( new String[]{
                PROJECT_ARTIFACTID + "-" + VERSION + ".pom",
                PROJECT_ARTIFACTID + "-" + VERSION + ".lib",
                PROJECT_ARTIFACTID + "-" + VERSION + "-Win32-Debug.lib"} ) );


        verifier.resetStreams();

        verifier.executeGoal( "clean" );
        verifier.verifyErrorFreeLog();
        checkProjectBuildOutputIsCleaned( "hello-world-lib", releaseDir );
        checkProjectBuildOutputIsCleaned( "hello-world-lib", debugDir );
    }

    private static final String GROUPID = "uk.org.raje.maven.plugins.msbuild.it";
    private static final String SOLUTION_ARTIFACTID = "hello-world-lib-solution-test";
    private static final String PROJECT_ARTIFACTID = "hello-world-lib-project-test";