1   package org.apache.maven.artifact;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one or more
5    * contributor license agreements.  See the NOTICE file distributed with
6    * this work for additional information regarding copyright ownership.
7    * The ASF licenses this file to You under the Apache License, Version 2.0
8    * (the "License"); you may not use this file except in compliance with
9    * the License.  You may obtain a copy of the License at
10   *
11   *      http://www.apache.org/licenses/LICENSE-2.0
12   *
13   * Unless required by applicable law or agreed to in writing, software
14   * distributed under the License is distributed on an "AS IS" BASIS,
15   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   * See the License for the specific language governing permissions and
17   * limitations under the License.
18   */
19  
20  import org.apache.maven.MavenConstants;
21  import org.apache.maven.project.Dependency;
22  import org.apache.maven.project.Model;
23  
24  import java.io.File;
25  
26  import junit.framework.Assert;
27  import junit.framework.TestCase;
28  
29  /**
30   * Test the POM rewriter.
31   *
32   * @author <a href="mailto:brett@apache.org">Brett Porter</a>
33   * @version $Id: PomRewriterTest.java 532339 2007-04-25 12:28:56Z ltheussl $
34   */
35  public class PomRewriterTest
36      extends TestCase
37  {
38      protected void setUp()
39          throws Exception
40      {
41          if ( System.getProperty( MavenConstants.MAVEN_HOME ) == null )
42          {
43              System.setProperty( MavenConstants.MAVEN_HOME, "target/maven-home" );
44          }
45      }
46  
47      public void testPropertiesRewriting()
48          throws Exception
49      {
50          final String resourceName = "pom-with-properties.xml";
51  
52          final Model model = PomRewriter.getRewrittenModel( new File( System.getProperty( "basedir" ), "src/test/resources/"
53              + resourceName ), null );
54  
55          Dependency dep = (Dependency) model.getDependencies().get( 0 );
56          Assert.assertEquals( "check property war.bundle", "true", dep.getProperty( "war.bundle" ) );
57          Assert.assertEquals( "check num properties", 1, dep.getProperties().size() );
58  
59          dep = (Dependency) model.getDependencies().get( 1 );
60          Assert.assertEquals( "check property gump.project", "jakarta-taglibs-standard", dep.getProperty( "gump.project" ) );
61          Assert.assertEquals( "check property gump.id", "jstl", dep.getProperty( "gump.id" ) );
62          Assert.assertEquals( "check num properties", 2, dep.getProperties().size() );
63      }
64  
65  }