Examples of Wagon


Examples of org.apache.maven.wagon.Wagon

    {
        setupRepositories();

        setupWagonTestingFixtures();

        Wagon wagon = getWagon();

        if ( wagon.supportsDirectoryCopy() )
        {
            // do the cleanup first
            File destDir = new File( getRepositoryDirectory(), "dirExists" );
            FileUtils.deleteDirectory(destDir);
            destDir.mkdirs();
            destDir = new File( destDir, "not_yet_existing/also_not" );

            File sourceDir = new File( getRepositoryDirectory(), "testDirectory" );

            FileUtils.deleteDirectory(sourceDir);
            sourceDir.mkdir();

            File testRes = new File( sourceDir, "test-resource-1.txt" );
            testRes.createNewFile();

            // This is the difference to our normal use case:
            // the directory specified in the repo string doesn't yet exist!

            testRepository.setUrl( testRepository.getUrl() + "/dirExists/not_yet_existing/also_not" );

            wagon.connect( testRepository, getAuthInfo() );

            wagon.putDirectory( sourceDir, "testDirectory" );

            destFile = FileTestUtils.createUniqueFile(getName(), getName());

            destFile.deleteOnExit();

            wagon.get( "testDirectory/test-resource-1.txt", destFile );

            wagon.disconnect();
        }

        tearDownWagonTestingFixtures();

View Full Code Here

Examples of org.apache.maven.wagon.Wagon

        File dummy = new File( "src/test/resources/dummy.txt" );
        FileUtils.copyFileToDirectory( dummy, sub );

        String url = getTestRepositoryUrl() + "/" + dir;
        Repository repo = new Repository( "foo", url );
        Wagon wagon = getWagon();
        wagon.connect( repo, getAuthInfo() );
        List<String> files = wagon.getFileList( subDir );
        assertNotNull( files );
        assertEquals( 1, files.size() );
        assertTrue( files.contains( "dummy.txt" ) );

        wagon.put( new File( "src/test/resources/dummy.txt" ), subDir + "/newdummy.txt" );

        files = wagon.getFileList( subDir );
        assertNotNull( files );
        assertEquals( 2, files.size() );
        assertTrue( files.contains( "dummy.txt" ) );
        assertTrue( files.contains( "newdummy.txt" ) );

        File sourceWithSpace = new File( "target/directory with spaces" );
        if ( sourceWithSpace.exists() )
        {
            FileUtils.deleteDirectory( sourceWithSpace );
        }
        File resources = new File( "src/test/resources" );

        FileUtils.copyDirectory( resources, sourceWithSpace );

        wagon.putDirectory( sourceWithSpace, "target with spaces" );

        files = wagon.getFileList( "target with spaces" );

        assertNotNull( files );
        assertTrue( files.contains( "dummy.txt" ) );
        assertFalse( files.contains( "newdummy.txt" ) );
        assertTrue( files.contains( "log4j.xml" ) );
View Full Code Here

Examples of org.apache.maven.wagon.Wagon

     * int)
    */
    public void testTransferEventProperties()
        throws ConnectionException, AuthenticationException
    {
        final Wagon wagon = (Wagon) MockControl.createControl( Wagon.class ).getMock();

        final Repository repo = new Repository();

        wagon.connect( repo );

        final long timestamp = System.currentTimeMillis();

        final Exception exception = new AuthenticationException( "dummy" );

View Full Code Here

Examples of org.apache.maven.wagon.Wagon

   */
    public void testSessionEventProperties()
        throws ConnectionException, AuthenticationException
    {

        final Wagon wagon = (Wagon) MockControl.createControl( Wagon.class ).getMock();
        final Repository repo = new Repository();

        wagon.connect( repo );

        final long timestamp = System.currentTimeMillis();
        final Exception exception = new AuthenticationException( "dummy" );

        SessionEvent event = new SessionEvent( wagon, SessionEvent.SESSION_CLOSED );
View Full Code Here

Examples of org.apache.maven.wagon.Wagon

        for ( int i = 0; i < dirnames.length; i++ )
        {
            new File( getDavRepository(), dirName + "/" + dirnames[i] ).mkdirs();
        }

        Wagon wagon = getWagon();

        wagon.connect( testRepository, getAuthInfo() );

        List<String> list = wagon.getFileList( dirName );

        assertNotNull( "file list should not be null.", list );
        assertEquals( "file list should contain 6 items", 6, list.size() );

        for ( int i = 0; i < filenames.length; i++ )
        {
            assertTrue( "Filename '" + filenames[i] + "' should be in list.", list.contains( filenames[i] ) );
        }

        for ( int i = 0; i < dirnames.length; i++ )
        {
            assertTrue( "Directory '" + dirnames[i] + "' should be in list.", list.contains( dirnames[i] + "/" ) );
        }

        ///////////////////////////////////////////////////////////////////////////
        list = wagon.getFileList( "" );
        assertNotNull( "file list should not be null.", list );
        assertEquals( "file list should contain 1 items", 1, list.size() );

        ///////////////////////////////////////////////////////////////////////////
        list = wagon.getFileList( dirName + "/test-dir1" );
        assertNotNull( "file list should not be null.", list );
        assertEquals( "file list should contain 0 items", 0, list.size() );

        /////////////////////////////////////////////////////////////////////////////
        try
        {
            list = wagon.getFileList( dirName + "/test-dir-bogus" );
            fail( "Exception expected" );
        }
        catch ( ResourceDoesNotExistException e )
        {

        }

        wagon.disconnect();

        tearDownWagonTestingFixtures();
    }
View Full Code Here

Examples of org.apache.maven.wagon.Wagon

        wagonFactory = mock( WagonFactory.class );

        storage.setWagonFactory( wagonFactory );

        Wagon wagon = new MockWagon();
        when( wagonFactory.getWagon( "wagon#http" ) ).thenReturn( wagon );
    }
View Full Code Here

Examples of org.apache.maven.wagon.Wagon

        {
            Repository repository = new Repository();

            repository.setProtocol( null );

            Wagon wagon = wagonManager.getWagon( repository );

            fail( "Expected :" + UnsupportedProtocolException.class.getName() );
        }
        catch ( UnsupportedProtocolException e )
        {
View Full Code Here

Examples of org.apache.maven.wagon.Wagon

    }

    private void assertWagon( String protocol )
        throws Exception
    {
        Wagon wagon = wagonManager.getWagon( protocol );

        assertNotNull( "Check wagon, protocol=" + protocol, wagon );
    }
View Full Code Here

Examples of org.apache.maven.wagon.Wagon

        File resource = new File( targetRepository.getLocation(), artifactPath );

        File workingDirectory = createWorkingDirectory( targetRepository.getLocation() );
        try
        {
            Wagon wagon = null;
            try
            {
                String protocol = getProtocol( remoteRepository.getUrl() );

                wagon = wagonFactory.getWagon( "wagon#" + protocol );
                if ( wagon == null )
                {
                    throw new RuntimeException( "Unsupported remote repository protocol: " + protocol );
                }

                boolean connected = connectToRepository( wagon, remoteRepository );
                if ( connected )
                {
                    tmpResource = new File( workingDirectory, filename );

                    if ( VersionUtil.isSnapshot( version ) )
                    {
                        // get the metadata first!
                        File tmpMetadataResource = new File( workingDirectory, METADATA_FILENAME );

                        String metadataPath = StringUtils.substringBeforeLast( artifactPath, "/" ) + "/" + METADATA_FILENAME;

                        wagon.get( metadataPath, tmpMetadataResource );

                        log.debug( "Successfully downloaded metadata." );

                        MavenRepositoryMetadata metadata = MavenRepositoryMetadataReader.read( tmpMetadataResource );

                        // re-adjust to timestamp if present, otherwise retain the original -SNAPSHOT filename
                        MavenRepositoryMetadata.Snapshot snapshotVersion = metadata.getSnapshotVersion();
                        String timestampVersion = version;
                        if ( snapshotVersion != null )
                        {
                            timestampVersion =
                                timestampVersion.substring( 0, timestampVersion.length() - 8 ); // remove SNAPSHOT from end
                            timestampVersion =
                                timestampVersion + snapshotVersion.getTimestamp() + "-" + snapshotVersion.getBuildNumber();

                            filename = artifactId + "-" + timestampVersion + ".pom";

                            artifactPath = pathTranslator.toPath( groupId, artifactId, version, filename );

                            log.debug( "New artifactPath : " + artifactPath );
                        }
                    }

                    log.info( "Retrieving " + artifactPath + " from " + remoteRepository.getName() );

                    wagon.get( artifactPath, tmpResource );

                    log.debug( "Downloaded successfully." );

                    tmpSha1 =
                        transferChecksum( wagon, remoteRepository, artifactPath, tmpResource, workingDirectory, ".sha1" );
                    tmpMd5 =
                        transferChecksum( wagon, remoteRepository, artifactPath, tmpResource, workingDirectory, ".md5" );
                }
            }
            finally
            {
                if ( wagon != null )
                {
                    try
                    {
                        wagon.disconnect();
                    }
                    catch ( ConnectionException e )
                    {
                        log.warn( "Unable to disconnect wagon.", e );
                    }
View Full Code Here

Examples of org.apache.maven.wagon.Wagon

        if ( protocol == null )
        {
            throw new UnsupportedProtocolException( "The repository " + repository + " does not specify a protocol" );
        }

        Wagon wagon = getWagon( protocol );

        configureWagon( wagon, repository.getId(), protocol );

        return wagon;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.