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.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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.easymock.EasyMock;
  25. import org.junit.After;
  26. import org.junit.Test;
  27. import javax.inject.Inject;
  28. import java.nio.file.Path;
  29. import java.util.Arrays;
  30. import java.util.Collections;
  31. import java.util.List;
  32. /**
  33. * @author Olivier Lamy
  34. */
  35. public class MavenRepositorySearchOSGITest
  36. extends AbstractMavenRepositorySearch
  37. {
  38. @Inject
  39. ArchivaRepositoryRegistry repositoryRegistry;
  40. @After
  41. @Override
  42. public void tearDown() throws Exception {
  43. super.tearDown();
  44. repositoryRegistry.destroy();
  45. }
  46. @Test
  47. public void searchFelixWithSymbolicName()
  48. throws Exception
  49. {
  50. createIndex( TEST_REPO_1, Collections.<Path>emptyList(), true );
  51. List<String> selectedRepos = Arrays.asList( TEST_REPO_1 );
  52. // search artifactId
  53. // EasyMock.expect( archivaConfig.getDefaultLocale() ).andReturn( Locale.getDefault( ) ).anyTimes();
  54. EasyMock.expect( archivaConfig.getConfiguration()).andReturn(config).anyTimes();
  55. archivaConfigControl.replay();
  56. SearchFields searchFields = new SearchFields();
  57. searchFields.setBundleSymbolicName( "org.apache.felix.bundlerepository" );
  58. searchFields.setBundleVersion( "1.6.6" );
  59. searchFields.setRepositories( selectedRepos );
  60. SearchResults results = search.search( "user", searchFields, null );
  61. archivaConfigControl.verify();
  62. assertNotNull( results );
  63. assertEquals( 1, results.getTotalHits() );
  64. SearchResultHit hit = results.getHits().get( 0 );
  65. assertEquals( "org.apache.felix", hit.getGroupId() );
  66. assertEquals( "org.apache.felix.bundlerepository", hit.getArtifactId() );
  67. assertEquals( "1.6.6", hit.getVersions().get( 0 ) );
  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. }