[java-idp-plugin-scripting] 10/15: Add more download jars
Ian Young
ian at iay.org.uk
Mon Jun 22 13:03:46 UTC 2020
This is an automated email from the git hooks/post-receive script.
iay pushed a commit to branch master
in repository java-idp-plugin-scripting.
View the commit online:
http://git.shibboleth.net/view/?p=java-idp-plugin-scripting.git;a=commit;h=a7383e41a93266e1d59e7a9b0e1c8afd2d346305
commit a7383e41a93266e1d59e7a9b0e1c8afd2d346305
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Wed Jun 3 16:18:45 2020 +0100
Add more download jars
---
.../scripting/nashorn/NashornDescription.java | 33 ++++++++++++++++++----
.../plugins/scripting/nashorn/PluginTest.java | 25 ++++++++--------
2 files changed, 40 insertions(+), 18 deletions(-)
diff --git a/nashorn-impl/src/main/java/net/shibboleth/plugins/scripting/nashorn/NashornDescription.java b/nashorn-impl/src/main/java/net/shibboleth/plugins/scripting/nashorn/NashornDescription.java
index dfa687c..6faf15a 100644
--- a/nashorn-impl/src/main/java/net/shibboleth/plugins/scripting/nashorn/NashornDescription.java
+++ b/nashorn-impl/src/main/java/net/shibboleth/plugins/scripting/nashorn/NashornDescription.java
@@ -19,8 +19,10 @@ package net.shibboleth.plugins.scripting.nashorn;
import java.io.IOException;
import java.nio.file.Path;
+import java.util.ArrayList;
import java.util.List;
+import org.apache.http.client.HttpClient;
import org.springframework.core.io.ClassPathResource;
import net.shibboleth.ext.spring.resource.HTTPResource;
@@ -36,6 +38,19 @@ import net.shibboleth.utilities.java.support.resource.Resource;
*/
public class NashornDescription extends PluginDescription {
+ static final String GRAAL_VERSION = "20.0.0";
+ static final String MAVEN_REPO = "https://repo1.maven.org/maven2/";
+ static final List<String> jars = List.of(MAVEN_REPO + "org/graalvm/sdk/graal-sdk/" + GRAAL_VERSION + "/graal-sdk-" + GRAAL_VERSION +".jar",
+ MAVEN_REPO + "org/graalvm/js/js/" + GRAAL_VERSION + "/js-" + GRAAL_VERSION +".jar",
+ MAVEN_REPO + "org/graalvm/regex/regex/" + GRAAL_VERSION + "/regex-" + GRAAL_VERSION +".jar",
+ MAVEN_REPO + "org/graalvm/truffle/truffle-api/" + GRAAL_VERSION + "/truffle-api-" + GRAAL_VERSION +".jar",
+ MAVEN_REPO + "org/os2/asm/asm/7.1/asm-7.1.jar",
+ MAVEN_REPO + "org/os2/asm/asm-analysis/7.1/asm-analysis-7.1.jar",
+ MAVEN_REPO + "org/os2/asm/asm-commons/7.1/asm-commons-7.1.jar",
+ MAVEN_REPO + "org/os2/asm/asm-tree/7.1/asm-tree-7.1.jar",
+ MAVEN_REPO + "org/os2/asm/asm-uril/7.1/asm-util-7.1.jar",
+ MAVEN_REPO + "com/ibm/icu/icu4j/64.2/icu4j-64.2.jar");
+
@Override
public String getPluginId() {
return "net.shibboleth.plugins.scripting.nashorn";
@@ -50,15 +65,21 @@ public class NashornDescription extends PluginDescription {
public List<Pair<Resource, Path>> getExternalFilePathsToCopy() throws IOException {
final HttpClientBuilder builder = new HttpClientBuilder();
- HTTPResource resource ;
+ final Path to = Path.of("dist", "edit-webapp-" + getPluginId(), "WEB-INF", "lib");
try {
- resource = new HTTPResource(builder.buildClient(), "https://repo1.maven.org/maven2/org/graalvm/sdk/graal-sdk/20.0.0/graal-sdk-20.0.0.jar");
+ final HttpClient client = builder.buildClient();
+ List<Pair<Resource, Path>> result = new ArrayList<>(jars.size());
+ for (String url : jars) {
+ // cannot use stream because the constructor throws and pipes hate that
+ result.add( new Pair<>((Resource) new HTTPResource(client, url), to));
+ }
+ return List.copyOf(result);
} catch (Exception e) {
- throw new IOException("Construction client failed:", e);
+ if (e instanceof IOException) {
+ throw (IOException) e;
+ }
+ throw new IOException("Failed to create HTTPClient", e);
}
- final Path to = Path.of("dist", "edit-webapp-" + getPluginId(), "WEB-INF", "lib");
- final Pair<Resource, Path> pair = new Pair<>(resource, to);
- return List.of(pair);
}
@Override
diff --git a/nashorn-impl/src/test/java/net/shibboleth/plugins/scripting/nashorn/PluginTest.java b/nashorn-impl/src/test/java/net/shibboleth/plugins/scripting/nashorn/PluginTest.java
index e90af19..e794fd2 100644
--- a/nashorn-impl/src/test/java/net/shibboleth/plugins/scripting/nashorn/PluginTest.java
+++ b/nashorn-impl/src/test/java/net/shibboleth/plugins/scripting/nashorn/PluginTest.java
@@ -62,16 +62,17 @@ public class PluginTest {
@Test
public void testDownload() throws IOException {
- for (Pair<Resource, Path> p:nashorn.getExternalFilePathsToCopy()) {
-
- final InputStream stream = p.getFirst().getInputStream();
- byte[] buffer;
- int count = 0;
- do {
- buffer = stream.readNBytes(10240);
- count += buffer.length;
- } while (buffer.length >= 10240);
- assertEquals(count, 539904);
- }
- }
+ //
+ // Abuse: We 'know' that the first dowload is the sdk
+ //
+ final Pair<Resource, Path> p = nashorn.getExternalFilePathsToCopy().get(0);
+ final InputStream stream = p.getFirst().getInputStream();
+ byte[] buffer;
+ int count = 0;
+ do {
+ buffer = stream.readNBytes(10240);
+ count += buffer.length;
+ } while (buffer.length >= 10240);
+ assertEquals(count, 539904);
+ }
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list