1 package org.apache.archiva.repository.metadata;
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 junit.framework.TestCase;
23 import org.apache.archiva.maven2.metadata.MavenMetadataReader;
24 import org.apache.archiva.model.ArchivaRepositoryMetadata;
25 import org.apache.archiva.xml.XMLException;
26 import org.junit.Test;
27 import org.junit.runner.RunWith;
30 import org.apache.archiva.test.ArchivaBlockJUnit4ClassRunner;
33 * RepositoryMetadataReaderTest
37 @RunWith( ArchivaBlockJUnit4ClassRunner.class )
38 public class RepositoryMetadataReaderTest
42 public void testLoadSimple()
45 File defaultRepoDir = new File( "src/test/repositories/default-repository" );
46 File metadataFile = new File( defaultRepoDir, "org/apache/maven/shared/maven-downloader/maven-metadata.xml" );
48 ArchivaRepositoryMetadata metadata = MavenMetadataReader.read( metadataFile );
50 assertNotNull( metadata );
51 assertEquals( "Group Id", "org.apache.maven.shared", metadata.getGroupId() );
52 assertEquals( "Artifact Id", "maven-downloader", metadata.getArtifactId() );
53 assertEquals( "Released Version", "1.1", metadata.getReleasedVersion() );
54 assertEquals( "List of Available Versions", 2, metadata.getAvailableVersions().size() );
55 assertTrue( "Available version 1.0", metadata.getAvailableVersions().contains( "1.0" ) );
56 assertTrue( "Available version 1.1", metadata.getAvailableVersions().contains( "1.1" ) );
60 public void testLoadComplex()
63 File defaultRepoDir = new File( "src/test/repositories/default-repository" );
64 File metadataFile = new File( defaultRepoDir, "org/apache/maven/samplejar/maven-metadata.xml" );
66 ArchivaRepositoryMetadata metadata = MavenMetadataReader.read( metadataFile );
68 assertNotNull( metadata );
69 assertEquals( "Group Id", "org.apache.maven", metadata.getGroupId() );
70 assertEquals( "Artifact Id", "samplejar", metadata.getArtifactId() );
71 assertEquals( "Released Version", "2.0", metadata.getReleasedVersion() );
72 assertEquals( "Latest Version", "6.0-SNAPSHOT", metadata.getLatestVersion() );
73 assertEquals( "List of Available Versions", 18, metadata.getAvailableVersions().size() );
74 assertTrue( "Available version 6.0-20060311.183228-10",
75 metadata.getAvailableVersions().contains( "6.0-20060311.183228-10" ) );
76 assertTrue( "Available version 6.0-SNAPSHOT", metadata.getAvailableVersions().contains( "6.0-SNAPSHOT" ) );