Examples of NexusIndexer


Examples of org.apache.maven.index.NexusIndexer

    private IndexingContext context;

    public void testSearchIterator()
        throws Exception
    {
        NexusIndexer indexer = prepare();

        Query q = indexer.constructQuery( MAVEN.GROUP_ID, "qdox", SearchType.SCORED );

        IteratorSearchRequest request = new IteratorSearchRequest( q );

        IteratorSearchResponse response = indexer.searchIterator( request );

        assertEquals( 2, response.getTotalHits() );

        for ( ArtifactInfo ai : response.getResults() )
        {
View Full Code Here

Examples of org.apache.maven.index.NexusIndexer

    }

    public void testSearchIteratorWithFilter()
        throws Exception
    {
        NexusIndexer indexer = prepare();

        Query q = indexer.constructQuery( MAVEN.GROUP_ID, "commons", SearchType.SCORED );

        UniqueArtifactFilterPostprocessor filter = new UniqueArtifactFilterPostprocessor();
        filter.addField( MAVEN.GROUP_ID );
        filter.addField( MAVEN.ARTIFACT_ID );

        IteratorSearchRequest request = new IteratorSearchRequest( q, filter );

        IteratorSearchResponse response = indexer.searchIterator( request );

        assertEquals( "15 total hits (before filtering!)", 15, response.getTotalHits() );

        ArtifactInfo ai = response.getResults().next();
        assertTrue( "Iterator has to have next (2 should be returned)", ai != null );
View Full Code Here

Examples of org.apache.maven.index.NexusIndexer

    // ==

    private NexusIndexer prepare()
        throws Exception, IOException, UnsupportedExistingLuceneIndexException
    {
        NexusIndexer indexer = lookup( NexusIndexer.class );

        // Directory indexDir = new RAMDirectory();
        File indexDir = new File( getBasedir(), "target/index/test-" + Long.toString( System.currentTimeMillis() ) );
        FileUtils.deleteDirectory( indexDir );

        File repo = new File( getBasedir(), "src/test/repo" );

        context = indexer.addIndexingContext( "test", "test", repo, indexDir, null, null, DEFAULT_CREATORS );

        indexer.scan( context );

        return indexer;
    }
View Full Code Here

Examples of org.apache.maven.index.NexusIndexer

    private void assertIndexFiles( final String indexDir )
        throws Exception
    {
        IndexingContext context = null;
        NexusIndexer indexer = lookup( NexusIndexer.class );
        try
        {
            List<IndexCreator> indexCreators = getContainer().lookupList( IndexCreator.class );

            context =
                indexer.addIndexingContext( "index", "index", new File( TEST_REPO ), new File( indexDir ), null, null,
                                            indexCreators );

            assertFalse( "No index file was generated", new File( indexDir ).list().length == 0 );

            Query query = indexer.constructQuery( MAVEN.GROUP_ID, "ch.marcus-schulte.maven", SearchType.SCORED );

            FlatSearchRequest request = new FlatSearchRequest( query );
            FlatSearchResponse response = indexer.searchFlat( request );
            assertEquals( response.getResults().toString(), 1, response.getTotalHits() );
        }
        finally
        {
            if ( context != null )
            {
                indexer.removeIndexingContext( context, true );
            }
        }
    }
View Full Code Here

Examples of org.apache.maven.index.NexusIndexer

    @After
    public void tearDown()
        throws Exception
    {
        NexusIndexer nexusIndexer = plexusSisuBridge.lookup( NexusIndexer.class );
        for ( IndexingContext indexingContext : nexusIndexer.getIndexingContexts().values() )
        {
            nexusIndexer.removeIndexingContext( indexingContext, false );
        }
    }
View Full Code Here

Examples of org.apache.maven.index.NexusIndexer

    }

    protected void removeMavenIndexes()
        throws Exception
    {
        NexusIndexer nexusIndexer = plexusSisuBridge.lookup( NexusIndexer.class );
        for ( IndexingContext indexingContext : nexusIndexer.getIndexingContexts().values() )
        {
            nexusIndexer.removeIndexingContext( indexingContext, false );
        }
    }
View Full Code Here

Examples of org.apache.maven.index.NexusIndexer


    protected void removeMavenIndexes()
        throws Exception
    {
        NexusIndexer nexusIndexer = plexusSisuBridge.lookup( NexusIndexer.class );

        for ( IndexingContext indexingContext : nexusIndexer.getIndexingContexts().values() )
        {
            nexusIndexer.removeIndexingContext( indexingContext, false );
        }
    }
View Full Code Here

Examples of org.apache.maven.index.NexusIndexer

        throws RepositoryAdminException
    {

        try
        {
            NexusIndexer nexusIndexer = plexusSisuBridge.lookup( NexusIndexer.class );

            IndexingContext context = nexusIndexer.getIndexingContexts().get( repository.getId() );
            if ( context != null )
            {
                // delete content only if directory exists
                nexusIndexer.removeIndexingContext( context,
                                                    deleteContent && context.getIndexDirectoryFile().exists() );
            }
        }
        catch ( PlexusSisuBridgeException e )
        {
View Full Code Here

Examples of org.apache.maven.index.NexusIndexer

    }

    protected void removeMavenIndexes()
        throws Exception
    {
        NexusIndexer nexusIndexer = plexusSisuBridge.lookup( NexusIndexer.class );
        for ( IndexingContext indexingContext : nexusIndexer.getIndexingContexts().values() )
        {
            nexusIndexer.removeIndexingContext( indexingContext, false );
        }
    }
View Full Code Here

Examples of org.apache.maven.index.NexusIndexer

    public void cleanupIndex()
    {
        log.info( "cleanup IndexingContext" );
        try
        {
            NexusIndexer nexusIndexer = plexusSisuBridge.lookup( NexusIndexer.class );
            for ( IndexingContext context : nexusIndexer.getIndexingContexts().values() )
            {
                nexusIndexer.removeIndexingContext( context, true );
            }
        }
        catch ( Exception e )
        {
            log.warn( "fail to cleanupIndex: {}", e.getMessage(), e );
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.