1 package org.apache.maven.archiva.repository.content;
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.commons.lang.StringUtils;
23 import org.apache.maven.archiva.repository.ArchivaArtifact;
24 import org.apache.maven.archiva.repository.ArchivaRepository;
25 import org.codehaus.plexus.PlexusTestCase;
30 * AbstractBidirectionalRepositoryLayoutTestCase
32 * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
35 public class AbstractBidirectionalRepositoryLayoutTestCase extends PlexusTestCase
37 protected ArchivaRepository repository;
39 protected void setUp() throws Exception
43 repository = createTestRepository();
46 protected ArchivaRepository createTestRepository()
48 File targetDir = new File( getBasedir(), "target" );
49 File testRepo = new File( targetDir, "test-repo" );
51 if ( !testRepo.exists() )
56 String repoUri = "file://" + StringUtils.replace( testRepo.getAbsolutePath(), "\\", "/" ) ;
58 ArchivaRepository repo = new ArchivaRepository( "testRepo", "Test Repository", repoUri );
63 protected ArchivaArtifact createArtifact( String groupId, String artifactId, String version, String classifier, String type )
65 ArchivaArtifact artifact = new ArchivaArtifact( repository, groupId, artifactId, version, classifier, type );
66 assertNotNull( artifact );
70 protected void assertArtifact( ArchivaArtifact actualArtifact, String groupId, String artifactId, String version, String classifier, String type )
72 String expectedId = groupId + ":" + artifactId + ":" + version + ":" + classifier + ":" + type;
74 assertEquals( expectedId + " - Group ID", actualArtifact.getGroupId(), groupId );
75 assertEquals( expectedId + " - Artifact ID", actualArtifact.getArtifactId(), artifactId );
76 assertEquals( expectedId + " - Version ID", actualArtifact.getVersion(), version );
77 assertEquals( expectedId + " - Classifier", actualArtifact.getClassifier(), classifier );
78 assertEquals( expectedId + " - Type", actualArtifact.getType(), type );
81 protected void assertSnapshotArtifact( ArchivaArtifact actualArtifact, String groupId, String artifactId, String version, String classifier, String type )
83 String expectedId = groupId + ":" + artifactId + ":" + version + ":" + classifier + ":" + type;
85 assertEquals( expectedId + " - Group ID", actualArtifact.getGroupId(), groupId );
86 assertEquals( expectedId + " - Artifact ID", actualArtifact.getArtifactId(), artifactId );
87 assertEquals( expectedId + " - Version ID", actualArtifact.getVersion(), version );
88 assertEquals( expectedId + " - Classifier", actualArtifact.getClassifier(), classifier );
89 assertEquals( expectedId + " - Type", actualArtifact.getType(), type );
90 assertTrue( expectedId + " - Snapshot", actualArtifact.isSnapshot() );