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
11070796
Commit
11070796
authored
Jan 15, 2016
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '1.2.x'
parents
89beef40
b56eef23
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
3 deletions
+37
-3
MustacheViewResolver.java
...boot/autoconfigure/mustache/web/MustacheViewResolver.java
+8
-2
MustacheViewResolverTests.java
...autoconfigure/mustache/web/MustacheViewResolverTests.java
+29
-1
No files found.
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mustache/web/MustacheViewResolver.java
View file @
11070796
/*
* Copyright 2012-201
5
the original author or authors.
* Copyright 2012-201
6
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.
...
...
@@ -108,7 +108,13 @@ public class MustacheViewResolver extends UrlBasedViewResolver {
}
private
Template
createTemplate
(
Resource
resource
)
throws
IOException
{
return
this
.
compiler
.
compile
(
getReader
(
resource
));
Reader
reader
=
getReader
(
resource
);
try
{
return
this
.
compiler
.
compile
(
reader
);
}
finally
{
reader
.
close
();
}
}
private
Reader
getReader
(
Resource
resource
)
throws
IOException
{
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mustache/web/MustacheViewResolverTests.java
View file @
11070796
/*
* Copyright 2012-201
5
the original author or authors.
* Copyright 2012-201
6
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.
...
...
@@ -16,11 +16,14 @@
package
org
.
springframework
.
boot
.
autoconfigure
.
mustache
.
web
;
import
java.io.InputStream
;
import
java.util.Locale
;
import
org.fusesource.hawtbuf.ByteArrayInputStream
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.springframework.core.io.Resource
;
import
org.springframework.mock.web.MockServletContext
;
import
org.springframework.web.context.support.StaticWebApplicationContext
;
import
org.springframework.web.servlet.View
;
...
...
@@ -29,11 +32,16 @@ import static org.hamcrest.Matchers.equalTo;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
import
static
org
.
junit
.
Assert
.
assertNull
;
import
static
org
.
junit
.
Assert
.
assertThat
;
import
static
org
.
mockito
.
BDDMockito
.
given
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
spy
;
import
static
org
.
mockito
.
Mockito
.
verify
;
/**
* Tests for {@link MustacheViewResolver}.
*
* @author Dave Syer
* @author Andy Wilkinson
*/
public
class
MustacheViewResolverTests
{
...
...
@@ -85,4 +93,24 @@ public class MustacheViewResolverTests {
}
@Test
public
void
templateResourceInputStreamIsClosed
()
throws
Exception
{
final
Resource
resource
=
mock
(
Resource
.
class
);
given
(
resource
.
exists
()).
willReturn
(
true
);
InputStream
inputStream
=
new
ByteArrayInputStream
(
new
byte
[
0
]);
InputStream
spyInputStream
=
spy
(
inputStream
);
given
(
resource
.
getInputStream
()).
willReturn
(
spyInputStream
);
this
.
resolver
=
new
MustacheViewResolver
();
this
.
resolver
.
setApplicationContext
(
new
StaticWebApplicationContext
()
{
@Override
public
Resource
getResource
(
String
location
)
{
return
resource
;
}
});
this
.
resolver
.
loadView
(
"foo"
,
null
);
verify
(
spyInputStream
).
close
();
}
}
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