// Path: src/it/non-lifecycle/src/main/java/test/maven/plugin/profiler/PomRead.java
// public class PomRead {
// 
//     public String getPomVersion(Model model) {
//         String result = model.getVersion();
//         if (result == null) {
//             throw new IllegalArgumentException("The artifact does not define a version.");
//         }
//         return result;
//     }
// 
//     public Model readModel(InputStream is) throws IOException, XmlPullParserException {
//         MavenXpp3Reader model = new MavenXpp3Reader();
//         Model read = model.read(is);
//         return read;
//     }
// 
//     public Model readModel(File file) throws IOException, XmlPullParserException {
//         FileInputStream fis = new FileInputStream(file);
//         return readModel(fis);
//     }
// 
//     public String getVersionFromPom(File pomFile) throws IOException, XmlPullParserException {
//         Model model = readModel(pomFile);
//         return getPomVersion(model);
//     }
// 
//     public static void main(String[] args) {
//         if (args.length != 1) {
//             System.err.println("Invalid number of arguments.");
//             System.err.println("");
//             System.err.println("usage: pom.xml");
//             return;
//         }
// 
//         String pom = args[0];
//         File pomFile = new File(pom);
//         if (!pomFile.exists() || !pomFile.isFile() || !pomFile.canRead()) {
//             System.err.println("File " + pomFile + " can not be accessed or does not exist.");
//             return;
//         }
// 
//         PomRead pomRead = new PomRead();
//         try {
//             String version = pomRead.getVersionFromPom(pomFile);
//             System.out.println(version);
//         } catch (IllegalArgumentException e) {
//             System.err.println(e.getMessage());
//         } catch (IOException e) {
//             System.err.println(e.getMessage());
//         } catch (XmlPullParserException e) {
//             System.err.println(e.getMessage());
//         }
// 
//     }
// }


import static org.assertj.core.api.Assertions.assertThat;
import java.io.File;
import java.io.OutputStream;
import java.io.PrintStream;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import test.maven.plugin.profiler.PomRead;


        assertThat( consoleOutputStdErr.toString()).isEqualTo(expectedLines);
        assertThat(consoleOutputStdOut.toString()).isEmpty();
    }

    @Test
    public void shouldFailWithExceptionCauseArtifactDoesNotDefineAVersion() {
        String testResourcesLocation = getTestResourcesDirectory();
        PomRead.main(new String[] { testResourcesLocation + File.separator + "first-pom.xml" });

        //@formatter:off
        String expectedErrorLines = 
                "The artifact does not define a version." + LINE_FEED;
        //@formatter:on
        assertThat(consoleOutputStdErr.toString()).isEqualTo(expectedErrorLines);
        assertThat(consoleOutputStdOut.toString()).isEmpty();
    }

    @Test
    public void shouldFailWithErrorBasedOnTooMuchArguments() {
        PomRead.main(new String[] { "first", "second" });

        //@formatter:off
        String expectedLines = 
              "Invalid number of arguments." + LINE_FEED
            + LINE_FEED
            + "usage: pom.xml" + LINE_FEED;
        //@formatter:on

        assertThat(consoleOutputStdErr.toString()).isEqualTo(expectedLines);

// Path: src/it/non-lifecycle/src/main/java/test/maven/plugin/profiler/PomRead.java
// public class PomRead {
// 
//     public String getPomVersion(Model model) {
//         String result = model.getVersion();
//         if (result == null) {
//             throw new IllegalArgumentException("The artifact does not define a version.");
//         }
//         return result;
//     }
// 
//     public Model readModel(InputStream is) throws IOException, XmlPullParserException {
//         MavenXpp3Reader model = new MavenXpp3Reader();
//         Model read = model.read(is);
//         return read;
//     }
// 
//     public Model readModel(File file) throws IOException, XmlPullParserException {
//         FileInputStream fis = new FileInputStream(file);
//         return readModel(fis);
//     }
// 
//     public String getVersionFromPom(File pomFile) throws IOException, XmlPullParserException {
//         Model model = readModel(pomFile);
//         return getPomVersion(model);
//     }
// 
//     public static void main(String[] args) {
//         if (args.length != 1) {
//             System.err.println("Invalid number of arguments.");
//             System.err.println("");
//             System.err.println("usage: pom.xml");
//             return;
//         }
// 
//         String pom = args[0];
//         File pomFile = new File(pom);
//         if (!pomFile.exists() || !pomFile.isFile() || !pomFile.canRead()) {
//             System.err.println("File " + pomFile + " can not be accessed or does not exist.");
//             return;
//         }
// 
//         PomRead pomRead = new PomRead();
//         try {
//             String version = pomRead.getVersionFromPom(pomFile);
//             System.out.println(version);
//         } catch (IllegalArgumentException e) {
//             System.err.println(e.getMessage());
//         } catch (IOException e) {
//             System.err.println(e.getMessage());
//         } catch (XmlPullParserException e) {
//             System.err.println(e.getMessage());
//         }
// 
//     }
// }


// Path: src/it/non-lifecycle/src/test/java/test/maven/plugin/profiler/PomReadIT.java
import static org.assertj.core.api.Assertions.assertThat;
import java.io.File;
import java.io.OutputStream;
import java.io.PrintStream;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import test.maven.plugin.profiler.PomRead;


        assertThat( consoleOutputStdErr.toString()).isEqualTo(expectedLines);
        assertThat(consoleOutputStdOut.toString()).isEmpty();
    }

    @Test
    public void shouldFailWithExceptionCauseArtifactDoesNotDefineAVersion() {
        String testResourcesLocation = getTestResourcesDirectory();
        PomRead.main(new String[] { testResourcesLocation + File.separator + "first-pom.xml" });

        //@formatter:off
        String expectedErrorLines = 
                "The artifact does not define a version." + LINE_FEED;
        //@formatter:on
        assertThat(consoleOutputStdErr.toString()).isEqualTo(expectedErrorLines);
        assertThat(consoleOutputStdOut.toString()).isEmpty();
    }

    @Test
    public void shouldFailWithErrorBasedOnTooMuchArguments() {
        PomRead.main(new String[] { "first", "second" });

        //@formatter:off
        String expectedLines = 
              "Invalid number of arguments." + LINE_FEED
            + LINE_FEED
            + "usage: pom.xml" + LINE_FEED;
        //@formatter:on

        assertThat(consoleOutputStdErr.toString()).isEqualTo(expectedLines);

        assertThat(consoleOutputStdOut.toString()).isEmpty();
