From d66f0ef141813a21ee0aeb06ee38b744c3a111fb Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Fri, 7 Aug 2020 10:52:20 +0200 Subject: [PATCH] Fix broken test and missing license headers --- .../sonia/scm/plugin/PluginProcessor.java | 4 +- .../scm/plugin/SmpDescriptorExtractor.java | 6 +-- .../plugin/SmpDescriptorExtractorTest.java | 8 ++-- .../sonia/scm/plugin/scm-g-plugin.xml | 46 ++++++++++--------- .../sonia/scm/plugin/scm-h-plugin.xml | 46 ++++++++++--------- .../sonia/scm/plugin/scm-i-plugin.xml | 46 ++++++++++--------- 6 files changed, 83 insertions(+), 73 deletions(-) diff --git a/scm-webapp/src/main/java/sonia/scm/plugin/PluginProcessor.java b/scm-webapp/src/main/java/sonia/scm/plugin/PluginProcessor.java index 96fa648976..1265a28977 100644 --- a/scm-webapp/src/main/java/sonia/scm/plugin/PluginProcessor.java +++ b/scm-webapp/src/main/java/sonia/scm/plugin/PluginProcessor.java @@ -105,6 +105,8 @@ public final class PluginProcessor //~--- constructors --------------------------------------------------------- + private final SmpDescriptorExtractor extractor = new SmpDescriptorExtractor(); + private ClassLoaderLifeCycle classLoaderLifeCycle; /** @@ -198,7 +200,7 @@ public final class PluginProcessor Map pending = new HashMap<>(); for (Path archive : archives) { - pending.put(archive, SmpDescriptorExtractor.extractPluginDescriptor(archive)); + pending.put(archive, extractor.extractPluginDescriptor(archive)); } PluginInstallationContext installationContext = PluginInstallationContext.fromDescriptors( diff --git a/scm-webapp/src/main/java/sonia/scm/plugin/SmpDescriptorExtractor.java b/scm-webapp/src/main/java/sonia/scm/plugin/SmpDescriptorExtractor.java index aae8439d19..6e1255175d 100644 --- a/scm-webapp/src/main/java/sonia/scm/plugin/SmpDescriptorExtractor.java +++ b/scm-webapp/src/main/java/sonia/scm/plugin/SmpDescriptorExtractor.java @@ -33,12 +33,12 @@ import java.nio.file.Path; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; -final class SmpDescriptorExtractor { + class SmpDescriptorExtractor { - private SmpDescriptorExtractor() { + public SmpDescriptorExtractor() { } - static InstalledPluginDescriptor extractPluginDescriptor(Path file) throws IOException { + InstalledPluginDescriptor extractPluginDescriptor(Path file) throws IOException { try (ZipInputStream zipInputStream = new ZipInputStream(Files.newInputStream(file), StandardCharsets.UTF_8)) { ZipEntry nextEntry; while ((nextEntry = zipInputStream.getNextEntry()) != null) { diff --git a/scm-webapp/src/test/java/sonia/scm/plugin/SmpDescriptorExtractorTest.java b/scm-webapp/src/test/java/sonia/scm/plugin/SmpDescriptorExtractorTest.java index aa6e2223c3..79f5d29060 100644 --- a/scm-webapp/src/test/java/sonia/scm/plugin/SmpDescriptorExtractorTest.java +++ b/scm-webapp/src/test/java/sonia/scm/plugin/SmpDescriptorExtractorTest.java @@ -63,11 +63,13 @@ class SmpDescriptorExtractorTest { "\n" + "\n"; + private final SmpDescriptorExtractor extractor = new SmpDescriptorExtractor(); + @Test void shouldExtractPluginXml(@TempDir Path tempDir) throws IOException { Path pluginFile = createZipFile(tempDir, "META-INF/scm/plugin.xml", PLUGIN_XML); - InstalledPluginDescriptor installedPluginDescriptor = SmpDescriptorExtractor.extractPluginDescriptor(pluginFile); + InstalledPluginDescriptor installedPluginDescriptor = extractor.extractPluginDescriptor(pluginFile); Assertions.assertThat(installedPluginDescriptor.getInformation().getName()).isEqualTo("scm-test-plugin"); } @@ -76,14 +78,14 @@ class SmpDescriptorExtractorTest { void shouldFailWithoutPluginXml(@TempDir Path tempDir) throws IOException { Path pluginFile = createZipFile(tempDir, "META-INF/wrong/plugin.xml", PLUGIN_XML); - assertThrows(IOException.class, () -> SmpDescriptorExtractor.extractPluginDescriptor(pluginFile)); + assertThrows(IOException.class, () -> extractor.extractPluginDescriptor(pluginFile)); } @Test void shouldFailWithIllegalPluginXml(@TempDir Path tempDir) throws IOException { Path pluginFile = createZipFile(tempDir, "META-INF/scm/plugin.xml", "content"); - assertThrows(IOException.class, () -> SmpDescriptorExtractor.extractPluginDescriptor(pluginFile)); + assertThrows(IOException.class, () -> extractor.extractPluginDescriptor(pluginFile)); } Path createZipFile(Path tempDir, String internalFileName, String content) throws IOException { diff --git a/scm-webapp/src/test/resources/sonia/scm/plugin/scm-g-plugin.xml b/scm-webapp/src/test/resources/sonia/scm/plugin/scm-g-plugin.xml index c6b3339938..8fca8bbdfc 100644 --- a/scm-webapp/src/test/resources/sonia/scm/plugin/scm-g-plugin.xml +++ b/scm-webapp/src/test/resources/sonia/scm/plugin/scm-g-plugin.xml @@ -1,27 +1,29 @@ + + MIT License + + Copyright (c) 2020-present Cloudogu GmbH and Contributors + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. + +--> 2 diff --git a/scm-webapp/src/test/resources/sonia/scm/plugin/scm-h-plugin.xml b/scm-webapp/src/test/resources/sonia/scm/plugin/scm-h-plugin.xml index fa2d0767cc..fb7977da6f 100644 --- a/scm-webapp/src/test/resources/sonia/scm/plugin/scm-h-plugin.xml +++ b/scm-webapp/src/test/resources/sonia/scm/plugin/scm-h-plugin.xml @@ -1,27 +1,29 @@ + + MIT License + + Copyright (c) 2020-present Cloudogu GmbH and Contributors + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. + +--> 2 diff --git a/scm-webapp/src/test/resources/sonia/scm/plugin/scm-i-plugin.xml b/scm-webapp/src/test/resources/sonia/scm/plugin/scm-i-plugin.xml index 0fd2c1999a..e49dd45da8 100644 --- a/scm-webapp/src/test/resources/sonia/scm/plugin/scm-i-plugin.xml +++ b/scm-webapp/src/test/resources/sonia/scm/plugin/scm-i-plugin.xml @@ -1,27 +1,29 @@ + + MIT License + + Copyright (c) 2020-present Cloudogu GmbH and Contributors + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. + +--> 2