1 package org.apache.archiva.metadata.repository.storage.maven2;
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
23 import java.util.Arrays;
25 import org.apache.maven.archiva.xml.XMLException;
26 import org.codehaus.plexus.spring.PlexusInSpringTestCase;
29 * RepositoryMetadataReaderTest
33 public class MavenRepositoryMetadataReaderTest
34 extends PlexusInSpringTestCase
36 public void testGroupMetadata()
39 File defaultRepoDir = new File( getBasedir(), "src/test/repositories/test" );
40 File metadataFile = new File( defaultRepoDir, "org/apache/maven/plugins/maven-metadata.xml" );
42 MavenRepositoryMetadata metadata = MavenRepositoryMetadataReader.read( metadataFile );
44 assertNotNull( metadata );
45 assertEquals( "org.apache.maven.plugins", metadata.getGroupId() );
46 assertNull( metadata.getArtifactId() );
47 assertNull( metadata.getReleasedVersion() );
48 assertNull( metadata.getLatestVersion() );
49 assertTrue( metadata.getAvailableVersions().isEmpty() );
50 assertNull( metadata.getSnapshotVersion() );
51 assertNull( metadata.getLastUpdated() );
53 MavenRepositoryMetadata.Plugin cleanPlugin = new MavenRepositoryMetadata.Plugin();
54 cleanPlugin.setPrefix( "clean" );
55 cleanPlugin.setArtifactId( "maven-clean-plugin" );
56 cleanPlugin.setName( "Maven Clean Plugin" );
58 MavenRepositoryMetadata.Plugin compilerPlugin = new MavenRepositoryMetadata.Plugin();
59 compilerPlugin.setPrefix( "compiler" );
60 compilerPlugin.setArtifactId( "maven-compiler-plugin" );
61 compilerPlugin.setName( "Maven Compiler Plugin" );
63 MavenRepositoryMetadata.Plugin surefirePlugin = new MavenRepositoryMetadata.Plugin();
64 surefirePlugin.setPrefix( "surefire" );
65 surefirePlugin.setArtifactId( "maven-surefire-plugin" );
66 surefirePlugin.setName( "Maven Surefire Plugin" );
68 assertEquals( Arrays.asList( cleanPlugin, compilerPlugin, surefirePlugin ), metadata.getPlugins() );
71 public void testProjectMetadata()
74 File defaultRepoDir = new File( getBasedir(), "src/test/repositories/test" );
75 File metadataFile = new File( defaultRepoDir, "org/apache/maven/shared/maven-downloader/maven-metadata.xml" );
77 MavenRepositoryMetadata metadata = MavenRepositoryMetadataReader.read( metadataFile );
79 assertNotNull( metadata );
80 assertEquals( "org.apache.maven.shared", metadata.getGroupId() );
81 assertEquals( "maven-downloader", metadata.getArtifactId() );
82 assertEquals( "1.1", metadata.getReleasedVersion() );
83 assertNull( metadata.getLatestVersion() );
84 assertEquals( Arrays.asList( "1.0", "1.1" ), metadata.getAvailableVersions() );
85 assertNull( metadata.getSnapshotVersion() );
86 assertEquals( "20061212214311", metadata.getLastUpdated() );
89 public void testProjectVersionMetadata()
92 File defaultRepoDir = new File( getBasedir(), "src/test/repositories/test" );
93 File metadataFile = new File( defaultRepoDir, "org/apache/apache/5-SNAPSHOT/maven-metadata.xml" );
95 MavenRepositoryMetadata metadata = MavenRepositoryMetadataReader.read( metadataFile );
97 assertNotNull( metadata );
98 assertEquals( "org.apache", metadata.getGroupId() );
99 assertEquals( "apache", metadata.getArtifactId() );
100 assertNull( metadata.getReleasedVersion() );
101 assertNull( metadata.getLatestVersion() );
102 assertTrue( metadata.getAvailableVersions().isEmpty() );
103 assertNotNull( metadata.getSnapshotVersion() );
104 assertEquals( "20080801.151215", metadata.getSnapshotVersion().getTimestamp() );
105 assertEquals( 1, metadata.getSnapshotVersion().getBuildNumber() );
106 assertEquals( "20080801151215", metadata.getLastUpdated() );