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
01ddee22
Commit
01ddee22
authored
Oct 10, 2020
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish
parent
0f9e8315
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
15 deletions
+8
-15
MustacheViewTests.java
...work/boot/web/reactive/result/view/MustacheViewTests.java
+8
-15
No files found.
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/reactive/result/view/MustacheViewTests.java
View file @
01ddee22
/*
/*
* Copyright 2012-20
19
the original author or authors.
* Copyright 2012-20
20
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -21,10 +21,10 @@ import java.time.Duration;
...
@@ -21,10 +21,10 @@ import java.time.Duration;
import
java.util.Collections
;
import
java.util.Collections
;
import
com.samskivert.mustache.Mustache
;
import
com.samskivert.mustache.Mustache
;
import
org.junit.jupiter.api.BeforeEach
;
import
org.junit.jupiter.api.Test
;
import
org.junit.jupiter.api.Test
;
import
reactor.test.StepVerifier
;
import
org.springframework.context.support.
Gener
icApplicationContext
;
import
org.springframework.context.support.
Stat
icApplicationContext
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.MediaType
;
import
org.springframework.mock.http.server.reactive.MockServerHttpRequest
;
import
org.springframework.mock.http.server.reactive.MockServerHttpRequest
;
import
org.springframework.mock.web.server.MockServerWebExchange
;
import
org.springframework.mock.web.server.MockServerWebExchange
;
...
@@ -41,27 +41,20 @@ class MustacheViewTests {
...
@@ -41,27 +41,20 @@ class MustacheViewTests {
private
final
String
templateUrl
=
"classpath:/"
+
getClass
().
getPackage
().
getName
().
replace
(
"."
,
"/"
)
private
final
String
templateUrl
=
"classpath:/"
+
getClass
().
getPackage
().
getName
().
replace
(
"."
,
"/"
)
+
"/template.html"
;
+
"/template.html"
;
private
GenericApplicationContext
context
=
new
GenericApplicationContext
();
private
final
StaticApplicationContext
context
=
new
StaticApplicationContext
();
private
MockServerWebExchange
exchange
;
@BeforeEach
void
init
()
{
this
.
context
.
refresh
();
}
@Test
@Test
void
viewResolvesHandlebars
()
{
void
viewResolvesHandlebars
()
{
this
.
exchange
=
MockServerWebExchange
.
from
(
MockServerHttpRequest
.
get
(
"/test"
).
build
());
MockServerWebExchange
exchange
=
MockServerWebExchange
.
from
(
MockServerHttpRequest
.
get
(
"/test"
).
build
());
MustacheView
view
=
new
MustacheView
();
MustacheView
view
=
new
MustacheView
();
view
.
setCompiler
(
Mustache
.
compiler
());
view
.
setCompiler
(
Mustache
.
compiler
());
view
.
setUrl
(
this
.
templateUrl
);
view
.
setUrl
(
this
.
templateUrl
);
view
.
setCharset
(
StandardCharsets
.
UTF_8
.
displayName
());
view
.
setCharset
(
StandardCharsets
.
UTF_8
.
displayName
());
view
.
setApplicationContext
(
this
.
context
);
view
.
setApplicationContext
(
this
.
context
);
view
.
render
(
Collections
.
singletonMap
(
"World"
,
"Spring"
),
MediaType
.
TEXT_HTML
,
this
.
exchange
)
view
.
render
(
Collections
.
singletonMap
(
"World"
,
"Spring"
),
MediaType
.
TEXT_HTML
,
exchange
)
.
block
(
Duration
.
ofSeconds
(
30
));
.
block
(
Duration
.
ofSeconds
(
30
));
assertThat
(
this
.
exchange
.
getResponse
().
getBodyAsString
().
block
(
Duration
.
ofSeconds
(
30
)).
trim
())
StepVerifier
.
create
(
exchange
.
getResponse
().
getBodyAsString
())
.
isEqualTo
(
"Hello Spring"
);
.
assertNext
((
body
)
->
assertThat
(
body
).
isEqualToIgnoringWhitespace
(
"Hello Spring"
)).
verifyComplete
(
);
}
}
}
}
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