1 package org.apache.archiva.webtest.memory;
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
22 import org.apache.archiva.metadata.model.ArtifactMetadata;
23 import org.apache.archiva.metadata.model.MetadataFacet;
24 import org.apache.archiva.metadata.model.ProjectMetadata;
25 import org.apache.archiva.metadata.model.ProjectVersionMetadata;
26 import org.apache.archiva.metadata.model.ProjectVersionReference;
27 import org.apache.archiva.metadata.repository.MetadataRepository;
28 import org.apache.archiva.metadata.repository.MetadataRepositoryException;
30 import java.util.ArrayList;
31 import java.util.Collection;
32 import java.util.Collections;
33 import java.util.Date;
34 import java.util.List;
36 public class TestMetadataRepository
37 implements MetadataRepository
39 private static final String TEST_REPO = "test-repo";
41 private static final String TEST_NAMESPACE = "org.apache.archiva";
43 private List<ArtifactMetadata> artifacts = new ArrayList<ArtifactMetadata>();
45 private List<String> versions = new ArrayList<String>();
47 public TestMetadataRepository()
49 Date whenGathered = new Date( 123456789 );
51 addArtifact( "artifact-one", "1.0", whenGathered );
52 addArtifact( "artifact-one", "1.1", whenGathered );
53 addArtifact( "artifact-one", "2.0", whenGathered );
54 addArtifact( "artifact-two", "1.0.1", whenGathered );
55 addArtifact( "artifact-two", "1.0.2", whenGathered );
56 addArtifact( "artifact-two", "1.0.3-SNAPSHOT", whenGathered );
57 addArtifact( "artifact-three", "2.0-SNAPSHOT", whenGathered );
58 addArtifact( "artifact-four", "1.1-beta-2", whenGathered );
61 private void addArtifact( String projectId, String projectVersion, Date whenGathered )
63 ArtifactMetadata artifact = new ArtifactMetadata();
64 artifact.setFileLastModified( System.currentTimeMillis() );
65 artifact.setNamespace( TEST_NAMESPACE );
66 artifact.setProjectVersion( projectVersion );
67 artifact.setVersion( projectVersion );
68 artifact.setId( projectId + "-" + projectVersion + ".jar" );
69 artifact.setProject( projectId );
70 artifact.setRepositoryId( TEST_REPO );
71 artifact.setWhenGathered( whenGathered );
72 artifacts.add( artifact );
74 versions.add( projectVersion );
77 public ProjectMetadata getProject( String repoId, String namespace, String projectId )
79 throw new UnsupportedOperationException();
82 public ProjectVersionMetadata getProjectVersion( String repoId, String namespace, String projectId,
83 String projectVersion )
85 throw new UnsupportedOperationException();
88 public Collection<String> getArtifactVersions( String repoId, String namespace, String projectId,
89 String projectVersion )
91 throw new UnsupportedOperationException();
94 public Collection<ProjectVersionReference> getProjectReferences( String repoId, String namespace, String projectId,
95 String projectVersion )
97 throw new UnsupportedOperationException();
100 public Collection<String> getRootNamespaces( String repoId )
102 throw new UnsupportedOperationException();
105 public Collection<String> getNamespaces( String repoId, String namespace )
107 throw new UnsupportedOperationException();
110 public Collection<String> getProjects( String repoId, String namespace )
112 throw new UnsupportedOperationException();
115 public Collection<String> getProjectVersions( String repoId, String namespace, String projectId )
120 public void updateProject( String repoId, ProjectMetadata project )
122 throw new UnsupportedOperationException();
125 public void updateArtifact( String repoId, String namespace, String projectId, String projectVersion,
126 ArtifactMetadata artifactMeta )
128 throw new UnsupportedOperationException();
131 public void updateProjectVersion( String repoId, String namespace, String projectId,
132 ProjectVersionMetadata versionMetadata )
134 throw new UnsupportedOperationException();
137 public void updateNamespace( String repoId, String namespace )
139 throw new UnsupportedOperationException();
142 public List<String> getMetadataFacets( String repodId, String facetId )
144 return Collections.emptyList();
147 public MetadataFacet getMetadataFacet( String repositoryId, String facetId, String name )
149 throw new UnsupportedOperationException();
152 public void addMetadataFacet( String repositoryId, MetadataFacet metadataFacet )
154 throw new UnsupportedOperationException();
157 public void removeMetadataFacets( String repositoryId, String facetId )
159 throw new UnsupportedOperationException();
162 public void removeMetadataFacet( String repoId, String facetId, String name )
164 //To change body of implemented methods use File | Settings | File Templates.
167 public List<ArtifactMetadata> getArtifactsByDateRange( String repoId, Date startTime, Date endTime )
172 public Collection<String> getRepositories()
174 return Collections.singletonList( TEST_REPO );
177 public List<ArtifactMetadata> getArtifactsByChecksum( String repoId, String checksum )
182 public void removeArtifact( String repositoryId, String namespace, String project, String version, String id )
184 throw new UnsupportedOperationException();
187 public void removeArtifact( String repositoryId, String namespace, String project, String version,
188 MetadataFacet metadataFacet )
189 throws MetadataRepositoryException
191 throw new UnsupportedOperationException();
194 public void removeRepository( String repoId )
196 throw new UnsupportedOperationException();
199 public Collection<ArtifactMetadata> getArtifacts( String repoId, String namespace, String projectId,
200 String projectVersion )
215 throw new UnsupportedOperationException();
218 public boolean canObtainAccess( Class<?> aClass )
223 public Object obtainAccess( Class<?> aClass )
228 public List<ArtifactMetadata> getArtifacts( String repositoryId )