本文整理汇总了Java中org.apache.maven.wagon.providers.http.HttpWagon.get方法的典型用法代码示例。如果您正苦于以下问题:Java HttpWagon.get方法的具体用法?Java HttpWagon.get怎么用?Java HttpWagon.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.maven.wagon.providers.http.HttpWagon
的用法示例。
在下文中一共展示了HttpWagon.get方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: downloadWithRemoteRedirect
import org.apache.maven.wagon.providers.http.HttpWagon; //导入方法依赖的package包/类
@Test
public void downloadWithRemoteRedirect()
throws Exception
{
RemoteRepository remoteRepository = getRemoteRepositoriesService().getRemoteRepository( "central" );
remoteRepository.setUrl( "http://localhost:" + redirectPort );
getRemoteRepositoriesService().updateRemoteRepository( remoteRepository );
RoleManagementService roleManagementService = getRoleManagementService( authorizationHeader );
if ( !roleManagementService.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER,
"internal" ) )
{
roleManagementService.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, "internal" );
}
getUserService( authorizationHeader ).createGuestUser();
roleManagementService.assignRole( ArchivaRoleConstants.TEMPLATE_GUEST, "guest" );
roleManagementService.assignTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, "internal",
"guest" );
getUserService( authorizationHeader ).removeFromCache( "guest" );
Path file = Paths.get( "target/junit-4.9.jar" );
Files.deleteIfExists( file );
HttpWagon httpWagon = new HttpWagon();
httpWagon.connect( new Repository( "foo", "http://localhost:" + port ) );
httpWagon.get( "repository/internal/junit/junit/4.9/junit-4.9.jar", file.toFile() );
ZipFile zipFile = new ZipFile( file.toFile() );
List<String> entries = getZipEntriesNames( zipFile );
ZipEntry zipEntry = zipFile.getEntry( "org/junit/runners/JUnit4.class" );
assertNotNull( "cannot find zipEntry org/junit/runners/JUnit4.class, entries: " + entries + ", content is: "
+ FileUtils.readFileToString( file.toFile() ), zipEntry );
zipFile.close();
file.toFile().deleteOnExit();
}
示例2: downloadWithRemoteRedirect
import org.apache.maven.wagon.providers.http.HttpWagon; //导入方法依赖的package包/类
@Test
public void downloadWithRemoteRedirect()
throws Exception
{
RemoteRepository remoteRepository = getRemoteRepositoriesService().getRemoteRepository( "central" );
remoteRepository.setUrl( "http://localhost:" + redirectPort );
getRemoteRepositoriesService().updateRemoteRepository( remoteRepository );
RoleManagementService roleManagementService = getRoleManagementService( authorizationHeader );
if ( !roleManagementService.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER,
"internal" ) )
{
roleManagementService.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, "internal" );
}
getUserService( authorizationHeader ).createGuestUser();
roleManagementService.assignRole( ArchivaRoleConstants.TEMPLATE_GUEST, "guest" );
roleManagementService.assignTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, "internal",
"guest" );
getUserService( authorizationHeader ).removeFromCache( "guest" );
File file = new File( "target/junit-4.9.jar" );
if ( file.exists() )
{
file.delete();
}
HttpWagon httpWagon = new HttpWagon();
httpWagon.connect( new Repository( "foo", "http://localhost:" + port ) );
httpWagon.get( "/repository/internal/junit/junit/4.9/junit-4.9.jar", file );
ZipFile zipFile = new ZipFile( file );
List<String> entries = getZipEntriesNames( zipFile );
ZipEntry zipEntry = zipFile.getEntry( "org/junit/runners/JUnit4.class" );
assertNotNull( "cannot find zipEntry org/junit/runners/JUnit4.class, entries: " + entries + ", content is: "
+ FileUtils.readFileToString( file ), zipEntry );
zipFile.close();
file.deleteOnExit();
}
示例3: downloadSNAPSHOT
import org.apache.maven.wagon.providers.http.HttpWagon; //导入方法依赖的package包/类
@Test
public void downloadSNAPSHOT()
throws Exception
{
File tmpIndexDir = new File( System.getProperty( "java.io.tmpdir" ) + "/tmpIndex" );
if ( tmpIndexDir.exists() )
{
FileUtils.deleteDirectory( tmpIndexDir );
}
String id = Long.toString( System.currentTimeMillis() );
ManagedRepository managedRepository = new ManagedRepository();
managedRepository.setId( id );
managedRepository.setName( "name of " + id );
managedRepository.setLocation( System.getProperty( "basedir" ) + "/src/test/repositories/snapshot-repo" );
managedRepository.setIndexDirectory( System.getProperty( "java.io.tmpdir" ) + "/tmpIndex/" + id );
ManagedRepositoriesService managedRepositoriesService = getManagedRepositoriesService();
if ( managedRepositoriesService.getManagedRepository( id ) != null )
{
managedRepositoriesService.deleteManagedRepository( id, false );
}
getManagedRepositoriesService().addManagedRepository( managedRepository );
RoleManagementService roleManagementService = getRoleManagementService( authorizationHeader );
if ( !roleManagementService.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER,
id ) )
{
roleManagementService.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, id );
}
getUserService( authorizationHeader ).createGuestUser();
roleManagementService.assignRole( ArchivaRoleConstants.TEMPLATE_GUEST, "guest" );
roleManagementService.assignTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, id,
"guest" );
getUserService( authorizationHeader ).removeFromCache( "guest" );
File file = new File( "target/archiva-model-1.4-M4-SNAPSHOT.jar" );
if ( file.exists() )
{
file.delete();
}
HttpWagon httpWagon = new HttpWagon();
httpWagon.connect( new Repository( "foo", "http://localhost:" + port ) );
httpWagon.get( "/repository/"+ id +"/org/apache/archiva/archiva-model/1.4-M4-SNAPSHOT/archiva-model-1.4-M4-SNAPSHOT.jar", file );
ZipFile zipFile = new ZipFile( file );
List<String> entries = getZipEntriesNames( zipFile );
ZipEntry zipEntry = zipFile.getEntry( "org/apache/archiva/model/ArchivaArtifact.class" );
assertNotNull( "cannot find zipEntry org/apache/archiva/model/ArchivaArtifact.class, entries: " + entries + ", content is: "
+ FileUtils.readFileToString( file ), zipEntry );
zipFile.close();
file.deleteOnExit();
}
示例4: downloadSNAPSHOT
import org.apache.maven.wagon.providers.http.HttpWagon; //导入方法依赖的package包/类
@Test
public void downloadSNAPSHOT()
throws Exception
{
Path tmpIndexDir = Paths.get( System.getProperty( "java.io.tmpdir" ) + "/tmpIndex" );
if ( Files.exists(tmpIndexDir) )
{
org.apache.archiva.common.utils.FileUtils.deleteDirectory( tmpIndexDir );
}
String id = Long.toString( System.currentTimeMillis() );
ManagedRepository managedRepository = new ManagedRepository( Locale.getDefault());
managedRepository.setId( id );
managedRepository.setName( "name of " + id );
managedRepository.setLocation( System.getProperty( "basedir" ) + "/src/test/repositories/snapshot-repo" );
managedRepository.setIndexDirectory( System.getProperty( "java.io.tmpdir" ) + "/tmpIndex/" + id );
ManagedRepositoriesService managedRepositoriesService = getManagedRepositoriesService();
if ( managedRepositoriesService.getManagedRepository( id ) != null )
{
managedRepositoriesService.deleteManagedRepository( id, false );
}
getManagedRepositoriesService().addManagedRepository( managedRepository );
RoleManagementService roleManagementService = getRoleManagementService( authorizationHeader );
if ( !roleManagementService.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER,
id ) )
{
roleManagementService.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, id );
}
getUserService( authorizationHeader ).createGuestUser();
roleManagementService.assignRole( ArchivaRoleConstants.TEMPLATE_GUEST, "guest" );
roleManagementService.assignTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, id,
"guest" );
getUserService( authorizationHeader ).removeFromCache( "guest" );
Path file = Paths.get( "target/archiva-model-1.4-M4-SNAPSHOT.jar" );
Files.deleteIfExists(file);
HttpWagon httpWagon = new HttpWagon();
httpWagon.connect( new Repository( "foo", "http://localhost:" + port ) );
httpWagon.get( "/repository/"+ id +"/org/apache/archiva/archiva-model/1.4-M4-SNAPSHOT/archiva-model-1.4-M4-SNAPSHOT.jar", file.toFile() );
ZipFile zipFile = new ZipFile( file.toFile() );
List<String> entries = getZipEntriesNames( zipFile );
ZipEntry zipEntry = zipFile.getEntry( "org/apache/archiva/model/ArchivaArtifact.class" );
assertNotNull( "cannot find zipEntry org/apache/archiva/model/ArchivaArtifact.class, entries: " + entries + ", content is: "
+ FileUtils.readFileToString( file.toFile() ), zipEntry );
zipFile.close();
file.toFile().deleteOnExit();
}