Search in sources :

Example 1 with TestInputHandler

use of org.apache.maven.plugins.repository.testutil.TestInputHandler in project maven-plugins by apache.

the class BundleCreateMojoTest method testDefaultconfiguration_RemoveTwoWithSpace.

public void testDefaultconfiguration_RemoveTwoWithSpace() throws Exception {
    try {
        createTestJars("default-configuration", true, true, getBasedir() + "/target/test/unit/default-configuration/target");
    } catch (IOException ie) {
        ie.printStackTrace();
    }
    File testPom = new File(getBasedir(), "src/test/resources/unit/default-configuration/pom.xml");
    try {
        BundleCreateMojo mojo = (BundleCreateMojo) lookupMojo("bundle-create", testPom);
        // NOTE: This is sensitive to the lookupMojo method timing...
        TestInputHandler ih = (TestInputHandler) lookup(InputHandler.ROLE, "default");
        Stack<String> responses = new Stack<String>();
        responses.push("2, 3");
        ih.setLineResponses(responses);
        mojo.execute();
    } catch (Exception e) {
        e.printStackTrace();
    }
    File bundleSource = new File(getBasedir(), "target/test/unit/default-configuration/target/default-configuration-bundle.jar");
    assertTrue(FileUtils.fileExists(bundleSource.getAbsolutePath()));
    Set<String> entryNames = new HashSet<String>();
    entryNames.add("default-configuration.jar");
    entryNames.add("pom.xml");
    entryNames.add("META-INF/MANIFEST.MF");
    entryNames.add("META-INF/");
    Set<String> bannedNames = new HashSet<String>();
    bannedNames.add("default-configuration-javadoc.jar");
    bannedNames.add("default-configuration-sources.jar");
    assertZipContents(entryNames, bannedNames, bundleSource);
}
Also used : IOException(java.io.IOException) File(java.io.File) TestInputHandler(org.apache.maven.plugins.repository.testutil.TestInputHandler) IOException(java.io.IOException) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) Stack(java.util.Stack) HashSet(java.util.HashSet)

Example 2 with TestInputHandler

use of org.apache.maven.plugins.repository.testutil.TestInputHandler in project maven-plugins by apache.

the class BundleCreateMojoTest method testDefaultconfiguration_RemoveOne.

public void testDefaultconfiguration_RemoveOne() throws Exception {
    try {
        createTestJars("default-configuration", true, true, getBasedir() + "/target/test/unit/default-configuration/target");
    } catch (IOException ie) {
        ie.printStackTrace();
    }
    File testPom = new File(getBasedir(), "src/test/resources/unit/default-configuration/pom.xml");
    try {
        BundleCreateMojo mojo = (BundleCreateMojo) lookupMojo("bundle-create", testPom);
        // NOTE: This is sensitive to the lookupMojo method timing...
        TestInputHandler ih = (TestInputHandler) lookup(InputHandler.ROLE, "default");
        Stack<String> responses = new Stack<String>();
        responses.push("2");
        ih.setLineResponses(responses);
        mojo.execute();
    } catch (Exception e) {
        e.printStackTrace();
    }
    File bundleSource = new File(getBasedir(), "target/test/unit/default-configuration/target/default-configuration-bundle.jar");
    assertTrue(FileUtils.fileExists(bundleSource.getAbsolutePath()));
    Set<String> entryNames = new HashSet<String>();
    entryNames.add("default-configuration-sources.jar");
    entryNames.add("default-configuration.jar");
    entryNames.add("pom.xml");
    entryNames.add("META-INF/MANIFEST.MF");
    entryNames.add("META-INF/");
    Set<String> bannedNames = new HashSet<String>();
    bannedNames.add("default-configuration-javadoc.jar");
    assertZipContents(entryNames, bannedNames, bundleSource);
}
Also used : IOException(java.io.IOException) File(java.io.File) TestInputHandler(org.apache.maven.plugins.repository.testutil.TestInputHandler) IOException(java.io.IOException) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) Stack(java.util.Stack) HashSet(java.util.HashSet)

Example 3 with TestInputHandler

use of org.apache.maven.plugins.repository.testutil.TestInputHandler in project maven-plugins by apache.

the class BundleCreateMojoTest method testDefaultconfiguration_RemoveTwoUnordered.

public void testDefaultconfiguration_RemoveTwoUnordered() throws Exception {
    try {
        createTestJars("default-configuration", true, true, getBasedir() + "/target/test/unit/default-configuration/target");
    } catch (IOException ie) {
        ie.printStackTrace();
    }
    File testPom = new File(getBasedir(), "src/test/resources/unit/default-configuration/pom.xml");
    try {
        BundleCreateMojo mojo = (BundleCreateMojo) lookupMojo("bundle-create", testPom);
        // NOTE: This is sensitive to the lookupMojo method timing...
        TestInputHandler ih = (TestInputHandler) lookup(InputHandler.ROLE, "default");
        Stack<String> responses = new Stack<String>();
        responses.push("3,2");
        ih.setLineResponses(responses);
        mojo.execute();
    } catch (Exception e) {
        e.printStackTrace();
    }
    File bundleSource = new File(getBasedir(), "target/test/unit/default-configuration/target/default-configuration-bundle.jar");
    assertTrue(FileUtils.fileExists(bundleSource.getAbsolutePath()));
    Set<String> entryNames = new HashSet<String>();
    entryNames.add("default-configuration.jar");
    entryNames.add("pom.xml");
    entryNames.add("META-INF/MANIFEST.MF");
    entryNames.add("META-INF/");
    Set<String> bannedNames = new HashSet<String>();
    bannedNames.add("default-configuration-javadoc.jar");
    bannedNames.add("default-configuration-sources.jar");
    assertZipContents(entryNames, bannedNames, bundleSource);
}
Also used : IOException(java.io.IOException) File(java.io.File) TestInputHandler(org.apache.maven.plugins.repository.testutil.TestInputHandler) IOException(java.io.IOException) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) Stack(java.util.Stack) HashSet(java.util.HashSet)

Example 4 with TestInputHandler

use of org.apache.maven.plugins.repository.testutil.TestInputHandler in project maven-plugins by apache.

the class BundlePackMojoTest method testPack_RemoveTwo.

public void testPack_RemoveTwo() throws Exception {
    File testPom = new File(getBasedir(), "src/test/resources/unit/bundle-pack/pom.xml");
    BundlePackMojo mojo = (BundlePackMojo) lookupMojo("bundle-pack", testPom);
    URL repoURL = new File(getBasedir(), "src/test/resources/repo").toURL();
    mojo.localRepository = new DefaultArtifactRepository("test", repoURL.toString(), new DefaultRepositoryLayout());
    // NOTE: This is sensitive to the lookupMojo method timing...
    TestInputHandler ih = (TestInputHandler) lookup(InputHandler.ROLE, "default");
    Stack<String> responses = new Stack<String>();
    responses.push("2,3");
    ih.setLineResponses(responses);
    File generatedFilesDir = new File(getBasedir(), "target/bundle-pack-tests");
    mojo.basedir = generatedFilesDir.getAbsolutePath();
    mojo.execute();
    File bundleSource = new File(generatedFilesDir, "testartifact-1.0-bundle.jar");
    Set<String> entryNames = new HashSet<String>();
    entryNames.add("testartifact-1.0.jar");
    entryNames.add("pom.xml");
    entryNames.add("META-INF/MANIFEST.MF");
    entryNames.add("META-INF/");
    Set<String> bannedNames = new HashSet<String>();
    // determined experimentally, so this could change!
    bannedNames.add("testartifact-1.0-sources.jar");
    bannedNames.add("testartifact-1.0-javadoc.jar");
    assertZipContents(entryNames, bannedNames, bundleSource);
}
Also used : DefaultArtifactRepository(org.apache.maven.artifact.repository.DefaultArtifactRepository) DefaultRepositoryLayout(org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout) File(java.io.File) TestInputHandler(org.apache.maven.plugins.repository.testutil.TestInputHandler) URL(java.net.URL) Stack(java.util.Stack) HashSet(java.util.HashSet)

Example 5 with TestInputHandler

use of org.apache.maven.plugins.repository.testutil.TestInputHandler in project maven-plugins by apache.

the class BundlePackMojoTest method testPack_RemoveTwoUnordered.

public void testPack_RemoveTwoUnordered() throws Exception {
    File testPom = new File(getBasedir(), "src/test/resources/unit/bundle-pack/pom.xml");
    BundlePackMojo mojo = (BundlePackMojo) lookupMojo("bundle-pack", testPom);
    URL repoURL = new File(getBasedir(), "src/test/resources/repo").toURL();
    mojo.localRepository = new DefaultArtifactRepository("test", repoURL.toString(), new DefaultRepositoryLayout());
    // NOTE: This is sensitive to the lookupMojo method timing...
    TestInputHandler ih = (TestInputHandler) lookup(InputHandler.ROLE, "default");
    Stack<String> responses = new Stack<String>();
    responses.push("3,2");
    ih.setLineResponses(responses);
    File generatedFilesDir = new File(getBasedir(), "target/bundle-pack-tests");
    mojo.basedir = generatedFilesDir.getAbsolutePath();
    mojo.execute();
    File bundleSource = new File(generatedFilesDir, "testartifact-1.0-bundle.jar");
    Set<String> entryNames = new HashSet<String>();
    entryNames.add("testartifact-1.0.jar");
    entryNames.add("pom.xml");
    entryNames.add("META-INF/MANIFEST.MF");
    entryNames.add("META-INF/");
    Set<String> bannedNames = new HashSet<String>();
    // determined experimentally, so this could change!
    bannedNames.add("testartifact-1.0-sources.jar");
    bannedNames.add("testartifact-1.0-javadoc.jar");
    assertZipContents(entryNames, bannedNames, bundleSource);
}
Also used : DefaultArtifactRepository(org.apache.maven.artifact.repository.DefaultArtifactRepository) DefaultRepositoryLayout(org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout) File(java.io.File) TestInputHandler(org.apache.maven.plugins.repository.testutil.TestInputHandler) URL(java.net.URL) Stack(java.util.Stack) HashSet(java.util.HashSet)

Aggregations

File (java.io.File)9 HashSet (java.util.HashSet)9 Stack (java.util.Stack)9 TestInputHandler (org.apache.maven.plugins.repository.testutil.TestInputHandler)9 URL (java.net.URL)5 DefaultArtifactRepository (org.apache.maven.artifact.repository.DefaultArtifactRepository)5 DefaultRepositoryLayout (org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout)5 IOException (java.io.IOException)4 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)4