From b123d01157fc6dbbc82313508183a2b6f683c2c8 Mon Sep 17 00:00:00 2001 From: Alex Earl Date: Mon, 2 Dec 2024 16:41:14 -0800 Subject: [PATCH] Update to Java 17 (#53) --- juseppe-cli/pom.xml | 2 +- .../ru/lanwen/jenkins/juseppe/JuseppeCli.java | 4 +- .../jenkins/juseppe/cli/EnvCommand.java | 3 +- .../jenkins/juseppe/cli/PrintCertCommand.java | 4 +- .../jenkins/juseppe/files/WatchFiles.java | 6 +- .../jenkins/juseppe/cli/ServeCommandTest.java | 8 +-- .../lanwen/jenkins/juseppe/cli/ServeRule.java | 3 +- .../src/test/resources/serve/cert/uc.crt | 36 ++++++------ .../src/test/resources/serve/cert/uc.key | 55 ++++++++++--------- juseppe-core/pom.xml | 13 ++++- .../jenkins/juseppe/gen/SavableSite.java | 2 +- .../ru/lanwen/jenkins/juseppe/gen/Signer.java | 10 +++- .../jenkins/juseppe/gen/UpdateSiteGen.java | 9 ++- .../juseppe/gen/source/PathPluginSource.java | 4 +- .../juseppe/gen/view/JsonpUpdateSite.java | 2 +- .../gen/source/PathPluginSourceTest.java | 6 +- .../src/test/resources/tmp/cert/uc.crt | 36 ++++++------ .../src/test/resources/tmp/cert/uc.key | 55 ++++++++++--------- pom.xml | 19 ++----- 19 files changed, 143 insertions(+), 134 deletions(-) diff --git a/juseppe-cli/pom.xml b/juseppe-cli/pom.xml index 86ed4b2..0de8e46 100644 --- a/juseppe-cli/pom.xml +++ b/juseppe-cli/pom.xml @@ -45,7 +45,7 @@ - com.jayway.restassured + io.rest-assured rest-assured test diff --git a/juseppe-cli/src/main/java/ru/lanwen/jenkins/juseppe/JuseppeCli.java b/juseppe-cli/src/main/java/ru/lanwen/jenkins/juseppe/JuseppeCli.java index c46d94e..bed78e9 100644 --- a/juseppe-cli/src/main/java/ru/lanwen/jenkins/juseppe/JuseppeCli.java +++ b/juseppe-cli/src/main/java/ru/lanwen/jenkins/juseppe/JuseppeCli.java @@ -31,8 +31,8 @@ public static void main(String[] args) { Runnable parse = builder.build().parse(args); parse.run(); - if (parse instanceof JuseppeCommand) { - System.exit(((JuseppeCommand) parse).getExitCode()); + if (parse instanceof JuseppeCommand command) { + System.exit(command.getExitCode()); } } diff --git a/juseppe-cli/src/main/java/ru/lanwen/jenkins/juseppe/cli/EnvCommand.java b/juseppe-cli/src/main/java/ru/lanwen/jenkins/juseppe/cli/EnvCommand.java index 330d6f3..ebcc2f4 100644 --- a/juseppe-cli/src/main/java/ru/lanwen/jenkins/juseppe/cli/EnvCommand.java +++ b/juseppe-cli/src/main/java/ru/lanwen/jenkins/juseppe/cli/EnvCommand.java @@ -3,7 +3,6 @@ import io.airlift.airline.Command; import ru.lanwen.jenkins.juseppe.props.JuseppeEnvVars.JuseppeEnvEnum; -import static java.lang.String.format; import static java.util.stream.Collectors.joining; import static java.util.stream.Stream.of; @@ -16,7 +15,7 @@ public class EnvCommand implements Runnable { @Override public void run() { System.out.println(of(JuseppeEnvEnum.values()) - .map(env -> format("\t%s (%s) %n\t\t- %s%n\t\tresolved: %s%n", + .map(env -> "\t%s (%s) %n\t\t- %s%n\t\tresolved: %s%n".formatted( env.name(), env.mapping(), env.description(), env.resolved())) .collect(joining("\n")) ); diff --git a/juseppe-cli/src/main/java/ru/lanwen/jenkins/juseppe/cli/PrintCertCommand.java b/juseppe-cli/src/main/java/ru/lanwen/jenkins/juseppe/cli/PrintCertCommand.java index 8d03991..e156e4b 100644 --- a/juseppe-cli/src/main/java/ru/lanwen/jenkins/juseppe/cli/PrintCertCommand.java +++ b/juseppe-cli/src/main/java/ru/lanwen/jenkins/juseppe/cli/PrintCertCommand.java @@ -7,7 +7,7 @@ import java.io.IOException; import java.nio.file.Files; -import java.nio.file.Paths; +import java.nio.file.Path; import static java.nio.charset.StandardCharsets.UTF_8; @@ -23,7 +23,7 @@ public class PrintCertCommand implements Runnable { @Override public void run() { try { - Files.readAllLines(Paths.get(Props.populated().getCertPath()), UTF_8).forEach(System.out::println); + Files.readAllLines(Path.of(Props.populated().getCertPath()), UTF_8).forEach(System.out::println); } catch (IOException e) { LOG.error("Can't read certificate {}", Props.populated().getCertPath(), e); } diff --git a/juseppe-cli/src/main/java/ru/lanwen/jenkins/juseppe/files/WatchFiles.java b/juseppe-cli/src/main/java/ru/lanwen/jenkins/juseppe/files/WatchFiles.java index b1d9d34..a750d66 100644 --- a/juseppe-cli/src/main/java/ru/lanwen/jenkins/juseppe/files/WatchFiles.java +++ b/juseppe-cli/src/main/java/ru/lanwen/jenkins/juseppe/files/WatchFiles.java @@ -7,7 +7,6 @@ import java.nio.file.FileVisitResult; import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.Paths; import java.nio.file.SimpleFileVisitor; import java.nio.file.WatchEvent; import java.nio.file.WatchKey; @@ -19,7 +18,6 @@ import ru.lanwen.jenkins.juseppe.gen.UpdateSiteGen; import ru.lanwen.jenkins.juseppe.props.Props; -import static java.lang.String.format; import static java.nio.file.StandardWatchEventKinds.ENTRY_CREATE; import static java.nio.file.StandardWatchEventKinds.ENTRY_DELETE; import static java.nio.file.StandardWatchEventKinds.ENTRY_MODIFY; @@ -45,9 +43,9 @@ private WatchFiles() { public WatchFiles configureFor(Props props) throws IOException { this.props = props; - path = Paths.get(props.getPluginsDir()); + path = Path.of(props.getPluginsDir()); this.keys = new HashMap<>(); - setName(format("file-watcher-%s", path.getFileName())); + setName("file-watcher-%s".formatted(path.getFileName())); watcher = this.path.getFileSystem().newWatchService(); walkAndRegisterDirectories(path); diff --git a/juseppe-cli/src/test/java/ru/lanwen/jenkins/juseppe/cli/ServeCommandTest.java b/juseppe-cli/src/test/java/ru/lanwen/jenkins/juseppe/cli/ServeCommandTest.java index 50ecea0..0d17a0f 100644 --- a/juseppe-cli/src/test/java/ru/lanwen/jenkins/juseppe/cli/ServeCommandTest.java +++ b/juseppe-cli/src/test/java/ru/lanwen/jenkins/juseppe/cli/ServeCommandTest.java @@ -4,7 +4,7 @@ import org.junit.ClassRule; import org.junit.Test; -import static com.jayway.restassured.RestAssured.given; +import static io.restassured.RestAssured.given; /** * @author lanwen (Merkushev Kirill) @@ -21,7 +21,7 @@ public void shouldFetchUpdateCenter() throws Exception { .log().all() .expect() .log().status() - .get("update-center.json").then().assertThat().statusCode(200); + .when().get("update-center.json").then().assertThat().statusCode(200); } @Test(timeout = 10000) @@ -31,7 +31,7 @@ public void shouldFetchHpi() throws Exception { .log().all() .expect() .log().status() - .get("clang-scanbuild-plugin.hpi").then().assertThat().statusCode(200); + .when().get("clang-scanbuild-plugin.hpi").then().assertThat().statusCode(200); } @Test(timeout = 10000) @@ -41,6 +41,6 @@ public void shouldFetchJpi() throws Exception { .log().all() .expect() .log().status() - .get("sample-pipeline-dsl-ext-plugin-0.1.0.jpi").then().assertThat().statusCode(200); + .when().get("sample-pipeline-dsl-ext-plugin-0.1.0.jpi").then().assertThat().statusCode(200); } } \ No newline at end of file diff --git a/juseppe-cli/src/test/java/ru/lanwen/jenkins/juseppe/cli/ServeRule.java b/juseppe-cli/src/test/java/ru/lanwen/jenkins/juseppe/cli/ServeRule.java index aee4135..bd702a2 100644 --- a/juseppe-cli/src/test/java/ru/lanwen/jenkins/juseppe/cli/ServeRule.java +++ b/juseppe-cli/src/test/java/ru/lanwen/jenkins/juseppe/cli/ServeRule.java @@ -11,7 +11,6 @@ import java.util.concurrent.CompletableFuture; import static com.google.common.io.Resources.getResource; -import static java.lang.String.format; /** * @author lanwen (Merkushev Kirill) @@ -45,7 +44,7 @@ protected void after() { } public URI uri() { - return URI.create(format("http://localhost:%s", port)); + return URI.create("http://localhost:%s".formatted(port)); } private Integer findRandomOpenPortOnAllLocalInterfaces() throws IOException { diff --git a/juseppe-cli/src/test/resources/serve/cert/uc.crt b/juseppe-cli/src/test/resources/serve/cert/uc.crt index b742c82..2075040 100644 --- a/juseppe-cli/src/test/resources/serve/cert/uc.crt +++ b/juseppe-cli/src/test/resources/serve/cert/uc.crt @@ -1,19 +1,21 @@ -----BEGIN CERTIFICATE----- -MIIDDjCCAfYCCQCxvzbj/rKRG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HVmFxXxGESfFueO0SyjG/Q +xUiOM3gKu/HPPjqhKiT4bg76RBt0uRchcozViKWkvnHZh6rR5OOX+CLMegTXIVsh +QV2VZkuOb0ZMPC/7I9rY/S8PLMdt4ps= -----END CERTIFICATE----- diff --git a/juseppe-cli/src/test/resources/serve/cert/uc.key b/juseppe-cli/src/test/resources/serve/cert/uc.key index 3604efe..b9f8047 100644 --- a/juseppe-cli/src/test/resources/serve/cert/uc.key +++ b/juseppe-cli/src/test/resources/serve/cert/uc.key @@ -1,27 +1,28 @@ ------BEGIN RSA PRIVATE KEY----- -MIIEogIBAAKCAQEAoAhYmHhRmtI+afJtctDoyiXDnyfj6UHxqWnYXBO39xMCDHTj -WmYdkCLjzzNRl8d+MmfmX8XHfJy3iOpFa9sxACf12lQ/kd1PuYkNbJ9mQCmVJD3X -G6woMrKKex4ot7DMnkIDCf5Q+zPwlo/GEkiMQSZy8JWpBLPVm4GTodAwQhgGojGw -z2TlNO675wEnoe+Y0jXpInDiBbPSwero0ZFKL2t+tl4jATStT6u6BnDdiwpnEC7f -wXZt4lf4MgTVmo+C7cxeCM0QEso7UqFA8i+ZouBJ6QXJpdjHvNs/aMJD/Z+UrZa/ -BI1pXH0xkrXWJnOqFZYt8HjyuFTuC4DA/Yp66QIDAQABAoIBAFogeSzdTjAgSfBH -DObFyuTV4dcHky6x6dTcfHJW1Jt8hAHZ7pThv7KGQ8BUiZYuTt86bp7vdwqyBBdC -wPgeSPlqh+Z+3hJbDmRSUFIlb2OhR5JSlYvLKBRtQtpVwN663nIegTGmnZrrxIo2 -zHlNjFfAvKjL0JWKZjme/zL5WcROeWF0O3lYJyUt8gNEWC61/LhiEgpXVUYr99PJ -WolguCTZqDpPn9YTnf6ST6/x3Xa8hDBFgTpFIpnsV9FupB5CcBuiAHxPiwdAB8Du -SC4qHQ/zpj5DaZw8CeMwupEGvsKOJezFlJJoA/rRnBJJ4eqJHPskAJEbvBdouWt8 -GuZm3DUCgYEA1LurnLNnp5d+MF9JACUp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+VNoKu7vJ5eNLpQLj8+a5WrPl/MV6pxiBbUGwzMKhWzaeaWbXXmSsGbLSiQKBgDKF +HDkgi9KpZiov6JAB5MnE23KgQ5Y7WL6xrbRA7Nrcm+GsqnC2Wz9o2VE06baGwVgv +xhtyTIpayJG7UWpa+KdLlk3V1+qWaQYZuTuBAnrGkatO+MPIAlgNZZpBraboixaD +x+oRQYLfmrFrMBcP8IeXFs5LYCyNlY4xiKeTW/DBAoGAUFt40V1zJslr/K/d8J6Z +sPZPixpJIQMHVnFio7cx7bNIi6zqLk1501LKGtdUiKQ2020QpiMltkFCDcZfuOuo +dECVfd6v4R0ylXseMzQeGOXpfG/Tgpk42XreykPPz/q47nJRnHfuCB6hKbt56JJW +ZryGBu5iFCJPyASvqd0sJvQ= +-----END PRIVATE KEY----- diff --git a/juseppe-core/pom.xml b/juseppe-core/pom.xml index 9027b40..70560fc 100644 --- a/juseppe-core/pom.xml +++ b/juseppe-core/pom.xml @@ -77,6 +77,13 @@ guava test + + + + jakarta.validation + jakarta.validation-api + 3.1.0 + @@ -86,7 +93,7 @@ org.jsonschema2pojo jsonschema2pojo-maven-plugin - 0.4.7 + 1.2.2 ${project.basedir}/src/main/resources/jsonschema ${project.build.directory}/generated-sources/java-gen @@ -94,8 +101,12 @@ gson false false + true + false + true jsonschema true + false diff --git a/juseppe-core/src/main/java/ru/lanwen/jenkins/juseppe/gen/SavableSite.java b/juseppe-core/src/main/java/ru/lanwen/jenkins/juseppe/gen/SavableSite.java index c46e79f..d966d95 100644 --- a/juseppe-core/src/main/java/ru/lanwen/jenkins/juseppe/gen/SavableSite.java +++ b/juseppe-core/src/main/java/ru/lanwen/jenkins/juseppe/gen/SavableSite.java @@ -34,7 +34,7 @@ public Path save() { try { return Files.write(whereToSave, Collections.singleton(view.content())); } catch (IOException e) { - throw new RuntimeException(String.format("Can't save json to file %s", whereToSave.toAbsolutePath()), e); + throw new RuntimeException("Can't save json to file %s".formatted(whereToSave.toAbsolutePath()), e); } } } diff --git a/juseppe-core/src/main/java/ru/lanwen/jenkins/juseppe/gen/Signer.java b/juseppe-core/src/main/java/ru/lanwen/jenkins/juseppe/gen/Signer.java index ab67c47..0a1486b 100644 --- a/juseppe-core/src/main/java/ru/lanwen/jenkins/juseppe/gen/Signer.java +++ b/juseppe-core/src/main/java/ru/lanwen/jenkins/juseppe/gen/Signer.java @@ -102,8 +102,14 @@ public Signature sign(UpdateSite site) throws GeneralSecurityException, IOExcept X509Certificate signer = certs.get(0); // the first one is the signer, and the rest is the chain to a root CA. Object o = new PEMParser(new FileReader(privateKey)).readObject(); - isInstanceOf(PEMKeyPair.class, o, "File %s is not rsa private key!", privateKey); - PrivateKeyInfo key = ((PEMKeyPair) o).getPrivateKeyInfo(); + PrivateKeyInfo key; + if(o instanceof PEMKeyPair keyPair) { + key = keyPair.getPrivateKeyInfo(); + } else if(o instanceof PrivateKeyInfo) { + key = (PrivateKeyInfo) o; + } else { + throw new IllegalArgumentException(String.format("File %s is not rsa private key!", privateKey)); + } SignatureGenerator signatureGenerator = new SignatureGenerator(signer, key); diff --git a/juseppe-core/src/main/java/ru/lanwen/jenkins/juseppe/gen/UpdateSiteGen.java b/juseppe-core/src/main/java/ru/lanwen/jenkins/juseppe/gen/UpdateSiteGen.java index b57ea2f..68effed 100644 --- a/juseppe-core/src/main/java/ru/lanwen/jenkins/juseppe/gen/UpdateSiteGen.java +++ b/juseppe-core/src/main/java/ru/lanwen/jenkins/juseppe/gen/UpdateSiteGen.java @@ -9,7 +9,7 @@ import ru.lanwen.jenkins.juseppe.props.Props; import java.io.IOException; -import java.nio.file.Paths; +import java.nio.file.Path; import java.security.GeneralSecurityException; import java.util.ArrayList; import java.util.Collections; @@ -17,7 +17,6 @@ import java.util.function.Consumer; import java.util.stream.Stream; -import static java.lang.String.format; import static java.util.Collections.singletonList; import static java.util.stream.Collectors.toList; import static ru.lanwen.jenkins.juseppe.props.Props.populated; @@ -54,11 +53,11 @@ public UpdateSiteGen withDefaults() { site -> site.withUpdateCenterVersion(Props.UPDATE_CENTER_VERSION) .withId(props.getUcId()) ).register( - site -> Collections.singleton(new PathPluginSource(Paths.get(props.getPluginsDir()), props.getRecursiveWatch())) + site -> Collections.singleton(new PathPluginSource(Path.of(props.getPluginsDir()), props.getRecursiveWatch())) .forEach(source -> site.getPlugins().addAll(source.plugins())) ).register( site -> site.getPlugins() - .forEach(plugin -> plugin.setUrl(format("%s/%s", props.getBaseurl(), plugin.getUrl()))) + .forEach(plugin -> plugin.setUrl("%s/%s".formatted(props.getBaseurl(), plugin.getUrl()))) ).register( site -> { try { @@ -86,7 +85,7 @@ public SavableSitesCollection toSave() { new JsonpUpdateSite(filled, props.getUcJsonName()), new ReleaseHistoryUpdateSite(filled, props.getReleaseHistoryJsonName()) ) - .map(view -> new SavableSite(Paths.get(props.getSaveto()), view)) + .map(view -> new SavableSite(Path.of(props.getSaveto()), view)) .collect(toList()); return new SavableSitesCollection(files); diff --git a/juseppe-core/src/main/java/ru/lanwen/jenkins/juseppe/gen/source/PathPluginSource.java b/juseppe-core/src/main/java/ru/lanwen/jenkins/juseppe/gen/source/PathPluginSource.java index 0b558d3..8ee1ae8 100644 --- a/juseppe-core/src/main/java/ru/lanwen/jenkins/juseppe/gen/source/PathPluginSource.java +++ b/juseppe-core/src/main/java/ru/lanwen/jenkins/juseppe/gen/source/PathPluginSource.java @@ -16,8 +16,6 @@ import ru.lanwen.jenkins.juseppe.beans.Plugin; import ru.lanwen.jenkins.juseppe.gen.HPI; -import static java.lang.String.format; - /** * @author lanwen (Merkushev Kirill) */ @@ -50,7 +48,7 @@ public List plugins() { } }).filter(Objects::nonNull).collect(Collectors.toList()); } catch (IOException e) { - throw new RuntimeException(format("Can't read path %s", pluginsDir.toAbsolutePath()), e); + throw new RuntimeException("Can't read path %s".formatted(pluginsDir.toAbsolutePath()), e); } } } diff --git a/juseppe-core/src/main/java/ru/lanwen/jenkins/juseppe/gen/view/JsonpUpdateSite.java b/juseppe-core/src/main/java/ru/lanwen/jenkins/juseppe/gen/view/JsonpUpdateSite.java index b185fcf..4e08d20 100644 --- a/juseppe-core/src/main/java/ru/lanwen/jenkins/juseppe/gen/view/JsonpUpdateSite.java +++ b/juseppe-core/src/main/java/ru/lanwen/jenkins/juseppe/gen/view/JsonpUpdateSite.java @@ -25,7 +25,7 @@ public JsonpUpdateSite(UpdateSite site, String name) { @Override public String content() { String json = UpdateSiteSerializer.serializer().toJson(site); - return String.format("updateCenter.post(%n%s%n);", json); + return "updateCenter.post(%n%s%n);".formatted(json); } @Override diff --git a/juseppe-core/src/test/java/ru/lanwen/jenkins/juseppe/gen/source/PathPluginSourceTest.java b/juseppe-core/src/test/java/ru/lanwen/jenkins/juseppe/gen/source/PathPluginSourceTest.java index 7350846..8f37030 100644 --- a/juseppe-core/src/test/java/ru/lanwen/jenkins/juseppe/gen/source/PathPluginSourceTest.java +++ b/juseppe-core/src/test/java/ru/lanwen/jenkins/juseppe/gen/source/PathPluginSourceTest.java @@ -3,7 +3,7 @@ import org.junit.Test; import ru.lanwen.jenkins.juseppe.beans.Plugin; -import java.nio.file.Paths; +import java.nio.file.Path; import java.util.List; import static com.google.common.io.Resources.getResource; @@ -21,7 +21,7 @@ public class PathPluginSourceTest { @Test public void shouldFindAllPlugins() throws Exception { boolean recursiveWatch = false; - List plugins = new PathPluginSource(Paths.get(getResource(PLUGINS_DIR_CLASSPATH).getFile()), + List plugins = new PathPluginSource(Path.of(getResource(PLUGINS_DIR_CLASSPATH).getFile()), recursiveWatch) .plugins(); @@ -33,7 +33,7 @@ public void shouldFindAllPlugins() throws Exception { @Test public void shouldFindAllPluginsRecursively() throws Exception { boolean recursiveWatch = true; - List plugins = new PathPluginSource(Paths.get(getResource(PLUGINS_DIR_CLASSPATH).getFile()), + List plugins = new PathPluginSource(Path.of(getResource(PLUGINS_DIR_CLASSPATH).getFile()), recursiveWatch) .plugins(); diff --git a/juseppe-core/src/test/resources/tmp/cert/uc.crt b/juseppe-core/src/test/resources/tmp/cert/uc.crt index b742c82..b7cd416 100644 --- a/juseppe-core/src/test/resources/tmp/cert/uc.crt +++ b/juseppe-core/src/test/resources/tmp/cert/uc.crt @@ -1,19 +1,21 @@ -----BEGIN CERTIFICATE----- -MIIDDjCCAfYCCQCxvzbj/rKRGTANBgkqhkiG9w0BAQsFADBJMQswCQYDVQQGEwJF -TjEWMBQGA1UECAwNVXBkYXRlLUNlbnRlcjEQMA4GA1UEBwwHSnVzZXBwZTEQMA4G -A1UECgwHSnVzZXBwZTAeFw0xODA2MTUwNDA1MzlaFw0yMTA1MDYwNDA1MzlaMEkx -CzAJBgNVBAYTAkVOMRYwFAYDVQQIDA1VcGRhdGUtQ2VudGVyMRAwDgYDVQQHDAdK -dXNlcHBlMRAwDgYDVQQKDAdKdXNlcHBlMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A -MIIBCgKCAQEAoAhYmHhRmtI+afJtctDoyiXDnyfj6UHxqWnYXBO39xMCDHTjWmYd -kCLjzzNRl8d+MmfmX8XHfJy3iOpFa9sxACf12lQ/kd1PuYkNbJ9mQCmVJD3XG6wo -MrKKex4ot7DMnkIDCf5Q+zPwlo/GEkiMQSZy8JWpBLPVm4GTodAwQhgGojGwz2Tl -NO675wEnoe+Y0jXpInDiBbPSwero0ZFKL2t+tl4jATStT6u6BnDdiwpnEC7fwXZt -4lf4MgTVmo+C7cxeCM0QEso7UqFA8i+ZouBJ6QXJpdjHvNs/aMJD/Z+UrZa/BI1p -XH0xkrXWJnOqFZYt8HjyuFTuC4DA/Yp66QIDAQABMA0GCSqGSIb3DQEBCwUAA4IB -AQCb6+8/joVAUiwStLlzvBm3fHNErlQeiVSAh3T6pneGxYIkwTQlVLMND5ilsPlU -S00+/mmKZurQGRVFY8xgHaJjh5/qo8joFSKdvc7H551VdxEcvkdw0SLgUKzCklmt -1Wzup4dgwGEFtvWm9H52BS/rNZhWtnSe1HjgAUOPjUjxdJUqQCM2PFdaDDsAV6sR -X7fZg3ZfaAKV3E+5Lq6gQ/69Q16apVNoX3izxDV3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m/6WhtHsXXBBiQNHozjzmnB/hFZppqT2mEVmKjHPq +2orOXkeHGjgY7s5JyIPUZUfMMMUs/QOVieXV3Wtp8U+Z+/myHEisgVcmRVKGNAYe +8I0bZEU97RwQbjX+85dGLdsCWiQLERQY+0G6YMkpci7+1E98n4M0J0piSXV9G3tx +K0Vocb8pltmDC6xj7Q2g+IV9bSIZmHL32ncXGwYG8uVnRRb3hMqF/6D78Oc/YK8h +LdWKYn7gxMd1022qG2kMWppMa1Hnerw= -----END CERTIFICATE----- diff --git a/juseppe-core/src/test/resources/tmp/cert/uc.key b/juseppe-core/src/test/resources/tmp/cert/uc.key index 3604efe..5cb3fc1 100644 --- a/juseppe-core/src/test/resources/tmp/cert/uc.key +++ b/juseppe-core/src/test/resources/tmp/cert/uc.key @@ -1,27 +1,28 @@ ------BEGIN RSA PRIVATE KEY----- -MIIEogIBAAKCAQEAoAhYmHhRmtI+afJtctDoyiXDnyfj6UHxqWnYXBO39xMCDHTj -WmYdkCLjzzNRl8d+MmfmX8XHfJy3iOpFa9sxACf12lQ/kd1PuYkNbJ9mQCmVJD3X -G6woMrKKex4ot7DMnkIDCf5Q+zPwlo/GEkiMQSZy8JWpBLPVm4GTodAwQhgGojGw -z2TlNO675wEnoe+Y0jXpInDiBbPSwero0ZFKL2t+tl4jATStT6u6BnDdiwpnEC7f -wXZt4lf4MgTVmo+C7cxeCM0QEso7UqFA8i+ZouBJ6QXJpdjHvNs/aMJD/Z+UrZa/ -BI1pXH0xkrXWJnOqFZYt8HjyuFTuC4DA/Yp66QIDAQABAoIBAFogeSzdTjAgSfBH -DObFyuTV4dcHky6x6dTcfHJW1Jt8hAHZ7pThv7KGQ8BUiZYuTt86bp7vdwqyBBdC -wPgeSPlqh+Z+3hJbDmRSUFIlb2OhR5JSlYvLKBRtQtpVwN663nIegTGmnZrrxIo2 -zHlNjFfAvKjL0JWKZjme/zL5WcROeWF0O3lYJyUt8gNEWC61/LhiEgpXVUYr99PJ -WolguCTZqDpPn9YTn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BZOZGAPjS7WOMDNYsqlyrYk/ZV +OmfL9S0VawKBgDvAxDF56X8GN16q8qtKMWR4iYdfCqoFs4zc4hTP3rD/F4Tk5Ntv ++JyETdnuDRvAetwlUltNLDeLhW6cl0vDoDlciVYGsNftPZa30yga5ZBw9ezIr4Wj +Y3yrmsVVNiSUWqSC12miIipAjBX8wH/deIvGVT25zJ7Ri6JP0T+Ky8FlAoGBALow +gTWDppFJSNdg4AqHQY6cOFzkotVFaBqoPthlj+6PQD70l3h2AgEf6FoWOxcZCuij +ViKXfrzMP+maWA5lXjf6039PRGTFAnwjSviAlo9osU7AKzoCYej0jqu8sCeEp2dT +QSs40fErwjcwGuea59vbLrRLYKGbUETPgKeLY8p3AoGBALPD6lcjvJP6obyUHqHC +YTPD1hheu8qZMtGdOZ30dTW35hLkzumOQNLV0NMaax/L3GmKDiQ3ScERfKYtyGhT +nDKT+nVnBhhZFM6OnLnYRg0s8pIS43nnYPfXo5RNWBFXBKbNagzyQnc9fPSW92fc +SrZOlPTzcTBoC8jvPP/j++b+ +-----END PRIVATE KEY----- diff --git a/pom.xml b/pom.xml index b828347..e43b608 100644 --- a/pom.xml +++ b/pom.xml @@ -23,8 +23,7 @@ https://github.com/yandex-qatools/juseppe scm:git:git://github.com/yandex-qatools/juseppe.git - scm:git:git@github.com:yandex-qatools/juseppe.git - + scm:git:git@github.com:yandex-qatools/juseppe.git HEAD @@ -140,9 +139,9 @@ - com.jayway.restassured + io.rest-assured rest-assured - 2.8.0 + 5.5.0 test @@ -154,12 +153,11 @@ org.apache.maven.plugins maven-compiler-plugin - 3.5.1 + 3.13.0 - 1.8 - 1.8 true utf-8 + 17 @@ -181,7 +179,7 @@ org.apache.maven.plugins maven-checkstyle-plugin - 2.15 + 3.6.0 juseppe-core/src/test/resources/checkstyle-config.xml @@ -191,11 +189,6 @@ findbugs-maven-plugin 3.0.1 - - org.codehaus.mojo - cobertura-maven-plugin - 2.7 -