View Javadoc
1   package org.apache.maven.plugins.release;
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 static org.mockito.Mockito.mock;
23  import static org.mockito.Mockito.verify;
24  import static org.mockito.Mockito.verifyNoMoreInteractions;
25  
26  import java.io.File;
27  
28  import org.apache.maven.plugin.MojoExecutionException;
29  import org.apache.maven.plugin.MojoFailureException;
30  import org.apache.maven.plugin.testing.AbstractMojoTestCase;
31  import org.apache.maven.shared.release.ReleaseManager;
32  import org.apache.maven.shared.release.config.ReleaseDescriptor;
33  
34  /**
35   * Test release:clean.
36   *
37   * @author <a href="mailto:brett@apache.org">Brett Porter</a>
38   */
39  public class CleanReleaseMojoTest
40      extends AbstractMojoTestCase
41  {
42      protected CleanReleaseMojo mojo;
43  
44      private File workingDirectory;
45  
46      protected void setUp()
47          throws Exception
48      {
49          super.setUp();
50  
51          File testFile = getTestFile( "target/test-classes/mojos/clean/clean.xml" );
52          mojo = (CleanReleaseMojo) lookupMojo( "clean", testFile );
53          workingDirectory = testFile.getParentFile();
54          mojo.setBasedir( workingDirectory );
55      }
56  
57      public void testClean()
58          throws MojoFailureException, MojoExecutionException
59      {
60          // prepare
61          ReleaseDescriptor descriptor = new ReleaseDescriptor();
62          descriptor.setWorkingDirectory( workingDirectory.getAbsolutePath() );
63  
64          ReleaseManager mock = mock( ReleaseManager.class );
65          mojo.setReleaseManager( mock );
66  
67          // execute
68          mojo.execute();
69  
70          // verify
71          verify( mock ).clean( descriptor, null, mojo.getReactorProjects() );
72          verifyNoMoreInteractions( mock );
73      }
74  }