Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

TestMetadataRepository.java 8.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. package org.apache.archiva.webtest.memory;
  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.ArtifactMetadata;
  21. import org.apache.archiva.metadata.model.MetadataFacet;
  22. import org.apache.archiva.metadata.model.ProjectMetadata;
  23. import org.apache.archiva.metadata.model.ProjectVersionMetadata;
  24. import org.apache.archiva.metadata.model.ProjectVersionReference;
  25. import org.apache.archiva.metadata.repository.MetadataRepository;
  26. import org.apache.archiva.metadata.repository.MetadataRepositoryException;
  27. import java.util.ArrayList;
  28. import java.util.Collection;
  29. import java.util.Collections;
  30. import java.util.Date;
  31. import java.util.List;
  32. public class TestMetadataRepository
  33. implements MetadataRepository
  34. {
  35. private static final String TEST_REPO = "test-repo";
  36. private static final String TEST_NAMESPACE = "org.apache.archiva";
  37. private List<ArtifactMetadata> artifacts = new ArrayList<>();
  38. private List<String> versions = new ArrayList<>();
  39. public TestMetadataRepository()
  40. {
  41. Date whenGathered = new Date( 123456789 );
  42. addArtifact( "artifact-one", "1.0", whenGathered );
  43. addArtifact( "artifact-one", "1.1", whenGathered );
  44. addArtifact( "artifact-one", "2.0", whenGathered );
  45. addArtifact( "artifact-two", "1.0.1", whenGathered );
  46. addArtifact( "artifact-two", "1.0.2", whenGathered );
  47. addArtifact( "artifact-two", "1.0.3-SNAPSHOT", whenGathered );
  48. addArtifact( "artifact-three", "2.0-SNAPSHOT", whenGathered );
  49. addArtifact( "artifact-four", "1.1-beta-2", whenGathered );
  50. }
  51. private void addArtifact( String projectId, String projectVersion, Date whenGathered )
  52. {
  53. ArtifactMetadata artifact = new ArtifactMetadata();
  54. artifact.setFileLastModified( System.currentTimeMillis() );
  55. artifact.setNamespace( TEST_NAMESPACE );
  56. artifact.setProjectVersion( projectVersion );
  57. artifact.setVersion( projectVersion );
  58. artifact.setId( projectId + "-" + projectVersion + ".jar" );
  59. artifact.setProject( projectId );
  60. artifact.setRepositoryId( TEST_REPO );
  61. artifact.setWhenGathered( whenGathered );
  62. artifacts.add( artifact );
  63. versions.add( projectVersion );
  64. }
  65. public ProjectMetadata getProject( String repoId, String namespace, String projectId )
  66. {
  67. throw new UnsupportedOperationException();
  68. }
  69. public ProjectVersionMetadata getProjectVersion( String repoId, String namespace, String projectId,
  70. String projectVersion )
  71. {
  72. throw new UnsupportedOperationException();
  73. }
  74. public Collection<String> getArtifactVersions( String repoId, String namespace, String projectId,
  75. String projectVersion )
  76. {
  77. throw new UnsupportedOperationException();
  78. }
  79. public Collection<ProjectVersionReference> getProjectReferences( String repoId, String namespace, String projectId,
  80. String projectVersion )
  81. {
  82. throw new UnsupportedOperationException();
  83. }
  84. public Collection<String> getRootNamespaces( String repoId )
  85. {
  86. throw new UnsupportedOperationException();
  87. }
  88. public Collection<String> getNamespaces( String repoId, String namespace )
  89. {
  90. throw new UnsupportedOperationException();
  91. }
  92. public Collection<String> getProjects( String repoId, String namespace )
  93. {
  94. throw new UnsupportedOperationException();
  95. }
  96. public Collection<String> getProjectVersions( String repoId, String namespace, String projectId )
  97. {
  98. return versions;
  99. }
  100. public void updateProject( String repoId, ProjectMetadata project )
  101. {
  102. throw new UnsupportedOperationException();
  103. }
  104. public void updateArtifact( String repoId, String namespace, String projectId, String projectVersion,
  105. ArtifactMetadata artifactMeta )
  106. {
  107. throw new UnsupportedOperationException();
  108. }
  109. public void updateProjectVersion( String repoId, String namespace, String projectId,
  110. ProjectVersionMetadata versionMetadata )
  111. {
  112. throw new UnsupportedOperationException();
  113. }
  114. public void updateNamespace( String repoId, String namespace )
  115. {
  116. throw new UnsupportedOperationException();
  117. }
  118. public List<String> getMetadataFacets( String repodId, String facetId )
  119. {
  120. return Collections.emptyList();
  121. }
  122. public MetadataFacet getMetadataFacet( String repositoryId, String facetId, String name )
  123. {
  124. throw new UnsupportedOperationException();
  125. }
  126. public void addMetadataFacet( String repositoryId, MetadataFacet metadataFacet )
  127. {
  128. throw new UnsupportedOperationException();
  129. }
  130. public void removeMetadataFacets( String repositoryId, String facetId )
  131. {
  132. throw new UnsupportedOperationException();
  133. }
  134. public void removeMetadataFacet( String repoId, String facetId, String name )
  135. {
  136. //To change body of implemented methods use File | Settings | File Templates.
  137. }
  138. public List<ArtifactMetadata> getArtifactsByDateRange( String repoId, Date startTime, Date endTime )
  139. {
  140. return artifacts;
  141. }
  142. public Collection<String> getRepositories()
  143. {
  144. return Collections.singletonList( TEST_REPO );
  145. }
  146. public List<ArtifactMetadata> getArtifactsByChecksum( String repoId, String checksum )
  147. {
  148. return null;
  149. }
  150. public void removeArtifact( String repositoryId, String namespace, String project, String version, String id )
  151. {
  152. throw new UnsupportedOperationException();
  153. }
  154. public void removeArtifact( String repositoryId, String namespace, String project, String version,
  155. MetadataFacet metadataFacet )
  156. throws MetadataRepositoryException
  157. {
  158. throw new UnsupportedOperationException();
  159. }
  160. public void removeRepository( String repoId )
  161. {
  162. throw new UnsupportedOperationException();
  163. }
  164. public Collection<ArtifactMetadata> getArtifacts( String repoId, String namespace, String projectId,
  165. String projectVersion )
  166. {
  167. return artifacts;
  168. }
  169. public void save()
  170. {
  171. }
  172. public void close()
  173. {
  174. }
  175. public void revert()
  176. {
  177. throw new UnsupportedOperationException();
  178. }
  179. public boolean canObtainAccess( Class<?> aClass )
  180. {
  181. return false;
  182. }
  183. public <T>T obtainAccess( Class<T> aClass )
  184. {
  185. return null;
  186. }
  187. public List<ArtifactMetadata> getArtifacts( String repositoryId )
  188. {
  189. return artifacts;
  190. }
  191. public void removeArtifact( ArtifactMetadata artifactMetadata, String baseVersion )
  192. throws MetadataRepositoryException
  193. {
  194. throw new UnsupportedOperationException();
  195. }
  196. public void removeNamespace( String repositoryId, String namespace )
  197. throws MetadataRepositoryException
  198. {
  199. }
  200. public void removeProjectVersion( String repoId, String namespace, String projectId, String projectVersion )
  201. throws MetadataRepositoryException
  202. {
  203. }
  204. public void removeProject( String repositoryId, String namespace, String projectId )
  205. throws MetadataRepositoryException
  206. {
  207. throw new UnsupportedOperationException();
  208. }
  209. public boolean hasMetadataFacet( String repositoryId, String facetId )
  210. throws MetadataRepositoryException
  211. {
  212. return false;
  213. }
  214. }