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 org.apache.maven.plugin.MojoExecutionException;
23  import org.apache.maven.plugin.MojoFailureException;
24  import org.apache.maven.plugin.testing.AbstractMojoTestCase;
25  import org.apache.maven.shared.release.ReleaseManager;
26  import org.apache.maven.shared.release.config.ReleaseDescriptor;
27  import org.jmock.Mock;
28  import org.jmock.core.constraint.IsEqual;
29  import org.jmock.core.constraint.IsNull;
30  import org.jmock.core.matcher.InvokeOnceMatcher;
31  
32  import java.io.File;
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          ReleaseDescriptor descriptor = new ReleaseDescriptor();
61          descriptor.setWorkingDirectory( workingDirectory.getAbsolutePath() );
62  
63          Mock mock = new Mock( ReleaseManager.class );
64          mock.expects( new InvokeOnceMatcher() ).method( "clean" ).with( new IsEqual( descriptor ), new IsNull(),
65                                                                          new IsEqual( mojo.getReactorProjects() ) );
66          mojo.setReleaseManager( (ReleaseManager) mock.proxy() );
67  
68          mojo.execute();
69  
70          assertTrue( true );
71      }
72  }