Search in sources :

Example 41 with ProjectVersionMetadata

use of org.apache.archiva.metadata.model.ProjectVersionMetadata 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);
}
Also used : ReadMetadataRequest(org.apache.archiva.metadata.repository.storage.ReadMetadataRequest) ProjectVersionMetadata(org.apache.archiva.metadata.model.ProjectVersionMetadata) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 42 with ProjectVersionMetadata

use of org.apache.archiva.metadata.model.ProjectVersionMetadata 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);
}
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 43 with ProjectVersionMetadata

use of org.apache.archiva.metadata.model.ProjectVersionMetadata 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);
}
Also used : ArchivaConfiguration(org.apache.archiva.configuration.ArchivaConfiguration) ProxyConnectorConfiguration(org.apache.archiva.configuration.ProxyConnectorConfiguration) ManagedRepositoryConfiguration(org.apache.archiva.configuration.ManagedRepositoryConfiguration) RemoteRepositoryConfiguration(org.apache.archiva.configuration.RemoteRepositoryConfiguration) ContextConfiguration(org.springframework.test.context.ContextConfiguration) Configuration(org.apache.archiva.configuration.Configuration) ReadMetadataRequest(org.apache.archiva.metadata.repository.storage.ReadMetadataRequest) ProjectVersionMetadata(org.apache.archiva.metadata.model.ProjectVersionMetadata) ArrayList(java.util.ArrayList) RemoteRepositoryConfiguration(org.apache.archiva.configuration.RemoteRepositoryConfiguration) Test(org.junit.Test)

Example 44 with ProjectVersionMetadata

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

the class Maven2RepositoryMetadataResolverTest method testGetProjectVersionMetadata.

@Test
public void testGetProjectVersionMetadata() throws Exception {
    ProjectVersionMetadata metadata = storage.readProjectVersionMetadata(new ReadMetadataRequest(TEST_REPO_ID, "org.apache.archiva", "archiva-common", "1.2.1"));
    MavenProjectFacet facet = (MavenProjectFacet) metadata.getFacet(MavenProjectFacet.FACET_ID);
    assertEquals("jar", facet.getPackaging());
    assertEquals("http://archiva.apache.org/ref/1.2.1/archiva-base/archiva-common", metadata.getUrl());
    assertEquals("org.apache.archiva", facet.getParent().getGroupId());
    assertEquals("archiva-base", facet.getParent().getArtifactId());
    assertEquals("1.2.1", facet.getParent().getVersion());
    assertEquals("archiva-common", facet.getArtifactId());
    assertEquals("org.apache.archiva", facet.getGroupId());
    assertEquals("continuum", metadata.getCiManagement().getSystem());
    assertEquals("http://vmbuild.apache.org/continuum", metadata.getCiManagement().getUrl());
    assertNotNull(metadata.getDescription());
    // TODO: this would be better
    // assertEquals(
    // "Archiva is an application for managing one or more remote repositories, including administration, artifact handling, browsing and searching.",
    // metadata.getDescription() );
    assertEquals("1.2.1", metadata.getId());
    assertEquals("jira", metadata.getIssueManagement().getSystem());
    assertEquals("http://jira.codehaus.org/browse/MRM", metadata.getIssueManagement().getUrl());
    checkApacheLicense(metadata);
    assertEquals("Archiva Base :: Common", metadata.getName());
    String path = "archiva/tags/archiva-1.2.1/archiva-modules/archiva-base/archiva-common";
    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(4, metadata.getMailingLists().size());
    assertMailingList("users", metadata.getMailingLists().get(0), "Archiva User List", true, "http://www.nabble.com/archiva-users-f16426.html");
    assertMailingList("dev", metadata.getMailingLists().get(1), "Archiva Developer List", true, "http://www.nabble.com/archiva-dev-f16427.html");
    assertMailingList("commits", metadata.getMailingLists().get(2), "Archiva Commits List", false, null);
    assertMailingList("issues", metadata.getMailingLists().get(3), "Archiva Issues List", false, "http://www.nabble.com/Archiva---Issues-f29617.html");
    List<Dependency> dependencies = metadata.getDependencies();
    assertEquals(10, dependencies.size());
    assertDependency(dependencies.get(0), "commons-lang", "commons-lang", "2.2");
    assertDependency(dependencies.get(1), "commons-io", "commons-io", "1.4");
    assertDependency(dependencies.get(2), "org.slf4j", "slf4j-api", "1.5.0");
    assertDependency(dependencies.get(3), "org.codehaus.plexus", "plexus-component-api", "1.0-alpha-22");
    assertDependency(dependencies.get(4), "org.codehaus.plexus", "plexus-spring", "1.2", "test");
    assertDependency(dependencies.get(5), "xalan", "xalan", "2.7.0");
    assertDependency(dependencies.get(6), "dom4j", "dom4j", "1.6.1", "test");
    assertDependency(dependencies.get(7), "junit", "junit", "3.8.1", "test");
    assertDependency(dependencies.get(8), "easymock", "easymock", "1.2_Java1.3", "test");
    assertDependency(dependencies.get(9), "easymock", "easymockclassextension", "1.2", "test");
    assertEquals(8, metadata.getProperties().size());
    assertEquals("http://www.apache.org/images/asf_logo_wide.gif", metadata.getProperties().get("organization.logo"));
}
Also used : ReadMetadataRequest(org.apache.archiva.metadata.repository.storage.ReadMetadataRequest) ProjectVersionMetadata(org.apache.archiva.metadata.model.ProjectVersionMetadata) Dependency(org.apache.archiva.metadata.model.Dependency) 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