Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
a5ae1de7
Commit
a5ae1de7
authored
Jun 20, 2019
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix spring-boot-loader's tests on Windows
Closes gh-17275
parent
7e5ca6d2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
17 deletions
+13
-17
HandlerTests.java
...ava/org/springframework/boot/loader/jar/HandlerTests.java
+3
-3
JarURLConnectionTests.java
...pringframework/boot/loader/jar/JarURLConnectionTests.java
+10
-14
No files found.
spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/jar/HandlerTests.java
View file @
a5ae1de7
...
...
@@ -159,10 +159,10 @@ public class HandlerTests {
public
void
fallbackToJdksJarUrlStreamHandler
()
throws
Exception
{
File
testJar
=
this
.
temporaryFolder
.
newFile
(
"test.jar"
);
TestJarCreator
.
createTestJar
(
testJar
);
URLConnection
connection
=
new
URL
(
null
,
"jar:
file:"
+
testJar
.
getAbsolutePath
()
+
"!/nested.jar!/"
,
this
.
handler
)
.
openConnection
();
URLConnection
connection
=
new
URL
(
null
,
"jar:
"
+
testJar
.
toURI
().
toURL
()
+
"!/nested.jar!/"
,
this
.
handler
)
.
openConnection
();
assertThat
(
connection
).
isInstanceOf
(
JarURLConnection
.
class
);
URLConnection
jdkConnection
=
new
URL
(
null
,
"jar:file:
file:"
+
testJar
.
getAbsolutePath
()
+
"!/nested.jar!/"
,
URLConnection
jdkConnection
=
new
URL
(
null
,
"jar:file:
"
+
testJar
.
toURI
().
toURL
()
+
"!/nested.jar!/"
,
this
.
handler
).
openConnection
();
assertThat
(
jdkConnection
).
isNotInstanceOf
(
JarURLConnection
.
class
);
}
...
...
spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/jar/JarURLConnectionTests.java
View file @
a5ae1de7
...
...
@@ -57,7 +57,7 @@ public class JarURLConnectionTests {
@Test
public
void
connectionToRootUsingAbsoluteUrl
()
throws
Exception
{
URL
url
=
new
URL
(
"jar:
file:"
+
getAbsolutePath
()
+
"!/"
);
URL
url
=
new
URL
(
"jar:
"
+
this
.
rootJarFile
.
toURI
().
toURL
()
+
"!/"
);
assertThat
(
JarURLConnection
.
get
(
url
,
this
.
jarFile
).
getContent
()).
isSameAs
(
this
.
jarFile
);
}
...
...
@@ -69,7 +69,7 @@ public class JarURLConnectionTests {
@Test
public
void
connectionToEntryUsingAbsoluteUrl
()
throws
Exception
{
URL
url
=
new
URL
(
"jar:
file:"
+
getAbsolutePath
()
+
"!/1.dat"
);
URL
url
=
new
URL
(
"jar:
"
+
this
.
rootJarFile
.
toURI
().
toURL
()
+
"!/1.dat"
);
assertThat
(
JarURLConnection
.
get
(
url
,
this
.
jarFile
).
getInputStream
())
.
hasSameContentAs
(
new
ByteArrayInputStream
(
new
byte
[]
{
1
}));
}
...
...
@@ -83,14 +83,14 @@ public class JarURLConnectionTests {
@Test
public
void
connectionToEntryUsingAbsoluteUrlWithFileColonSlashSlashPrefix
()
throws
Exception
{
URL
url
=
new
URL
(
"jar:
file:/"
+
getAbsolutePath
()
+
"!/1.dat"
);
URL
url
=
new
URL
(
"jar:
"
+
this
.
rootJarFile
.
toURI
().
toURL
()
+
"!/1.dat"
);
assertThat
(
JarURLConnection
.
get
(
url
,
this
.
jarFile
).
getInputStream
())
.
hasSameContentAs
(
new
ByteArrayInputStream
(
new
byte
[]
{
1
}));
}
@Test
public
void
connectionToEntryUsingAbsoluteUrlForNestedEntry
()
throws
Exception
{
URL
url
=
new
URL
(
"jar:
file:"
+
getAbsolutePath
()
+
"!/nested.jar!/3.dat"
);
URL
url
=
new
URL
(
"jar:
"
+
this
.
rootJarFile
.
toURI
().
toURL
()
+
"!/nested.jar!/3.dat"
);
assertThat
(
JarURLConnection
.
get
(
url
,
this
.
jarFile
).
getInputStream
())
.
hasSameContentAs
(
new
ByteArrayInputStream
(
new
byte
[]
{
3
}));
}
...
...
@@ -104,7 +104,7 @@ public class JarURLConnectionTests {
@Test
public
void
connectionToEntryUsingAbsoluteUrlForEntryFromNestedJarFile
()
throws
Exception
{
URL
url
=
new
URL
(
"jar:
file:"
+
getAbsolutePath
()
+
"!/nested.jar!/3.dat"
);
URL
url
=
new
URL
(
"jar:
"
+
this
.
rootJarFile
.
toURI
().
toURL
()
+
"!/nested.jar!/3.dat"
);
JarFile
nested
=
this
.
jarFile
.
getNestedJarFile
(
this
.
jarFile
.
getEntry
(
"nested.jar"
));
assertThat
(
JarURLConnection
.
get
(
url
,
nested
).
getInputStream
())
.
hasSameContentAs
(
new
ByteArrayInputStream
(
new
byte
[]
{
3
}));
...
...
@@ -120,7 +120,7 @@ public class JarURLConnectionTests {
@Test
public
void
connectionToEntryInNestedJarFromUrlThatUsesExistingUrlAsContext
()
throws
Exception
{
URL
url
=
new
URL
(
new
URL
(
"jar"
,
null
,
-
1
,
"file:"
+
getAbsolutePath
()
+
"!/nested.jar!/"
,
new
Handler
()),
URL
url
=
new
URL
(
new
URL
(
"jar"
,
null
,
-
1
,
this
.
rootJarFile
.
toURI
().
toURL
()
+
"!/nested.jar!/"
,
new
Handler
()),
"/3.dat"
);
JarFile
nested
=
this
.
jarFile
.
getNestedJarFile
(
this
.
jarFile
.
getEntry
(
"nested.jar"
));
assertThat
(
JarURLConnection
.
get
(
url
,
nested
).
getInputStream
())
...
...
@@ -143,7 +143,7 @@ public class JarURLConnectionTests {
@Test
public
void
connectionToEntryUsingWrongAbsoluteUrlForEntryFromNestedJarFile
()
throws
Exception
{
URL
url
=
new
URL
(
"jar:
file:"
+
getAbsolutePath
()
+
"!/w.jar!/3.dat"
);
URL
url
=
new
URL
(
"jar:
"
+
this
.
rootJarFile
.
toURI
().
toURL
()
+
"!/w.jar!/3.dat"
);
JarFile
nested
=
this
.
jarFile
.
getNestedJarFile
(
this
.
jarFile
.
getEntry
(
"nested.jar"
));
assertThatExceptionOfType
(
FileNotFoundException
.
class
)
.
isThrownBy
(
JarURLConnection
.
get
(
url
,
nested
)::
getInputStream
);
...
...
@@ -151,21 +151,21 @@ public class JarURLConnectionTests {
@Test
public
void
getContentLengthReturnsLengthOfUnderlyingEntry
()
throws
Exception
{
URL
url
=
new
URL
(
new
URL
(
"jar"
,
null
,
-
1
,
"file:"
+
getAbsolutePath
()
+
"!/nested.jar!/"
,
new
Handler
()),
URL
url
=
new
URL
(
new
URL
(
"jar"
,
null
,
-
1
,
this
.
rootJarFile
.
toURI
().
toURL
()
+
"!/nested.jar!/"
,
new
Handler
()),
"/3.dat"
);
assertThat
(
url
.
openConnection
().
getContentLength
()).
isEqualTo
(
1
);
}
@Test
public
void
getContentLengthLongReturnsLengthOfUnderlyingEntry
()
throws
Exception
{
URL
url
=
new
URL
(
new
URL
(
"jar"
,
null
,
-
1
,
"file:"
+
getAbsolutePath
()
+
"!/nested.jar!/"
,
new
Handler
()),
URL
url
=
new
URL
(
new
URL
(
"jar"
,
null
,
-
1
,
this
.
rootJarFile
.
toURI
().
toURL
()
+
"!/nested.jar!/"
,
new
Handler
()),
"/3.dat"
);
assertThat
(
url
.
openConnection
().
getContentLengthLong
()).
isEqualTo
(
1
);
}
@Test
public
void
getLastModifiedReturnsLastModifiedTimeOfJarEntry
()
throws
Exception
{
URL
url
=
new
URL
(
"jar:
file:"
+
getAbsolutePath
()
+
"!/1.dat"
);
URL
url
=
new
URL
(
"jar:
"
+
this
.
rootJarFile
.
toURI
().
toURL
()
+
"!/1.dat"
);
JarURLConnection
connection
=
JarURLConnection
.
get
(
url
,
this
.
jarFile
);
assertThat
(
connection
.
getLastModified
()).
isEqualTo
(
connection
.
getJarEntry
().
getTime
());
}
...
...
@@ -191,10 +191,6 @@ public class JarURLConnectionTests {
.
isEqualTo
(
"\u00e1/b/\u00c7.class"
);
}
private
String
getAbsolutePath
()
{
return
this
.
rootJarFile
.
getAbsolutePath
().
replace
(
'\\'
,
'/'
);
}
private
String
getRelativePath
()
{
return
this
.
rootJarFile
.
getPath
().
replace
(
'\\'
,
'/'
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment