1 package org.apache.maven.archiva.repository.project.filters;
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.Dependency;
24 import org.apache.maven.archiva.repository.project.ProjectModelException;
25 import org.apache.maven.archiva.repository.project.filters.ProjectModelExpressionExpander;
27 import java.util.Iterator;
29 import junit.framework.TestCase;
32 * ProjectModelExpressionExpanderTest
34 * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
37 public class ProjectModelExpressionExpanderTest
40 public void testExpressionEvaluation()
41 throws ProjectModelException
43 ArchivaProjectModel model = new ArchivaProjectModel();
44 model.setGroupId( "org.apache.maven.archiva" );
45 model.setArtifactId( "archiva-test-project" );
46 model.setVersion( "1.0-SNAPSHOT" );
48 model.addDependency( createDependency( "org.apache.maven.archiva", "archiva-model", "${archiva.version}" ) );
49 model.addDependency( createDependency( "org.apache.maven.archiva", "archiva-common", "${archiva.version}" ) );
50 model.addDependency( createDependency( "org.apache.maven.archiva", "archiva-indexer", "${archiva.version}" ) );
52 model.addProperty( "archiva.version", "1.0-SNAPSHOT" );
54 ProjectModelExpressionExpander.evaluateExpressions( model );
56 assertNotNull( model );
57 assertEquals( "Group ID", "org.apache.maven.archiva", model.getGroupId() );
58 assertEquals( "Artifact ID", "archiva-test-project", model.getArtifactId() );
59 assertEquals( "Version", "1.0-SNAPSHOT", model.getVersion() );
60 assertNotNull( "Dependencies", model.getDependencies() );
61 assertEquals( "Dependencies Size", 3, model.getDependencies().size() );
63 Iterator it = model.getDependencies().iterator();
64 while ( it.hasNext() )
66 Dependency dep = (Dependency) it.next();
67 assertEquals( "Dependency [" + dep.getArtifactId() + "] Group ID", "org.apache.maven.archiva", dep
69 assertEquals( "Dependency [" + dep.getArtifactId() + "] Version", "1.0-SNAPSHOT", dep.getVersion() );
73 private Dependency createDependency( String groupId, String artifactId, String version )
75 Dependency dep = new Dependency();
77 dep.setGroupId( groupId );
78 dep.setArtifactId( artifactId );
79 dep.setVersion( version );