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

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