View Javadoc
1   package org.apache.maven.shared.transfer.project.install.internal;
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  
24  import java.io.IOException;
25  
26  import org.apache.maven.project.ProjectBuildingRequest;
27  import org.apache.maven.shared.transfer.artifact.install.ArtifactInstallerException;
28  import org.apache.maven.shared.transfer.project.NoFileAssignedException;
29  import org.apache.maven.shared.transfer.project.install.ProjectInstaller;
30  import org.apache.maven.shared.transfer.project.install.internal.DefaultProjectInstaller;
31  import org.junit.Rule;
32  import org.junit.Test;
33  import org.junit.rules.ExpectedException;
34  
35  /**
36   * Check the parameter contracts which have been made based on the interface {@link ProjectInstaller}.
37   * 
38   * @author Karl Heinz Marbaise <a href="mailto:khmarbaise@apache.org">khmabaise@apache.org</a>
39   */
40  public class DefaultProjectInstallerTest
41  {
42  
43      @Rule
44      public ExpectedException expectedException = ExpectedException.none();
45  
46      @Test
47      public void installShouldFailWithIAEWhileBuildingRequestIsNull()
48          throws IOException, ArtifactInstallerException, NoFileAssignedException
49      {
50          ProjectInstaller dpi = new DefaultProjectInstaller();
51  
52          expectedException.expect( IllegalArgumentException.class );
53          expectedException.expectMessage( "The parameter buildingRequest is not allowed to be null." );
54  
55          dpi.install( null, null );
56      }
57  
58      @Test
59      public void installShouldFailWithIAEWhileProjectInstallerRequestIsNull()
60          throws IOException, ArtifactInstallerException, NoFileAssignedException
61      {
62          ProjectInstaller dpi = new DefaultProjectInstaller();
63  
64          expectedException.expect( IllegalArgumentException.class );
65          expectedException.expectMessage( "The parameter installerRequest is not allowed to be null." );
66          ProjectBuildingRequest pbr = mock( ProjectBuildingRequest.class );
67  
68          dpi.install( pbr, null );
69      }
70  
71  }