View Javadoc
1   package org.apache.maven.shared.release.phase;
2   
3   /*
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
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
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
19   * under the License.
20   */
21  
22  import java.io.InputStream;
23  import java.util.Collections;
24  import java.util.List;
25  
26  import org.apache.maven.model.Model;
27  import org.apache.maven.project.MavenProject;
28  import org.apache.maven.shared.release.ReleaseResult;
29  import org.apache.maven.shared.release.config.ReleaseDescriptor;
30  import org.apache.maven.shared.release.env.DefaultReleaseEnvironment;
31  import org.apache.maven.shared.release.env.ReleaseEnvironment;
32  import org.codehaus.plexus.PlexusTestCase;
33  
34  public class MapDevelopmentVersionPhaseIT
35      extends PlexusTestCase
36  {
37      private MapVersionsPhase mapVersionsPhase;
38  
39      @Override
40      protected InputStream getCustomConfiguration()
41          throws Exception
42      {
43          return MapVersionsPhase.class.getResourceAsStream( "/META-INF/plexus/components.xml" );
44      }
45  
46      @Override
47      protected void setUp()
48          throws Exception
49      {
50          super.setUp();
51          mapVersionsPhase = (MapVersionsPhase) lookup( ReleasePhase.class.getName(), "map-development-versions" );
52      }
53      
54      private static MavenProject createProject( String artifactId, String version )
55      {
56          Model model = new Model();
57          model.setGroupId( "groupId" );
58          model.setArtifactId( artifactId );
59          model.setVersion( version );
60          return new MavenProject( model );
61      }
62  
63      public void testNoUpdateWorkingCopyVersions() throws Exception
64      {
65          ReleaseDescriptor releaseDescriptor = new ReleaseDescriptor();
66          releaseDescriptor.setInteractive( false );
67          releaseDescriptor.setUpdateWorkingCopyVersions( false );
68          
69          List<MavenProject> reactorProjects = Collections.singletonList( createProject( "artifactId", "1.0" ) );
70          mapVersionsPhase.execute( releaseDescriptor, new DefaultReleaseEnvironment(), reactorProjects );
71          
72          assertEquals( "1.0", releaseDescriptor.getDevelopmentVersions().get( "groupId:artifactId" ) );
73      }
74  }