1 package org.apache.maven.archiva.repository.layout;
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.configuration.ManagedRepositoryConfiguration;
24 import org.apache.maven.archiva.model.ArchivaArtifact;
25 import org.apache.maven.archiva.model.ArtifactReference;
26 import org.apache.maven.archiva.model.ProjectReference;
27 import org.apache.maven.archiva.model.VersionedReference;
28 import org.codehaus.plexus.PlexusTestCase;
33 * AbstractBidirectionalRepositoryLayoutTestCase
35 * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
38 public abstract class AbstractBidirectionalRepositoryLayoutTestCase
39 extends PlexusTestCase
41 protected ManagedRepositoryConfiguration repository;
43 protected void setUp()
48 repository = createTestRepository();
51 protected ManagedRepositoryConfiguration createTestRepository()
53 File targetDir = new File( getBasedir(), "target" );
54 File testRepo = new File( targetDir, "test-repo" );
56 if ( !testRepo.exists() )
61 ManagedRepositoryConfiguration repo = new ManagedRepositoryConfiguration();
62 repo.setId( "testRepo" );
63 repo.setName( "Test Repository" );
64 repo.setLocation( testRepo.getAbsolutePath() );
68 protected ArchivaArtifact createArtifact( String groupId, String artifactId, String version, String classifier,
71 ArchivaArtifact artifact = new ArchivaArtifact( groupId, artifactId, version, classifier, type );
72 assertNotNull( artifact );
73 artifact.getModel().setRepositoryId( repository.getId() );
77 protected void assertArtifact( ArchivaArtifact actualArtifact, String groupId, String artifactId, String version,
78 String classifier, String type )
80 String expectedId = groupId + ":" + artifactId + ":" + version + ":" + classifier + ":" + type;
82 assertNotNull( expectedId + " - Should not be null.", actualArtifact );
84 assertEquals( expectedId + " - Group ID", groupId, actualArtifact.getGroupId() );
85 assertEquals( expectedId + " - Artifact ID", artifactId, actualArtifact.getArtifactId() );
86 if ( StringUtils.isNotBlank( classifier ) )
88 assertEquals( expectedId + " - Classifier", classifier, actualArtifact.getClassifier() );
90 assertEquals( expectedId + " - Version ID", version, actualArtifact.getVersion() );
91 assertEquals( expectedId + " - Type", type, actualArtifact.getType() );
94 protected void assertArtifactReference( ArtifactReference actualReference, String groupId, String artifactId,
95 String version, String classifier, String type )
97 String expectedId = "ArtifactReference - " + groupId + ":" + artifactId + ":" + version + ":" + classifier
100 assertNotNull( expectedId + " - Should not be null.", actualReference );
102 assertEquals( expectedId + " - Group ID", groupId, actualReference.getGroupId() );
103 assertEquals( expectedId + " - Artifact ID", artifactId, actualReference.getArtifactId() );
104 if ( StringUtils.isNotBlank( classifier ) )
106 assertEquals( expectedId + " - Classifier", classifier, actualReference.getClassifier() );
108 assertEquals( expectedId + " - Version ID", version, actualReference.getVersion() );
109 assertEquals( expectedId + " - Type", type, actualReference.getType() );
112 protected void assertVersionedReference( VersionedReference actualReference, String groupId, String artifactId,
115 String expectedId = "VersionedReference - " + groupId + ":" + artifactId + ":" + version;
117 assertNotNull( expectedId + " - Should not be null.", actualReference );
118 assertEquals( expectedId + " - Group ID", groupId, actualReference.getGroupId() );
119 assertEquals( expectedId + " - Artifact ID", artifactId, actualReference.getArtifactId() );
120 assertEquals( expectedId + " - Version ID", version, actualReference.getVersion() );
123 protected void assertProjectReference( ProjectReference actualReference, String groupId, String artifactId )
125 String expectedId = "ProjectReference - " + groupId + ":" + artifactId;
127 assertNotNull( expectedId + " - Should not be null.", actualReference );
128 assertEquals( expectedId + " - Group ID", groupId, actualReference.getGroupId() );
129 assertEquals( expectedId + " - Artifact ID", artifactId, actualReference.getArtifactId() );
132 protected void assertSnapshotArtifact( ArchivaArtifact actualArtifact, String groupId, String artifactId,
133 String version, String classifier, String type )
135 String expectedId = groupId + ":" + artifactId + ":" + version + ":" + classifier + ":" + type;
137 assertNotNull( expectedId + " - Should not be null.", actualArtifact );
139 assertEquals( expectedId + " - Group ID", actualArtifact.getGroupId(), groupId );
140 assertEquals( expectedId + " - Artifact ID", actualArtifact.getArtifactId(), artifactId );
141 assertEquals( expectedId + " - Version ID", actualArtifact.getVersion(), version );
142 assertEquals( expectedId + " - Classifier", actualArtifact.getClassifier(), classifier );
143 assertEquals( expectedId + " - Type", actualArtifact.getType(), type );
144 assertTrue( expectedId + " - Snapshot", actualArtifact.isSnapshot() );