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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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.RepositoryHandlerDependencies;
  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. @SuppressWarnings( "unused" )
  42. @Inject
  43. RepositoryHandlerDependencies repositoryHandlerDependencies;
  44. @After
  45. @Override
  46. public void tearDown() throws Exception {
  47. super.tearDown();
  48. repositoryRegistry.destroy();
  49. }
  50. @Test
  51. public void searchFelixWithSymbolicName()
  52. throws Exception
  53. {
  54. createIndex( TEST_REPO_1, Collections.<Path>emptyList(), true );
  55. List<String> selectedRepos = Arrays.asList( TEST_REPO_1 );
  56. // search artifactId
  57. // EasyMock.expect( archivaConfig.getDefaultLocale() ).andReturn( Locale.getDefault( ) ).anyTimes();
  58. EasyMock.expect( archivaConfig.getConfiguration()).andReturn(config).anyTimes();
  59. archivaConfigControl.replay();
  60. SearchFields searchFields = new SearchFields();
  61. searchFields.setBundleSymbolicName( "org.apache.felix.bundlerepository" );
  62. searchFields.setBundleVersion( "1.6.6" );
  63. searchFields.setRepositories( selectedRepos );
  64. SearchResults results = search.search( "user", searchFields, null );
  65. archivaConfigControl.verify();
  66. assertNotNull( results );
  67. assertEquals( 1, results.getTotalHits() );
  68. SearchResultHit hit = results.getHits().get( 0 );
  69. assertEquals( "org.apache.felix", hit.getGroupId() );
  70. assertEquals( "org.apache.felix.bundlerepository", hit.getArtifactId() );
  71. assertEquals( "1.6.6", hit.getVersions().get( 0 ) );
  72. assertEquals( "org.apache.felix.bundlerepository;uses:=\"org.osgi.framework\";version=\"2.0\"",
  73. hit.getBundleExportPackage() );
  74. assertEquals( "org.apache.felix.bundlerepository.RepositoryAdmin,org.osgi.service.obr.RepositoryAdmin",
  75. hit.getBundleExportService() );
  76. assertEquals( "org.apache.felix.bundlerepository", hit.getBundleSymbolicName() );
  77. assertEquals( "1.6.6", hit.getBundleVersion() );
  78. }
  79. }