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
1d35b629
Commit
1d35b629
authored
Jun 04, 2018
by
Phillip Webb
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '2.0.x'
parents
bd8106d7
abe92eba
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
5 deletions
+16
-5
InetAddressFormatterTests.java
...ringframework/boot/convert/InetAddressFormatterTests.java
+16
-5
No files found.
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/convert/InetAddressFormatterTests.java
View file @
1d35b629
...
...
@@ -52,7 +52,7 @@ public class InetAddressFormatterTests {
@Test
public
void
convertFromInetAddressToStringShouldConvert
()
throws
UnknownHostException
{
assumeResolves
(
"example.com"
);
assumeResolves
(
"example.com"
,
true
);
InetAddress
address
=
InetAddress
.
getByName
(
"example.com"
);
String
converted
=
this
.
conversionService
.
convert
(
address
,
String
.
class
);
assertThat
(
converted
).
isEqualTo
(
address
.
getHostAddress
());
...
...
@@ -60,7 +60,7 @@ public class InetAddressFormatterTests {
@Test
public
void
convertFromStringToInetAddressShouldConvert
()
{
assumeResolves
(
"example.com"
);
assumeResolves
(
"example.com"
,
true
);
InetAddress
converted
=
this
.
conversionService
.
convert
(
"example.com"
,
InetAddress
.
class
);
assertThat
(
converted
.
toString
()).
startsWith
(
"example.com"
);
...
...
@@ -68,16 +68,27 @@ public class InetAddressFormatterTests {
@Test
public
void
convertFromStringToInetAddressWhenHostDoesNotExistShouldThrowException
()
{
String
missingDomain
=
"ireallydontexist.example.com"
;
assumeResolves
(
missingDomain
,
false
);
this
.
thrown
.
expect
(
ConversionFailedException
.
class
);
this
.
conversionService
.
convert
(
"ireallydontexist.example.com"
,
InetAddress
.
class
);
this
.
conversionService
.
convert
(
missingDomain
,
InetAddress
.
class
);
}
private
void
assumeResolves
(
String
host
)
{
private
void
assumeResolves
(
String
host
,
boolean
expectedToResolve
)
{
boolean
resolved
=
isResolvable
(
host
);
if
(
resolved
!=
expectedToResolve
)
{
throw
new
AssumptionViolatedException
(
"Host "
+
host
+
" resolved "
+
resolved
);
}
}
private
boolean
isResolvable
(
String
host
)
{
try
{
InetAddress
.
getByName
(
host
);
return
true
;
}
catch
(
UnknownHostException
ex
)
{
throw
new
AssumptionViolatedException
(
"Host "
+
host
+
" not resolvable"
,
ex
)
;
return
false
;
}
}
...
...
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