Package org.apache.maven.wagon.resource

Examples of org.apache.maven.wagon.resource.Resource


    }

    public void fillInputData( InputData inputData )
        throws TransferFailedException, ResourceDoesNotExistException
    {
        Resource resource = inputData.getResource();

        String content = (String) expectedContent.get( resource.getName() );
       
        if ( content != null )
        {
            resource.setContentLength( content.length() );
            resource.setLastModified( System.currentTimeMillis() );

            inputData.setInputStream( new StringInputStream( content ) );
        }
        else
        {
            throw new ResourceDoesNotExistException( "No content provided for " + resource.getName() );
        }
    }
View Full Code Here


        extends TransferEvent
    {
        public TransferEventMock()
            throws ConnectionException, AuthenticationException
        {
            super( new FileWagon(), new Resource(), TransferEvent.TRANSFER_INITIATED, TransferEvent.REQUEST_GET );
            getResource().setContentLength( 100000 );
            Repository repository = new Repository();
            getWagon().connect( repository );
        }
View Full Code Here

        }

        public TransferEventMock( Exception exception )
            throws ConnectionException, AuthenticationException
        {
            super( new FileWagon(), new Resource(), exception, TransferEvent.REQUEST_GET );
            getResource().setContentLength( 100000 );
            Repository repository = new Repository();
            getWagon().connect( repository );
        }
View Full Code Here

        if ( getRepository().getBasedir() == null )
        {
            throw new TransferFailedException( "Unable to operate with a null basedir." );
        }

        Resource resource = inputData.getResource();

        File file = new File( getRepository().getBasedir(), resource.getName() );

        if ( !file.exists() )
        {
            throw new ResourceDoesNotExistException( "File: " + file + " does not exist" );
        }

        try
        {
            InputStream in = new FileInputStream( file );

            inputData.setInputStream( in );

            resource.setContentLength( file.length() );

            resource.setLastModified( file.lastModified() );
        }
        catch ( FileNotFoundException e )
        {
            throw new TransferFailedException( "Could not read from file: " + file.getAbsolutePath(), e );
        }
View Full Code Here

        if ( getRepository().getBasedir() == null )
        {
            throw new TransferFailedException( "Unable to operate with a null basedir." );
        }
       
        Resource resource = outputData.getResource();

        File file = new File( getRepository().getBasedir(), resource.getName() );

        createParentDirectories( file );

        OutputStream outputStream = new LazyFileOutputStream( file );
View Full Code Here

    {

        public TransferEventMock()
            throws ConnectionException, AuthenticationException
        {
            super( new FileWagon(), new Resource(), TransferEvent.TRANSFER_INITIATED, TransferEvent.REQUEST_GET );
            getResource().setContentLength( 100000 );
            getResource().setName( "foo.bar" );
            Repository repository = new Repository();
            getWagon().connect( repository );
        }
View Full Code Here

        }

        public TransferEventMock( Exception exception )
            throws ConnectionException, AuthenticationException
        {
            super( new FileWagon(), new Resource(), exception, TransferEvent.REQUEST_GET );
            getResource().setContentLength( 100000 );
            getResource().setName( "foo.bar" );
            Repository repository = new Repository();
            getWagon().connect( repository );
        }
View Full Code Here

    public void testTransferProgress()
        throws Exception
    {
        byte[] buffer = new byte[1024];
        monitor.transferProgress( new TransferEventMock(new Resource(), 10000), buffer, 1024 );
        assertEquals("1/9K\r", new String(bout.toByteArray()));
    }
View Full Code Here

    public void testTransferProgressTwoFiles()
        throws Exception
    {
        byte[] buffer = new byte[2048];
        monitor.transferProgress( new TransferEventMock(new Resource("foo"), 10000), buffer, 1024 );
        assertEquals("1/9K\r", new String(bout.toByteArray()));
        bout.reset();
        monitor.transferProgress( new TransferEventMock(new Resource("bar"), 10000), buffer, 2048 );
        assertEquals("1/9K 2/9K\r", new String(bout.toByteArray()));
        bout.reset();
        monitor.transferProgress( new TransferEventMock(new Resource("bar"), 10000), buffer, 2048 );
        assertEquals("1/9K 4/9K\r", new String(bout.toByteArray()));
        bout.reset();
        monitor.transferProgress( new TransferEventMock(new Resource("foo"), 10000), buffer, 2048 );
        assertEquals("3/9K 4/9K\r", new String(bout.toByteArray()));
    }
View Full Code Here

        // This space left intentionally blank
    }

    public synchronized void transferProgress( TransferEvent transferEvent, byte[] buffer, int length )
    {
        Resource resource = transferEvent.getResource();
        if ( !downloads.containsKey( resource ) )
        {
            downloads.put( resource, new Long( length ) );
        }
        else
View Full Code Here

TOP

Related Classes of org.apache.maven.wagon.resource.Resource

Copyright © 2018 www.massapicom. 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.