desruisseaux commented on code in PR #508:
URL: https://github.com/apache/maven-jar-plugin/pull/508#discussion_r3949352425


##########
src/test/java/org/apache/maven/plugins/jar/ArchiveTest.java:
##########
@@ -0,0 +1,257 @@
+/*
+ * 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.
+ */
+package org.apache.maven.plugins.jar;
+
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.jar.Attributes;
+import java.util.jar.Manifest;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotSame;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/**
+ * Unit tests for {@link Archive}, focused on the two behaviours that are 
otherwise only
+ * exercised by integration tests whose outcome depends on the (unspecified) 
filesystem
+ * directory-iteration order, and therefore pass on some platforms while 
failing on others.
+ */
+class ArchiveTest {
+
+    /**
+     * Creates an {@code Archive} suitable for a unit test. {@code 
forceCreation = true} skips the
+     * existing-JAR timestamp check, so the (here {@code null}) logger is 
never dereferenced.
+     */
+    private static Archive archive(String moduleName, Runtime.Version version, 
Path directory) {
+        return new Archive(directory.resolve("out.jar"), moduleName, version, 
directory, true, null);
+    }
+
+    /**
+     * Creates a manifest with the main class attribute set to the given value.
+     *
+     * @param value value of the main class attribute
+     * @return a new manifest with the given attribute value
+     */
+    private static Manifest manifestWithMainClass(String value) {
+        Manifest m = new Manifest();
+        Attributes attributes = m.getMainAttributes();
+        attributes.put(Attributes.Name.MANIFEST_VERSION, "1.0");
+        attributes.put(Attributes.Name.MAIN_CLASS, value);
+        return m;
+    }
+
+    /**
+     * Returns the value of the main class attribute.
+     *
+     * @param m the manifest from which to get the value

Review Comment:
   Done.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to