Examples of IndexingContext


Examples of org.apache.maven.index.context.IndexingContext

        basedir.delete();
        basedir.mkdirs();

        try
        {
            IndexingContext ctx = newTestContext( basedir, baseUrl + "slow/" );

            IndexUpdateRequest updateRequest =
                new IndexUpdateRequest( ctx, wagonHelper.getWagonResourceFetcher( new TransferListenerFixture(),
                    new AuthenticationInfo()
                    {
                        private static final long serialVersionUID = 1L;

                        {
                            setUserName( "user" );
                            setPassword( "password" );
                        }
                    }, null ) );

            updater.fetchAndUpdateIndex( updateRequest );
           
            ctx.close( false );
        }
        finally
        {
            try
            {
View Full Code Here

Examples of org.apache.maven.index.context.IndexingContext

        basedir.delete();
        basedir.mkdirs();

        try
        {
            IndexingContext ctx = newTestContext( basedir, baseUrl + "slow/" );

            IndexUpdateRequest updateRequest =
                new IndexUpdateRequest( ctx, wagonHelper.getWagonResourceFetcher( new TransferListenerFixture()
                {
                    @Override
                    public void transferError( final TransferEvent transferEvent )
                    {
                    }
                }, new AuthenticationInfo()
                {
                    private static final long serialVersionUID = 1L;

                    {
                        setUserName( "user" );
                        setPassword( "password" );
                    }
                }, null ) );

            // ResourceFetcher fetcher =
            // new JettyResourceFetcher().setConnectionTimeoutMillis( 100 ).setAuthenticationInfo(
            // updateRequest.getAuthenticationInfo() ).addTransferListener( updateRequest.getTransferListener() );

            try
            {
                updater.fetchAndUpdateIndex( updateRequest );
                fail( "Should timeout and throw IOException." );
            }
            catch ( IOException e )
            {
                System.out.println( "Operation timed out due to short connection timeout, as expected." );
            }
           
            ctx.close( false );
        }
        finally
        {
            try
            {
View Full Code Here

Examples of org.apache.maven.index.context.IndexingContext

        basedir.delete();
        basedir.mkdirs();

        try
        {
            IndexingContext ctx = newTestContext( basedir, baseUrl + "slow/" );

            IndexUpdateRequest updateRequest =
                new IndexUpdateRequest( ctx, wagonHelper.getWagonResourceFetcher( new TransferListenerFixture()
                {
                    @Override
                    public void transferError( final TransferEvent transferEvent )
                    {
                    }
                }, new AuthenticationInfo()
                {
                    private static final long serialVersionUID = 1L;

                    {
                        setUserName( "user" );
                        setPassword( "password" );
                    }
                }, null ) );

            // ResourceFetcher fetcher =
            // new JettyResourceFetcher().setTransactionTimeoutMillis( 100 ).setAuthenticationInfo(
            // updateRequest.getAuthenticationInfo() ).addTransferListener( updateRequest.getTransferListener() );

            try
            {
                updater.fetchAndUpdateIndex( updateRequest );
                fail( "Should timeout and throw IOException." );
            }
            catch ( IOException e )
            {
                System.out.println( "Operation timed out due to short transaction timeout, as expected." );
            }
           
            ctx.close( false );
        }
        finally
        {
            try
            {
View Full Code Here

Examples of org.apache.maven.index.context.IndexingContext

        basedir.delete();
        basedir.mkdirs();

        try
        {
            IndexingContext ctx = newTestContext( basedir, baseUrl + "redirect-trap/" );

            IndexUpdateRequest updateRequest =
                new IndexUpdateRequest( ctx, wagonHelper.getWagonResourceFetcher( new TransferListenerFixture()
                {
                    @Override
                    public void transferError( final TransferEvent transferEvent )
                    {
                    }
                }, null, null ) );

            try
            {
                updater.fetchAndUpdateIndex( updateRequest );
                fail( "Should throw IOException from too many redirects." );
            }
            catch ( IOException e )
            {
                System.out.println( "Operation timed out due to too many redirects, as expected." );
            }
           
            ctx.close( false );
        }
        finally
        {
            try
            {
View Full Code Here

Examples of org.apache.maven.index.context.IndexingContext

        basedir.delete();
        basedir.mkdirs();

        try
        {
            IndexingContext ctx = newTestContext( basedir, "http://dummy/" );

            IndexUpdateRequest updateRequest =
                new IndexUpdateRequest( ctx, wagonHelper.getWagonResourceFetcher( new TransferListenerFixture()
                {
                    @Override
                    public void transferError( final TransferEvent transferEvent )
                    {
                    }
                }, new AuthenticationInfo()
                {
                    private static final long serialVersionUID = 1L;

                    {
                        setUserName( "user" );
                        setPassword( "password" );
                    }
                }, null ) );

            try
            {
                updater.fetchAndUpdateIndex( updateRequest );
                fail( "Should timeout and throw IOException." );
            }
            catch ( Exception e )
            {
                System.out.println( "Connection failed as expected." );
            }
           
            ctx.close( false );
        }
        finally
        {
            try
            {
View Full Code Here

Examples of org.apache.maven.index.context.IndexingContext

    public IndexUpdateResult fetchAndUpdateIndex( final IndexUpdateRequest updateRequest )
        throws IOException
    {
        IndexUpdateResult result = new IndexUpdateResult();

        IndexingContext context = updateRequest.getIndexingContext();

        ResourceFetcher fetcher = null;

        if ( !updateRequest.isOffline() )
        {
            fetcher = updateRequest.getResourceFetcher();

            // If no resource fetcher passed in, use the wagon fetcher by default
            // and put back in request for future use
            if ( fetcher == null )
            {
                throw new IOException( "Update of the index without provided ResourceFetcher is impossible." );
            }

            fetcher.connect( context.getId(), context.getIndexUpdateUrl() );
        }

        File cacheDir = updateRequest.getLocalIndexCacheDir();
        Locker locker = updateRequest.getLocker();
        Lock lock = locker != null && cacheDir != null ? locker.lock( cacheDir ) : null;
View Full Code Here

Examples of org.apache.maven.index.context.IndexingContext

        String repositoryUrl = "http://localhost:8081/nexus/content/groups/sonatype-public/";
        // String repositoryUrl = "http://repository.sonatype.org/content/groups/public/";
        // String repositoryUrl = "http://repository.sonatype.org/content/groups/sonatype/";
        String indexUrl = repositoryUrl + ".index";

        IndexingContext ctx =
            new DefaultIndexingContext( repositoryId, repositoryId, basedir, basedir, repositoryUrl, indexUrl,
                creators, true );

        // craft the Wagon based Resource
View Full Code Here

Examples of org.apache.maven.index.context.IndexingContext

        Directory newIndexDir = FSDirectory.open( newIndex );

        DefaultIndexUpdater.unpackIndexArchive( new ByteArrayInputStream( os.toByteArray() ), newIndexDir, context );

        IndexingContext newContext =
            nexusIndexer.addIndexingContext( "test-new", "test", null, newIndexDir, null, null, DEFAULT_CREATORS );

        assertEquals( context.getTimestamp().getTime(), newContext.getTimestamp().getTime() );

        assertEquals( context.getTimestamp(), newContext.getTimestamp() );

        // make sure context has the same artifacts

        Query query = nexusIndexer.constructQuery( MAVEN.GROUP_ID, "qdox", SearchType.SCORED );

        FlatSearchRequest request = new FlatSearchRequest( query, newContext );
        FlatSearchResponse response = nexusIndexer.searchFlat( request );
        Collection<ArtifactInfo> r = response.getResults();

        assertEquals( 2, r.size() );

        List<ArtifactInfo> list = new ArrayList<ArtifactInfo>( r );

        assertEquals( 2, list.size() );

        ArtifactInfo ai = list.get( 0 );

        assertEquals( "1.6.1", ai.version );

        ai = list.get( 1 );

        assertEquals( "1.5", ai.version );

        assertEquals( "test", ai.repository );

        Date timestamp = newContext.getTimestamp();

        newContext.close( false );

        newIndexDir = FSDirectory.open( newIndex );

        DefaultIndexUpdater.unpackIndexArchive( new ByteArrayInputStream( os.toByteArray() ), newIndexDir, context );

        newContext =
            nexusIndexer.addIndexingContext( "test-new", "test", null, newIndexDir, null, null, DEFAULT_CREATORS );

        assertEquals( timestamp, newContext.getTimestamp() );

        newContext.close( true );

        assertFalse( new File( newIndex, "timestamp" ).exists() );
    }
View Full Code Here

Examples of org.apache.maven.index.context.IndexingContext

        }
    }

    private void processFile( File file, ScanningRequest request )
    {
        IndexingContext context = request.getIndexingContext();

        ArtifactContext ac = artifactContextProducer.getArtifactContext( context, file );

        if ( ac != null )
        {
View Full Code Here

Examples of org.apache.maven.index.context.IndexingContext

        packIndex( remoteRepo, context );

        //
        TrackingFetcher fetcher;
        IndexUpdateRequest updateRequest;
        IndexingContext testContext;

        // initial index download (expected: full index download)
        testContext = getNewTempContext();
        fetcher = new TrackingFetcher( remoteRepo );
        updateRequest = new IndexUpdateRequest( testContext, fetcher );
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.