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.test.utils.ArchivaBlockJUnit4ClassRunner;
26 import org.apache.archiva.xml.XMLException;
27 import org.junit.Test;
28 import org.junit.runner.RunWith;
30 import java.nio.file.Path;
31 import java.nio.file.Paths;
34 * RepositoryMetadataReaderTest
38 @RunWith( ArchivaBlockJUnit4ClassRunner.class )
39 public class RepositoryMetadataReaderTest
43 public void testLoadSimple()
46 Path defaultRepoDir = Paths.get( "src/test/repositories/default-repository" );
47 Path metadataFile = defaultRepoDir.resolve( "org/apache/maven/shared/maven-downloader/maven-metadata.xml" );
49 ArchivaRepositoryMetadata metadata = MavenMetadataReader.read( metadataFile);
51 assertNotNull( metadata );
52 assertEquals( "Group Id", "org.apache.maven.shared", metadata.getGroupId() );
53 assertEquals( "Artifact Id", "maven-downloader", metadata.getArtifactId() );
54 assertEquals( "Released Version", "1.1", metadata.getReleasedVersion() );
55 assertEquals( "List of Available Versions", 2, metadata.getAvailableVersions().size() );
56 assertTrue( "Available version 1.0", metadata.getAvailableVersions().contains( "1.0" ) );
57 assertTrue( "Available version 1.1", metadata.getAvailableVersions().contains( "1.1" ) );
61 public void testLoadComplex()
64 Path defaultRepoDir = Paths.get( "src/test/repositories/default-repository" );
65 Path metadataFile = defaultRepoDir.resolve( "org/apache/maven/samplejar/maven-metadata.xml" );
67 ArchivaRepositoryMetadata metadata = MavenMetadataReader.read( metadataFile );
69 assertNotNull( metadata );
70 assertEquals( "Group Id", "org.apache.maven", metadata.getGroupId() );
71 assertEquals( "Artifact Id", "samplejar", metadata.getArtifactId() );
72 assertEquals( "Released Version", "2.0", metadata.getReleasedVersion() );
73 assertEquals( "Latest Version", "6.0-SNAPSHOT", metadata.getLatestVersion() );
74 assertEquals( "List of Available Versions", 18, metadata.getAvailableVersions().size() );
75 assertTrue( "Available version 6.0-20060311.183228-10",
76 metadata.getAvailableVersions().contains( "6.0-20060311.183228-10" ) );
77 assertTrue( "Available version 6.0-SNAPSHOT", metadata.getAvailableVersions().contains( "6.0-SNAPSHOT" ) );