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
35 public class ProjectModel400ReaderTest
36 extends PlexusInSpringTestCase
38 public void testLoadSimple()
39 throws ProjectModelException
41 File defaultRepoDir = new File( getBasedir(), "src/test/repositories/default-repository" );
42 File pomFile = new File( defaultRepoDir,
43 "org/apache/maven/shared/maven-downloader/1.0/maven-downloader-1.0.pom" );
45 ProjectModelReader reader = new ProjectModel400Reader();
47 ArchivaProjectModel project = reader.read( pomFile );
49 assertNotNull( project );
50 assertEquals( "Group Id", "org.apache.maven.shared", project.getGroupId() );
51 assertEquals( "Artifact Id", "maven-downloader", project.getArtifactId() );
52 assertEquals( "Version", "1.0", project.getVersion() );
53 assertEquals( "Name", "Maven Downloader", project.getName() );
54 assertEquals( "Description", "Provide a super simple interface for downloading a single artifact.", project
58 VersionedReference parentRef = project.getParentProject();
59 assertNotNull( "Parent Reference", parentRef );
60 assertEquals( "Parent Group ID", "org.apache.maven.shared", parentRef.getGroupId() );
61 assertEquals( "Parent Artifact ID", "maven-shared-components", parentRef.getArtifactId() );
62 assertEquals( "Parent Version", "4", parentRef.getVersion() );
64 assertNotNull( "Dependencies", project.getDependencies() );
65 assertEquals( "Dependencies.size", 3, project.getDependencies().size() );
68 public void testLoadWithNamespace()
69 throws ProjectModelException
71 File defaultRepoDir = new File( getBasedir(), "src/test/repositories/default-repository" );
72 File pomFile = new File( defaultRepoDir,
73 "org/apache/maven/archiva/archiva-model/1.0-SNAPSHOT/archiva-model-1.0-SNAPSHOT.pom" );
75 ProjectModelReader reader = new ProjectModel400Reader();
77 ArchivaProjectModel project = reader.read( pomFile );
79 assertNotNull( project );
80 assertEquals( "Group Id", null, project.getGroupId() );
81 assertEquals( "Artifact Id", "archiva-model", project.getArtifactId() );
82 assertEquals( "Version", null, project.getVersion() );
83 assertEquals( "Name", "Archiva Base :: Model", project.getName() );
84 assertEquals( "Description", null, project.getDescription() );
87 VersionedReference parentRef = project.getParentProject();
88 assertNotNull( "Parent Reference", parentRef );
89 assertEquals( "Parent Group ID", "org.apache.maven.archiva", parentRef.getGroupId() );
90 assertEquals( "Parent Artifact ID", "archiva-base", parentRef.getArtifactId() );
91 assertEquals( "Parent Version", "1.0-SNAPSHOT", parentRef.getVersion() );
93 assertNotNull( "Dependencies", project.getDependencies() );
94 assertEquals( "Dependencies.size", 8, project.getDependencies().size() );