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.

Maven2RepositoryMetadataResolverManagedSnapshotTest.java 5.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. package org.apache.archiva.repository.maven.metadata.storage;
  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. * Unless required by applicable law or agreed to in writing,
  13. * software distributed under the License is distributed on an
  14. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15. * KIND, either express or implied. See the License for the
  16. * specific language governing permissions and limitations
  17. * under the License.
  18. */
  19. import org.apache.archiva.filter.AllFilter;
  20. import org.apache.archiva.filter.Filter;
  21. import org.apache.archiva.metadata.model.ProjectVersionMetadata;
  22. import org.apache.archiva.metadata.repository.storage.ReadMetadataRequest;
  23. import org.apache.archiva.metadata.repository.storage.RepositoryStorageRuntimeException;
  24. import org.apache.archiva.repository.RepositoryRegistry;
  25. import org.junit.Before;
  26. import org.junit.Test;
  27. import javax.inject.Inject;
  28. import javax.inject.Named;
  29. public class Maven2RepositoryMetadataResolverManagedSnapshotTest
  30. extends Maven2RepositoryMetadataResolverTest
  31. {
  32. private static final Filter<String> ALL = new AllFilter<String>();
  33. @Inject
  34. @Named ( "repositoryStorage#maven2")
  35. private Maven2RepositoryStorage storage;
  36. @Inject
  37. RepositoryRegistry repositoryRegistry;
  38. private static final String TEST_REPO_ID = "test";
  39. private static final String TEST_REMOTE_REPO_ID = "central";
  40. private static final String ASF_SCM_CONN_BASE = "scm:svn:http://svn.apache.org/repos/asf/";
  41. private static final String ASF_SCM_DEV_CONN_BASE = "scm:svn:https://svn.apache.org/repos/asf/";
  42. private static final String ASF_SCM_VIEWVC_BASE = "http://svn.apache.org/viewvc/";
  43. private static final String TEST_SCM_CONN_BASE = "scm:svn:http://svn.example.com/repos/";
  44. private static final String TEST_SCM_DEV_CONN_BASE = "scm:svn:https://svn.example.com/repos/";
  45. private static final String TEST_SCM_URL_BASE = "http://svn.example.com/repos/";
  46. private static final String EMPTY_MD5 = "d41d8cd98f00b204e9800998ecf8427e";
  47. private static final String EMPTY_SHA1 = "da39a3ee5e6b4b0d3255bfef95601890afd80709";
  48. @Before
  49. @Override
  50. public void setUp()
  51. throws Exception
  52. {
  53. super.setUp();
  54. testRepo.setReleases( false );
  55. testRepo.setSnapshots( true );
  56. configuration.save( c );
  57. repositoryRegistry.reload();
  58. assertTrue( c.getManagedRepositories().get( 0 ).isSnapshots() );
  59. assertFalse( c.getManagedRepositories().get( 0 ).isReleases() );
  60. }
  61. @Test (expected = RepositoryStorageRuntimeException.class)
  62. @Override
  63. public void testModelWithJdkProfileActivation()
  64. throws Exception
  65. {
  66. // skygo IMHO must fail because TEST_REPO_ID ( is snap ,no release) and we seek for a snapshot
  67. ReadMetadataRequest readMetadataRequest =
  68. new ReadMetadataRequest().repositoryId( TEST_REPO_ID ).namespace( "org.apache.maven" ).projectId(
  69. "maven-archiver" ).projectVersion( "2.4.1" );
  70. ProjectVersionMetadata metadata = storage.readProjectVersionMetadata( readMetadataRequest );
  71. }
  72. @Test (expected = RepositoryStorageRuntimeException.class)
  73. @Override
  74. public void testGetProjectVersionMetadataForMislocatedPom()
  75. throws Exception
  76. {
  77. ReadMetadataRequest readMetadataRequest =
  78. new ReadMetadataRequest().repositoryId( TEST_REPO_ID ).namespace( "com.example.test" ).projectId(
  79. "mislocated-pom" ).projectVersion( "1.0" );
  80. storage.readProjectVersionMetadata( readMetadataRequest );
  81. }
  82. @Test
  83. @Override
  84. public void testGetProjectVersionMetadata()
  85. throws Exception
  86. {
  87. // super test is on release
  88. }
  89. @Test (expected = RepositoryStorageRuntimeException.class)
  90. @Override
  91. public void testGetProjectVersionMetadataForInvalidPom()
  92. throws Exception
  93. {
  94. ReadMetadataRequest readMetadataRequest =
  95. new ReadMetadataRequest().repositoryId( TEST_REPO_ID ).namespace( "com.example.test" ).projectId(
  96. "invalid-pom" ).projectVersion( "1.0" );
  97. storage.readProjectVersionMetadata( readMetadataRequest );
  98. }
  99. @Test (expected = RepositoryStorageRuntimeException.class)
  100. @Override
  101. public void testGetProjectVersionMetadataForMissingPom()
  102. throws Exception
  103. {
  104. ReadMetadataRequest readMetadataRequest =
  105. new ReadMetadataRequest().repositoryId( TEST_REPO_ID ).namespace( "com.example.test" ).projectId(
  106. "missing-pom" ).projectVersion( "1.0" );
  107. storage.readProjectVersionMetadata( readMetadataRequest );
  108. }
  109. }