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 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. package org.apache.archiva.indexer.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.easymock.EasyMock;
  21. import org.junit.Test;
  22. import java.nio.file.Path;
  23. import java.util.Arrays;
  24. import java.util.Collections;
  25. import java.util.List;
  26. import java.util.Locale;
  27. /**
  28. * @author Olivier Lamy
  29. */
  30. public class MavenRepositorySearchOSGITest
  31. extends AbstractMavenRepositorySearch
  32. {
  33. @Test
  34. public void searchFelixWithSymbolicName()
  35. throws Exception
  36. {
  37. createIndex( TEST_REPO_1, Collections.<Path>emptyList(), true );
  38. List<String> selectedRepos = Arrays.asList( TEST_REPO_1 );
  39. // search artifactId
  40. EasyMock.expect( archivaConfig.getDefaultLocale() ).andReturn( Locale.getDefault( ) ).anyTimes();
  41. EasyMock.expect( archivaConfig.getConfiguration()).andReturn(config).anyTimes();
  42. archivaConfigControl.replay();
  43. SearchFields searchFields = new SearchFields();
  44. searchFields.setBundleSymbolicName( "org.apache.felix.bundlerepository" );
  45. searchFields.setBundleVersion( "1.6.6" );
  46. searchFields.setRepositories( selectedRepos );
  47. SearchResults results = search.search( "user", searchFields, null );
  48. archivaConfigControl.verify();
  49. assertNotNull( results );
  50. assertEquals( 1, results.getTotalHits() );
  51. SearchResultHit hit = results.getHits().get( 0 );
  52. assertEquals( "org.apache.felix", hit.getGroupId() );
  53. assertEquals( "org.apache.felix.bundlerepository", hit.getArtifactId() );
  54. assertEquals( "1.6.6", hit.getVersions().get( 0 ) );
  55. assertEquals( "org.apache.felix.bundlerepository;uses:=\"org.osgi.framework\";version=\"2.0\"",
  56. hit.getBundleExportPackage() );
  57. assertEquals( "org.apache.felix.bundlerepository.RepositoryAdmin,org.osgi.service.obr.RepositoryAdmin",
  58. hit.getBundleExportService() );
  59. assertEquals( "org.apache.felix.bundlerepository", hit.getBundleSymbolicName() );
  60. assertEquals( "1.6.6", hit.getBundleVersion() );
  61. }
  62. }