You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by kh...@apache.org on 2017/08/20 13:01:53 UTC
svn commit: r1805553 - in /maven/shared/trunk/maven-artifact-transfer:
pom.xml
src/test/java/org/apache/maven/shared/artifact/install/internal/DefaultArtifactInstallerTest.java
Author: khmarbaise
Date: Sun Aug 20 13:01:53 2017
New Revision: 1805553
URL: http://svn.apache.org/viewvc?rev=1805553&view=rev
Log:
[MSHARED-655] ArtifactInstaller check for integrity of parameters null, empty collection, being a directory
o Added unit test to check the parameter contracts which are implemented.
Added:
maven/shared/trunk/maven-artifact-transfer/src/test/java/org/apache/maven/shared/artifact/install/internal/DefaultArtifactInstallerTest.java
Modified:
maven/shared/trunk/maven-artifact-transfer/pom.xml
Modified: maven/shared/trunk/maven-artifact-transfer/pom.xml
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-artifact-transfer/pom.xml?rev=1805553&r1=1805552&r2=1805553&view=diff
==============================================================================
--- maven/shared/trunk/maven-artifact-transfer/pom.xml (original)
+++ maven/shared/trunk/maven-artifact-transfer/pom.xml Sun Aug 20 13:01:53 2017
@@ -1,23 +1,25 @@
<?xml version='1.0' encoding='UTF-8'?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
+ or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
+ regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
+ with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
+ KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+>
<modelVersion>4.0.0</modelVersion>
<parent>
@@ -172,7 +174,7 @@
<artifactId>plexus-utils</artifactId>
<version>3.1.0</version>
</dependency>
-
+
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
@@ -232,6 +234,12 @@
<version>4.11</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ <version>2.7.12</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<pluginRepositories>
Added: maven/shared/trunk/maven-artifact-transfer/src/test/java/org/apache/maven/shared/artifact/install/internal/DefaultArtifactInstallerTest.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-artifact-transfer/src/test/java/org/apache/maven/shared/artifact/install/internal/DefaultArtifactInstallerTest.java?rev=1805553&view=auto
==============================================================================
--- maven/shared/trunk/maven-artifact-transfer/src/test/java/org/apache/maven/shared/artifact/install/internal/DefaultArtifactInstallerTest.java (added)
+++ maven/shared/trunk/maven-artifact-transfer/src/test/java/org/apache/maven/shared/artifact/install/internal/DefaultArtifactInstallerTest.java Sun Aug 20 13:01:53 2017
@@ -0,0 +1,78 @@
+package org.apache.maven.shared.artifact.install.internal;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import static org.mockito.Mockito.mock;
+
+import java.util.Collections;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.project.ProjectBuildingRequest;
+
+import org.apache.maven.shared.artifact.install.ArtifactInstallerException;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+/**
+ * Check the parameter contracts which have been made based on the interface {@link ArtifactInstaller}.
+ *
+ * @author Karl Heinz Marbaise <a href="mailto:khmarbaise@apache.org">khmabaise@apache.org</a>
+ */
+public class DefaultArtifactInstallerTest
+{
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ @Test
+ public void installShouldReturnIllegalArgumentExceptionForFirstParameterWithNull()
+ throws ArtifactInstallerException
+ {
+ DefaultArtifactInstaller dai = new DefaultArtifactInstaller();
+
+ thrown.expect( IllegalArgumentException.class );
+ thrown.expectMessage( "The parameter request is not allowed to be null." );
+ dai.install( null, Collections.<Artifact>emptyList() );
+ }
+
+ @Test
+ public void installShouldReturnIllegalArgumentExceptionForSecondParameterWithNull()
+ throws ArtifactInstallerException
+ {
+ DefaultArtifactInstaller dai = new DefaultArtifactInstaller();
+
+ thrown.expect( IllegalArgumentException.class );
+ thrown.expectMessage( "The parameter mavenArtifacts is not allowed to be null." );
+ ProjectBuildingRequest pbr = mock( ProjectBuildingRequest.class );
+ dai.install( pbr, null );
+ }
+
+ @Test
+ public void installShouldReturnIllegalArgumentExceptionForSecondParameterWithEmpty()
+ throws ArtifactInstallerException
+ {
+ DefaultArtifactInstaller dai = new DefaultArtifactInstaller();
+
+ thrown.expect( IllegalArgumentException.class );
+ thrown.expectMessage( "The collection mavenArtifacts is not allowed to be empty." );
+ ProjectBuildingRequest pbr = mock( ProjectBuildingRequest.class );
+ dai.install( pbr, Collections.<Artifact>emptyList() );
+ }
+}