org.apache.maven.wagon.Wagon Java Examples

The following examples show how to use org.apache.maven.wagon.Wagon. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NexusRepositoryIndexerImpl.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private WagonHelper.WagonFetcher createFetcher(final Wagon wagon, TransferListener listener, AuthenticationInfo authenticationInfo, ProxyInfo proxyInfo) {
    if(isDiag()) {
        return new WagonHelper.WagonFetcher(wagon, listener, authenticationInfo, proxyInfo) {
            @Override
            public InputStream retrieve(String name) throws IOException, FileNotFoundException {
                String id = wagon.getRepository().getId();
                if(name.contains("properties") && System.getProperty("maven.diag.index.properties." + id) != null) { // NOI18N
                    LOGGER.log(Level.INFO, "maven indexer will use local properties file: {0}", System.getProperty("maven.diag.index.properties." + id)); // NOI18N
                    return new FileInputStream(new File(System.getProperty("maven.diag.index.properties." + id))); // NOI18N
                } else if(name.contains(".gz") && System.getProperty("maven.diag.index.gz." + id) != null) { // NOI18N
                    LOGGER.log(Level.INFO, "maven indexer will use gz file: {0}", System.getProperty("maven.diag.index.gz." + id)); // NOI18N
                    return new FileInputStream(new File(System.getProperty("maven.diag.index.gz." + id))); // NOI18N
                }
                return super.retrieve(name);
            }
        };
    } else {
        return new WagonHelper.WagonFetcher(wagon, listener, authenticationInfo, proxyInfo);
    }
}
 
Example #2
Source File: RepositoryModelResolver.java    From archiva with Apache License 2.0 6 votes vote down vote up
/**
 *
 * @param wagon The wagon instance that should be connected.
 * @param remoteRepository The repository from where the checksum file should be retrieved
 * @param remotePath The remote path of the artifact (without extension)
 * @param resource The local artifact (without extension)
 * @param workingDir The working directory where the downloaded file should be placed to
 * @param ext The extension of th checksum file
 * @return The file where the data has been downloaded to.
 * @throws AuthorizationException
 * @throws TransferFailedException
 * @throws ResourceDoesNotExistException
 */
private Path transferChecksum( final Wagon wagon, final RemoteRepository remoteRepository,
                               final String remotePath, final Path resource,
                               final Path workingDir, final String ext )
    throws AuthorizationException, TransferFailedException, ResourceDoesNotExistException
{
    Path destFile = workingDir.resolve( resource.getFileName() + ext );
    String remoteChecksumPath = remotePath + ext;

    log.info( "Retrieving {} from {}", remoteChecksumPath, remoteRepository.getName() );

    wagon.get( addParameters( remoteChecksumPath, remoteRepository ), destFile.toFile() );

    log.debug( "Downloaded successfully." );

    return destFile;
}
 
Example #3
Source File: ManualWagonProvider.java    From furnace with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 * 
 * @see org.sonatype.aether.connector.wagon.WagonProvider#lookup(java.lang.String)
 */
@Override
public Wagon lookup(final String roleHint) throws Exception
{
   if (roleHint.equals(HTTP))
   {
      return setAuthenticator(new LightweightHttpWagon());
   }
   else if (roleHint.equals(HTTPS))
   {
      return setAuthenticator(new LightweightHttpsWagon());
   }
   else if (roleHint.equals(FILE))
   {
      return new FileWagon();
   }

   throw new RuntimeException("Role hint not supported: " + roleHint);
}
 
Example #4
Source File: DefaultVersionsHelperTest.java    From versions-maven-plugin with Apache License 2.0 6 votes vote down vote up
private DefaultVersionsHelper createHelper( String rulesUri, ArtifactMetadataSource metadataSource )
    throws MojoExecutionException
{
    final DefaultWagonManager wagonManager = new DefaultWagonManager()
    {
        public Wagon getWagon( Repository repository )
            throws UnsupportedProtocolException, WagonConfigurationException
        {
            return new FileWagon();
        }
    };

    DefaultVersionsHelper helper =
        new DefaultVersionsHelper( new DefaultArtifactFactory(), new DefaultArtifactResolver(), metadataSource, new ArrayList(),
                                   new ArrayList(),
                                   new DefaultArtifactRepository( "", "", new DefaultRepositoryLayout() ),
                                   wagonManager, new Settings(), "", rulesUri, mock( Log.class ), mock( MavenSession.class ),
                                   new DefaultPathTranslator());
    return helper;
}
 
Example #5
Source File: RepositorySystemFactory.java    From zeppelin with Apache License 2.0 5 votes vote down vote up
@Override
public Wagon lookup(String roleHint) throws Exception {
  if ("http".equals(roleHint)) {
    return new LightweightHttpWagon();
  }

  if ("https".equals(roleHint)) {
    return new HttpWagon();
  }

  return null;
}
 
Example #6
Source File: ArchivaIndexManagerMock.java    From archiva with Apache License 2.0 5 votes vote down vote up
private WagonResourceFetcher( Logger log, Path tempIndexDirectory, Wagon wagon,
                              RemoteRepository remoteRepository )
{
    this.log = log;
    this.tempIndexDirectory = tempIndexDirectory;
    this.wagon = wagon;
    this.remoteRepository = remoteRepository;
}
 
Example #7
Source File: BootstrapWagonProvider.java    From quarkus with Apache License 2.0 5 votes vote down vote up
@Override
public Wagon lookup(String roleHint) throws Exception {
    String impl = null;
    switch (roleHint) {
        case "https":
        case "http":
            impl = "org.apache.maven.wagon.providers.http.HttpWagon";
            break;
        case "file":
            impl = "org.apache.maven.wagon.providers.file.FileWagon";
            break;
        case "ftp":
            impl = "org.apache.maven.wagon.providers.ftp.FtpWagon";
            break;
        case "ftps":
            impl = "org.apache.maven.wagon.providers.ftp.FtpsWagon";
            break;
        case "ftph":
            impl = "org.apache.maven.wagon.providers.ftp.FtpHttpWagon";
            break;
        case "scm":
            impl = "org.apache.maven.wagon.providers.scm.ScmWagon";
            break;
        default:
            throw new IllegalStateException("Not supported Wagon implementation hint " + roleHint);
    }
    final Class<?> cls = loadClass(impl, roleHint);
    final Object wagon;
    try {
        wagon = cls.newInstance();
    } catch (Throwable t) {
        throw new IllegalStateException("Failed to instantiate Wagon impl " + impl, t);
    }
    return Wagon.class.cast(wagon);
}
 
Example #8
Source File: ArchivaIndexManagerMock.java    From archiva with Apache License 2.0 5 votes vote down vote up
private WagonResourceFetcher( Logger log, Path tempIndexDirectory, Wagon wagon,
                              RemoteRepository remoteRepository )
{
    this.log = log;
    this.tempIndexDirectory = tempIndexDirectory;
    this.wagon = wagon;
    this.remoteRepository = remoteRepository;
}
 
Example #9
Source File: WagonUtils.java    From versions-maven-plugin with Apache License 2.0 5 votes vote down vote up
/**
 * Convenience method to create a wagon.
 *
 * @param serverId The serverId to use if the wagonManager needs help.
 * @param url The url to create a wagon for.
 * @param wagonManager The wgaon manager to use.
 * @param settings The settings to use.
 * @param logger The logger to use.
 * @return The wagon to connect to the url.
 * @throws org.apache.maven.wagon.UnsupportedProtocolException if the protocol is not supported.
 * @throws org.apache.maven.artifact.manager.WagonConfigurationException if the wagon cannot be configured.
 * @throws org.apache.maven.wagon.ConnectionException If the connection cannot be established.
 * @throws org.apache.maven.wagon.authentication.AuthenticationException If the connection cannot be authenticated.
 */
public static Wagon createWagon( String serverId, String url, WagonManager wagonManager, Settings settings,
                                 Log logger )
                                     throws UnsupportedProtocolException, WagonConfigurationException,
                                     ConnectionException, AuthenticationException
{
    Repository repository = new Repository( serverId, url );
    Wagon wagon = wagonManager.getWagon( repository );

    if ( logger.isDebugEnabled() )
    {
        Debug debug = new Debug();
        wagon.addSessionListener( debug );
        wagon.addTransferListener( debug );
    }

    ProxyInfo proxyInfo = getProxyInfo( settings );
    if ( proxyInfo != null )
    {
        wagon.connect( repository, wagonManager.getAuthenticationInfo( repository.getId() ), proxyInfo );
    }
    else
    {
        wagon.connect( repository, wagonManager.getAuthenticationInfo( repository.getId() ) );
    }
    return wagon;
}
 
Example #10
Source File: DefaultVersionsHelper.java    From versions-maven-plugin with Apache License 2.0 5 votes vote down vote up
@Deprecated
private static RuleSet getRuleSet( Wagon wagon, String remoteURI )
    throws IOException, AuthorizationException, TransferFailedException, ResourceDoesNotExistException
{
    File tempFile = File.createTempFile( "ruleset", ".xml" );
    try
    {
        wagon.get( remoteURI, tempFile );
        InputStream is = new FileInputStream(tempFile );
        try
        {
            return readRulesFromStream(is);
        }
        finally
        {
            try
            {
                is.close();
            }
            catch ( IOException e )
            {
                // ignore
            }
        }
    }
    finally
    {
        if ( !tempFile.delete() )
        {
            // maybe we can delete this later
            tempFile.deleteOnExit();
        }
    }
}
 
Example #11
Source File: MavenIndexManager.java    From archiva with Apache License 2.0 5 votes vote down vote up
private WagonResourceFetcher( Logger log, Path tempIndexDirectory, Wagon wagon,
                              RemoteRepository remoteRepository )
{
    this.log = log;
    this.tempIndexDirectory = tempIndexDirectory;
    this.wagon = wagon;
    this.remoteRepository = remoteRepository;
}
 
Example #12
Source File: DownloadRemoteIndexTask.java    From archiva with Apache License 2.0 5 votes vote down vote up
private WagonResourceFetcher( Logger log, Path tempIndexDirectory, Wagon wagon,
                              RemoteRepository remoteRepository )
{
    this.log = log;
    this.tempIndexDirectory = tempIndexDirectory;
    this.wagon = wagon;
    this.remoteRepository = remoteRepository;
}
 
Example #13
Source File: StaticWagonConfigurator.java    From spring-cloud-deployer with Apache License 2.0 5 votes vote down vote up
@Override
public void configure(Wagon wagon, Object configuration) throws Exception {
	log.debug("Configuring wagon {} with {}", wagon, configuration);
	if (wagon instanceof HttpWagon && configuration instanceof MavenProperties.Wagon) {
		HttpWagon httpWagon = (HttpWagon)wagon;
		Map<WagonHttpMethod, WagonHttpMethodProperties> httpMethodProperties = ((MavenProperties.Wagon) configuration)
				.getHttp();
		HttpConfiguration httpConfiguration = new HttpConfiguration();
		for (Entry<WagonHttpMethod, WagonHttpMethodProperties> entry : httpMethodProperties.entrySet()) {
			switch (entry.getKey()) {
				case all:
					httpConfiguration.setAll(buildConfig(entry.getValue()));
					break;
				case get:
					httpConfiguration.setGet(buildConfig(entry.getValue()));
					break;
				case head:
					httpConfiguration.setHead(buildConfig(entry.getValue()));
					break;
				case put:
					httpConfiguration.setPut(buildConfig(entry.getValue()));
					break;
				default:
					break;
			}
		}
		httpWagon.setHttpConfiguration(httpConfiguration);
	}
}
 
Example #14
Source File: DefaultWagonFactory.java    From archiva with Apache License 2.0 5 votes vote down vote up
@Override
public Wagon getWagon( WagonFactoryRequest wagonFactoryRequest )
    throws WagonFactoryException
{
    try
    {
        String protocol = StringUtils.startsWith( wagonFactoryRequest.getProtocol(), "wagon#" )
            ? wagonFactoryRequest.getProtocol()
            : "wagon#" + wagonFactoryRequest.getProtocol();

        // if it's a ntlm proxy we have to lookup the wagon light which support thats
        // wagon http client doesn't support that
        if ( wagonFactoryRequest.getNetworkProxy() != null && wagonFactoryRequest.getNetworkProxy().isUseNtlm() )
        {
            protocol = protocol + "-ntlm";
        }

        Wagon wagon = applicationContext.getBean( protocol, Wagon.class );
        wagon.addTransferListener( debugTransferListener );
        configureUserAgent( wagon, wagonFactoryRequest );
        return wagon;
    }
    catch ( BeansException e )
    {
        throw new WagonFactoryException( e.getMessage(), e );
    }
}
 
Example #15
Source File: StaticWagonProvider.java    From spring-cloud-deployer with Apache License 2.0 5 votes vote down vote up
public Wagon lookup( String roleHint ) throws Exception {
	log.debug("Looking up wagon for roleHint {}", roleHint);
	if ("https".equals(roleHint)) {
		return new HttpWagon();
	} else if ("http".equals(roleHint)) {
		return new HttpWagon();
	}
	throw new IllegalArgumentException("No wagon available for " + roleHint);
}
 
Example #16
Source File: ArchivaIndexManagerMock.java    From archiva with Apache License 2.0 5 votes vote down vote up
private WagonResourceFetcher( Logger log, Path tempIndexDirectory, Wagon wagon,
                              RemoteRepository remoteRepository )
{
    this.log = log;
    this.tempIndexDirectory = tempIndexDirectory;
    this.wagon = wagon;
    this.remoteRepository = remoteRepository;
}
 
Example #17
Source File: AbstractDeployMojo.java    From opoopress with Apache License 2.0 5 votes vote down vote up
private static void chmod(final Wagon wagon, final Repository repository,
                          final String chmodOptions, final String chmodMode)
        throws MojoExecutionException {
    try {
        if (wagon instanceof CommandExecutor) {
            CommandExecutor exec = (CommandExecutor) wagon;
            exec.executeCommand("chmod " + chmodOptions + " " + chmodMode + " " + repository.getBasedir());
        }
        // else ? silently ignore, FileWagon is not a CommandExecutor!
    } catch (CommandExecutionException e) {
        throw new MojoExecutionException("Error uploading site", e);
    }
}
 
Example #18
Source File: AbstractDeployMojo.java    From opoopress with Apache License 2.0 5 votes vote down vote up
/**
 * @param wagon
 * @param log
 */
private static void configureLog(Wagon wagon, Log log) {
    try {
        Method method = wagon.getClass().getMethod("setLog", Log.class);
        method.invoke(wagon, log);
        log.info("Set log for wagon: " + wagon);
    } catch (Exception e) {
        log.debug("Wagon does not supports setLog() method.");
    }
}
 
Example #19
Source File: IndexQuerier.java    From sling-whiteboard with Apache License 2.0 5 votes vote down vote up
public IndexQuerier() throws PlexusContainerException, ComponentLookupException {

        DefaultContainerConfiguration config = new DefaultContainerConfiguration();
        config.setClassPathScanning(PlexusConstants.SCANNING_INDEX);

        this.plexusContainer = new DefaultPlexusContainer(config);

        // lookup the indexer components from plexus
        this.indexer = plexusContainer.lookup(Indexer.class);
        this.indexUpdater = plexusContainer.lookup(IndexUpdater.class);
        // lookup wagon used to remotely fetch index
        this.httpWagon = plexusContainer.lookup(Wagon.class, "https");
    }
 
Example #20
Source File: MavenRepositoryProxyHandler.java    From archiva with Apache License 2.0 4 votes vote down vote up
protected void transferArtifact( Wagon wagon, RemoteRepository remoteRepository, String remotePath,
                                 Path resource,
                                 StorageAsset destFile )
        throws ProxyException {
    transferSimpleFile(wagon, remoteRepository, remotePath, resource, destFile.getFilePath());
}
 
Example #21
Source File: Maven2RepositoryMetadataResolverMRM1411RepoGroupTest.java    From archiva with Apache License 2.0 4 votes vote down vote up
@Before
@Override
public void setUp()
    throws Exception
{
    super.setUp();

    c = new Configuration();

    testRepo = new ManagedRepositoryConfiguration();
    testRepo.setId( TEST_REPO_ID );
    testRepo.setLocation( Paths.get( "target/test-repository" ).toAbsolutePath().toString() );
    testRepo.setReleases( true );
    testRepo.setSnapshots( false );
    c.addManagedRepository( testRepo );

    testRepoS = new ManagedRepositoryConfiguration();
    testRepoS.setId( TEST_SNAP_REPO_ID );
    testRepoS.setLocation( Paths.get( "target/test-repositorys" ).toAbsolutePath().toString() );
    testRepoS.setReleases( false );
    testRepoS.setSnapshots( true );
    c.addManagedRepository( testRepoS );

    RemoteRepositoryConfiguration testRemoteRepo = new RemoteRepositoryConfiguration();
    testRemoteRepo.setId( TEST_REMOTE_REPO_ID );
    testRemoteRepo.setLayout( "default" );
    testRemoteRepo.setName( "Central Repository" );
    testRemoteRepo.setUrl( "http://central.repo.com/maven2" );
    testRemoteRepo.setTimeout( 10 );
    c.addRemoteRepository( testRemoteRepo );

    ProxyConnectorConfiguration proxyConnector = new ProxyConnectorConfiguration();
    proxyConnector.setSourceRepoId( TEST_REPO_ID );
    proxyConnector.setTargetRepoId( TEST_REMOTE_REPO_ID );
    proxyConnector.setDisabled( false );
    c.addProxyConnector( proxyConnector );

    ProxyConnectorConfiguration proxyConnectors = new ProxyConnectorConfiguration();
    proxyConnectors.setSourceRepoId( TEST_SNAP_REPO_ID );
    proxyConnectors.setTargetRepoId( TEST_REMOTE_REPO_ID );
    proxyConnectors.setDisabled( false );
    c.addProxyConnector( proxyConnectors );

    List<String> repos = new ArrayList<>();
    repos.add( TEST_REPO_ID );
    repos.add( TEST_SNAP_REPO_ID );

    RepositoryGroupConfiguration repoGroup = new RepositoryGroupConfiguration();
    repoGroup.setId( TEST_REPO_GROUP_ID );
    repoGroup.setRepositories( repos );
    c.addRepositoryGroup( repoGroup );

    configuration.save( c );
    repositoryRegistry.reload();

    assertFalse( c.getManagedRepositories().get( 0 ).isSnapshots() );
    assertTrue( c.getManagedRepositories().get( 0 ).isReleases() );

    assertTrue( c.getManagedRepositories().get( 1 ).isSnapshots() );
    assertFalse( c.getManagedRepositories().get( 1 ).isReleases() );

    wagonFactory = mock( WagonFactory.class );

    storage.setWagonFactory( wagonFactory );

    Wagon wagon = new MockWagon();
    when( wagonFactory.getWagon( new WagonFactoryRequest().protocol( "wagon#http" ) ) ).thenReturn( wagon );
}
 
Example #22
Source File: Maven2RepositoryMetadataResolverMRM1411Test.java    From archiva with Apache License 2.0 4 votes vote down vote up
@Before
@Override
public void setUp()
    throws Exception
{
    super.setUp();

    c = new Configuration();
    testRepo = new ManagedRepositoryConfiguration();
    testRepo.setId( TEST_REPO_ID );
    testRepo.setLocation( Paths.get( "target/test-repository" ).toAbsolutePath().toString() );
    testRepo.setReleases( true );
    testRepo.setSnapshots( true );
    c.addManagedRepository( testRepo );

    RemoteRepositoryConfiguration testRemoteRepo = new RemoteRepositoryConfiguration();
    testRemoteRepo.setId( TEST_REMOTE_REPO_ID );
    testRemoteRepo.setLayout( "default" );
    testRemoteRepo.setName( "Central Repository" );
    testRemoteRepo.setUrl( "http://central.repo.com/maven2" );
    testRemoteRepo.setTimeout( 10 );
    c.addRemoteRepository( testRemoteRepo );

    ProxyConnectorConfiguration proxyConnector = new ProxyConnectorConfiguration();
    proxyConnector.setSourceRepoId( TEST_REPO_ID );
    proxyConnector.setTargetRepoId( TEST_REMOTE_REPO_ID );
    proxyConnector.setDisabled( false );
    c.addProxyConnector( proxyConnector );

    configuration.save( c );

    repositoryRegistry.reload();

    assertTrue( c.getManagedRepositories().get( 0 ).isSnapshots() );
    assertTrue( c.getManagedRepositories().get( 0 ).isReleases() );

    wagonFactory = mock( WagonFactory.class );

    storage.setWagonFactory( wagonFactory );

    Wagon wagon = new MockWagon();
    when( wagonFactory.getWagon(
        new WagonFactoryRequest( "wagon#http", new HashMap<String, String>() ) ) ).thenReturn( wagon );
}
 
Example #23
Source File: Maven2RepositoryMetadataResolverTest.java    From archiva with Apache License 2.0 4 votes vote down vote up
@Before
@Override
public void setUp()
    throws Exception
{
    super.setUp();

    c = new Configuration();

    c.setVersion("2.0");
    testRepo = new ManagedRepositoryConfiguration();
    testRepo.setId( TEST_REPO_ID );
    testRepo.setLocation( Paths.get( "target/test-repository" ).toAbsolutePath().toString() );
    testRepo.setReleases( true );
    testRepo.setSnapshots( true );
    c.addManagedRepository( testRepo );

    RemoteRepositoryConfiguration testRemoteRepo = new RemoteRepositoryConfiguration();
    testRemoteRepo.setId( TEST_REMOTE_REPO_ID );
    testRemoteRepo.setLayout( "default" );
    testRemoteRepo.setName( "Central Repository" );
    testRemoteRepo.setUrl( "http://central.repo.com/maven2" );
    testRemoteRepo.setTimeout( 10 );
    c.addRemoteRepository( testRemoteRepo );

    ProxyConnectorConfiguration proxyConnector = new ProxyConnectorConfiguration();
    proxyConnector.setSourceRepoId( TEST_REPO_ID );
    proxyConnector.setTargetRepoId( TEST_REMOTE_REPO_ID );
    proxyConnector.setDisabled( false );
    c.addProxyConnector( proxyConnector );

    RepositoryScanningConfiguration scCfg = new RepositoryScanningConfiguration();
    c.setRepositoryScanning(scCfg);

    configuration.save( c );
    assertFalse(configuration.isDefaulted());
    repositoryRegistry.reload();

    assertTrue( c.getManagedRepositories().get( 0 ).isSnapshots() );
    assertTrue( c.getManagedRepositories().get( 0 ).isReleases() );

    wagonFactory = mock( WagonFactory.class );

    storage.setWagonFactory( wagonFactory );

    Wagon wagon = new MockWagon();
    when( wagonFactory.getWagon( new WagonFactoryRequest().protocol( "wagon#http" ) ) ).thenReturn( wagon );
}
 
Example #24
Source File: ManualWagonProvider.java    From furnace with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 * 
 * @see org.sonatype.aether.connector.wagon.WagonProvider#release(org.apache.maven.wagon.Wagon)
 */
@Override
public void release(final Wagon wagon)
{
   // NO-OP
}
 
Example #25
Source File: WagonFactoryTest.java    From archiva with Apache License 2.0 4 votes vote down vote up
@Test
public void testLookupSuccessiveWagons()
    throws Exception
{

    Wagon first = factory.getWagon( new org.apache.archiva.proxy.maven.WagonFactoryRequest().protocol( "wagon#file" ) );

    Wagon second = factory.getWagon( new org.apache.archiva.proxy.maven.WagonFactoryRequest().protocol( "wagon#file" ) );

    // ensure we support only protocol name too
    Wagon third = factory.getWagon( new WagonFactoryRequest().protocol( "file" ) );

    assertNotSame( first, second );

    assertNotSame( first, third );
}
 
Example #26
Source File: WagonDelegate.java    From archiva with Apache License 2.0 4 votes vote down vote up
public void setDelegate( Wagon delegate )
{
    this.delegate = delegate;
}
 
Example #27
Source File: AbstractProxyTestCase.java    From archiva with Apache License 2.0 4 votes vote down vote up
@Before
public void setUp()
    throws Exception
{
    config =
        (MockConfiguration) applicationContext.getBean( "archivaConfiguration#mock", ArchivaConfiguration.class );

    config.getConfiguration().setManagedRepositories( new ArrayList<ManagedRepositoryConfiguration>() );
    config.getConfiguration().setRemoteRepositories( new ArrayList<RemoteRepositoryConfiguration>() );
    config.getConfiguration().setProxyConnectors( new ArrayList<ProxyConnectorConfiguration>() );
    ArchivaRuntimeConfiguration runtimeConfiguration = new ArchivaRuntimeConfiguration();
    List<String> checksumTypes = new ArrayList<>();
    checksumTypes.add("md5");
    checksumTypes.add("sha256");
    checksumTypes.add("sha1");
    checksumTypes.add("asc");
    runtimeConfiguration.setChecksumTypes(checksumTypes);
    config.getConfiguration().setArchivaRuntimeConfiguration(runtimeConfiguration);
    repositoryRegistry.setArchivaConfiguration( config );

    // Setup source repository (using default layout)
    String name = getClass().getSimpleName();
    Path repoPath = Paths.get("target/test-repository/managed/" + name);

    managedDefaultRepository =
        createRepository( ID_DEFAULT_MANAGED, "Default Managed Repository", repoPath.toString(), "default" );

    managedDefaultDir = repoPath.resolve(ID_DEFAULT_MANAGED) ;

    org.apache.archiva.repository.ManagedRepository repoConfig = repositoryRegistry.getManagedRepository(ID_DEFAULT_MANAGED);

    // Setup target (proxied to) repository.
    saveRemoteRepositoryConfig( ID_PROXIED1, "Proxied Repository 1",
        Paths.get( REPOPATH_PROXIED1 ).toUri().toURL().toExternalForm(), "default" );

    // Setup target (proxied to) repository.
    saveRemoteRepositoryConfig( ID_PROXIED2, "Proxied Repository 2",
        Paths.get( REPOPATH_PROXIED2 ).toUri().toURL().toExternalForm(), "default" );


    repositoryRegistry.reload();
    repositoryRegistry.putRepository(repoConfig);


    // Setup the proxy handler.
    //proxyHandler = applicationContext.getBean (RepositoryProxyHandler) lookup( RepositoryProxyHandler.class.getName() );

    proxyHandler = applicationContext.getBean( "repositoryProxyHandler#test", RepositoryProxyHandler.class );
    assertNotNull( proxyRegistry );
    assertTrue(proxyRegistry.getAllHandler( ).get( RepositoryType.MAVEN).contains( proxyHandler ));


    // Setup the wagon mock.
    wagonMockControl = EasyMock.createNiceControl();
    wagonMock = wagonMockControl.createMock( Wagon.class );

    delegate = (WagonDelegate) applicationContext.getBean( "wagon#http", Wagon.class );

    delegate.setDelegate( wagonMock );

    CacheManager.getInstance().clearAll();

    log.info( "\n.\\ {}() \\._________________________________________\n", name );
}
 
Example #28
Source File: RemoteExistsMojo.java    From exists-maven-plugin with Apache License 2.0 4 votes vote down vote up
Wagon connectWagon(String serverId, String url) throws Exception {
  Repository repository = new Repository(serverId, url);
  Wagon wagon = container.lookup(Wagon.class, repository.getProtocol());
  wagon.connect(repository, getAuthInfo(serverId), getProxyInfo());
  return wagon;
}
 
Example #29
Source File: StaticWagonProvider.java    From spring-cloud-deployer with Apache License 2.0 4 votes vote down vote up
public void release(Wagon wagon) {
	// nothing to do now
}
 
Example #30
Source File: AbstractWagonTest.java    From lambadaframework with MIT License 4 votes vote down vote up
@Test
public void timeOut() {
    assertEquals(Wagon.DEFAULT_CONNECTION_TIMEOUT, this.wagon.getTimeout());
    this.wagon.setTimeout(Integer.MAX_VALUE);
    assertEquals(Integer.MAX_VALUE, this.wagon.getTimeout());
}