1 package org.apache.archiva.maven.indexer.search;
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
21 import org.apache.archiva.indexer.search.SearchFields;
22 import org.apache.archiva.indexer.search.SearchResultHit;
23 import org.apache.archiva.indexer.search.SearchResults;
24 import org.apache.archiva.repository.base.ArchivaRepositoryRegistry;
25 import org.apache.archiva.repository.base.RepositoryHandlerDependencies;
26 import org.easymock.EasyMock;
27 import org.junit.After;
28 import org.junit.Test;
30 import javax.inject.Inject;
31 import java.nio.file.Path;
32 import java.util.Arrays;
33 import java.util.Collections;
34 import java.util.List;
37 * @author Olivier Lamy
39 public class MavenRepositorySearchOSGITest
40 extends AbstractMavenRepositorySearch
44 ArchivaRepositoryRegistry repositoryRegistry;
46 @SuppressWarnings( "unused" )
48 RepositoryHandlerDependencies repositoryHandlerDependencies;
53 public void tearDown() throws Exception {
55 repositoryRegistry.destroy();
59 public void searchFelixWithSymbolicName()
63 createIndex( TEST_REPO_1, Collections.<Path>emptyList(), true );
65 List<String> selectedRepos = Arrays.asList( TEST_REPO_1 );
68 // EasyMock.expect( archivaConfig.getDefaultLocale() ).andReturn( Locale.getDefault( ) ).anyTimes();
69 EasyMock.expect( archivaConfig.getConfiguration()).andReturn(config).anyTimes();
71 archivaConfigControl.replay();
73 SearchFields searchFields = new SearchFields();
74 searchFields.setBundleSymbolicName( "org.apache.felix.bundlerepository" );
75 searchFields.setBundleVersion( "1.6.6" );
76 searchFields.setRepositories( selectedRepos );
78 SearchResults results = search.search( "user", searchFields, null );
80 archivaConfigControl.verify();
82 assertNotNull( results );
83 assertEquals( 1, results.getTotalHits() );
85 SearchResultHit hit = results.getHits().get( 0 );
86 assertEquals( "org.apache.felix", hit.getGroupId() );
87 assertEquals( "org.apache.felix.bundlerepository", hit.getArtifactId() );
88 assertEquals( "1.6.6", hit.getVersions().get( 0 ) );
90 assertEquals( "org.apache.felix.bundlerepository;uses:=\"org.osgi.framework\";version=\"2.0\"",
91 hit.getBundleExportPackage() );
92 assertEquals( "org.apache.felix.bundlerepository.RepositoryAdmin,org.osgi.service.obr.RepositoryAdmin",
93 hit.getBundleExportService() );
94 assertEquals( "org.apache.felix.bundlerepository", hit.getBundleSymbolicName() );
95 assertEquals( "1.6.6", hit.getBundleVersion() );