Skip to content

Commit 659dcbd

Browse files
committed
Fix PlugPluginTest on Java 8.
1 parent 2ea68c3 commit 659dcbd

3 files changed

Lines changed: 11 additions & 3 deletions

File tree

atplug-plugin-gradle/src/test/java/com/diffplug/atplug/tooling/gradle/PlugPluginTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class PlugPluginTest : GradleIntegrationHarness() {
6363
" }\n" +
6464
"}")
6565
assertFile("src/main/resources/META-INF/MANIFEST.MF")
66-
.hasContent(
66+
.hasContentIgnoreWhitespace(
6767
"Manifest-Version: 1.0\n" +
6868
"Service-Component: OSGI-INF/com.diffplug.atplug.Apple.xml,OSGI-INF/com.d\n" +
6969
" iffplug.atplug.Orange.xml,OSGI-INF/com.diffplug.atplug.Shape\$Circle.xml\n" +

atplug-plugin-gradle/src/test/java/com/diffplug/atplug/tooling/gradle/ResourceHarness.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,12 @@ private ReadAsserter(File file) throws IOException {
9191
public void hasContent(String expected) {
9292
Assertions.assertEquals(expected, content);
9393
}
94+
95+
public void hasContentIgnoreWhitespace(String expected) {
96+
String actualClean = content.replace("\n", "").replace(" ", "");
97+
String expectedClean = expected.replace("\n", "").replace(" ", "");
98+
Assertions.assertEquals(expectedClean, actualClean);
99+
}
94100
}
95101

96102
protected WriteAsserter setFile(String path) throws IOException {

atplug-runtime/src/main/java/com/diffplug/atplug/PlugRegistry.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,10 @@ interface PlugRegistry {
3737
URL(manifestUrl.substring(0, manifestUrl.length - PATH_MANIFEST.length) + servicePath)
3838

3939
val out = ByteArrayOutputStream()
40-
serviceUrl.openStream().transferTo(out)
41-
val serviceFileContent = out.toString(StandardCharsets.UTF_8)
40+
serviceUrl.openStream().use {
41+
it.copyTo(out)
42+
}
43+
val serviceFileContent = String(out.toByteArray(), StandardCharsets.UTF_8)
4244
return PlugDescriptor.fromJson(serviceFileContent)
4345
}
4446

0 commit comments

Comments
 (0)