blob: 2b6943ece609463326c7f30c7023005814a50eca [file] [log] [blame]
package org.apache.maven.plugins.repository.it;
import static org.apache.maven.plugins.repository.it.support.IntegrationTestUtils.bootstrap;
import static org.apache.maven.plugins.repository.it.support.IntegrationTestUtils.getCliPluginPrefix;
import static org.apache.maven.plugins.repository.it.support.IntegrationTestUtils.getTestDir;
import static org.apache.maven.plugins.repository.testutil.Assertions.assertZipContents;
import org.apache.maven.it.VerificationException;
import org.apache.maven.it.Verifier;
import org.apache.maven.plugins.repository.testutil.Assertions;
import org.junit.BeforeClass;
import org.junit.Test;
import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public class BundlePackIT
{
@BeforeClass
public static void doBootstrap()
throws VerificationException, IOException, URISyntaxException
{
bootstrap();
}
@SuppressWarnings( "unchecked" )
@Test
public void packWithSCMInfoProvided()
throws IOException, URISyntaxException, VerificationException
{
File dir = getTestDir( "bundle-pack" );
String prefix = getCliPluginPrefix();
String artifactId = "bundle-pack-target";
String groupId = "org.apache.maven.its.repository";
String version = "1.0";
File bundleSource = new File( dir, artifactId + "-" + version + "-bundle.jar" );
if ( bundleSource.exists() )
{
bundleSource.delete();
}
Verifier verifier = new Verifier( dir.getAbsolutePath() );
verifier.setAutoclean( false );
List<String> cliOptions = verifier.getCliOptions();
cliOptions.add( "-DgroupId=" + groupId );
cliOptions.add( "-DartifactId=" + artifactId );
cliOptions.add( "-Dversion=" + version );
verifier.executeGoal( prefix + "bundle-pack" );
verifier.verifyErrorFreeLog();
verifier.resetStreams();
Set<String> requiredEntries = new HashSet<String>();
requiredEntries.add( "pom.xml" );
requiredEntries.add( artifactId + "-" + version + ".jar" );
if ( !verifier.isMavenDebug() )
{
bundleSource.deleteOnExit();
}
assertZipContents( requiredEntries, Assertions.EMPTY_ENTRY_NAMES, bundleSource );
}
@SuppressWarnings( "unchecked" )
@Test
public void packWithSCMInfoMissing()
throws IOException, URISyntaxException, VerificationException
{
File dir = getTestDir( "bundle-pack" );
String prefix = getCliPluginPrefix();
String artifactId = "bundle-pack-target-no-scm";
String groupId = "org.apache.maven.its.repository";
String version = "1.0";
File bundleSource = new File( dir, artifactId + "-" + version + "-bundle.jar" );
if ( bundleSource.exists() )
{
bundleSource.delete();
}
Verifier verifier = new Verifier( dir.getAbsolutePath() );
verifier.setAutoclean( false );
List<String> cliOptions = verifier.getCliOptions();
cliOptions.add( "-DgroupId=" + groupId );
cliOptions.add( "-DartifactId=" + artifactId );
cliOptions.add( "-Dversion=" + version );
cliOptions.add( "-DscmUrl=http://foo/" );
cliOptions.add( "-DscmConnection=scm:svn:http://foo/" );
verifier.executeGoal( prefix + "bundle-pack" );
verifier.verifyErrorFreeLog();
verifier.resetStreams();
Set<String> requiredEntries = new HashSet<String>();
requiredEntries.add( "pom.xml" );
requiredEntries.add( artifactId + "-" + version + ".jar" );
if ( !verifier.isMavenDebug() )
{
bundleSource.deleteOnExit();
}
assertZipContents( requiredEntries, Assertions.EMPTY_ENTRY_NAMES, bundleSource );
}
}