import org.codehaus.plexus.archiver.zip.ZipArchiver; //导入方法依赖的package包/类
@Test
public void testWithValidRoboconfDependencies() throws Exception {
// Prepare the project
final String projectName = "project--valid";
File baseDir = this.resources.getBasedir( projectName );
Assert.assertNotNull( baseDir );
Assert.assertTrue( baseDir.isDirectory());
AbstractMojo mojo = findMojo( projectName, "resolve" );
this.rule.setVariableValueToObject( mojo, "repoSystem", newRepositorySystem());
this.rule.setVariableValueToObject( mojo, "repositories", new ArrayList( 0 ));
// Create a Roboconf application
File dir = this.folder.newFolder();
File targetZipFile = this.folder.newFile();
Assert.assertTrue( targetZipFile.delete());
CreationBean bean = new CreationBean()
.projectDescription( "some desc" ).projectName( "my-project" )
.groupId( "net.roboconf" ).projectVersion( "1.0-SNAPSHOT" ).mavenProject( false );
ProjectUtils.createProjectSkeleton( dir, bean );
ZipArchiver zipArchiver = new ZipArchiver();
zipArchiver.addDirectory( dir );
zipArchiver.setCompress( true );
zipArchiver.setDestFile( targetZipFile );
zipArchiver.createArchive();
Assert.assertTrue( targetZipFile.isFile());
// Add dependencies
MavenProject project = (MavenProject) this.rule.getVariableValueFromObject( mojo, "project" );
project.setDependencyArtifacts( new HashSet ());
Artifact rbcfArtifact3 = new DefaultArtifact( "net.roboconf", "roboconf-core", "0.2", "runtime", "jar", null, new DefaultArtifactHandler());
rbcfArtifact3.setFile( targetZipFile );
project.getDependencyArtifacts().add( rbcfArtifact3 );
// Add it to our "local" repository
this.artifactIdToArtifact.put( rbcfArtifact3.getArtifactId(), rbcfArtifact3 );
// Execute it
File targetDir = new File( baseDir, MavenPluginConstants.TARGET_MODEL_DIRECTORY + "/" + Constants.PROJECT_DIR_GRAPH );
Assert.assertFalse( targetDir.isDirectory());
mojo.execute();
// Verify the import was copied in the right location
File importDir = new File( targetDir, "net.roboconf/roboconf-core" );
Assert.assertTrue( importDir.isDirectory());
Assert.assertTrue( new File( importDir, "main.graph" ).isFile());
}