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.ReleaseEnvironment;
31  import org.codehaus.plexus.PlexusTestCase;
32  
33  public class MapDevelopmentVersionPhaseIT
34      extends PlexusTestCase
35  {
36      private MapVersionsPhase mapVersionsPhase;
37  
38      @Override
39      protected InputStream getCustomConfiguration()
40          throws Exception
41      {
42          return MapVersionsPhase.class.getResourceAsStream( "/META-INF/plexus/components.xml" );
43      }
44  
45      @Override
46      protected void setUp()
47          throws Exception
48      {
49          super.setUp();
50          mapVersionsPhase = (MapVersionsPhase) lookup( ReleasePhase.class.getName(), "map-development-versions" );
51      }
52      
53      private static MavenProject createProject( String artifactId, String version )
54      {
55          Model model = new Model();
56          model.setGroupId( "groupId" );
57          model.setArtifactId( artifactId );
58          model.setVersion( version );
59          return new MavenProject( model );
60      }
61  
62      public void testNoUpdateWorkingCopyVersions() throws Exception
63      {
64          ReleaseDescriptor releaseDescriptor = new ReleaseDescriptor();
65          releaseDescriptor.setInteractive( false );
66          releaseDescriptor.setUpdateWorkingCopyVersions( false );
67          
68          List<MavenProject> reactorProjects = Collections.singletonList( createProject( "artifactId", "1.0" ) );
69          mapVersionsPhase.execute( releaseDescriptor, (ReleaseEnvironment) null, reactorProjects );
70          
71          assertEquals( "1.0", releaseDescriptor.getDevelopmentVersions().get( "groupId:artifactId" ) );
72      }
73  }