You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

MavenRepositorySearchOSGITest.java 3.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. package org.apache.archiva.indexer.maven.search;
  2. /*
  3. * Licensed to the Apache Software Foundation (ASF) under one
  4. * or more contributor license agreements. See the NOTICE file
  5. * distributed with this work for additional information
  6. * regarding copyright ownership. The ASF licenses this file
  7. * to you under the Apache License, Version 2.0 (the
  8. * "License"); you may not use this file except in compliance
  9. * with the License. You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  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
  18. * under the License.
  19. */
  20. import org.apache.archiva.indexer.search.SearchFields;
  21. import org.apache.archiva.indexer.search.SearchResultHit;
  22. import org.apache.archiva.indexer.search.SearchResults;
  23. import org.apache.archiva.repository.base.ArchivaRepositoryRegistry;
  24. import org.apache.archiva.repository.base.group.RepositoryGroupHandler;
  25. import org.easymock.EasyMock;
  26. import org.junit.After;
  27. import org.junit.Test;
  28. import javax.inject.Inject;
  29. import java.nio.file.Path;
  30. import java.util.Arrays;
  31. import java.util.Collections;
  32. import java.util.List;
  33. /**
  34. * @author Olivier Lamy
  35. */
  36. public class MavenRepositorySearchOSGITest
  37. extends AbstractMavenRepositorySearch
  38. {
  39. @Inject
  40. ArchivaRepositoryRegistry repositoryRegistry;
  41. @Inject
  42. RepositoryGroupHandler repositoryGroupHandler;
  43. @After
  44. @Override
  45. public void tearDown() throws Exception {
  46. super.tearDown();
  47. repositoryRegistry.destroy();
  48. }
  49. @Test
  50. public void searchFelixWithSymbolicName()
  51. throws Exception
  52. {
  53. createIndex( TEST_REPO_1, Collections.<Path>emptyList(), true );
  54. List<String> selectedRepos = Arrays.asList( TEST_REPO_1 );
  55. // search artifactId
  56. // EasyMock.expect( archivaConfig.getDefaultLocale() ).andReturn( Locale.getDefault( ) ).anyTimes();
  57. EasyMock.expect( archivaConfig.getConfiguration()).andReturn(config).anyTimes();
  58. archivaConfigControl.replay();
  59. SearchFields searchFields = new SearchFields();
  60. searchFields.setBundleSymbolicName( "org.apache.felix.bundlerepository" );
  61. searchFields.setBundleVersion( "1.6.6" );
  62. searchFields.setRepositories( selectedRepos );
  63. SearchResults results = search.search( "user", searchFields, null );
  64. archivaConfigControl.verify();
  65. assertNotNull( results );
  66. assertEquals( 1, results.getTotalHits() );
  67. SearchResultHit hit = results.getHits().get( 0 );
  68. assertEquals( "org.apache.felix", hit.getGroupId() );
  69. assertEquals( "org.apache.felix.bundlerepository", hit.getArtifactId() );
  70. assertEquals( "1.6.6", hit.getVersions().get( 0 ) );
  71. assertEquals( "org.apache.felix.bundlerepository;uses:=\"org.osgi.framework\";version=\"2.0\"",
  72. hit.getBundleExportPackage() );
  73. assertEquals( "org.apache.felix.bundlerepository.RepositoryAdmin,org.osgi.service.obr.RepositoryAdmin",
  74. hit.getBundleExportService() );
  75. assertEquals( "org.apache.felix.bundlerepository", hit.getBundleSymbolicName() );
  76. assertEquals( "1.6.6", hit.getBundleVersion() );
  77. }
  78. }