use of org.apache.archiva.repository.ManagedRepositoryContent in project archiva by apache.
the class MetadataToolsTest method assertUpdatedProjectMetadata.
private void assertUpdatedProjectMetadata(String artifactId, String[] expectedVersions, String latestVersion, String releaseVersion) throws Exception {
ManagedRepositoryContent testRepo = createTestRepoContent();
ProjectReference reference = new ProjectReference();
reference.setGroupId("org.apache.archiva.metadata.tests");
reference.setArtifactId(artifactId);
prepTestRepo(testRepo, reference);
tools.updateMetadata(testRepo, reference);
StringBuilder buf = new StringBuilder();
buf.append("<metadata>\n");
buf.append(" <groupId>").append(reference.getGroupId()).append("</groupId>\n");
buf.append(" <artifactId>").append(reference.getArtifactId()).append("</artifactId>\n");
if (expectedVersions != null) {
buf.append(" <versioning>\n");
if (latestVersion != null) {
buf.append(" <latest>").append(latestVersion).append("</latest>\n");
}
if (releaseVersion != null) {
buf.append(" <release>").append(releaseVersion).append("</release>\n");
}
buf.append(" <versions>\n");
for (int i = 0; i < expectedVersions.length; i++) {
buf.append(" <version>").append(expectedVersions[i]).append("</version>\n");
}
buf.append(" </versions>\n");
buf.append(" </versioning>\n");
}
buf.append("</metadata>");
assertMetadata(buf.toString(), testRepo, reference);
}
use of org.apache.archiva.repository.ManagedRepositoryContent in project archiva by apache.
the class MetadataToolsTest method testUpdateProjectNonExistingVersion.
// TODO: replace with group tests
// public void testUpdateProjectBadArtifact()
// throws Exception
// {
// try
// {
// assertUpdatedProjectMetadata( "bad_artifact", null );
// fail( "Should have thrown an IOException on a bad artifact." );
// }
// catch ( IOException e )
// {
// // Expected path
// }
// }
@Test
public void testUpdateProjectNonExistingVersion() throws Exception {
ManagedRepositoryContent testRepo = createTestRepoContent();
ProjectReference reference = new ProjectReference();
reference.setGroupId("org.apache.archiva.metadata.tests");
reference.setArtifactId("missing_artifact");
prepTestRepo(testRepo, reference);
// check metadata prior to update -- should contain the non-existing artifact version
assertProjectMetadata(testRepo, reference, "missing_artifact", new String[] { "1.0-SNAPSHOT", "1.1-SNAPSHOT", "1.2-SNAPSHOT" }, "1.2-SNAPSHOT", null);
tools.updateMetadata(testRepo, reference);
// metadata should not contain the non-existing artifact version -- 1.1-SNAPSHOT
assertProjectMetadata(testRepo, reference, "missing_artifact", new String[] { "1.0-SNAPSHOT", "1.2-SNAPSHOT" }, "1.2-SNAPSHOT", null);
}
use of org.apache.archiva.repository.ManagedRepositoryContent in project archiva by apache.
the class MetadataToolsTest method assertUpdatedReleaseVersionMetadata.
private void assertUpdatedReleaseVersionMetadata(String artifactId, String version) throws Exception {
ManagedRepositoryContent testRepo = createTestRepoContent();
VersionedReference reference = new VersionedReference();
reference.setGroupId("org.apache.archiva.metadata.tests");
reference.setArtifactId(artifactId);
reference.setVersion(version);
prepTestRepo(testRepo, reference);
tools.updateMetadata(testRepo, reference);
StringBuilder buf = new StringBuilder();
buf.append("<metadata>\n");
buf.append(" <groupId>").append(reference.getGroupId()).append("</groupId>\n");
buf.append(" <artifactId>").append(reference.getArtifactId()).append("</artifactId>\n");
buf.append(" <version>").append(reference.getVersion()).append("</version>\n");
buf.append("</metadata>");
assertMetadata(buf.toString(), testRepo, reference);
}
use of org.apache.archiva.repository.ManagedRepositoryContent in project archiva by apache.
the class RepositoryRequestTest method testNativePathBadRequestNull.
@Test
public void testNativePathBadRequestNull() throws Exception {
ManagedRepositoryContent repository = createManagedRepo("default");
// Test bad request path (too short)
try {
repoRequest.toNativePath(null, repository);
fail("Should have thrown an exception about an null request.");
} catch (LayoutException e) {
// expected path.
}
}
use of org.apache.archiva.repository.ManagedRepositoryContent in project archiva by apache.
the class RepositoryRequestTest method testToNativePathArtifactDefaultToDefaultDualExtension.
/**
* [MRM-481] Artifact requests with a .xml.zip extension fail with a 404 Error
*/
@Test
public void testToNativePathArtifactDefaultToDefaultDualExtension() throws Exception {
ManagedRepositoryContent repository = createManagedRepo("default");
// Test (artifact) default to default - dual extension
assertEquals("org/project/example-presentation/3.2/example-presentation-3.2.xml.zip", repoRequest.toNativePath("org/project/example-presentation/3.2/example-presentation-3.2.xml.zip", repository));
}
Aggregations