1 package org.apache.archiva.indexer.maven.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
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
22 import org.apache.archiva.indexer.search.SearchFields;
23 import org.apache.archiva.indexer.search.SearchResultHit;
24 import org.apache.archiva.indexer.search.SearchResults;
25 import org.apache.archiva.repository.base.ArchivaRepositoryRegistry;
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;
48 public void tearDown() throws Exception {
50 repositoryRegistry.destroy();
54 public void searchFelixWithSymbolicName()
58 createIndex( TEST_REPO_1, Collections.<Path>emptyList(), true );
60 List<String> selectedRepos = Arrays.asList( TEST_REPO_1 );
63 // EasyMock.expect( archivaConfig.getDefaultLocale() ).andReturn( Locale.getDefault( ) ).anyTimes();
64 EasyMock.expect( archivaConfig.getConfiguration()).andReturn(config).anyTimes();
66 archivaConfigControl.replay();
68 SearchFields searchFields = new SearchFields();
69 searchFields.setBundleSymbolicName( "org.apache.felix.bundlerepository" );
70 searchFields.setBundleVersion( "1.6.6" );
71 searchFields.setRepositories( selectedRepos );
73 SearchResults results = search.search( "user", searchFields, null );
75 archivaConfigControl.verify();
77 assertNotNull( results );
78 assertEquals( 1, results.getTotalHits() );
80 SearchResultHit hit = results.getHits().get( 0 );
81 assertEquals( "org.apache.felix", hit.getGroupId() );
82 assertEquals( "org.apache.felix.bundlerepository", hit.getArtifactId() );
83 assertEquals( "1.6.6", hit.getVersions().get( 0 ) );
85 assertEquals( "org.apache.felix.bundlerepository;uses:=\"org.osgi.framework\";version=\"2.0\"",
86 hit.getBundleExportPackage() );
87 assertEquals( "org.apache.felix.bundlerepository.RepositoryAdmin,org.osgi.service.obr.RepositoryAdmin",
88 hit.getBundleExportService() );
89 assertEquals( "org.apache.felix.bundlerepository", hit.getBundleSymbolicName() );
90 assertEquals( "1.6.6", hit.getBundleVersion() );