Search in sources :

Example 16 with ProjectVersionMetadata

use of org.apache.archiva.metadata.model.ProjectVersionMetadata in project archiva by apache.

the class Maven2RepositoryMetadataResolverMRM1411RepoGroupTest method testGetProjectVersionMetadataWithParentSnapshotVersionAndSnapNotAllowed.

@Test
public void testGetProjectVersionMetadataWithParentSnapshotVersionAndSnapNotAllowed() 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("src/test/resources/com/example/test/test-artifact-parent", "target/test-repositorys/com/example/test/test-artifact-parent");
    copyTestArtifactWithParent("src/test/resources/com/example/test/test-snapshot-artifact-root", "target/test-repositorys/com/example/test/test-snapshot-artifact-root");
    ReadMetadataRequest readMetadataRequest = new ReadMetadataRequest().repositoryId(TEST_SNAP_REPO_ID).namespace("com.example.test").projectId("test-snapshot-artifact-module-a").projectVersion("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);
}
Also used : ReadMetadataRequest(org.apache.archiva.metadata.repository.storage.ReadMetadataRequest) ProjectVersionMetadata(org.apache.archiva.metadata.model.ProjectVersionMetadata) ArrayList(java.util.ArrayList) Dependency(org.apache.archiva.metadata.model.Dependency) Test(org.junit.Test)

Example 17 with ProjectVersionMetadata

use of org.apache.archiva.metadata.model.ProjectVersionMetadata in project archiva by apache.

the class Maven2RepositoryMetadataResolverMRM1411Test method testGetProjectVersionMetadataWithParentSnapshotVersion.

@Test
public void testGetProjectVersionMetadataWithParentSnapshotVersion() throws Exception {
    copyTestArtifactWithParent("target/test-classes/com/example/test/test-snapshot-artifact-module-a", "target/test-repository/com/example/test/test-snapshot-artifact-module-a");
    // copyTestArtifactWithParent( "target/test-classes/com/example/test/test-snapshot-artifact-root",
    // "target/test-repository/com/example/test/test-snapshot-artifact-root" );
    ProjectVersionMetadata metadata = storage.readProjectVersionMetadata(new ReadMetadataRequest(TEST_REPO_ID, "com.example.test", "test-snapshot-artifact-module-a", "1.1-SNAPSHOT"));
    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-repository/com/example/test/test-snapshot-artifact-module-a");
    paths.add("target/test-repository/com/example/test/test-snapshot-artifact-root");
    deleteTestArtifactWithParent(paths);
}
Also used : ReadMetadataRequest(org.apache.archiva.metadata.repository.storage.ReadMetadataRequest) ProjectVersionMetadata(org.apache.archiva.metadata.model.ProjectVersionMetadata) ArrayList(java.util.ArrayList) Dependency(org.apache.archiva.metadata.model.Dependency) Test(org.junit.Test)

Example 18 with ProjectVersionMetadata

use of org.apache.archiva.metadata.model.ProjectVersionMetadata in project archiva by apache.

the class Maven2RepositoryMetadataResolverManagedReleaseTest method testModelWithJdkProfileActivation.

@Test
@Override
public void testModelWithJdkProfileActivation() throws Exception {
    // skygo IMHO must fail because TEST_REPO_ID ( is snap ,no release) and we seek for a snapshot
    ReadMetadataRequest readMetadataRequest = new ReadMetadataRequest().repositoryId(TEST_REPO_ID).namespace("org.apache.maven").projectId("maven-archiver").projectVersion("2.4.1");
    ProjectVersionMetadata metadata = storage.readProjectVersionMetadata(readMetadataRequest);
}
Also used : ReadMetadataRequest(org.apache.archiva.metadata.repository.storage.ReadMetadataRequest) ProjectVersionMetadata(org.apache.archiva.metadata.model.ProjectVersionMetadata) Test(org.junit.Test)

Example 19 with ProjectVersionMetadata

use of org.apache.archiva.metadata.model.ProjectVersionMetadata in project archiva by apache.

the class Maven2RepositoryMetadataResolverManagedSnapshotTest method testModelWithJdkProfileActivation.

@Test(expected = RepositoryStorageRuntimeException.class)
@Override
public void testModelWithJdkProfileActivation() throws Exception {
    // skygo IMHO must fail because TEST_REPO_ID ( is snap ,no release) and we seek for a snapshot
    ReadMetadataRequest readMetadataRequest = new ReadMetadataRequest().repositoryId(TEST_REPO_ID).namespace("org.apache.maven").projectId("maven-archiver").projectVersion("2.4.1");
    ProjectVersionMetadata metadata = storage.readProjectVersionMetadata(readMetadataRequest);
}
Also used : ReadMetadataRequest(org.apache.archiva.metadata.repository.storage.ReadMetadataRequest) ProjectVersionMetadata(org.apache.archiva.metadata.model.ProjectVersionMetadata) Test(org.junit.Test)

Example 20 with ProjectVersionMetadata

use of org.apache.archiva.metadata.model.ProjectVersionMetadata in project archiva by apache.

the class Maven2RepositoryMetadataResolverTest method testGetProjectVersionMetadataForTimestampedSnapshot.

@Test
public void testGetProjectVersionMetadataForTimestampedSnapshot() throws Exception {
    ProjectVersionMetadata metadata = storage.readProjectVersionMetadata(new ReadMetadataRequest(TEST_REPO_ID, "org.apache", "apache", "5-SNAPSHOT"));
    MavenProjectFacet facet = MavenProjectFacet.class.cast(metadata.getFacet(MavenProjectFacet.FACET_ID));
    assertEquals("pom", facet.getPackaging());
    assertEquals("http://www.apache.org/", metadata.getUrl());
    assertNull(facet.getParent());
    assertEquals("org.apache", facet.getGroupId());
    assertEquals("apache", facet.getArtifactId());
    assertNull(metadata.getCiManagement());
    assertNotNull(metadata.getDescription());
    // TODO: this would be better
    // assertEquals(
    // "The Apache Software Foundation provides support for the Apache community of open-source software projects. " +
    // "The Apache projects are characterized by a collaborative, consensus based development process, an open " +
    // "and pragmatic software license, and a desire to create high quality software that leads the way in its " +
    // "field. We consider ourselves not simply a group of projects sharing a server, but rather a community of " +
    // "developers and users.", metadata.getDescription() );
    assertEquals("5-SNAPSHOT", metadata.getId());
    assertNull(metadata.getIssueManagement());
    checkApacheLicense(metadata);
    assertEquals("The Apache Software Foundation", metadata.getName());
    String path = "maven/pom/trunk/asf";
    assertEquals(ASF_SCM_CONN_BASE + path, metadata.getScm().getConnection());
    assertEquals(ASF_SCM_DEV_CONN_BASE + path, metadata.getScm().getDeveloperConnection());
    assertEquals(ASF_SCM_VIEWVC_BASE + path, metadata.getScm().getUrl());
    checkOrganizationApache(metadata);
    assertEquals(1, metadata.getMailingLists().size());
    assertMailingList(metadata.getMailingLists().get(0), "Apache Announce List", "http://mail-archives.apache.org/mod_mbox/www-announce/", "announce@apache.org", "announce-subscribe@apache.org", "announce-unsubscribe@apache.org", Collections.<String>emptyList(), true);
    assertEquals(Collections.<Dependency>emptyList(), metadata.getDependencies());
}
Also used : ReadMetadataRequest(org.apache.archiva.metadata.repository.storage.ReadMetadataRequest) ProjectVersionMetadata(org.apache.archiva.metadata.model.ProjectVersionMetadata) Test(org.junit.Test)

Aggregations

ProjectVersionMetadata (org.apache.archiva.metadata.model.ProjectVersionMetadata)44 Test (org.junit.Test)29 ReadMetadataRequest (org.apache.archiva.metadata.repository.storage.ReadMetadataRequest)19 ArrayList (java.util.ArrayList)14 Dependency (org.apache.archiva.metadata.model.Dependency)11 MetadataFacet (org.apache.archiva.metadata.model.MetadataFacet)8 HashMap (java.util.HashMap)7 GenericMetadataFacet (org.apache.archiva.metadata.generic.GenericMetadataFacet)6 ArtifactMetadata (org.apache.archiva.metadata.model.ArtifactMetadata)5 RepositorySession (org.apache.archiva.metadata.repository.RepositorySession)5 RepositoryStorageRuntimeException (org.apache.archiva.metadata.repository.storage.RepositoryStorageRuntimeException)5 CiManagement (org.apache.archiva.metadata.model.CiManagement)4 IssueManagement (org.apache.archiva.metadata.model.IssueManagement)4 MailingList (org.apache.archiva.metadata.model.MailingList)4 Scm (org.apache.archiva.metadata.model.Scm)4 MetadataResolutionException (org.apache.archiva.metadata.repository.MetadataResolutionException)4 RepositoryStorageMetadataInvalidException (org.apache.archiva.metadata.repository.storage.RepositoryStorageMetadataInvalidException)4 RepositoryStorageMetadataNotFoundException (org.apache.archiva.metadata.repository.storage.RepositoryStorageMetadataNotFoundException)4 Path (java.nio.file.Path)3 License (org.apache.archiva.metadata.model.License)3