]> source.dussan.org Git - archiva.git/commitdiff
more %s/nexus/maven
authorOlivier Lamy <olamy@apache.org>
Thu, 29 Nov 2012 16:14:54 +0000 (16:14 +0000)
committerOlivier Lamy <olamy@apache.org>
Thu, 29 Nov 2012 16:14:54 +0000 (16:14 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1415237 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/AbstractMavenRepositorySearch.java [new file with mode: 0644]
archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/AbstractNexusRepositorySearch.java [deleted file]
archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/MavenRepositorySearchOSGITest.java [new file with mode: 0644]
archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/MavenRepositorySearchPaginateTest.java [new file with mode: 0644]
archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/MavenRepositorySearchTest.java [new file with mode: 0644]
archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/NexusRepositorySearchOSGITest.java [deleted file]
archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/NexusRepositorySearchPaginateTest.java [deleted file]
archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/NexusRepositorySearchTest.java [deleted file]

diff --git a/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/AbstractMavenRepositorySearch.java b/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/AbstractMavenRepositorySearch.java
new file mode 100644 (file)
index 0000000..e8fe0f3
--- /dev/null
@@ -0,0 +1,257 @@
+package org.apache.archiva.indexer.search;
+
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*  http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied.  See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+import junit.framework.TestCase;
+import org.apache.archiva.admin.repository.managed.DefaultManagedRepositoryAdmin;
+import org.apache.archiva.admin.repository.proxyconnector.DefaultProxyConnectorAdmin;
+import org.apache.archiva.common.plexusbridge.MavenIndexerUtils;
+import org.apache.archiva.common.plexusbridge.PlexusSisuBridge;
+import org.apache.archiva.common.utils.FileUtil;
+import org.apache.archiva.configuration.ArchivaConfiguration;
+import org.apache.archiva.configuration.Configuration;
+import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang.SystemUtils;
+import org.apache.maven.index.ArtifactContext;
+import org.apache.maven.index.ArtifactContextProducer;
+import org.apache.maven.index.ArtifactScanningListener;
+import org.apache.maven.index.NexusIndexer;
+import org.apache.maven.index.ScanningResult;
+import org.apache.maven.index.context.IndexingContext;
+import org.easymock.MockControl;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.runner.RunWith;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.test.context.ContextConfiguration;
+
+import javax.inject.Inject;
+import java.io.File;
+import java.util.List;
+import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
+
+/**
+ * @author Olivier Lamy
+ */
+@RunWith( ArchivaSpringJUnit4ClassRunner.class )
+@ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context.xml" } )
+public abstract class AbstractMavenRepositorySearch
+    extends TestCase
+{
+
+    protected Logger log = LoggerFactory.getLogger( getClass() );
+
+    public static String TEST_REPO_1 = "nexus-search-test-repo";
+
+    public static String TEST_REPO_2 = "nexus-search-test-repo-2";
+
+
+    public static String REPO_RELEASE = "repo-release";
+
+    MavenRepositorySearch search;
+
+    ArchivaConfiguration archivaConfig;
+
+    ArtifactContextProducer artifactContextProducer;
+
+    MockControl archivaConfigControl;
+
+    Configuration config;
+
+    @Inject
+    PlexusSisuBridge plexusSisuBridge;
+
+    @Inject
+    MavenIndexerUtils mavenIndexerUtils;
+
+    NexusIndexer nexusIndexer;
+
+    @Before
+    public void setUp()
+        throws Exception
+    {
+        super.setUp();
+
+        FileUtils.deleteDirectory( new File( FileUtil.getBasedir(), "/target/repos/" + TEST_REPO_1 + "/.indexer" ) );
+        assertFalse( new File( FileUtil.getBasedir(), "/target/repos/" + TEST_REPO_1 + "/.indexer" ).exists() );
+
+        FileUtils.deleteDirectory( new File( FileUtil.getBasedir(), "/target/repos/" + TEST_REPO_2 + "/.indexer" ) );
+        assertFalse( new File( FileUtil.getBasedir(), "/target/repos/" + TEST_REPO_2 + "/.indexer" ).exists() );
+
+        archivaConfigControl = MockControl.createControl( ArchivaConfiguration.class );
+
+        archivaConfig = (ArchivaConfiguration) archivaConfigControl.getMock();
+
+        DefaultManagedRepositoryAdmin defaultManagedRepositoryAdmin = new DefaultManagedRepositoryAdmin();
+        defaultManagedRepositoryAdmin.setArchivaConfiguration( archivaConfig );
+
+        DefaultProxyConnectorAdmin defaultProxyConnectorAdmin = new DefaultProxyConnectorAdmin();
+        defaultProxyConnectorAdmin.setArchivaConfiguration( archivaConfig );
+
+        search = new MavenRepositorySearch( plexusSisuBridge, defaultManagedRepositoryAdmin, mavenIndexerUtils,
+                                            defaultProxyConnectorAdmin );
+
+        nexusIndexer = plexusSisuBridge.lookup( NexusIndexer.class );
+
+        artifactContextProducer = plexusSisuBridge.lookup( ArtifactContextProducer.class );
+
+        config = new Configuration();
+        config.addManagedRepository( createRepositoryConfig( TEST_REPO_1 ) );
+        config.addManagedRepository( createRepositoryConfig( TEST_REPO_2 ) );
+        config.addManagedRepository( createRepositoryConfig( REPO_RELEASE ) );
+    }
+
+    @After
+    public void tearDown()
+        throws Exception
+    {
+        for ( IndexingContext indexingContext : nexusIndexer.getIndexingContexts().values() )
+        {
+            nexusIndexer.removeIndexingContext( indexingContext, true );
+        }
+
+        FileUtils.deleteDirectory( new File( FileUtil.getBasedir(), "/target/repos/" + TEST_REPO_1 ) );
+        assertFalse( new File( FileUtil.getBasedir(), "/target/repos/" + TEST_REPO_1 ).exists() );
+
+        FileUtils.deleteDirectory( new File( FileUtil.getBasedir(), "/target/repos/" + TEST_REPO_2 ) );
+        assertFalse( new File( FileUtil.getBasedir(), "/target/repos/" + TEST_REPO_2 ).exists() );
+
+        super.tearDown();
+    }
+
+    protected ManagedRepositoryConfiguration createRepositoryConfig( String repository )
+    {
+        ManagedRepositoryConfiguration repositoryConfig = new ManagedRepositoryConfiguration();
+        repositoryConfig.setId( repository );
+        repositoryConfig.setLocation( FileUtil.getBasedir() + "/target/repos/" + repository );
+        File f = new File( repositoryConfig.getLocation() );
+        if ( !f.exists() )
+        {
+            f.mkdirs();
+        }
+        repositoryConfig.setLayout( "default" );
+        repositoryConfig.setName( repository );
+        repositoryConfig.setScanned( true );
+        repositoryConfig.setSnapshots( false );
+        repositoryConfig.setReleases( true );
+
+        return repositoryConfig;
+    }
+
+    protected void createIndex( String repository, List<File> filesToBeIndexed, boolean scan )
+        throws Exception
+    {
+
+        IndexingContext context = nexusIndexer.getIndexingContexts().get( repository );
+
+        if ( context != null )
+        {
+            nexusIndexer.removeIndexingContext( context, true );
+        }
+
+        File indexerDirectory = new File( FileUtil.getBasedir(), "/target/repos/" + repository + "/.indexer" );
+
+        if ( indexerDirectory.exists() )
+        {
+            FileUtils.deleteDirectory( indexerDirectory );
+        }
+
+        assertFalse( indexerDirectory.exists() );
+
+        File lockFile = new File( FileUtil.getBasedir(), "/target/repos/" + repository + "/.indexer/write.lock" );
+        if ( lockFile.exists() )
+        {
+            lockFile.delete();
+        }
+
+        assertFalse( lockFile.exists() );
+
+        File repo = new File( FileUtil.getBasedir(), "src/test/" + repository );
+        assertTrue( repo.exists() );
+        File indexDirectory =
+            new File( FileUtil.getBasedir(), "target/index/test-" + Long.toString( System.currentTimeMillis() ) );
+        indexDirectory.deleteOnExit();
+        FileUtils.deleteDirectory( indexDirectory );
+
+        context = nexusIndexer.addIndexingContext( repository, repository, repo, indexDirectory,
+                                                   repo.toURI().toURL().toExternalForm(),
+                                                   indexDirectory.toURI().toURL().toString(),
+                                                   search.getAllIndexCreators() );
+
+        // minimize datas in memory
+        context.getIndexWriter().setMaxBufferedDocs( -1 );
+        context.getIndexWriter().setRAMBufferSizeMB( 1 );
+        for ( File artifactFile : filesToBeIndexed )
+        {
+            assertTrue( "file not exists " + artifactFile.getPath(), artifactFile.exists() );
+            ArtifactContext ac = artifactContextProducer.getArtifactContext( context, artifactFile );
+            nexusIndexer.addArtifactToIndex( ac, context );
+            context.updateTimestamp( true );
+        }
+
+        if ( scan )
+        {
+            nexusIndexer.scan( context, new ArtifactScanListener(), false );
+        }
+        // force flushing
+        context.getIndexWriter().commit();
+        context.setSearchable( true );
+
+    }
+
+    static class ArtifactScanListener
+        implements ArtifactScanningListener
+    {
+        protected Logger log = LoggerFactory.getLogger( getClass() );
+
+        public void scanningStarted( IndexingContext ctx )
+        {
+
+        }
+
+        public void scanningFinished( IndexingContext ctx, ScanningResult result )
+        {
+
+        }
+
+        public void artifactError( ArtifactContext ac, Exception e )
+        {
+            log.debug( "artifactError {}", ac.getArtifact().getPath(), e );
+        }
+
+        public void artifactDiscovered( ArtifactContext ac )
+        {
+            log.debug( "artifactDiscovered {}:{}", ac.getArtifact().getPath(), ac.getArtifactInfo() );
+        }
+    }
+
+    public String niceDisplay( SearchResults searchResults )
+        throws Exception
+    {
+        StringBuilder sb = new StringBuilder();
+        for ( SearchResultHit hit : searchResults.getHits() )
+        {
+            sb.append( hit.toString() ).append( SystemUtils.LINE_SEPARATOR );
+        }
+        return sb.toString();
+    }
+}
diff --git a/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/AbstractNexusRepositorySearch.java b/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/AbstractNexusRepositorySearch.java
deleted file mode 100644 (file)
index 44df856..0000000
+++ /dev/null
@@ -1,257 +0,0 @@
-package org.apache.archiva.indexer.search;
-
-/*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements.  See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership.  The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License.  You may obtain a copy of the License at
-*
-*  http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied.  See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*/
-
-import junit.framework.TestCase;
-import org.apache.archiva.admin.repository.managed.DefaultManagedRepositoryAdmin;
-import org.apache.archiva.admin.repository.proxyconnector.DefaultProxyConnectorAdmin;
-import org.apache.archiva.common.plexusbridge.MavenIndexerUtils;
-import org.apache.archiva.common.plexusbridge.PlexusSisuBridge;
-import org.apache.archiva.common.utils.FileUtil;
-import org.apache.archiva.configuration.ArchivaConfiguration;
-import org.apache.archiva.configuration.Configuration;
-import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.lang.SystemUtils;
-import org.apache.maven.index.ArtifactContext;
-import org.apache.maven.index.ArtifactContextProducer;
-import org.apache.maven.index.ArtifactScanningListener;
-import org.apache.maven.index.NexusIndexer;
-import org.apache.maven.index.ScanningResult;
-import org.apache.maven.index.context.IndexingContext;
-import org.easymock.MockControl;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.runner.RunWith;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.test.context.ContextConfiguration;
-
-import javax.inject.Inject;
-import java.io.File;
-import java.util.List;
-import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
-
-/**
- * @author Olivier Lamy
- */
-@RunWith( ArchivaSpringJUnit4ClassRunner.class )
-@ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context.xml" } )
-public abstract class AbstractNexusRepositorySearch
-    extends TestCase
-{
-
-    protected Logger log = LoggerFactory.getLogger( getClass() );
-
-    public static String TEST_REPO_1 = "nexus-search-test-repo";
-
-    public static String TEST_REPO_2 = "nexus-search-test-repo-2";
-
-
-    public static String REPO_RELEASE = "repo-release";
-
-    MavenRepositorySearch search;
-
-    ArchivaConfiguration archivaConfig;
-
-    ArtifactContextProducer artifactContextProducer;
-
-    MockControl archivaConfigControl;
-
-    Configuration config;
-
-    @Inject
-    PlexusSisuBridge plexusSisuBridge;
-
-    @Inject
-    MavenIndexerUtils mavenIndexerUtils;
-
-    NexusIndexer nexusIndexer;
-
-    @Before
-    public void setUp()
-        throws Exception
-    {
-        super.setUp();
-
-        FileUtils.deleteDirectory( new File( FileUtil.getBasedir(), "/target/repos/" + TEST_REPO_1 + "/.indexer" ) );
-        assertFalse( new File( FileUtil.getBasedir(), "/target/repos/" + TEST_REPO_1 + "/.indexer" ).exists() );
-
-        FileUtils.deleteDirectory( new File( FileUtil.getBasedir(), "/target/repos/" + TEST_REPO_2 + "/.indexer" ) );
-        assertFalse( new File( FileUtil.getBasedir(), "/target/repos/" + TEST_REPO_2 + "/.indexer" ).exists() );
-
-        archivaConfigControl = MockControl.createControl( ArchivaConfiguration.class );
-
-        archivaConfig = (ArchivaConfiguration) archivaConfigControl.getMock();
-
-        DefaultManagedRepositoryAdmin defaultManagedRepositoryAdmin = new DefaultManagedRepositoryAdmin();
-        defaultManagedRepositoryAdmin.setArchivaConfiguration( archivaConfig );
-
-        DefaultProxyConnectorAdmin defaultProxyConnectorAdmin = new DefaultProxyConnectorAdmin();
-        defaultProxyConnectorAdmin.setArchivaConfiguration( archivaConfig );
-
-        search = new MavenRepositorySearch( plexusSisuBridge, defaultManagedRepositoryAdmin, mavenIndexerUtils,
-                                            defaultProxyConnectorAdmin );
-
-        nexusIndexer = plexusSisuBridge.lookup( NexusIndexer.class );
-
-        artifactContextProducer = plexusSisuBridge.lookup( ArtifactContextProducer.class );
-
-        config = new Configuration();
-        config.addManagedRepository( createRepositoryConfig( TEST_REPO_1 ) );
-        config.addManagedRepository( createRepositoryConfig( TEST_REPO_2 ) );
-        config.addManagedRepository( createRepositoryConfig( REPO_RELEASE ) );
-    }
-
-    @After
-    public void tearDown()
-        throws Exception
-    {
-        for ( IndexingContext indexingContext : nexusIndexer.getIndexingContexts().values() )
-        {
-            nexusIndexer.removeIndexingContext( indexingContext, true );
-        }
-
-        FileUtils.deleteDirectory( new File( FileUtil.getBasedir(), "/target/repos/" + TEST_REPO_1 ) );
-        assertFalse( new File( FileUtil.getBasedir(), "/target/repos/" + TEST_REPO_1 ).exists() );
-
-        FileUtils.deleteDirectory( new File( FileUtil.getBasedir(), "/target/repos/" + TEST_REPO_2 ) );
-        assertFalse( new File( FileUtil.getBasedir(), "/target/repos/" + TEST_REPO_2 ).exists() );
-
-        super.tearDown();
-    }
-
-    protected ManagedRepositoryConfiguration createRepositoryConfig( String repository )
-    {
-        ManagedRepositoryConfiguration repositoryConfig = new ManagedRepositoryConfiguration();
-        repositoryConfig.setId( repository );
-        repositoryConfig.setLocation( FileUtil.getBasedir() + "/target/repos/" + repository );
-        File f = new File( repositoryConfig.getLocation() );
-        if ( !f.exists() )
-        {
-            f.mkdirs();
-        }
-        repositoryConfig.setLayout( "default" );
-        repositoryConfig.setName( repository );
-        repositoryConfig.setScanned( true );
-        repositoryConfig.setSnapshots( false );
-        repositoryConfig.setReleases( true );
-
-        return repositoryConfig;
-    }
-
-    protected void createIndex( String repository, List<File> filesToBeIndexed, boolean scan )
-        throws Exception
-    {
-
-        IndexingContext context = nexusIndexer.getIndexingContexts().get( repository );
-
-        if ( context != null )
-        {
-            nexusIndexer.removeIndexingContext( context, true );
-        }
-
-        File indexerDirectory = new File( FileUtil.getBasedir(), "/target/repos/" + repository + "/.indexer" );
-
-        if ( indexerDirectory.exists() )
-        {
-            FileUtils.deleteDirectory( indexerDirectory );
-        }
-
-        assertFalse( indexerDirectory.exists() );
-
-        File lockFile = new File( FileUtil.getBasedir(), "/target/repos/" + repository + "/.indexer/write.lock" );
-        if ( lockFile.exists() )
-        {
-            lockFile.delete();
-        }
-
-        assertFalse( lockFile.exists() );
-
-        File repo = new File( FileUtil.getBasedir(), "src/test/" + repository );
-        assertTrue( repo.exists() );
-        File indexDirectory =
-            new File( FileUtil.getBasedir(), "target/index/test-" + Long.toString( System.currentTimeMillis() ) );
-        indexDirectory.deleteOnExit();
-        FileUtils.deleteDirectory( indexDirectory );
-
-        context = nexusIndexer.addIndexingContext( repository, repository, repo, indexDirectory,
-                                                   repo.toURI().toURL().toExternalForm(),
-                                                   indexDirectory.toURI().toURL().toString(),
-                                                   search.getAllIndexCreators() );
-
-        // minimize datas in memory
-        context.getIndexWriter().setMaxBufferedDocs( -1 );
-        context.getIndexWriter().setRAMBufferSizeMB( 1 );
-        for ( File artifactFile : filesToBeIndexed )
-        {
-            assertTrue( "file not exists " + artifactFile.getPath(), artifactFile.exists() );
-            ArtifactContext ac = artifactContextProducer.getArtifactContext( context, artifactFile );
-            nexusIndexer.addArtifactToIndex( ac, context );
-            context.updateTimestamp( true );
-        }
-
-        if ( scan )
-        {
-            nexusIndexer.scan( context, new ArtifactScanListener(), false );
-        }
-        // force flushing
-        context.getIndexWriter().commit();
-        context.setSearchable( true );
-
-    }
-
-    static class ArtifactScanListener
-        implements ArtifactScanningListener
-    {
-        protected Logger log = LoggerFactory.getLogger( getClass() );
-
-        public void scanningStarted( IndexingContext ctx )
-        {
-
-        }
-
-        public void scanningFinished( IndexingContext ctx, ScanningResult result )
-        {
-
-        }
-
-        public void artifactError( ArtifactContext ac, Exception e )
-        {
-            log.debug( "artifactError {}", ac.getArtifact().getPath(), e );
-        }
-
-        public void artifactDiscovered( ArtifactContext ac )
-        {
-            log.debug( "artifactDiscovered {}:{}", ac.getArtifact().getPath(), ac.getArtifactInfo() );
-        }
-    }
-
-    public String niceDisplay( SearchResults searchResults )
-        throws Exception
-    {
-        StringBuilder sb = new StringBuilder();
-        for ( SearchResultHit hit : searchResults.getHits() )
-        {
-            sb.append( hit.toString() ).append( SystemUtils.LINE_SEPARATOR );
-        }
-        return sb.toString();
-    }
-}
diff --git a/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/MavenRepositorySearchOSGITest.java b/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/MavenRepositorySearchOSGITest.java
new file mode 100644 (file)
index 0000000..ca59d65
--- /dev/null
@@ -0,0 +1,75 @@
+package org.apache.archiva.indexer.search;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.junit.Test;
+
+import java.io.File;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * @author Olivier Lamy
+ */
+public class MavenRepositorySearchOSGITest
+    extends AbstractMavenRepositorySearch
+{
+
+    @Test
+    public void searchFelixWithSymbolicName()
+        throws Exception
+    {
+
+        createIndex( TEST_REPO_1, Collections.<File>emptyList(), true );
+
+        List<String> selectedRepos = Arrays.asList( TEST_REPO_1 );
+
+        // search artifactId
+        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
+
+        archivaConfigControl.replay();
+
+        SearchFields searchFields = new SearchFields();
+        searchFields.setBundleSymbolicName( "org.apache.felix.bundlerepository" );
+        searchFields.setBundleVersion( "1.6.6" );
+        searchFields.setRepositories( selectedRepos );
+
+        SearchResults results = search.search( "user", searchFields, null );
+
+        archivaConfigControl.verify();
+
+        assertNotNull( results );
+        assertEquals( 1, results.getTotalHits() );
+
+        SearchResultHit hit = results.getHits().get( 0 );
+        assertEquals( "org.apache.felix", hit.getGroupId() );
+        assertEquals( "org.apache.felix.bundlerepository", hit.getArtifactId() );
+        assertEquals( "1.6.6", hit.getVersions().get( 0 ) );
+
+        assertEquals( "org.apache.felix.bundlerepository;uses:=\"org.osgi.framework\";version=\"2.0\"",
+                      hit.getBundleExportPackage() );
+        assertEquals( "org.apache.felix.bundlerepository.RepositoryAdmin,org.osgi.service.obr.RepositoryAdmin",
+                      hit.getBundleExportService() );
+        assertEquals( "org.apache.felix.bundlerepository", hit.getBundleSymbolicName() );
+        assertEquals( "1.6.6", hit.getBundleVersion() );
+    }
+
+}
diff --git a/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/MavenRepositorySearchPaginateTest.java b/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/MavenRepositorySearchPaginateTest.java
new file mode 100644 (file)
index 0000000..802444a
--- /dev/null
@@ -0,0 +1,105 @@
+package org.apache.archiva.indexer.search;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import junit.framework.TestCase;
+import org.apache.archiva.indexer.util.SearchUtil;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.util.Arrays;
+import org.apache.archiva.test.utils.ArchivaBlockJUnit4ClassRunner;
+
+/**
+ * @author Olivier Lamy
+ */
+@RunWith( ArchivaBlockJUnit4ClassRunner.class )
+public class MavenRepositorySearchPaginateTest
+    extends TestCase
+{
+    @Test
+    public void nonPaginatedResult()
+        throws Exception
+    {
+        MavenRepositorySearch search = new MavenRepositorySearch();
+
+        SearchResults searchResults = build( 10, new SearchResultLimits( 0 ) );
+
+        searchResults = search.paginate( searchResults );
+
+        assertEquals( 10, searchResults.getReturnedHitsCount() );
+
+    }
+
+    @Test
+    public void nonPaginatedHugeResult()
+        throws Exception
+    {
+        MavenRepositorySearch search = new MavenRepositorySearch();
+
+        SearchResults origSearchResults = build( 63, new SearchResultLimits( 0 ) );
+
+        SearchResults searchResults = search.paginate( origSearchResults );
+
+        assertEquals( 30, searchResults.getReturnedHitsCount() );
+
+        origSearchResults = build( 63, new SearchResultLimits( 1 ) );
+
+        searchResults = search.paginate( origSearchResults );
+
+        assertEquals( 30, searchResults.getReturnedHitsCount() );
+
+    }
+
+    @Test
+    public void paginatedResult()
+        throws Exception
+    {
+        MavenRepositorySearch search = new MavenRepositorySearch();
+
+        SearchResults searchResults = build( 32, new SearchResultLimits( 1 ) );
+
+        searchResults = search.paginate( searchResults );
+
+        assertEquals( 2, searchResults.getReturnedHitsCount() );
+
+    }
+
+
+    SearchResults build( int number, SearchResultLimits limits )
+    {
+        SearchResults searchResults = new SearchResults();
+        searchResults.setLimits( limits );
+        for ( int i = 0; i < number; i++ )
+        {
+            SearchResultHit hit = new SearchResultHit();
+            hit.setGroupId( "commons-foo" );
+            hit.setArtifactId( "commons-bar-" + i );
+            hit.setPackaging( "jar" );
+            hit.setVersions( Arrays.asList( "1.0" ) );
+            String id =
+                SearchUtil.getHitId( hit.getGroupId(), hit.getArtifactId(), hit.getClassifier(), hit.getPackaging() );
+            searchResults.addHit( id, hit );
+        }
+
+        searchResults.setTotalHits( number );
+        return searchResults;
+
+    }
+}
diff --git a/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/MavenRepositorySearchTest.java b/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/MavenRepositorySearchTest.java
new file mode 100644 (file)
index 0000000..344a39c
--- /dev/null
@@ -0,0 +1,899 @@
+package org.apache.archiva.indexer.search;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.archiva.common.utils.FileUtil;
+import org.apache.archiva.indexer.util.SearchUtil;
+import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
+import org.codehaus.plexus.util.FileUtils;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ContextConfiguration;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+
+@RunWith ( ArchivaSpringJUnit4ClassRunner.class )
+@ContextConfiguration ( locations = { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context.xml" } )
+public class MavenRepositorySearchTest
+    extends AbstractMavenRepositorySearch
+{
+
+
+    private void createSimpleIndex( boolean scan )
+        throws Exception
+    {
+        List<File> files = new ArrayList<File>();
+        files.add( new File( FileUtil.getBasedir(), "src/test/" + TEST_REPO_1
+            + "/org/apache/archiva/archiva-search/1.0/archiva-search-1.0.jar" ) );
+        files.add( new File( FileUtil.getBasedir(), "src/test/" + TEST_REPO_1
+            + "/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.jar" ) );
+        files.add( new File( FileUtil.getBasedir(), "/src/test/" + TEST_REPO_1
+            + "/org/apache/archiva/archiva-test/2.0/archiva-test-2.0.jar" ) );
+
+        createIndex( TEST_REPO_1, files, scan );
+    }
+
+    private void createIndexContainingMoreArtifacts( boolean scan )
+        throws Exception
+    {
+        List<File> files = new ArrayList<File>();
+        files.add( new File( FileUtil.getBasedir(), "src/test/" + TEST_REPO_1
+            + "/org/apache/archiva/archiva-search/1.0/archiva-search-1.0.jar" ) );
+        files.add( new File( FileUtil.getBasedir(), "src/test/" + TEST_REPO_1
+            + "/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.jar" ) );
+        files.add( new File( FileUtil.getBasedir(), "src/test/" + TEST_REPO_1
+            + "/org/apache/archiva/archiva-test/2.0/archiva-test-2.0.jar" ) );
+        files.add( new File( FileUtil.getBasedir(), "src/test/" + TEST_REPO_1
+            + "/org/apache/archiva/archiva-webapp/1.0/archiva-webapp-1.0.war" ) );
+        files.add( new File( FileUtil.getBasedir(),
+                             "src/test/" + TEST_REPO_1 + "/com/artifactid-numeric/1.0/artifactid-numeric-1.0.jar" ) );
+        files.add( new File( FileUtil.getBasedir(), "src/test/" + TEST_REPO_1
+            + "/com/artifactid-numeric123/1.0/artifactid-numeric123-1.0.jar" ) );
+        files.add( new File( FileUtil.getBasedir(),
+                             "src/test/" + TEST_REPO_1 + "/com/classname-search/1.0/classname-search-1.0.jar" ) );
+
+        createIndex( TEST_REPO_1, files, scan );
+    }
+
+    private void createIndexContainingMultipleArtifactsSameVersion( boolean scan )
+        throws Exception
+    {
+        List<File> files = new ArrayList<File>();
+
+        files.add( new File( FileUtil.getBasedir(), "src/test/" + TEST_REPO_1
+            + "/org/apache/archiva/archiva-search/1.0/archiva-search-1.0.jar" ) );
+        files.add( new File( FileUtil.getBasedir(), "src/test/" + TEST_REPO_1
+            + "/org/apache/archiva/archiva-search/1.0/archiva-search-1.0-sources.jar" ) );
+
+        createIndex( TEST_REPO_1, files, scan );
+    }
+
+    @Test
+    public void testQuickSearch()
+        throws Exception
+    {
+        createSimpleIndex( false );
+
+        List<String> selectedRepos = Arrays.asList( TEST_REPO_1 );
+
+        // search artifactId
+        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
+
+        archivaConfigControl.replay();
+
+        SearchResults results = search.search( "user", selectedRepos, "archiva-search", null, null );
+
+        archivaConfigControl.verify();
+
+        assertNotNull( results );
+
+        SearchResultHit hit =
+            results.getSearchResultHit( SearchUtil.getHitId( "org.apache.archiva", "archiva-search", null, "jar" ) );
+        assertNotNull( "hit null in result " + results.getHits(), hit );
+        assertEquals( "org.apache.archiva", hit.getGroupId() );
+        assertEquals( "archiva-search", hit.getArtifactId() );
+        assertEquals( "1.0", hit.getVersions().get( 0 ) );
+
+        archivaConfigControl.reset();
+
+        // search groupId
+        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
+
+        archivaConfigControl.replay();
+
+        results = search.search( "user", selectedRepos, "org.apache.archiva", null, null );
+
+        archivaConfigControl.verify();
+
+        assertNotNull( results );
+        assertEquals( "total hints not 3", 3, results.getTotalHits() );
+
+        //TODO: search for class & package names
+    }
+
+    @Test
+    public void testQuickSearchNotWithClassifier()
+        throws Exception
+    {
+        createSimpleIndex( true );
+
+        List<String> selectedRepos = Arrays.asList( TEST_REPO_1 );
+
+        // search artifactId
+        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
+
+        archivaConfigControl.replay();
+
+        SearchResults results = search.search( "user", selectedRepos, "archiva-search", null, null );
+
+        archivaConfigControl.verify();
+
+        assertNotNull( results );
+
+        SearchResultHit hit =
+            results.getSearchResultHit( SearchUtil.getHitId( "org.apache.archiva", "archiva-search", null, "jar" ) );
+        assertNotNull( "hit null in result " + results.getHits(), hit );
+        assertEquals( "org.apache.archiva", hit.getGroupId() );
+        assertEquals( "archiva-search", hit.getArtifactId() );
+        assertEquals( "1.0", hit.getVersions().get( 0 ) );
+
+        archivaConfigControl.reset();
+
+        // search groupId
+        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
+
+        archivaConfigControl.replay();
+
+        results = search.search( "user", selectedRepos, "archiva-search", null, null );
+
+        archivaConfigControl.verify();
+
+        assertNotNull( results );
+        assertEquals( "total hints not 3 hits " + results.getHits(), 3, results.getTotalHits() );
+
+        //TODO: search for class & package names
+    }
+
+    @Test
+    public void testQuickSearchMultipleArtifactsSameVersion()
+        throws Exception
+    {
+        createIndexContainingMultipleArtifactsSameVersion( false );
+
+        List<String> selectedRepos = new ArrayList<String>();
+        selectedRepos.add( TEST_REPO_1 );
+
+        // search artifactId
+        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
+
+        archivaConfigControl.replay();
+
+        SearchResults results = search.search( "user", selectedRepos, "archiva-search", null, null );
+
+        archivaConfigControl.verify();
+
+        assertNotNull( results );
+        assertEquals( 2, results.getTotalHits() );
+
+        SearchResultHit hit = results.getHits().get( 0 );
+        assertEquals( "org.apache.archiva", hit.getGroupId() );
+        assertEquals( "archiva-search", hit.getArtifactId() );
+        assertEquals( "1.0", hit.getVersions().get( 0 ) );
+
+        //only 1 version of 1.0 is retrieved
+        assertEquals( 1, hit.getVersions().size() );
+    }
+
+    @Test
+    public void testMultipleArtifactsSameVersionWithClassifier()
+        throws Exception
+    {
+        createIndexContainingMultipleArtifactsSameVersion( true );
+
+        List<String> selectedRepos = new ArrayList<String>();
+        selectedRepos.add( TEST_REPO_1 );
+
+        // search artifactId
+        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
+
+        archivaConfigControl.replay();
+
+        SearchFields searchFields = new SearchFields();
+        searchFields.setGroupId( "org.apache.archiva" );
+        searchFields.setArtifactId( "archiva-search" );
+        searchFields.setClassifier( "sources" );
+        searchFields.setRepositories( selectedRepos );
+
+        SearchResults results = search.search( "user", searchFields, null );
+
+        archivaConfigControl.verify();
+
+        assertNotNull( results );
+        assertEquals( 1, results.getTotalHits() );
+
+        SearchResultHit hit = results.getHits().get( 0 );
+        assertEquals( "org.apache.archiva", hit.getGroupId() );
+        assertEquals( "archiva-search", hit.getArtifactId() );
+        assertEquals( "1.0", hit.getVersions().get( 0 ) );
+
+        //only 1 version of 1.0 is retrieved
+        assertEquals( 1, hit.getVersions().size() );
+    }
+
+    // search for existing artifact using multiple keywords
+    @Test
+    public void testQuickSearchWithMultipleKeywords()
+        throws Exception
+    {
+        createSimpleIndex( false );
+
+        List<String> selectedRepos = new ArrayList<String>();
+        selectedRepos.add( TEST_REPO_1 );
+
+        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
+        archivaConfigControl.replay();
+
+        SearchResults results = search.search( "user", selectedRepos, "archiva search", null, null );
+
+        archivaConfigControl.verify();
+
+        assertNotNull( results );
+        assertEquals( 1, results.getTotalHits() );
+    }
+
+    @Test
+    public void testQuickSearchWithPagination()
+        throws Exception
+    {
+        createSimpleIndex( true );
+
+        List<String> selectedRepos = new ArrayList<String>();
+        selectedRepos.add( TEST_REPO_1 );
+
+        // page 1
+        SearchResultLimits limits = new SearchResultLimits( 0 );
+        limits.setPageSize( 1 );
+
+        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
+
+        archivaConfigControl.replay();
+
+        SearchResults results = search.search( "user", selectedRepos, "org", limits, new ArrayList<String>() );
+
+        archivaConfigControl.verify();
+
+        assertNotNull( results );
+        assertEquals( 1, results.getHits().size() );
+        assertEquals( "total hits not 8 for page1 " + results, 8, results.getTotalHits() );
+        assertEquals( "returned hits not 1 for page1 " + results, 1, results.getReturnedHitsCount() );
+        assertEquals( limits, results.getLimits() );
+
+        archivaConfigControl.reset();
+
+        // page 2
+        limits = new SearchResultLimits( 1 );
+        limits.setPageSize( 1 );
+
+        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
+
+        archivaConfigControl.replay();
+
+        results = search.search( "user", selectedRepos, "org", limits, null );
+
+        archivaConfigControl.verify();
+
+        assertNotNull( results );
+
+        assertEquals( "hits not 1", 1, results.getHits().size() );
+        assertEquals( "total hits not 8 for page 2 " + results, 8, results.getTotalHits() );
+        assertEquals( "returned hits not 1 for page2 " + results, 1, results.getReturnedHitsCount() );
+        assertEquals( limits, results.getLimits() );
+    }
+
+    @Test
+    public void testArtifactFoundInMultipleRepositories()
+        throws Exception
+    {
+        createSimpleIndex( true );
+
+        List<File> files = new ArrayList<File>();
+        files.add( new File( FileUtil.getBasedir(), "src/test/" + TEST_REPO_2
+            + "/org/apache/archiva/archiva-search/1.0/archiva-search-1.0.jar" ) );
+        files.add( new File( FileUtil.getBasedir(), "src/test/" + TEST_REPO_2
+            + "/org/apache/archiva/archiva-search/1.1/archiva-search-1.1.jar" ) );
+        createIndex( TEST_REPO_2, files, false );
+
+        List<String> selectedRepos = new ArrayList<String>();
+        selectedRepos.add( TEST_REPO_1 );
+        selectedRepos.add( TEST_REPO_2 );
+
+        config.addManagedRepository( createRepositoryConfig( TEST_REPO_2 ) );
+
+        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 5 );
+
+        archivaConfigControl.replay();
+
+        // wait lucene flush.....
+        Thread.sleep( 2000 );
+
+        SearchResults results = search.search( "user", selectedRepos, "archiva-search", null, null );
+
+        archivaConfigControl.verify();
+
+        assertNotNull( results );
+
+        SearchResultHit hit =
+            results.getSearchResultHit( SearchUtil.getHitId( "org.apache.archiva", "archiva-search", null, "jar" ) );
+        assertEquals( "org.apache.archiva", hit.getGroupId() );
+        assertEquals( "archiva-search", hit.getArtifactId() );
+        assertEquals( "not 2 version for hit " + hit + "::" + niceDisplay( results ), 2, hit.getVersions().size() );
+        assertTrue( hit.getVersions().contains( "1.0" ) );
+        assertTrue( hit.getVersions().contains( "1.1" ) );
+
+        archivaConfigControl.reset();
+
+        // TODO: [BROWSE] in artifact info from browse, display all the repositories where the artifact is found
+    }
+
+    @Test
+    public void testNoMatchFound()
+        throws Exception
+    {
+        createSimpleIndex( false );
+
+        List<String> selectedRepos = new ArrayList<String>();
+        selectedRepos.add( TEST_REPO_1 );
+
+        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
+
+        archivaConfigControl.replay();
+
+        SearchResults results = search.search( "user", selectedRepos, "dfghdfkweriuasndsaie", null, null );
+
+        archivaConfigControl.verify();
+
+        assertNotNull( results );
+        assertEquals( 0, results.getTotalHits() );
+    }
+
+    @Test
+    public void testNoIndexFound()
+        throws Exception
+    {
+        List<String> selectedRepos = new ArrayList<String>();
+        selectedRepos.add( TEST_REPO_1 );
+
+        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
+
+        archivaConfigControl.replay();
+
+        SearchResults results = search.search( "user", selectedRepos, "org.apache.archiva", null, null );
+        assertNotNull( results );
+        assertEquals( 0, results.getTotalHits() );
+
+        archivaConfigControl.verify();
+    }
+
+    @Test
+    public void testRepositoryNotFound()
+        throws Exception
+    {
+        List<String> selectedRepos = new ArrayList<String>();
+        selectedRepos.add( "non-existing-repo" );
+
+        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
+
+        archivaConfigControl.replay();
+
+        SearchResults results = search.search( "user", selectedRepos, "org.apache.archiva", null, null );
+        assertNotNull( results );
+        assertEquals( 0, results.getTotalHits() );
+
+        archivaConfigControl.verify();
+    }
+
+    @Test
+    public void testSearchWithinSearchResults()
+        throws Exception
+    {
+        createSimpleIndex( true );
+
+        List<String> selectedRepos = new ArrayList<String>();
+        selectedRepos.add( TEST_REPO_1 );
+
+        List<String> previousSearchTerms = new ArrayList<String>();
+        previousSearchTerms.add( "archiva-test" );
+
+        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
+
+        archivaConfigControl.replay();
+
+        SearchResults results = search.search( "user", selectedRepos, "1.0", null, previousSearchTerms );
+
+        archivaConfigControl.verify();
+
+        assertNotNull( results );
+        assertEquals( "total hints not 1", 1, results.getTotalHits() );
+
+        SearchResultHit hit = results.getHits().get( 0 );
+        assertEquals( "org.apache.archiva", hit.getGroupId() );
+        assertEquals( "archiva-test", hit.getArtifactId() );
+        assertEquals( "versions not 1", 1, hit.getVersions().size() );
+        assertEquals( "1.0", hit.getVersions().get( 0 ) );
+    }
+
+    // tests for advanced search
+    @Test
+    public void testAdvancedSearch()
+        throws Exception
+    {
+        List<File> files = new ArrayList<File>();
+        files.add( new File( FileUtil.getBasedir(), "src/test/" + TEST_REPO_2
+            + "/org/apache/archiva/archiva-search/1.0/archiva-search-1.0.jar" ) );
+        files.add( new File( FileUtil.getBasedir(), "src/test/" + TEST_REPO_2
+            + "/org/apache/archiva/archiva-search/1.1/archiva-search-1.1.jar" ) );
+        createIndex( TEST_REPO_2, files, false );
+
+        List<String> selectedRepos = new ArrayList<String>();
+        selectedRepos.add( TEST_REPO_2 );
+
+        SearchFields searchFields = new SearchFields();
+        searchFields.setGroupId( "org.apache.archiva" );
+        searchFields.setVersion( "1.0" );
+        searchFields.setRepositories( selectedRepos );
+
+        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
+
+        archivaConfigControl.replay();
+
+        SearchResults results = search.search( "user", searchFields, null );
+
+        archivaConfigControl.verify();
+
+        assertNotNull( results );
+        assertEquals( 1, results.getTotalHits() );
+
+        SearchResultHit hit = results.getHits().get( 0 );
+        assertEquals( "org.apache.archiva", hit.getGroupId() );
+        assertEquals( "archiva-search", hit.getArtifactId() );
+        assertEquals( "1.0", hit.getVersions().get( 0 ) );
+    }
+
+    @Test
+    public void testAdvancedSearchWithPagination()
+        throws Exception
+    {
+        createIndexContainingMoreArtifacts( false );
+
+        List<String> selectedRepos = new ArrayList<String>();
+        selectedRepos.add( TEST_REPO_1 );
+
+        SearchFields searchFields = new SearchFields();
+        searchFields.setGroupId( "org.apache.archiva" );
+        searchFields.setRepositories( selectedRepos );
+
+        // page 1
+
+        SearchResultLimits limits = new SearchResultLimits( 0 );
+        limits.setPageSize( 1 );
+
+        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
+
+        archivaConfigControl.replay();
+
+        SearchResults results = search.search( "user", searchFields, limits );
+
+        archivaConfigControl.verify();
+
+        assertNotNull( results );
+        assertEquals( 4, results.getTotalHits() );
+        assertEquals( 1, results.getHits().size() );
+
+        // page 2
+        archivaConfigControl.reset();
+
+        limits = new SearchResultLimits( 1 );
+        limits.setPageSize( 1 );
+
+        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
+
+        archivaConfigControl.replay();
+
+        results = search.search( "user", searchFields, limits );
+
+        archivaConfigControl.verify();
+
+        assertNotNull( results );
+        assertEquals( 4, results.getTotalHits() );
+        assertEquals( 1, results.getHits().size() );
+    }
+
+    // MRM-981 - artifactIds with numeric characters aren't found in advanced search
+    @Test
+    public void testAdvancedSearchArtifactIdHasNumericChar()
+        throws Exception
+    {
+        List<File> files = new ArrayList<File>();
+        files.add( new File( FileUtil.getBasedir(),
+                             "src/test/" + TEST_REPO_1 + "/com/artifactid-numeric/1.0/artifactid-numeric-1.0.jar" ) );
+        files.add( new File( FileUtil.getBasedir(), "src/test/" + TEST_REPO_1
+            + "/com/artifactid-numeric123/1.0/artifactid-numeric123-1.0.jar" ) );
+        createIndex( TEST_REPO_1, files, true );
+
+        List<String> selectedRepos = new ArrayList<String>();
+        selectedRepos.add( TEST_REPO_1 );
+
+        SearchFields searchFields = new SearchFields();
+        searchFields.setArtifactId( "artifactid-numeric" );
+        searchFields.setRepositories( selectedRepos );
+
+        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
+
+        archivaConfigControl.replay();
+
+        SearchResults results = search.search( "user", searchFields, null );
+
+        archivaConfigControl.verify();
+
+        assertNotNull( results );
+        assertEquals( 2, results.getTotalHits() );
+    }
+
+    @Test
+    public void testAdvancedSearchNoRepositoriesConfigured()
+        throws Exception
+    {
+        SearchFields searchFields = new SearchFields();
+        searchFields.setArtifactId( "archiva" );
+        searchFields.setRepositories( null );
+
+        try
+        {
+            search.search( "user", searchFields, null );
+            fail( "A RepositorySearchExcecption should have been thrown." );
+        }
+        catch ( RepositorySearchException e )
+        {
+            assertEquals( "Repositories cannot be null.", e.getMessage() );
+        }
+    }
+
+    @Test
+    public void testAdvancedSearchSearchFieldsAreNull()
+        throws Exception
+    {
+        List<String> selectedRepos = new ArrayList<String>();
+        selectedRepos.add( TEST_REPO_1 );
+
+        SearchFields searchFields = new SearchFields();
+        searchFields.setRepositories( selectedRepos );
+
+        try
+        {
+            archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
+
+            archivaConfigControl.replay();
+
+            search.search( "user", searchFields, null );
+
+            archivaConfigControl.verify();
+
+            fail( "A RepositorySearchExcecption should have been thrown." );
+        }
+        catch ( RepositorySearchException e )
+        {
+            assertEquals( "No search fields set.", e.getMessage() );
+        }
+    }
+
+    @Test
+    public void testAdvancedSearchSearchFieldsAreBlank()
+        throws Exception
+    {
+        List<String> selectedRepos = new ArrayList<String>();
+        selectedRepos.add( TEST_REPO_1 );
+
+        SearchFields searchFields = new SearchFields();
+        searchFields.setGroupId( "" );
+        searchFields.setArtifactId( "" );
+        searchFields.setVersion( "" );
+        searchFields.setPackaging( "" );
+        searchFields.setClassName( "" );
+
+        searchFields.setRepositories( selectedRepos );
+
+        try
+        {
+            archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
+
+            archivaConfigControl.replay();
+
+            search.search( "user", searchFields, null );
+
+            archivaConfigControl.verify();
+
+            fail( "A RepositorySearchExcecption should have been thrown." );
+        }
+        catch ( RepositorySearchException e )
+        {
+            assertEquals( "No search fields set.", e.getMessage() );
+        }
+    }
+
+    @Test
+    public void testAdvancedSearchAllSearchCriteriaSpecified()
+        throws Exception
+    {
+        createSimpleIndex( true );
+
+        List<String> selectedRepos = new ArrayList<String>();
+        selectedRepos.add( TEST_REPO_1 );
+
+        SearchFields searchFields = new SearchFields();
+        searchFields.setGroupId( "org.apache.archiva" );
+        searchFields.setArtifactId( "archiva-test" );
+        searchFields.setVersion( "2.0" );
+        searchFields.setPackaging( "jar" );
+        searchFields.setClassName( "org.apache.archiva.test.App" );
+        searchFields.setRepositories( selectedRepos );
+
+        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
+
+        archivaConfigControl.replay();
+
+        SearchResults results = search.search( "user", searchFields, null );
+
+        archivaConfigControl.verify();
+
+        assertNotNull( results );
+
+        assertEquals( "total hints not 1" + results, 1, results.getTotalHits() );
+
+        SearchResultHit hit = results.getHits().get( 0 );
+        assertEquals( "org.apache.archiva", hit.getGroupId() );
+        assertEquals( "archiva-test", hit.getArtifactId() );
+        assertEquals( "version not 2.0", "2.0", hit.getVersions().get( 0 ) );
+    }
+
+    @Test
+    public void testAdvancedSearchJarArtifacts()
+        throws Exception
+    {
+        createIndexContainingMoreArtifacts( true );
+
+        List<String> selectedRepos = new ArrayList<String>();
+        selectedRepos.add( TEST_REPO_1 );
+
+        SearchFields searchFields = new SearchFields();
+        searchFields.setPackaging( "jar" );
+        searchFields.setRepositories( selectedRepos );
+
+        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
+
+        archivaConfigControl.replay();
+
+        SearchResults results = search.search( "user", searchFields, null );
+
+        archivaConfigControl.verify();
+
+        assertNotNull( results );
+        assertEquals( "not 8 but " + results.getTotalHits() + ":" + niceDisplay( results ), 8, results.getTotalHits() );
+    }
+
+    @Test
+    public void testAdvancedSearchWithIncorrectPackaging()
+        throws Exception
+    {
+        createSimpleIndex( true );
+
+        List<String> selectedRepos = new ArrayList<String>();
+        selectedRepos.add( TEST_REPO_1 );
+
+        SearchFields searchFields = new SearchFields();
+        searchFields.setGroupId( "org.apache.archiva" );
+        searchFields.setArtifactId( "archiva-test" );
+        searchFields.setVersion( "2.0" );
+        searchFields.setPackaging( "war" );
+        searchFields.setRepositories( selectedRepos );
+
+        archivaConfigControl.expectAndDefaultReturn( archivaConfig.getConfiguration(), config );
+        archivaConfigControl.replay();
+
+        SearchResults results = search.search( "user", searchFields, null );
+
+        archivaConfigControl.verify();
+
+        assertNotNull( results );
+        assertEquals( 0, results.getTotalHits() );
+    }
+
+    @Test
+    public void testAdvancedSearchClassname()
+        throws Exception
+    {
+        createIndexContainingMoreArtifacts( true );
+
+        List<String> selectedRepos = Arrays.asList( TEST_REPO_1 );
+
+        SearchFields searchFields = new SearchFields();
+        searchFields.setClassName( "com.classname.search.App" );
+        searchFields.setRepositories( selectedRepos );
+
+        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
+
+        archivaConfigControl.replay();
+
+        SearchResults results = search.search( "user", searchFields, null );
+
+        archivaConfigControl.verify();
+
+        assertNotNull( results );
+        assertEquals( "totalHits not 1 results " + results, 1, results.getTotalHits() );
+
+        SearchResultHit hit = results.getHits().get( 0 );
+        assertEquals( "groupId not com", "com", hit.getGroupId() );
+        assertEquals( "arttifactId not classname-search", "classname-search", hit.getArtifactId() );
+        assertEquals( " hits.version(0) not 1.0", "1.0", hit.getVersions().get( 0 ) );
+    }
+
+    @Test
+    public void testAdvancedSearchNoIndexFound()
+        throws Exception
+    {
+        List<String> selectedRepos = new ArrayList<String>();
+        selectedRepos.add( TEST_REPO_1 );
+
+        SearchFields searchFields = new SearchFields();
+        searchFields.setGroupId( "org.apache.archiva" );
+        searchFields.setRepositories( selectedRepos );
+
+        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
+
+        archivaConfigControl.replay();
+
+        SearchResults results = search.search( "user", searchFields, null );
+
+        archivaConfigControl.verify();
+
+        assertNotNull( results );
+        assertEquals( 0, results.getTotalHits() );
+    }
+
+    @Test
+    public void testAdvancedSearchClassNameInWar()
+        throws Exception
+    {
+        createIndexContainingMoreArtifacts( true );
+
+        List<String> selectedRepos = Arrays.asList( TEST_REPO_1 );
+
+        SearchFields searchFields = new SearchFields();
+        searchFields.setClassName( "SomeClass" );
+        searchFields.setRepositories( selectedRepos );
+
+        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
+
+        archivaConfigControl.replay();
+
+        SearchResults results = search.search( "user", searchFields, null );
+
+        archivaConfigControl.verify();
+
+        assertNotNull( results );
+        assertEquals( 1, results.getHits().size() );
+        assertEquals( "test-webapp", results.getHits().get( 0 ).getArtifactId() );
+    }
+
+    @Test
+    public void getAllGroupIds()
+        throws Exception
+    {
+        createIndexContainingMoreArtifacts( true );
+
+        List<String> selectedRepos = Arrays.asList( TEST_REPO_1 );
+
+        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 0, 2 );
+
+        archivaConfigControl.replay();
+
+        Collection<String> groupIds = search.getAllGroupIds( "user", selectedRepos );
+
+        archivaConfigControl.verify();
+
+        log.info( "groupIds: " + groupIds );
+
+        assertEquals( 3, groupIds.size() );
+        assertTrue( groupIds.contains( "com" ) );
+        assertTrue( groupIds.contains( "org.apache.felix" ) );
+        assertTrue( groupIds.contains( "org.apache.archiva" ) );
+    }
+
+    @Test
+    public void testSearchWithUnknownRepo()
+        throws Exception
+    {
+        createIndexContainingMoreArtifacts( true );
+
+        List<String> selectedRepos = Arrays.asList( "foo" );
+
+        SearchFields searchFields = new SearchFields();
+        searchFields.setClassName( "SomeClass" );
+        searchFields.setRepositories( selectedRepos );
+
+        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
+
+        archivaConfigControl.replay();
+
+        SearchResults results = search.search( "user", searchFields, null );
+
+        archivaConfigControl.verify();
+
+        assertNotNull( results );
+        assertEquals( 0, results.getHits().size() );
+    }
+
+    @Test
+    public void nolimitedResult()
+        throws Exception
+    {
+
+        File repo = new File( "target/repo-release" );
+        File indexDirectory = new File( repo, ".index" );
+        FileUtils.copyDirectoryStructure( new File( "src/test/repo-release" ), repo );
+
+        createIndex( "repo-release", Collections.<File>emptyList(), false );
+
+        nexusIndexer.addIndexingContext( REPO_RELEASE, REPO_RELEASE, repo, indexDirectory,
+                                         repo.toURI().toURL().toExternalForm(),
+                                         indexDirectory.toURI().toURL().toString(), search.getAllIndexCreators() );
+
+        SearchResultLimits limits = new SearchResultLimits( 0 );
+        limits.setPageSize( 300 );
+
+        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 5 );
+
+        archivaConfigControl.replay();
+
+        SearchResults searchResults = search.search( null, Arrays.asList( REPO_RELEASE ), "org.example", limits,
+                                                     Collections.<String>emptyList() );
+
+        log.info( "results: {}", searchResults.getHits().size() );
+
+        assertEquals( 255, searchResults.getHits().size() );
+
+        SearchFields searchFields = new SearchFields();
+        searchFields.setGroupId( "org.example" );
+        searchFields.setRepositories( Arrays.asList( REPO_RELEASE ) );
+
+        searchResults = search.search( null, searchFields, limits );
+
+        log.info( "results: {}", searchResults.getHits().size() );
+
+        assertEquals( 255, searchResults.getHits().size() );
+
+        archivaConfigControl.verify();
+    }
+}
diff --git a/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/NexusRepositorySearchOSGITest.java b/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/NexusRepositorySearchOSGITest.java
deleted file mode 100644 (file)
index 9cc6763..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-package org.apache.archiva.indexer.search;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.junit.Test;
-
-import java.io.File;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-/**
- * @author Olivier Lamy
- */
-public class NexusRepositorySearchOSGITest
-    extends AbstractNexusRepositorySearch
-{
-
-    @Test
-    public void searchFelixWithSymbolicName()
-        throws Exception
-    {
-
-        createIndex( TEST_REPO_1, Collections.<File>emptyList(), true );
-
-        List<String> selectedRepos = Arrays.asList( TEST_REPO_1 );
-
-        // search artifactId
-        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
-
-        archivaConfigControl.replay();
-
-        SearchFields searchFields = new SearchFields();
-        searchFields.setBundleSymbolicName( "org.apache.felix.bundlerepository" );
-        searchFields.setBundleVersion( "1.6.6" );
-        searchFields.setRepositories( selectedRepos );
-
-        SearchResults results = search.search( "user", searchFields, null );
-
-        archivaConfigControl.verify();
-
-        assertNotNull( results );
-        assertEquals( 1, results.getTotalHits() );
-
-        SearchResultHit hit = results.getHits().get( 0 );
-        assertEquals( "org.apache.felix", hit.getGroupId() );
-        assertEquals( "org.apache.felix.bundlerepository", hit.getArtifactId() );
-        assertEquals( "1.6.6", hit.getVersions().get( 0 ) );
-
-        assertEquals( "org.apache.felix.bundlerepository;uses:=\"org.osgi.framework\";version=\"2.0\"",
-                      hit.getBundleExportPackage() );
-        assertEquals( "org.apache.felix.bundlerepository.RepositoryAdmin,org.osgi.service.obr.RepositoryAdmin",
-                      hit.getBundleExportService() );
-        assertEquals( "org.apache.felix.bundlerepository", hit.getBundleSymbolicName() );
-        assertEquals( "1.6.6", hit.getBundleVersion() );
-    }
-
-}
diff --git a/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/NexusRepositorySearchPaginateTest.java b/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/NexusRepositorySearchPaginateTest.java
deleted file mode 100644 (file)
index 3d2f01e..0000000
+++ /dev/null
@@ -1,105 +0,0 @@
-package org.apache.archiva.indexer.search;
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import junit.framework.TestCase;
-import org.apache.archiva.indexer.util.SearchUtil;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import java.util.Arrays;
-import org.apache.archiva.test.utils.ArchivaBlockJUnit4ClassRunner;
-
-/**
- * @author Olivier Lamy
- */
-@RunWith( ArchivaBlockJUnit4ClassRunner.class )
-public class NexusRepositorySearchPaginateTest
-    extends TestCase
-{
-    @Test
-    public void nonPaginatedResult()
-        throws Exception
-    {
-        MavenRepositorySearch search = new MavenRepositorySearch();
-
-        SearchResults searchResults = build( 10, new SearchResultLimits( 0 ) );
-
-        searchResults = search.paginate( searchResults );
-
-        assertEquals( 10, searchResults.getReturnedHitsCount() );
-
-    }
-
-    @Test
-    public void nonPaginatedHugeResult()
-        throws Exception
-    {
-        MavenRepositorySearch search = new MavenRepositorySearch();
-
-        SearchResults origSearchResults = build( 63, new SearchResultLimits( 0 ) );
-
-        SearchResults searchResults = search.paginate( origSearchResults );
-
-        assertEquals( 30, searchResults.getReturnedHitsCount() );
-
-        origSearchResults = build( 63, new SearchResultLimits( 1 ) );
-
-        searchResults = search.paginate( origSearchResults );
-
-        assertEquals( 30, searchResults.getReturnedHitsCount() );
-
-    }
-
-    @Test
-    public void paginatedResult()
-        throws Exception
-    {
-        MavenRepositorySearch search = new MavenRepositorySearch();
-
-        SearchResults searchResults = build( 32, new SearchResultLimits( 1 ) );
-
-        searchResults = search.paginate( searchResults );
-
-        assertEquals( 2, searchResults.getReturnedHitsCount() );
-
-    }
-
-
-    SearchResults build( int number, SearchResultLimits limits )
-    {
-        SearchResults searchResults = new SearchResults();
-        searchResults.setLimits( limits );
-        for ( int i = 0; i < number; i++ )
-        {
-            SearchResultHit hit = new SearchResultHit();
-            hit.setGroupId( "commons-foo" );
-            hit.setArtifactId( "commons-bar-" + i );
-            hit.setPackaging( "jar" );
-            hit.setVersions( Arrays.asList( "1.0" ) );
-            String id =
-                SearchUtil.getHitId( hit.getGroupId(), hit.getArtifactId(), hit.getClassifier(), hit.getPackaging() );
-            searchResults.addHit( id, hit );
-        }
-
-        searchResults.setTotalHits( number );
-        return searchResults;
-
-    }
-}
diff --git a/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/NexusRepositorySearchTest.java b/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/NexusRepositorySearchTest.java
deleted file mode 100644 (file)
index 2d5d970..0000000
+++ /dev/null
@@ -1,899 +0,0 @@
-package org.apache.archiva.indexer.search;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.archiva.common.utils.FileUtil;
-import org.apache.archiva.indexer.util.SearchUtil;
-import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
-import org.codehaus.plexus.util.FileUtils;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.test.context.ContextConfiguration;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-
-
-@RunWith ( ArchivaSpringJUnit4ClassRunner.class )
-@ContextConfiguration ( locations = { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context.xml" } )
-public class NexusRepositorySearchTest
-    extends AbstractNexusRepositorySearch
-{
-
-
-    private void createSimpleIndex( boolean scan )
-        throws Exception
-    {
-        List<File> files = new ArrayList<File>();
-        files.add( new File( FileUtil.getBasedir(), "src/test/" + TEST_REPO_1
-            + "/org/apache/archiva/archiva-search/1.0/archiva-search-1.0.jar" ) );
-        files.add( new File( FileUtil.getBasedir(), "src/test/" + TEST_REPO_1
-            + "/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.jar" ) );
-        files.add( new File( FileUtil.getBasedir(), "/src/test/" + TEST_REPO_1
-            + "/org/apache/archiva/archiva-test/2.0/archiva-test-2.0.jar" ) );
-
-        createIndex( TEST_REPO_1, files, scan );
-    }
-
-    private void createIndexContainingMoreArtifacts( boolean scan )
-        throws Exception
-    {
-        List<File> files = new ArrayList<File>();
-        files.add( new File( FileUtil.getBasedir(), "src/test/" + TEST_REPO_1
-            + "/org/apache/archiva/archiva-search/1.0/archiva-search-1.0.jar" ) );
-        files.add( new File( FileUtil.getBasedir(), "src/test/" + TEST_REPO_1
-            + "/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.jar" ) );
-        files.add( new File( FileUtil.getBasedir(), "src/test/" + TEST_REPO_1
-            + "/org/apache/archiva/archiva-test/2.0/archiva-test-2.0.jar" ) );
-        files.add( new File( FileUtil.getBasedir(), "src/test/" + TEST_REPO_1
-            + "/org/apache/archiva/archiva-webapp/1.0/archiva-webapp-1.0.war" ) );
-        files.add( new File( FileUtil.getBasedir(),
-                             "src/test/" + TEST_REPO_1 + "/com/artifactid-numeric/1.0/artifactid-numeric-1.0.jar" ) );
-        files.add( new File( FileUtil.getBasedir(), "src/test/" + TEST_REPO_1
-            + "/com/artifactid-numeric123/1.0/artifactid-numeric123-1.0.jar" ) );
-        files.add( new File( FileUtil.getBasedir(),
-                             "src/test/" + TEST_REPO_1 + "/com/classname-search/1.0/classname-search-1.0.jar" ) );
-
-        createIndex( TEST_REPO_1, files, scan );
-    }
-
-    private void createIndexContainingMultipleArtifactsSameVersion( boolean scan )
-        throws Exception
-    {
-        List<File> files = new ArrayList<File>();
-
-        files.add( new File( FileUtil.getBasedir(), "src/test/" + TEST_REPO_1
-            + "/org/apache/archiva/archiva-search/1.0/archiva-search-1.0.jar" ) );
-        files.add( new File( FileUtil.getBasedir(), "src/test/" + TEST_REPO_1
-            + "/org/apache/archiva/archiva-search/1.0/archiva-search-1.0-sources.jar" ) );
-
-        createIndex( TEST_REPO_1, files, scan );
-    }
-
-    @Test
-    public void testQuickSearch()
-        throws Exception
-    {
-        createSimpleIndex( false );
-
-        List<String> selectedRepos = Arrays.asList( TEST_REPO_1 );
-
-        // search artifactId
-        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
-
-        archivaConfigControl.replay();
-
-        SearchResults results = search.search( "user", selectedRepos, "archiva-search", null, null );
-
-        archivaConfigControl.verify();
-
-        assertNotNull( results );
-
-        SearchResultHit hit =
-            results.getSearchResultHit( SearchUtil.getHitId( "org.apache.archiva", "archiva-search", null, "jar" ) );
-        assertNotNull( "hit null in result " + results.getHits(), hit );
-        assertEquals( "org.apache.archiva", hit.getGroupId() );
-        assertEquals( "archiva-search", hit.getArtifactId() );
-        assertEquals( "1.0", hit.getVersions().get( 0 ) );
-
-        archivaConfigControl.reset();
-
-        // search groupId
-        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
-
-        archivaConfigControl.replay();
-
-        results = search.search( "user", selectedRepos, "org.apache.archiva", null, null );
-
-        archivaConfigControl.verify();
-
-        assertNotNull( results );
-        assertEquals( "total hints not 3", 3, results.getTotalHits() );
-
-        //TODO: search for class & package names
-    }
-
-    @Test
-    public void testQuickSearchNotWithClassifier()
-        throws Exception
-    {
-        createSimpleIndex( true );
-
-        List<String> selectedRepos = Arrays.asList( TEST_REPO_1 );
-
-        // search artifactId
-        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
-
-        archivaConfigControl.replay();
-
-        SearchResults results = search.search( "user", selectedRepos, "archiva-search", null, null );
-
-        archivaConfigControl.verify();
-
-        assertNotNull( results );
-
-        SearchResultHit hit =
-            results.getSearchResultHit( SearchUtil.getHitId( "org.apache.archiva", "archiva-search", null, "jar" ) );
-        assertNotNull( "hit null in result " + results.getHits(), hit );
-        assertEquals( "org.apache.archiva", hit.getGroupId() );
-        assertEquals( "archiva-search", hit.getArtifactId() );
-        assertEquals( "1.0", hit.getVersions().get( 0 ) );
-
-        archivaConfigControl.reset();
-
-        // search groupId
-        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
-
-        archivaConfigControl.replay();
-
-        results = search.search( "user", selectedRepos, "archiva-search", null, null );
-
-        archivaConfigControl.verify();
-
-        assertNotNull( results );
-        assertEquals( "total hints not 3 hits " + results.getHits(), 3, results.getTotalHits() );
-
-        //TODO: search for class & package names
-    }
-
-    @Test
-    public void testQuickSearchMultipleArtifactsSameVersion()
-        throws Exception
-    {
-        createIndexContainingMultipleArtifactsSameVersion( false );
-
-        List<String> selectedRepos = new ArrayList<String>();
-        selectedRepos.add( TEST_REPO_1 );
-
-        // search artifactId
-        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
-
-        archivaConfigControl.replay();
-
-        SearchResults results = search.search( "user", selectedRepos, "archiva-search", null, null );
-
-        archivaConfigControl.verify();
-
-        assertNotNull( results );
-        assertEquals( 2, results.getTotalHits() );
-
-        SearchResultHit hit = results.getHits().get( 0 );
-        assertEquals( "org.apache.archiva", hit.getGroupId() );
-        assertEquals( "archiva-search", hit.getArtifactId() );
-        assertEquals( "1.0", hit.getVersions().get( 0 ) );
-
-        //only 1 version of 1.0 is retrieved
-        assertEquals( 1, hit.getVersions().size() );
-    }
-
-    @Test
-    public void testMultipleArtifactsSameVersionWithClassifier()
-        throws Exception
-    {
-        createIndexContainingMultipleArtifactsSameVersion( true );
-
-        List<String> selectedRepos = new ArrayList<String>();
-        selectedRepos.add( TEST_REPO_1 );
-
-        // search artifactId
-        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
-
-        archivaConfigControl.replay();
-
-        SearchFields searchFields = new SearchFields();
-        searchFields.setGroupId( "org.apache.archiva" );
-        searchFields.setArtifactId( "archiva-search" );
-        searchFields.setClassifier( "sources" );
-        searchFields.setRepositories( selectedRepos );
-
-        SearchResults results = search.search( "user", searchFields, null );
-
-        archivaConfigControl.verify();
-
-        assertNotNull( results );
-        assertEquals( 1, results.getTotalHits() );
-
-        SearchResultHit hit = results.getHits().get( 0 );
-        assertEquals( "org.apache.archiva", hit.getGroupId() );
-        assertEquals( "archiva-search", hit.getArtifactId() );
-        assertEquals( "1.0", hit.getVersions().get( 0 ) );
-
-        //only 1 version of 1.0 is retrieved
-        assertEquals( 1, hit.getVersions().size() );
-    }
-
-    // search for existing artifact using multiple keywords
-    @Test
-    public void testQuickSearchWithMultipleKeywords()
-        throws Exception
-    {
-        createSimpleIndex( false );
-
-        List<String> selectedRepos = new ArrayList<String>();
-        selectedRepos.add( TEST_REPO_1 );
-
-        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
-        archivaConfigControl.replay();
-
-        SearchResults results = search.search( "user", selectedRepos, "archiva search", null, null );
-
-        archivaConfigControl.verify();
-
-        assertNotNull( results );
-        assertEquals( 1, results.getTotalHits() );
-    }
-
-    @Test
-    public void testQuickSearchWithPagination()
-        throws Exception
-    {
-        createSimpleIndex( true );
-
-        List<String> selectedRepos = new ArrayList<String>();
-        selectedRepos.add( TEST_REPO_1 );
-
-        // page 1
-        SearchResultLimits limits = new SearchResultLimits( 0 );
-        limits.setPageSize( 1 );
-
-        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
-
-        archivaConfigControl.replay();
-
-        SearchResults results = search.search( "user", selectedRepos, "org", limits, new ArrayList<String>() );
-
-        archivaConfigControl.verify();
-
-        assertNotNull( results );
-        assertEquals( 1, results.getHits().size() );
-        assertEquals( "total hits not 8 for page1 " + results, 8, results.getTotalHits() );
-        assertEquals( "returned hits not 1 for page1 " + results, 1, results.getReturnedHitsCount() );
-        assertEquals( limits, results.getLimits() );
-
-        archivaConfigControl.reset();
-
-        // page 2
-        limits = new SearchResultLimits( 1 );
-        limits.setPageSize( 1 );
-
-        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
-
-        archivaConfigControl.replay();
-
-        results = search.search( "user", selectedRepos, "org", limits, null );
-
-        archivaConfigControl.verify();
-
-        assertNotNull( results );
-
-        assertEquals( "hits not 1", 1, results.getHits().size() );
-        assertEquals( "total hits not 8 for page 2 " + results, 8, results.getTotalHits() );
-        assertEquals( "returned hits not 1 for page2 " + results, 1, results.getReturnedHitsCount() );
-        assertEquals( limits, results.getLimits() );
-    }
-
-    @Test
-    public void testArtifactFoundInMultipleRepositories()
-        throws Exception
-    {
-        createSimpleIndex( true );
-
-        List<File> files = new ArrayList<File>();
-        files.add( new File( FileUtil.getBasedir(), "src/test/" + TEST_REPO_2
-            + "/org/apache/archiva/archiva-search/1.0/archiva-search-1.0.jar" ) );
-        files.add( new File( FileUtil.getBasedir(), "src/test/" + TEST_REPO_2
-            + "/org/apache/archiva/archiva-search/1.1/archiva-search-1.1.jar" ) );
-        createIndex( TEST_REPO_2, files, false );
-
-        List<String> selectedRepos = new ArrayList<String>();
-        selectedRepos.add( TEST_REPO_1 );
-        selectedRepos.add( TEST_REPO_2 );
-
-        config.addManagedRepository( createRepositoryConfig( TEST_REPO_2 ) );
-
-        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 5 );
-
-        archivaConfigControl.replay();
-
-        // wait lucene flush.....
-        Thread.sleep( 2000 );
-
-        SearchResults results = search.search( "user", selectedRepos, "archiva-search", null, null );
-
-        archivaConfigControl.verify();
-
-        assertNotNull( results );
-
-        SearchResultHit hit =
-            results.getSearchResultHit( SearchUtil.getHitId( "org.apache.archiva", "archiva-search", null, "jar" ) );
-        assertEquals( "org.apache.archiva", hit.getGroupId() );
-        assertEquals( "archiva-search", hit.getArtifactId() );
-        assertEquals( "not 2 version for hit " + hit + "::" + niceDisplay( results ), 2, hit.getVersions().size() );
-        assertTrue( hit.getVersions().contains( "1.0" ) );
-        assertTrue( hit.getVersions().contains( "1.1" ) );
-
-        archivaConfigControl.reset();
-
-        // TODO: [BROWSE] in artifact info from browse, display all the repositories where the artifact is found
-    }
-
-    @Test
-    public void testNoMatchFound()
-        throws Exception
-    {
-        createSimpleIndex( false );
-
-        List<String> selectedRepos = new ArrayList<String>();
-        selectedRepos.add( TEST_REPO_1 );
-
-        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
-
-        archivaConfigControl.replay();
-
-        SearchResults results = search.search( "user", selectedRepos, "dfghdfkweriuasndsaie", null, null );
-
-        archivaConfigControl.verify();
-
-        assertNotNull( results );
-        assertEquals( 0, results.getTotalHits() );
-    }
-
-    @Test
-    public void testNoIndexFound()
-        throws Exception
-    {
-        List<String> selectedRepos = new ArrayList<String>();
-        selectedRepos.add( TEST_REPO_1 );
-
-        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
-
-        archivaConfigControl.replay();
-
-        SearchResults results = search.search( "user", selectedRepos, "org.apache.archiva", null, null );
-        assertNotNull( results );
-        assertEquals( 0, results.getTotalHits() );
-
-        archivaConfigControl.verify();
-    }
-
-    @Test
-    public void testRepositoryNotFound()
-        throws Exception
-    {
-        List<String> selectedRepos = new ArrayList<String>();
-        selectedRepos.add( "non-existing-repo" );
-
-        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
-
-        archivaConfigControl.replay();
-
-        SearchResults results = search.search( "user", selectedRepos, "org.apache.archiva", null, null );
-        assertNotNull( results );
-        assertEquals( 0, results.getTotalHits() );
-
-        archivaConfigControl.verify();
-    }
-
-    @Test
-    public void testSearchWithinSearchResults()
-        throws Exception
-    {
-        createSimpleIndex( true );
-
-        List<String> selectedRepos = new ArrayList<String>();
-        selectedRepos.add( TEST_REPO_1 );
-
-        List<String> previousSearchTerms = new ArrayList<String>();
-        previousSearchTerms.add( "archiva-test" );
-
-        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
-
-        archivaConfigControl.replay();
-
-        SearchResults results = search.search( "user", selectedRepos, "1.0", null, previousSearchTerms );
-
-        archivaConfigControl.verify();
-
-        assertNotNull( results );
-        assertEquals( "total hints not 1", 1, results.getTotalHits() );
-
-        SearchResultHit hit = results.getHits().get( 0 );
-        assertEquals( "org.apache.archiva", hit.getGroupId() );
-        assertEquals( "archiva-test", hit.getArtifactId() );
-        assertEquals( "versions not 1", 1, hit.getVersions().size() );
-        assertEquals( "1.0", hit.getVersions().get( 0 ) );
-    }
-
-    // tests for advanced search
-    @Test
-    public void testAdvancedSearch()
-        throws Exception
-    {
-        List<File> files = new ArrayList<File>();
-        files.add( new File( FileUtil.getBasedir(), "src/test/" + TEST_REPO_2
-            + "/org/apache/archiva/archiva-search/1.0/archiva-search-1.0.jar" ) );
-        files.add( new File( FileUtil.getBasedir(), "src/test/" + TEST_REPO_2
-            + "/org/apache/archiva/archiva-search/1.1/archiva-search-1.1.jar" ) );
-        createIndex( TEST_REPO_2, files, false );
-
-        List<String> selectedRepos = new ArrayList<String>();
-        selectedRepos.add( TEST_REPO_2 );
-
-        SearchFields searchFields = new SearchFields();
-        searchFields.setGroupId( "org.apache.archiva" );
-        searchFields.setVersion( "1.0" );
-        searchFields.setRepositories( selectedRepos );
-
-        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
-
-        archivaConfigControl.replay();
-
-        SearchResults results = search.search( "user", searchFields, null );
-
-        archivaConfigControl.verify();
-
-        assertNotNull( results );
-        assertEquals( 1, results.getTotalHits() );
-
-        SearchResultHit hit = results.getHits().get( 0 );
-        assertEquals( "org.apache.archiva", hit.getGroupId() );
-        assertEquals( "archiva-search", hit.getArtifactId() );
-        assertEquals( "1.0", hit.getVersions().get( 0 ) );
-    }
-
-    @Test
-    public void testAdvancedSearchWithPagination()
-        throws Exception
-    {
-        createIndexContainingMoreArtifacts( false );
-
-        List<String> selectedRepos = new ArrayList<String>();
-        selectedRepos.add( TEST_REPO_1 );
-
-        SearchFields searchFields = new SearchFields();
-        searchFields.setGroupId( "org.apache.archiva" );
-        searchFields.setRepositories( selectedRepos );
-
-        // page 1
-
-        SearchResultLimits limits = new SearchResultLimits( 0 );
-        limits.setPageSize( 1 );
-
-        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
-
-        archivaConfigControl.replay();
-
-        SearchResults results = search.search( "user", searchFields, limits );
-
-        archivaConfigControl.verify();
-
-        assertNotNull( results );
-        assertEquals( 4, results.getTotalHits() );
-        assertEquals( 1, results.getHits().size() );
-
-        // page 2
-        archivaConfigControl.reset();
-
-        limits = new SearchResultLimits( 1 );
-        limits.setPageSize( 1 );
-
-        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
-
-        archivaConfigControl.replay();
-
-        results = search.search( "user", searchFields, limits );
-
-        archivaConfigControl.verify();
-
-        assertNotNull( results );
-        assertEquals( 4, results.getTotalHits() );
-        assertEquals( 1, results.getHits().size() );
-    }
-
-    // MRM-981 - artifactIds with numeric characters aren't found in advanced search
-    @Test
-    public void testAdvancedSearchArtifactIdHasNumericChar()
-        throws Exception
-    {
-        List<File> files = new ArrayList<File>();
-        files.add( new File( FileUtil.getBasedir(),
-                             "src/test/" + TEST_REPO_1 + "/com/artifactid-numeric/1.0/artifactid-numeric-1.0.jar" ) );
-        files.add( new File( FileUtil.getBasedir(), "src/test/" + TEST_REPO_1
-            + "/com/artifactid-numeric123/1.0/artifactid-numeric123-1.0.jar" ) );
-        createIndex( TEST_REPO_1, files, true );
-
-        List<String> selectedRepos = new ArrayList<String>();
-        selectedRepos.add( TEST_REPO_1 );
-
-        SearchFields searchFields = new SearchFields();
-        searchFields.setArtifactId( "artifactid-numeric" );
-        searchFields.setRepositories( selectedRepos );
-
-        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
-
-        archivaConfigControl.replay();
-
-        SearchResults results = search.search( "user", searchFields, null );
-
-        archivaConfigControl.verify();
-
-        assertNotNull( results );
-        assertEquals( 2, results.getTotalHits() );
-    }
-
-    @Test
-    public void testAdvancedSearchNoRepositoriesConfigured()
-        throws Exception
-    {
-        SearchFields searchFields = new SearchFields();
-        searchFields.setArtifactId( "archiva" );
-        searchFields.setRepositories( null );
-
-        try
-        {
-            search.search( "user", searchFields, null );
-            fail( "A RepositorySearchExcecption should have been thrown." );
-        }
-        catch ( RepositorySearchException e )
-        {
-            assertEquals( "Repositories cannot be null.", e.getMessage() );
-        }
-    }
-
-    @Test
-    public void testAdvancedSearchSearchFieldsAreNull()
-        throws Exception
-    {
-        List<String> selectedRepos = new ArrayList<String>();
-        selectedRepos.add( TEST_REPO_1 );
-
-        SearchFields searchFields = new SearchFields();
-        searchFields.setRepositories( selectedRepos );
-
-        try
-        {
-            archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
-
-            archivaConfigControl.replay();
-
-            search.search( "user", searchFields, null );
-
-            archivaConfigControl.verify();
-
-            fail( "A RepositorySearchExcecption should have been thrown." );
-        }
-        catch ( RepositorySearchException e )
-        {
-            assertEquals( "No search fields set.", e.getMessage() );
-        }
-    }
-
-    @Test
-    public void testAdvancedSearchSearchFieldsAreBlank()
-        throws Exception
-    {
-        List<String> selectedRepos = new ArrayList<String>();
-        selectedRepos.add( TEST_REPO_1 );
-
-        SearchFields searchFields = new SearchFields();
-        searchFields.setGroupId( "" );
-        searchFields.setArtifactId( "" );
-        searchFields.setVersion( "" );
-        searchFields.setPackaging( "" );
-        searchFields.setClassName( "" );
-
-        searchFields.setRepositories( selectedRepos );
-
-        try
-        {
-            archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
-
-            archivaConfigControl.replay();
-
-            search.search( "user", searchFields, null );
-
-            archivaConfigControl.verify();
-
-            fail( "A RepositorySearchExcecption should have been thrown." );
-        }
-        catch ( RepositorySearchException e )
-        {
-            assertEquals( "No search fields set.", e.getMessage() );
-        }
-    }
-
-    @Test
-    public void testAdvancedSearchAllSearchCriteriaSpecified()
-        throws Exception
-    {
-        createSimpleIndex( true );
-
-        List<String> selectedRepos = new ArrayList<String>();
-        selectedRepos.add( TEST_REPO_1 );
-
-        SearchFields searchFields = new SearchFields();
-        searchFields.setGroupId( "org.apache.archiva" );
-        searchFields.setArtifactId( "archiva-test" );
-        searchFields.setVersion( "2.0" );
-        searchFields.setPackaging( "jar" );
-        searchFields.setClassName( "org.apache.archiva.test.App" );
-        searchFields.setRepositories( selectedRepos );
-
-        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
-
-        archivaConfigControl.replay();
-
-        SearchResults results = search.search( "user", searchFields, null );
-
-        archivaConfigControl.verify();
-
-        assertNotNull( results );
-
-        assertEquals( "total hints not 1" + results, 1, results.getTotalHits() );
-
-        SearchResultHit hit = results.getHits().get( 0 );
-        assertEquals( "org.apache.archiva", hit.getGroupId() );
-        assertEquals( "archiva-test", hit.getArtifactId() );
-        assertEquals( "version not 2.0", "2.0", hit.getVersions().get( 0 ) );
-    }
-
-    @Test
-    public void testAdvancedSearchJarArtifacts()
-        throws Exception
-    {
-        createIndexContainingMoreArtifacts( true );
-
-        List<String> selectedRepos = new ArrayList<String>();
-        selectedRepos.add( TEST_REPO_1 );
-
-        SearchFields searchFields = new SearchFields();
-        searchFields.setPackaging( "jar" );
-        searchFields.setRepositories( selectedRepos );
-
-        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
-
-        archivaConfigControl.replay();
-
-        SearchResults results = search.search( "user", searchFields, null );
-
-        archivaConfigControl.verify();
-
-        assertNotNull( results );
-        assertEquals( "not 8 but " + results.getTotalHits() + ":" + niceDisplay( results ), 8, results.getTotalHits() );
-    }
-
-    @Test
-    public void testAdvancedSearchWithIncorrectPackaging()
-        throws Exception
-    {
-        createSimpleIndex( true );
-
-        List<String> selectedRepos = new ArrayList<String>();
-        selectedRepos.add( TEST_REPO_1 );
-
-        SearchFields searchFields = new SearchFields();
-        searchFields.setGroupId( "org.apache.archiva" );
-        searchFields.setArtifactId( "archiva-test" );
-        searchFields.setVersion( "2.0" );
-        searchFields.setPackaging( "war" );
-        searchFields.setRepositories( selectedRepos );
-
-        archivaConfigControl.expectAndDefaultReturn( archivaConfig.getConfiguration(), config );
-        archivaConfigControl.replay();
-
-        SearchResults results = search.search( "user", searchFields, null );
-
-        archivaConfigControl.verify();
-
-        assertNotNull( results );
-        assertEquals( 0, results.getTotalHits() );
-    }
-
-    @Test
-    public void testAdvancedSearchClassname()
-        throws Exception
-    {
-        createIndexContainingMoreArtifacts( true );
-
-        List<String> selectedRepos = Arrays.asList( TEST_REPO_1 );
-
-        SearchFields searchFields = new SearchFields();
-        searchFields.setClassName( "com.classname.search.App" );
-        searchFields.setRepositories( selectedRepos );
-
-        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
-
-        archivaConfigControl.replay();
-
-        SearchResults results = search.search( "user", searchFields, null );
-
-        archivaConfigControl.verify();
-
-        assertNotNull( results );
-        assertEquals( "totalHits not 1 results " + results, 1, results.getTotalHits() );
-
-        SearchResultHit hit = results.getHits().get( 0 );
-        assertEquals( "groupId not com", "com", hit.getGroupId() );
-        assertEquals( "arttifactId not classname-search", "classname-search", hit.getArtifactId() );
-        assertEquals( " hits.version(0) not 1.0", "1.0", hit.getVersions().get( 0 ) );
-    }
-
-    @Test
-    public void testAdvancedSearchNoIndexFound()
-        throws Exception
-    {
-        List<String> selectedRepos = new ArrayList<String>();
-        selectedRepos.add( TEST_REPO_1 );
-
-        SearchFields searchFields = new SearchFields();
-        searchFields.setGroupId( "org.apache.archiva" );
-        searchFields.setRepositories( selectedRepos );
-
-        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
-
-        archivaConfigControl.replay();
-
-        SearchResults results = search.search( "user", searchFields, null );
-
-        archivaConfigControl.verify();
-
-        assertNotNull( results );
-        assertEquals( 0, results.getTotalHits() );
-    }
-
-    @Test
-    public void testAdvancedSearchClassNameInWar()
-        throws Exception
-    {
-        createIndexContainingMoreArtifacts( true );
-
-        List<String> selectedRepos = Arrays.asList( TEST_REPO_1 );
-
-        SearchFields searchFields = new SearchFields();
-        searchFields.setClassName( "SomeClass" );
-        searchFields.setRepositories( selectedRepos );
-
-        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
-
-        archivaConfigControl.replay();
-
-        SearchResults results = search.search( "user", searchFields, null );
-
-        archivaConfigControl.verify();
-
-        assertNotNull( results );
-        assertEquals( 1, results.getHits().size() );
-        assertEquals( "test-webapp", results.getHits().get( 0 ).getArtifactId() );
-    }
-
-    @Test
-    public void getAllGroupIds()
-        throws Exception
-    {
-        createIndexContainingMoreArtifacts( true );
-
-        List<String> selectedRepos = Arrays.asList( TEST_REPO_1 );
-
-        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 0, 2 );
-
-        archivaConfigControl.replay();
-
-        Collection<String> groupIds = search.getAllGroupIds( "user", selectedRepos );
-
-        archivaConfigControl.verify();
-
-        log.info( "groupIds: " + groupIds );
-
-        assertEquals( 3, groupIds.size() );
-        assertTrue( groupIds.contains( "com" ) );
-        assertTrue( groupIds.contains( "org.apache.felix" ) );
-        assertTrue( groupIds.contains( "org.apache.archiva" ) );
-    }
-
-    @Test
-    public void testSearchWithUnknownRepo()
-        throws Exception
-    {
-        createIndexContainingMoreArtifacts( true );
-
-        List<String> selectedRepos = Arrays.asList( "foo" );
-
-        SearchFields searchFields = new SearchFields();
-        searchFields.setClassName( "SomeClass" );
-        searchFields.setRepositories( selectedRepos );
-
-        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
-
-        archivaConfigControl.replay();
-
-        SearchResults results = search.search( "user", searchFields, null );
-
-        archivaConfigControl.verify();
-
-        assertNotNull( results );
-        assertEquals( 0, results.getHits().size() );
-    }
-
-    @Test
-    public void nolimitedResult()
-        throws Exception
-    {
-
-        File repo = new File( "target/repo-release" );
-        File indexDirectory = new File( repo, ".index" );
-        FileUtils.copyDirectoryStructure( new File( "src/test/repo-release" ), repo );
-
-        createIndex( "repo-release", Collections.<File>emptyList(), false );
-
-        nexusIndexer.addIndexingContext( REPO_RELEASE, REPO_RELEASE, repo, indexDirectory,
-                                         repo.toURI().toURL().toExternalForm(),
-                                         indexDirectory.toURI().toURL().toString(), search.getAllIndexCreators() );
-
-        SearchResultLimits limits = new SearchResultLimits( 0 );
-        limits.setPageSize( 300 );
-
-        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 5 );
-
-        archivaConfigControl.replay();
-
-        SearchResults searchResults = search.search( null, Arrays.asList( REPO_RELEASE ), "org.example", limits,
-                                                     Collections.<String>emptyList() );
-
-        log.info( "results: {}", searchResults.getHits().size() );
-
-        assertEquals( 255, searchResults.getHits().size() );
-
-        SearchFields searchFields = new SearchFields();
-        searchFields.setGroupId( "org.example" );
-        searchFields.setRepositories( Arrays.asList( REPO_RELEASE ) );
-
-        searchResults = search.search( null, searchFields, limits );
-
-        log.info( "results: {}", searchResults.getHits().size() );
-
-        assertEquals( 255, searchResults.getHits().size() );
-
-        archivaConfigControl.verify();
-    }
-}