|
|
|
@ -1,5 +1,5 @@
|
|
|
|
|
/*
|
|
|
|
|
* Copyright 2012-2015 the original author or authors.
|
|
|
|
|
* Copyright 2012-2016 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.
|
|
|
|
@ -321,24 +321,18 @@ public class JarFileTests {
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void createNonNestedUrlFromString() throws Exception {
|
|
|
|
|
JarFile.registerUrlProtocolHandler();
|
|
|
|
|
String spec = "jar:" + this.rootJarFile.toURI() + "!/2.dat";
|
|
|
|
|
URL url = new URL(spec);
|
|
|
|
|
assertThat(url.toString(), equalTo(spec));
|
|
|
|
|
InputStream inputStream = url.openStream();
|
|
|
|
|
assertThat(inputStream, notNullValue());
|
|
|
|
|
assertThat(inputStream.read(), equalTo(2));
|
|
|
|
|
JarURLConnection connection = (JarURLConnection) url.openConnection();
|
|
|
|
|
assertThat(connection.getURL().toString(), equalTo(spec));
|
|
|
|
|
assertThat(connection.getJarFileURL().toURI(), equalTo(this.rootJarFile.toURI()));
|
|
|
|
|
assertThat(connection.getEntryName(), equalTo("2.dat"));
|
|
|
|
|
nonNestedJarFileFromString(
|
|
|
|
|
"jar:file:" + this.rootJarFile.getAbsolutePath() + "!/2.dat");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void createNonNestedUrlFromStringCreatedUsingPath() throws Exception {
|
|
|
|
|
// gh-5287
|
|
|
|
|
public void createNonNestedUrlFromStringWithDoubleSlash() throws Exception {
|
|
|
|
|
nonNestedJarFileFromString(
|
|
|
|
|
"jar:file://" + this.rootJarFile.getAbsolutePath() + "!/2.dat");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void nonNestedJarFileFromString(String spec) throws Exception {
|
|
|
|
|
JarFile.registerUrlProtocolHandler();
|
|
|
|
|
String spec = "jar:" + this.rootJarFile.toPath().toUri() + "!/2.dat";
|
|
|
|
|
URL url = new URL(spec);
|
|
|
|
|
assertThat(url.toString(), equalTo(spec));
|
|
|
|
|
InputStream inputStream = url.openStream();
|
|
|
|
|