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.apache.archiva.repository.base.group.RepositoryGroupHandler;
27 import org.easymock.EasyMock;
28 import org.junit.After;
29 import org.junit.Test;
31 import javax.inject.Inject;
32 import java.nio.file.Path;
33 import java.util.Arrays;
34 import java.util.Collections;
35 import java.util.List;
38 * @author Olivier Lamy
40 public class MavenRepositorySearchOSGITest
41 extends AbstractMavenRepositorySearch
45 ArchivaRepositoryRegistry repositoryRegistry;
48 RepositoryGroupHandler repositoryGroupHandler;
52 public void tearDown() throws Exception {
54 repositoryRegistry.destroy();
58 public void searchFelixWithSymbolicName()
62 createIndex( TEST_REPO_1, Collections.<Path>emptyList(), true );
64 List<String> selectedRepos = Arrays.asList( TEST_REPO_1 );
67 // EasyMock.expect( archivaConfig.getDefaultLocale() ).andReturn( Locale.getDefault( ) ).anyTimes();
68 EasyMock.expect( archivaConfig.getConfiguration()).andReturn(config).anyTimes();
70 archivaConfigControl.replay();
72 SearchFields searchFields = new SearchFields();
73 searchFields.setBundleSymbolicName( "org.apache.felix.bundlerepository" );
74 searchFields.setBundleVersion( "1.6.6" );
75 searchFields.setRepositories( selectedRepos );
77 SearchResults results = search.search( "user", searchFields, null );
79 archivaConfigControl.verify();
81 assertNotNull( results );
82 assertEquals( 1, results.getTotalHits() );
84 SearchResultHit hit = results.getHits().get( 0 );
85 assertEquals( "org.apache.felix", hit.getGroupId() );
86 assertEquals( "org.apache.felix.bundlerepository", hit.getArtifactId() );
87 assertEquals( "1.6.6", hit.getVersions().get( 0 ) );
89 assertEquals( "org.apache.felix.bundlerepository;uses:=\"org.osgi.framework\";version=\"2.0\"",
90 hit.getBundleExportPackage() );
91 assertEquals( "org.apache.felix.bundlerepository.RepositoryAdmin,org.osgi.service.obr.RepositoryAdmin",
92 hit.getBundleExportService() );
93 assertEquals( "org.apache.felix.bundlerepository", hit.getBundleSymbolicName() );
94 assertEquals( "1.6.6", hit.getBundleVersion() );