This is an automated email from the ASF dual-hosted git repository.

slachiewicz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-shade-plugin.git


The following commit(s) were added to refs/heads/master by this push:
     new 87b3512  Merge ApacheLicenseResourceTransformer tests
87b3512 is described below

commit 87b3512df113040d1185af622e19c562c144c630
Author: Goooler <wangzong...@gmail.com>
AuthorDate: Mon Dec 9 12:55:25 2024 +0800

    Merge ApacheLicenseResourceTransformer tests
    
    Merge `ApacheNoticeResourceTransformerParameterTests` into 
`ApacheNoticeResourceTransformerTests`.
---
 ...cheNoticeResourceTransformerParameterTests.java | 90 ----------------------
 .../ApacheNoticeResourceTransformerTest.java       | 53 +++++++++++++
 2 files changed, 53 insertions(+), 90 deletions(-)

diff --git 
a/src/test/java/org/apache/maven/plugins/shade/resource/ApacheNoticeResourceTransformerParameterTests.java
 
b/src/test/java/org/apache/maven/plugins/shade/resource/ApacheNoticeResourceTransformerParameterTests.java
deleted file mode 100644
index cd61ca3..0000000
--- 
a/src/test/java/org/apache/maven/plugins/shade/resource/ApacheNoticeResourceTransformerParameterTests.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * 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.shade.resource;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.util.Collections;
-import java.util.List;
-
-import org.apache.maven.plugins.shade.relocation.Relocator;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.junit.Assert.fail;
-
-/**
- * Tests {@link ApacheLicenseResourceTransformer} parameters.
- */
-public class ApacheNoticeResourceTransformerParameterTests {
-
-    private static final String NOTICE_RESOURCE = "META-INF/NOTICE";
-    private ApacheNoticeResourceTransformer subject;
-
-    @Before
-    public void setUp() {
-        subject = new ApacheNoticeResourceTransformer();
-    }
-
-    @Test
-    public void testNoParametersShouldNotThrowNullPointerWhenNoInput() throws 
IOException {
-        processAndFailOnNullPointer("");
-    }
-
-    @Test
-    public void testNoParametersShouldNotThrowNullPointerWhenNoLinesOfInput() 
throws IOException {
-        processAndFailOnNullPointer("Some notice text");
-    }
-
-    @Test
-    public void testNoParametersShouldNotThrowNullPointerWhenOneLineOfInput() 
throws IOException {
-        processAndFailOnNullPointer("Some notice text\n");
-    }
-
-    @Test
-    public void testNoParametersShouldNotThrowNullPointerWhenTwoLinesOfInput() 
throws IOException {
-        processAndFailOnNullPointer("Some notice text\nSome notice text\n");
-    }
-
-    @Test
-    public void 
testNoParametersShouldNotThrowNullPointerWhenLineStartsWithSlashSlash() throws 
IOException {
-        processAndFailOnNullPointer("Some notice text\n//Some notice text\n");
-    }
-
-    @Test
-    public void 
testNoParametersShouldNotThrowNullPointerWhenLineIsSlashSlash() throws 
IOException {
-        processAndFailOnNullPointer("//\n");
-    }
-
-    @Test
-    public void testNoParametersShouldNotThrowNullPointerWhenLineIsEmpty() 
throws IOException {
-        processAndFailOnNullPointer("\n");
-    }
-
-    private void processAndFailOnNullPointer(final String noticeText) throws 
IOException {
-        try {
-            final ByteArrayInputStream noticeInputStream = new 
ByteArrayInputStream(noticeText.getBytes());
-            final List<Relocator> emptyList = Collections.emptyList();
-            subject.processResource(NOTICE_RESOURCE, noticeInputStream, 
emptyList, 0);
-            noticeInputStream.close();
-        } catch (NullPointerException e) {
-            fail("Null pointer should not be thrown when no parameters are 
set.");
-        }
-    }
-}
diff --git 
a/src/test/java/org/apache/maven/plugins/shade/resource/ApacheNoticeResourceTransformerTest.java
 
b/src/test/java/org/apache/maven/plugins/shade/resource/ApacheNoticeResourceTransformerTest.java
index d5cada8..b45464f 100644
--- 
a/src/test/java/org/apache/maven/plugins/shade/resource/ApacheNoticeResourceTransformerTest.java
+++ 
b/src/test/java/org/apache/maven/plugins/shade/resource/ApacheNoticeResourceTransformerTest.java
@@ -18,13 +18,19 @@
  */
 package org.apache.maven.plugins.shade.resource;
 
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.util.Collections;
+import java.util.List;
 import java.util.Locale;
 
+import org.apache.maven.plugins.shade.relocation.Relocator;
 import org.junit.Before;
 import org.junit.Test;
 
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
 /**
  * Test for {@link ApacheNoticeResourceTransformer}.
@@ -33,6 +39,7 @@ import static org.junit.Assert.assertTrue;
  */
 public class ApacheNoticeResourceTransformerTest {
 
+    private static final String NOTICE_RESOURCE = "META-INF/NOTICE";
     private ApacheNoticeResourceTransformer transformer;
 
     static {
@@ -57,4 +64,50 @@ public class ApacheNoticeResourceTransformerTest {
         assertTrue(transformer.canTransformResource("META-INF/Notice.md"));
         assertFalse(transformer.canTransformResource("META-INF/MANIFEST.MF"));
     }
+
+    @Test
+    public void testNoParametersShouldNotThrowNullPointerWhenNoInput() throws 
IOException {
+        processAndFailOnNullPointer("");
+    }
+
+    @Test
+    public void testNoParametersShouldNotThrowNullPointerWhenNoLinesOfInput() 
throws IOException {
+        processAndFailOnNullPointer("Some notice text");
+    }
+
+    @Test
+    public void testNoParametersShouldNotThrowNullPointerWhenOneLineOfInput() 
throws IOException {
+        processAndFailOnNullPointer("Some notice text\n");
+    }
+
+    @Test
+    public void testNoParametersShouldNotThrowNullPointerWhenTwoLinesOfInput() 
throws IOException {
+        processAndFailOnNullPointer("Some notice text\nSome notice text\n");
+    }
+
+    @Test
+    public void 
testNoParametersShouldNotThrowNullPointerWhenLineStartsWithSlashSlash() throws 
IOException {
+        processAndFailOnNullPointer("Some notice text\n//Some notice text\n");
+    }
+
+    @Test
+    public void 
testNoParametersShouldNotThrowNullPointerWhenLineIsSlashSlash() throws 
IOException {
+        processAndFailOnNullPointer("//\n");
+    }
+
+    @Test
+    public void testNoParametersShouldNotThrowNullPointerWhenLineIsEmpty() 
throws IOException {
+        processAndFailOnNullPointer("\n");
+    }
+
+    private void processAndFailOnNullPointer(final String noticeText) throws 
IOException {
+        try {
+            final ByteArrayInputStream noticeInputStream = new 
ByteArrayInputStream(noticeText.getBytes());
+            final List<Relocator> emptyList = Collections.emptyList();
+            transformer.processResource(NOTICE_RESOURCE, noticeInputStream, 
emptyList, 0);
+            noticeInputStream.close();
+        } catch (NullPointerException e) {
+            fail("Null pointer should not be thrown when no parameters are 
set.");
+        }
+    }
 }

Reply via email to