1 package org.apache.maven.archiva.repository.project.readers;
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.maven.archiva.model.ArchivaProjectModel;
23 import org.apache.maven.archiva.model.VersionedReference;
24 import org.apache.maven.archiva.repository.project.ProjectModelException;
25 import org.apache.maven.archiva.repository.project.ProjectModelReader;
26 import org.codehaus.plexus.spring.PlexusInSpringTestCase;
31 * ProjectModel400ReaderTest
33 * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
36 public class ProjectModel400ReaderTest
37 extends PlexusInSpringTestCase
39 public void testLoadSimple()
40 throws ProjectModelException
42 File defaultRepoDir = new File( getBasedir(), "src/test/repositories/default-repository" );
43 File pomFile = new File( defaultRepoDir,
44 "org/apache/maven/shared/maven-downloader/1.0/maven-downloader-1.0.pom" );
46 ProjectModelReader reader = new ProjectModel400Reader();
48 ArchivaProjectModel project = reader.read( pomFile );
50 assertNotNull( project );
51 assertEquals( "Group Id", "org.apache.maven.shared", project.getGroupId() );
52 assertEquals( "Artifact Id", "maven-downloader", project.getArtifactId() );
53 assertEquals( "Version", "1.0", project.getVersion() );
54 assertEquals( "Name", "Maven Downloader", project.getName() );
55 assertEquals( "Description", "Provide a super simple interface for downloading a single artifact.", project
59 VersionedReference parentRef = project.getParentProject();
60 assertNotNull( "Parent Reference", parentRef );
61 assertEquals( "Parent Group ID", "org.apache.maven.shared", parentRef.getGroupId() );
62 assertEquals( "Parent Artifact ID", "maven-shared-components", parentRef.getArtifactId() );
63 assertEquals( "Parent Version", "4", parentRef.getVersion() );
65 assertNotNull( "Dependencies", project.getDependencies() );
66 assertEquals( "Dependencies.size", 3, project.getDependencies().size() );
69 public void testLoadWithNamespace()
70 throws ProjectModelException
72 File defaultRepoDir = new File( getBasedir(), "src/test/repositories/default-repository" );
73 File pomFile = new File( defaultRepoDir,
74 "org/apache/maven/archiva/archiva-model/1.0-SNAPSHOT/archiva-model-1.0-SNAPSHOT.pom" );
76 ProjectModelReader reader = new ProjectModel400Reader();
78 ArchivaProjectModel project = reader.read( pomFile );
80 assertNotNull( project );
81 assertEquals( "Group Id", null, project.getGroupId() );
82 assertEquals( "Artifact Id", "archiva-model", project.getArtifactId() );
83 assertEquals( "Version", null, project.getVersion() );
84 assertEquals( "Name", "Archiva Base :: Model", project.getName() );
85 assertEquals( "Description", null, project.getDescription() );
88 VersionedReference parentRef = project.getParentProject();
89 assertNotNull( "Parent Reference", parentRef );
90 assertEquals( "Parent Group ID", "org.apache.maven.archiva", parentRef.getGroupId() );
91 assertEquals( "Parent Artifact ID", "archiva-base", parentRef.getArtifactId() );
92 assertEquals( "Parent Version", "1.0-SNAPSHOT", parentRef.getVersion() );
94 assertNotNull( "Dependencies", project.getDependencies() );
95 assertEquals( "Dependencies.size", 6, project.getDependencies().size() );