View Javadoc
1   package org.apache.maven.shared.transfer.project.deploy.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 org.apache.maven.project.ProjectBuildingRequest;
25  import org.apache.maven.shared.transfer.artifact.deploy.ArtifactDeployerException;
26  import org.apache.maven.shared.transfer.project.NoFileAssignedException;
27  import org.apache.maven.shared.transfer.project.deploy.ProjectDeployer;
28  import org.apache.maven.shared.transfer.project.deploy.ProjectDeployerRequest;
29  import org.apache.maven.shared.transfer.project.deploy.internal.DefaultProjectDeployer;
30  import org.junit.Rule;
31  import org.junit.Test;
32  import org.junit.rules.ExpectedException;
33  
34  /**
35   * Check the parameter contracts which have been made based on the interface {@link ProjectDeployer}.
36   * 
37   * @author Karl Heinz Marbaise <a href="mailto:khmarbaise@apache.org">khmabaise@apache.org</a>
38   */
39  public class DefaultProjectDeployerTest
40  {
41      @Rule
42      public ExpectedException expectedException = ExpectedException.none();
43  
44      @Test
45      public void deployShouldFailWithIAEWhileBuildingRequestIsNull()
46          throws IllegalArgumentException, NoFileAssignedException, ArtifactDeployerException
47      {
48          ProjectDeployer dpi = new DefaultProjectDeployer();
49  
50          expectedException.expect( IllegalArgumentException.class );
51          expectedException.expectMessage( "The parameter buildingRequest is not allowed to be null." );
52  
53          dpi.deploy( null, null, null );
54      }
55  
56      @Test
57      public void deployShouldFailWithIAEWhileProjectDeployerRequestIsNull()
58          throws IllegalArgumentException, NoFileAssignedException, ArtifactDeployerException
59      {
60          ProjectDeployer dpi = new DefaultProjectDeployer();
61  
62          expectedException.expect( IllegalArgumentException.class );
63          expectedException.expectMessage( "The parameter projectDeployerRequest is not allowed to be null." );
64  
65          ProjectBuildingRequest pbr = mock( ProjectBuildingRequest.class );
66          dpi.deploy( pbr, null, null );
67      }
68  
69      @Test
70      public void deployShouldFailWithIAEWhileArtifactRepositoryIsNull()
71          throws IllegalArgumentException, NoFileAssignedException, ArtifactDeployerException
72      {
73          ProjectDeployer dpi = new DefaultProjectDeployer();
74  
75          expectedException.expect( IllegalArgumentException.class );
76          expectedException.expectMessage( "The parameter artifactRepository is not allowed to be null." );
77  
78          ProjectBuildingRequest pbr = mock( ProjectBuildingRequest.class );
79          ProjectDeployerRequest pdr = mock( ProjectDeployerRequest.class );
80          dpi.deploy( pbr, pdr, null );
81      }
82  
83  }