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

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

commit 5ea1fb6c2c929e1c69ce1fc41fb15db183f84d07
Author: Fabiano C. de Oliveira <fabcipri...@yahoo.com.br>
AuthorDate: Sat Nov 10 01:31:40 2018 -0200

    - unit test for shadedPattern applied multiples times
---
 .../resource/ServiceResourceTransformerTest.java   | 44 ++++++++++++++++++++++
 1 file changed, 44 insertions(+)

diff --git 
a/src/test/java/org/apache/maven/plugins/shade/resource/ServiceResourceTransformerTest.java
 
b/src/test/java/org/apache/maven/plugins/shade/resource/ServiceResourceTransformerTest.java
index bde428a..fce1c71 100644
--- 
a/src/test/java/org/apache/maven/plugins/shade/resource/ServiceResourceTransformerTest.java
+++ 
b/src/test/java/org/apache/maven/plugins/shade/resource/ServiceResourceTransformerTest.java
@@ -90,6 +90,50 @@ public class ServiceResourceTransformerTest {
             tempJar.delete();
         }
     }
+    
+    @Test
+    public void concatanationAppliedMultipleTimes() throws Exception {
+        SimpleRelocator relocator =
+            new SimpleRelocator( "org.eclipse", "org.eclipse1234", null, null 
);
+        List<Relocator> relocators = Lists.<Relocator>newArrayList( relocator 
);
+
+        String content = "org.eclipse.osgi.launch.EquinoxFactory\n";
+        byte[] contentBytes = content.getBytes( "UTF-8" );
+        InputStream contentStream = new ByteArrayInputStream( contentBytes );
+        String contentResource = 
"META-INF/services/org.osgi.framework.launch.FrameworkFactory";
+
+        ServicesResourceTransformer xformer = new 
ServicesResourceTransformer();
+        xformer.processResource( contentResource, contentStream, relocators );
+        contentStream.close();
+
+        File tempJar = File.createTempFile("shade.", ".jar");
+        tempJar.deleteOnExit();
+        FileOutputStream fos = new FileOutputStream( tempJar );
+        JarOutputStream jos = new JarOutputStream( fos );
+        try {
+            xformer.modifyOutputStream( jos );
+            jos.close();
+            jos = null;
+            JarFile jarFile = new JarFile( tempJar );
+            JarEntry jarEntry = jarFile.getJarEntry( contentResource );
+            assertNotNull( jarEntry );
+            InputStream entryStream = jarFile.getInputStream( jarEntry );
+            try {
+                String xformedContent = IOUtils.toString(entryStream, "utf-8");
+                assertEquals( "org.eclipse1234.osgi.launch.EquinoxFactory" + 
System.getProperty( "line.separator" ), xformedContent );
+                
+            } finally {
+                IOUtils.closeQuietly( entryStream );
+                jarFile.close();
+            }
+        } finally {
+            if (jos != null)
+            {
+                IOUtils.closeQuietly( jos );
+            }
+            tempJar.delete();
+        }
+    }
 
     @Test
     public void concatenation() throws Exception {

Reply via email to