use of org.apache.archiva.metadata.repository.storage.ReadMetadataRequest in project archiva by apache.
the class Maven2RepositoryMetadataResolverMRM1411RepoGroupTest method testGetProjectVersionMetadataWithParentSnapshotVersion.
@Test
public void testGetProjectVersionMetadataWithParentSnapshotVersion() throws Exception {
copyTestArtifactWithParent("target/test-classes/com/example/test/test-snapshot-artifact-module-a", "target/test-repositorys/com/example/test/test-snapshot-artifact-module-a");
copyTestArtifactWithParent("target/test-classes/com/example/test/test-snapshot-artifact-root", "target/test-repositorys/com/example/test/test-snapshot-artifact-root");
copyTestArtifactWithParent("src/test/resources/com/example/test/test-artifact-parent", "target/test-repositorys/com/example/test/test-artifact-parent");
ReadMetadataRequest readMetadataRequest = new ReadMetadataRequest(TEST_SNAP_REPO_ID, "com.example.test", "test-snapshot-artifact-module-a", "1.1-SNAPSHOT");
ProjectVersionMetadata metadata = storage.readProjectVersionMetadata(readMetadataRequest);
MavenProjectFacet facet = (MavenProjectFacet) metadata.getFacet(MavenProjectFacet.FACET_ID);
assertEquals("jar", facet.getPackaging());
assertEquals("com.example.test", facet.getParent().getGroupId());
assertEquals("test-snapshot-artifact-root", facet.getParent().getArtifactId());
assertEquals("1.1-SNAPSHOT", facet.getParent().getVersion());
assertEquals("test-snapshot-artifact-module-a", facet.getArtifactId());
assertEquals("com.example.test", facet.getGroupId());
assertNull(metadata.getCiManagement());
assertNotNull(metadata.getDescription());
checkApacheLicense(metadata);
assertEquals("1.1-SNAPSHOT", metadata.getId());
assertEquals("Test Snapshot Artifact :: Module A", metadata.getName());
String path = "test-snapshot-artifact/trunk/test-snapshot-artifact-module-a";
assertEquals(TEST_SCM_CONN_BASE + path, metadata.getScm().getConnection());
assertEquals(TEST_SCM_DEV_CONN_BASE + path, metadata.getScm().getDeveloperConnection());
assertEquals(TEST_SCM_URL_BASE + path, metadata.getScm().getUrl());
List<Dependency> dependencies = metadata.getDependencies();
assertEquals(2, dependencies.size());
assertDependency(dependencies.get(0), "commons-io", "commons-io", "1.4");
assertDependency(dependencies.get(1), "junit", "junit", "3.8.1", "test");
List<String> paths = new ArrayList<>();
paths.add("target/test-repositorys/com/example/test/test-snapshot-artifact-module-a");
paths.add("target/test-repositorys/com/example/test/test-snapshot-artifact-root");
deleteTestArtifactWithParent(paths);
}
use of org.apache.archiva.metadata.repository.storage.ReadMetadataRequest in project archiva by apache.
the class Maven2RepositoryMetadataResolverMRM1411Test method testGetProjectVersionMetadataWithParentSnapshotVersionAndSnapNotAllowed.
@Test
public void testGetProjectVersionMetadataWithParentSnapshotVersionAndSnapNotAllowed() throws Exception {
testRepo.setSnapshots(false);
configuration.save(c);
repositoryRegistry.reload();
assertFalse(c.getManagedRepositories().get(0).isSnapshots());
copyTestArtifactWithParent("target/test-classes/com/example/test/test-snapshot-artifact-module-a", "target/test-repository/com/example/test/test-snapshot-artifact-module-a");
try {
ProjectVersionMetadata metadata = storage.readProjectVersionMetadata(new ReadMetadataRequest(TEST_REPO_ID, "com.example.test", "test-snapshot-artifact-module-a", "1.1-SNAPSHOT"));
fail("Should not be found");
} catch (RepositoryStorageRuntimeException e) {
}
List<String> paths = new ArrayList<>();
paths.add("target/test-repository/com/example/test/test-snapshot-artifact-module-a");
paths.add("target/test-repository/com/example/test/test-snapshot-artifact-root");
deleteTestArtifactWithParent(paths);
}
use of org.apache.archiva.metadata.repository.storage.ReadMetadataRequest in project archiva by apache.
the class Maven2RepositoryMetadataResolverMRM1411Test method testGetProjectVersionMetadataWithParentNotInAnyRemoteRepo.
@Test
public void testGetProjectVersionMetadataWithParentNotInAnyRemoteRepo() throws Exception {
copyTestArtifactWithParent("target/test-classes/com/example/test/test-artifact-module-a", "target/test-repository/com/example/test/test-artifact-module-a");
ProjectVersionMetadata metadata = storage.readProjectVersionMetadata(new ReadMetadataRequest(TEST_REPO_ID, "com.example.test", "missing-parent", "1.1"));
assertEquals("1.1", metadata.getId());
MavenProjectFacet facet = (MavenProjectFacet) metadata.getFacet(MavenProjectFacet.FACET_ID);
assertNotNull(facet);
assertEquals("com.example.test", facet.getGroupId());
assertEquals("missing-parent", facet.getArtifactId());
assertEquals("jar", facet.getPackaging());
List<String> paths = new ArrayList<>();
paths.add("target/test-repository/com/example/test/test-artifact-module-a");
paths.add("target/test-repository/com/example/test/test-artifact-parent");
paths.add("target/test-repository/com/example/test/test-artifact-root");
deleteTestArtifactWithParent(paths);
}
use of org.apache.archiva.metadata.repository.storage.ReadMetadataRequest in project archiva by apache.
the class Maven2RepositoryMetadataResolverMRM1411Test method testGetProjectVersionMetadataWithParentSuccessful.
// Tests for MRM-1411 - START
@Test
public void testGetProjectVersionMetadataWithParentSuccessful() throws Exception {
copyTestArtifactWithParent("target/test-classes/com/example/test/test-artifact-module-a", "target/test-repository/com/example/test/test-artifact-module-a");
ProjectVersionMetadata metadata = storage.readProjectVersionMetadata(new ReadMetadataRequest(TEST_REPO_ID, "com.example.test", "test-artifact-module-a", "1.0"));
MavenProjectFacet facet = (MavenProjectFacet) metadata.getFacet(MavenProjectFacet.FACET_ID);
assertEquals("jar", facet.getPackaging());
assertEquals("http://maven.apache.org", metadata.getUrl());
assertEquals("com.example.test", facet.getParent().getGroupId());
assertEquals("test-artifact-root", facet.getParent().getArtifactId());
assertEquals("1.0", facet.getParent().getVersion());
assertEquals("test-artifact-module-a", facet.getArtifactId());
assertEquals("com.example.test", facet.getGroupId());
assertNull(metadata.getCiManagement());
assertNotNull(metadata.getDescription());
checkApacheLicense(metadata);
assertEquals("1.0", metadata.getId());
assertEquals("Test Artifact :: Module A", metadata.getName());
String path = "test-artifact/trunk/test-artifact-module-a";
assertEquals(TEST_SCM_CONN_BASE + path, metadata.getScm().getConnection());
assertEquals(TEST_SCM_DEV_CONN_BASE + path, metadata.getScm().getDeveloperConnection());
assertEquals(TEST_SCM_URL_BASE + path, metadata.getScm().getUrl());
List<Dependency> dependencies = metadata.getDependencies();
assertEquals(2, dependencies.size());
assertDependency(dependencies.get(0), "commons-io", "commons-io", "1.4");
assertDependency(dependencies.get(1), "junit", "junit", "3.8.1", "test");
List<String> paths = new ArrayList<>();
paths.add("target/test-repository/com/example/test/test-artifact-module-a");
paths.add("target/test-repository/com/example/test/test-artifact-parent");
paths.add("target/test-repository/com/example/test/test-artifact-root");
deleteTestArtifactWithParent(paths);
}
use of org.apache.archiva.metadata.repository.storage.ReadMetadataRequest in project archiva by apache.
the class Maven2RepositoryMetadataResolverMRM1411Test method testGetProjectVersionMetadataWithParentNoRemoteReposConfigured.
@Test
public void testGetProjectVersionMetadataWithParentNoRemoteReposConfigured() throws Exception {
// remove configuration
Configuration config = configuration.getConfiguration();
RemoteRepositoryConfiguration remoteRepo = config.findRemoteRepositoryById(TEST_REMOTE_REPO_ID);
config.removeRemoteRepository(remoteRepo);
configuration.save(config);
copyTestArtifactWithParent("target/test-classes/com/example/test/test-artifact-module-a", "target/test-repository/com/example/test/test-artifact-module-a");
ProjectVersionMetadata metadata = storage.readProjectVersionMetadata(new ReadMetadataRequest(TEST_REPO_ID, "com.example.test", "test-artifact-module-a", "1.0"));
assertEquals("1.0", metadata.getId());
MavenProjectFacet facet = (MavenProjectFacet) metadata.getFacet(MavenProjectFacet.FACET_ID);
assertNotNull(facet);
assertEquals("com.example.test", facet.getGroupId());
assertEquals("test-artifact-module-a", facet.getArtifactId());
assertEquals("jar", facet.getPackaging());
List<String> paths = new ArrayList<>();
paths.add("target/test-repository/com/example/test/test-artifact-module-a");
paths.add("target/test-repository/com/example/test/test-artifact-parent");
paths.add("target/test-repository/com/example/test/test-artifact-root");
deleteTestArtifactWithParent(paths);
}
Aggregations