Giovds commented on a change in pull request #14:
URL: https://github.com/apache/maven-gpg-plugin/pull/14#discussion_r705752442



##########
File path: src/test/java/org/apache/maven/plugins/gpg/it/GpgSignArtifactIT.java
##########
@@ -0,0 +1,86 @@
+package org.apache.maven.plugins.gpg.it;
+
+/*
+ * 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 org.apache.maven.shared.invoker.InvocationRequest;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import java.io.File;
+import java.util.Arrays;
+import java.util.Collection;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.arrayContainingInAnyOrder;
+import static org.hamcrest.Matchers.equalTo;
+import static org.junit.runners.Parameterized.*;
+
+@RunWith( Parameterized.class )
+public class GpgSignArtifactIT
+{
+    private final File mavenHome;
+    private final File localRepository;
+    private final File mavenUserSettings;
+    private final File gpgHome;
+
+    public GpgSignArtifactIT() throws Exception
+    {
+        this.mavenHome = new File( System.getProperty( "maven.home" ) );
+        this.localRepository = new File( System.getProperty( 
"localRepositoryPath" ) );
+        this.mavenUserSettings = InvokerTestUtils.getTestResource( 
"/it/settings-with-passphrase.xml" );
+        this.gpgHome = new File( System.getProperty( "gpg.homedir" ) );
+    }
+
+    @Parameters
+    public static Collection<Object[]> data() {
+        return Arrays.asList(new Object[][] {
+                { "/it/sign-release-with-artifact/pom.xml", 
"/target/gpg/tarballs/", new String[]{ 
"sign-release-with-artifact-1.0-jar-with-dependencies.jar.asc" } },
+                { 
"/it/sign-release-with-artifact-and-output-directory/pom.xml", 
"/target/signed-files/tarballs/", new String[]{ 
"sign-release-with-artifact-and-output-directory-1.0-jar-with-dependencies.jar.asc"
 } },
+                { 
"/it/sign-release-with-artifact-and-output-directory-root/pom.xml", 
"/signed-files/tarballs/", new String[]{ 
"sign-release-with-artifact-and-output-directory-root-1.0-jar-with-dependencies.jar.asc"
 } },
+                { "/it/sign-release-with-artifact-same-directory/pom.xml", 
"/target/tarballs/", new String[]{ 
"sign-release-with-artifact-same-directory-1.0-jar-with-dependencies.jar", 
"sign-release-with-artifact-same-directory-1.0-jar-with-dependencies.jar.asc" } 
},
+        });
+    }
+
+    @Parameter
+    public String pomPath;
+    @Parameter(1)
+    public String expectedFileLocation;
+    @Parameter(2)
+    public String[] expectedFiles;
+
+    @Test
+    public void testPlacementOfArtifactInOutputDirectory() throws Exception
+    {
+        // given
+        final File pomFile = InvokerTestUtils.getTestResource( pomPath );
+        final InvocationRequest request = InvokerTestUtils.createRequest( 
pomFile, mavenUserSettings, gpgHome );
+        final File integrationTestRootDirectory = new File( 
pomFile.getParent());
+        final File expectedOutputDirectory = new File 
(integrationTestRootDirectory + expectedFileLocation );

Review comment:
       My personal preference goes to string concatenation, since this 
decreases the chance of a flaky test. That being said, whichever approach is 
preferred more is fine by me, as the chances of it happening are rather low.
   
   If the parent in `new File( parent, child )` is null then the new File 
instance is created as if by invoking the single-argument File constructor on 
the given child pathname string. In theory both approaches can pass, however I 
expect that
   ` new File ( null + "child-path" )` is less likely to pass, as this results 
in a path like `"nullchild-path"`, instead of 
   `"child-path"`.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@maven.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to