View Javadoc
1   package org.apache.archiva.indexer.search;
2   
3   /*
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
11   *
12   *  http://www.apache.org/licenses/LICENSE-2.0
13   *
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
19   * under the License.
20   */
21  
22  import org.easymock.EasyMock;
23  import org.junit.Test;
24  
25  import java.io.File;
26  import java.util.Arrays;
27  import java.util.Collections;
28  import java.util.List;
29  
30  /**
31   * @author Olivier Lamy
32   */
33  public class MavenRepositorySearchOSGITest
34      extends AbstractMavenRepositorySearch
35  {
36  
37      @Test
38      public void searchFelixWithSymbolicName()
39          throws Exception
40      {
41  
42          createIndex( TEST_REPO_1, Collections.<File>emptyList(), true );
43  
44          List<String> selectedRepos = Arrays.asList( TEST_REPO_1 );
45  
46          // search artifactId
47          EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 2 );
48  
49          archivaConfigControl.replay();
50  
51          SearchFields searchFields = new SearchFields();
52          searchFields.setBundleSymbolicName( "org.apache.felix.bundlerepository" );
53          searchFields.setBundleVersion( "1.6.6" );
54          searchFields.setRepositories( selectedRepos );
55  
56          SearchResults results = search.search( "user", searchFields, null );
57  
58          archivaConfigControl.verify();
59  
60          assertNotNull( results );
61          assertEquals( 1, results.getTotalHits() );
62  
63          SearchResultHit hit = results.getHits().get( 0 );
64          assertEquals( "org.apache.felix", hit.getGroupId() );
65          assertEquals( "org.apache.felix.bundlerepository", hit.getArtifactId() );
66          assertEquals( "1.6.6", hit.getVersions().get( 0 ) );
67  
68          assertEquals( "org.apache.felix.bundlerepository;uses:=\"org.osgi.framework\";version=\"2.0\"",
69                        hit.getBundleExportPackage() );
70          assertEquals( "org.apache.felix.bundlerepository.RepositoryAdmin,org.osgi.service.obr.RepositoryAdmin",
71                        hit.getBundleExportService() );
72          assertEquals( "org.apache.felix.bundlerepository", hit.getBundleSymbolicName() );
73          assertEquals( "1.6.6", hit.getBundleVersion() );
74      }
75  
76  }