Upgrade to Maven Shade Plugin 3.2.4

Closes gh-22074
This commit is contained in:
Andy Wilkinson
2020-06-23 11:32:47 +01:00
parent 66b84ac7e6
commit 5e7917e33a
3 changed files with 40 additions and 12 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,6 +18,10 @@ package org.springframework.boot.maven;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.jar.JarEntry;
import java.util.jar.JarInputStream;
import java.util.jar.JarOutputStream;
import org.junit.jupiter.api.Test;
@@ -36,28 +40,38 @@ class PropertiesMergingResourceTransformerTests {
@Test
void testProcess() throws Exception {
assertThat(this.transformer.hasTransformedResource()).isFalse();
this.transformer.processResource("foo", new ByteArrayInputStream("foo=bar".getBytes()), null);
this.transformer.processResource("foo", new ByteArrayInputStream("foo=bar".getBytes()), null, 0);
assertThat(this.transformer.hasTransformedResource()).isTrue();
}
@Test
void testMerge() throws Exception {
this.transformer.processResource("foo", new ByteArrayInputStream("foo=bar".getBytes()), null);
this.transformer.processResource("bar", new ByteArrayInputStream("foo=spam".getBytes()), null);
this.transformer.processResource("foo", new ByteArrayInputStream("foo=bar".getBytes()), null, 0);
this.transformer.processResource("bar", new ByteArrayInputStream("foo=spam".getBytes()), null, 0);
assertThat(this.transformer.getData().getProperty("foo")).isEqualTo("bar,spam");
}
@Test
void testOutput() throws Exception {
this.transformer.setResource("foo");
this.transformer.processResource("foo", new ByteArrayInputStream("foo=bar".getBytes()), null);
long time = 1592911068000L;
this.transformer.processResource("foo", new ByteArrayInputStream("foo=bar".getBytes()), null, time);
ByteArrayOutputStream out = new ByteArrayOutputStream();
JarOutputStream os = new JarOutputStream(out);
this.transformer.modifyOutputStream(os);
os.flush();
os.close();
assertThat(out.toByteArray()).isNotNull();
assertThat(out.toByteArray().length > 0).isTrue();
byte[] bytes = out.toByteArray();
assertThat(bytes).hasSizeGreaterThan(0);
List<JarEntry> entries = new ArrayList<>();
try (JarInputStream is = new JarInputStream(new ByteArrayInputStream(bytes))) {
JarEntry entry;
while ((entry = is.getNextJarEntry()) != null) {
entries.add(entry);
}
}
assertThat(entries).hasSize(1);
assertThat(entries.get(0).getTime()).isEqualTo(time);
}
}