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
93a7dc21
Commit
93a7dc21
authored
Jun 16, 2015
by
Phillip Webb
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '1.2.x'
parents
79179a77
cca0b76a
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
412 additions
and
6 deletions
+412
-6
VelocityAutoConfiguration.java
...oot/autoconfigure/velocity/VelocityAutoConfiguration.java
+2
-1
VelocityAutoConfigurationTests.java
...utoconfigure/velocity/VelocityAutoConfigurationTests.java
+10
-1
pom.xml
spring-boot/pom.xml
+19
-4
EmbeddedVelocityToolboxView.java
...eb/servlet/view/velocity/EmbeddedVelocityToolboxView.java
+111
-0
EmbeddedVelocityViewResolver.java
...b/servlet/view/velocity/EmbeddedVelocityViewResolver.java
+52
-0
package-info.java
...ramework/boot/web/servlet/view/velocity/package-info.java
+19
-0
EmbeddedVelocityToolboxViewTests.java
...rvlet/view/velocity/EmbeddedVelocityToolboxViewTests.java
+95
-0
EmbeddedVelocityViewResolverTests.java
...vlet/view/velocity/EmbeddedVelocityViewResolverTests.java
+96
-0
toolbox.xml
...pringframework/boot/web/servlet/view/velocity/toolbox.xml
+8
-0
No files found.
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/velocity/VelocityAutoConfiguration.java
View file @
93a7dc21
...
@@ -35,6 +35,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplicat
...
@@ -35,6 +35,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplicat
import
org.springframework.boot.autoconfigure.template.TemplateLocation
;
import
org.springframework.boot.autoconfigure.template.TemplateLocation
;
import
org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration
;
import
org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration
;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.boot.web.servlet.view.velocity.EmbeddedVelocityViewResolver
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
...
@@ -128,7 +129,7 @@ public class VelocityAutoConfiguration {
...
@@ -128,7 +129,7 @@ public class VelocityAutoConfiguration {
@ConditionalOnMissingBean
(
name
=
"velocityViewResolver"
)
@ConditionalOnMissingBean
(
name
=
"velocityViewResolver"
)
@ConditionalOnProperty
(
name
=
"spring.velocity.enabled"
,
matchIfMissing
=
true
)
@ConditionalOnProperty
(
name
=
"spring.velocity.enabled"
,
matchIfMissing
=
true
)
public
VelocityViewResolver
velocityViewResolver
()
{
public
VelocityViewResolver
velocityViewResolver
()
{
VelocityViewResolver
resolver
=
new
VelocityViewResolver
();
EmbeddedVelocityViewResolver
resolver
=
new
Embedded
VelocityViewResolver
();
this
.
properties
.
applyToViewResolver
(
resolver
);
this
.
properties
.
applyToViewResolver
(
resolver
);
return
resolver
;
return
resolver
;
}
}
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/velocity/VelocityAutoConfigurationTests.java
View file @
93a7dc21
...
@@ -30,6 +30,7 @@ import org.junit.Before;
...
@@ -30,6 +30,7 @@ import org.junit.Before;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.springframework.beans.factory.BeanCreationException
;
import
org.springframework.beans.factory.BeanCreationException
;
import
org.springframework.boot.test.EnvironmentTestUtils
;
import
org.springframework.boot.test.EnvironmentTestUtils
;
import
org.springframework.boot.web.servlet.view.velocity.EmbeddedVelocityViewResolver
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
org.springframework.mock.web.MockHttpServletRequest
;
import
org.springframework.mock.web.MockHttpServletRequest
;
import
org.springframework.mock.web.MockHttpServletResponse
;
import
org.springframework.mock.web.MockHttpServletResponse
;
...
@@ -42,6 +43,7 @@ import org.springframework.web.servlet.view.velocity.VelocityViewResolver;
...
@@ -42,6 +43,7 @@ import org.springframework.web.servlet.view.velocity.VelocityViewResolver;
import
static
org
.
hamcrest
.
Matchers
.
containsString
;
import
static
org
.
hamcrest
.
Matchers
.
containsString
;
import
static
org
.
hamcrest
.
Matchers
.
equalTo
;
import
static
org
.
hamcrest
.
Matchers
.
equalTo
;
import
static
org
.
hamcrest
.
Matchers
.
instanceOf
;
import
static
org
.
hamcrest
.
Matchers
.
notNullValue
;
import
static
org
.
hamcrest
.
Matchers
.
notNullValue
;
import
static
org
.
junit
.
Assert
.
assertThat
;
import
static
org
.
junit
.
Assert
.
assertThat
;
...
@@ -136,7 +138,7 @@ public class VelocityAutoConfigurationTests {
...
@@ -136,7 +138,7 @@ public class VelocityAutoConfigurationTests {
}
}
@Test
@Test
public
void
custom
FreeMarker
Settings
()
{
public
void
custom
Velocity
Settings
()
{
registerAndRefreshContext
(
"spring.velocity.properties.directive.parse.max.depth:10"
);
registerAndRefreshContext
(
"spring.velocity.properties.directive.parse.max.depth:10"
);
assertThat
(
this
.
context
.
getBean
(
VelocityConfigurer
.
class
).
getVelocityEngine
()
assertThat
(
this
.
context
.
getBean
(
VelocityConfigurer
.
class
).
getVelocityEngine
()
.
getProperty
(
"directive.parse.max.depth"
),
equalTo
((
Object
)
"10"
));
.
getProperty
(
"directive.parse.max.depth"
),
equalTo
((
Object
)
"10"
));
...
@@ -174,6 +176,13 @@ public class VelocityAutoConfigurationTests {
...
@@ -174,6 +176,13 @@ public class VelocityAutoConfigurationTests {
}
}
}
}
@Test
public
void
usesEmbeddedVelocityViewResolver
()
{
registerAndRefreshContext
(
"spring.velocity.toolbox:/toolbox.xml"
);
VelocityViewResolver
resolver
=
this
.
context
.
getBean
(
VelocityViewResolver
.
class
);
assertThat
(
resolver
,
instanceOf
(
EmbeddedVelocityViewResolver
.
class
));
}
private
void
registerAndRefreshContext
(
String
...
env
)
{
private
void
registerAndRefreshContext
(
String
...
env
)
{
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
env
);
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
env
);
this
.
context
.
register
(
VelocityAutoConfiguration
.
class
);
this
.
context
.
register
(
VelocityAutoConfiguration
.
class
);
...
...
spring-boot/pom.xml
View file @
93a7dc21
...
@@ -119,6 +119,16 @@
...
@@ -119,6 +119,16 @@
<artifactId>
tomcat-embed-logging-juli
</artifactId>
<artifactId>
tomcat-embed-logging-juli
</artifactId>
<optional>
true
</optional>
<optional>
true
</optional>
</dependency>
</dependency>
<dependency>
<groupId>
org.apache.velocity
</groupId>
<artifactId>
velocity
</artifactId>
<optional>
true
</optional>
</dependency>
<dependency>
<groupId>
org.apache.velocity
</groupId>
<artifactId>
velocity-tools
</artifactId>
<optional>
true
</optional>
</dependency>
<dependency>
<dependency>
<groupId>
org.codehaus.btm
</groupId>
<groupId>
org.codehaus.btm
</groupId>
<artifactId>
btm
</artifactId>
<artifactId>
btm
</artifactId>
...
@@ -189,6 +199,11 @@
...
@@ -189,6 +199,11 @@
<artifactId>
spring-web
</artifactId>
<artifactId>
spring-web
</artifactId>
<optional>
true
</optional>
<optional>
true
</optional>
</dependency>
</dependency>
<dependency>
<groupId>
org.springframework
</groupId>
<artifactId>
spring-webmvc
</artifactId>
<optional>
true
</optional>
</dependency>
<dependency>
<dependency>
<groupId>
org.yaml
</groupId>
<groupId>
org.yaml
</groupId>
<artifactId>
snakeyaml
</artifactId>
<artifactId>
snakeyaml
</artifactId>
...
@@ -207,13 +222,13 @@
...
@@ -207,13 +222,13 @@
<scope>
test
</scope>
<scope>
test
</scope>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
org.s
pringframework
</groupId>
<groupId>
org.s
lf4j
</groupId>
<artifactId>
spring-webmvc
</artifactId>
<artifactId>
jcl-over-slf4j
</artifactId>
<scope>
test
</scope>
<scope>
test
</scope>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
org.s
lf4j
</groupId>
<groupId>
org.s
pringframework
</groupId>
<artifactId>
jcl-over-slf4j
</artifactId>
<artifactId>
spring-context-support
</artifactId>
<scope>
test
</scope>
<scope>
test
</scope>
</dependency>
</dependency>
</dependencies>
</dependencies>
...
...
spring-boot/src/main/java/org/springframework/boot/web/servlet/view/velocity/EmbeddedVelocityToolboxView.java
0 → 100644
View file @
93a7dc21
/*
* Copyright 2012-2015 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
springframework
.
boot
.
web
.
servlet
.
view
.
velocity
;
import
java.io.InputStream
;
import
java.util.Map
;
import
javax.servlet.ServletContext
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
org.aopalliance.intercept.MethodInterceptor
;
import
org.aopalliance.intercept.MethodInvocation
;
import
org.apache.velocity.VelocityContext
;
import
org.apache.velocity.context.Context
;
import
org.springframework.aop.framework.ProxyFactory
;
import
org.springframework.core.io.ClassPathResource
;
import
org.springframework.web.servlet.view.velocity.VelocityToolboxView
;
/**
* Extended version of {@link VelocityToolboxView} that can load toolbox locations from
* the classpath as well as the servlet context. This is useful when run an embedded web
* server.
*
* @author Phillip Webb
* @since 1.2.5
*/
@SuppressWarnings
(
"deprecation"
)
public
class
EmbeddedVelocityToolboxView
extends
VelocityToolboxView
{
@Override
protected
Context
createVelocityContext
(
Map
<
String
,
Object
>
model
,
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
Exception
{
org
.
apache
.
velocity
.
tools
.
view
.
context
.
ChainedContext
context
=
new
org
.
apache
.
velocity
.
tools
.
view
.
context
.
ChainedContext
(
new
VelocityContext
(
model
),
getVelocityEngine
(),
request
,
response
,
getServletContext
());
if
(
getToolboxConfigLocation
()
!=
null
)
{
setContextToolbox
(
context
);
}
return
context
;
}
@SuppressWarnings
(
"unchecked"
)
private
void
setContextToolbox
(
org
.
apache
.
velocity
.
tools
.
view
.
context
.
ChainedContext
context
)
{
org
.
apache
.
velocity
.
tools
.
view
.
ToolboxManager
toolboxManager
=
org
.
apache
.
velocity
.
tools
.
view
.
servlet
.
ServletToolboxManager
.
getInstance
(
getToolboxConfigFileAwareServletContext
(),
getToolboxConfigLocation
());
Map
<
String
,
Object
>
toolboxContext
=
toolboxManager
.
getToolbox
(
context
);
context
.
setToolbox
(
toolboxContext
);
}
private
ServletContext
getToolboxConfigFileAwareServletContext
()
{
ProxyFactory
factory
=
new
ProxyFactory
();
factory
.
setTarget
(
getServletContext
());
factory
.
addAdvice
(
new
GetResourceMethodInterceptor
(
getToolboxConfigLocation
()));
return
(
ServletContext
)
factory
.
getProxy
();
}
/**
* {@link MethodInterceptor} to allow the calls to getResourceAsStream() to resolve
* the toolboxFile from the classpath.
*/
private
static
class
GetResourceMethodInterceptor
implements
MethodInterceptor
{
private
final
String
toolboxFile
;
public
GetResourceMethodInterceptor
(
String
toolboxFile
)
{
if
(
toolboxFile
!=
null
&&
!
toolboxFile
.
startsWith
(
"/"
))
{
toolboxFile
=
"/"
+
toolboxFile
;
}
this
.
toolboxFile
=
toolboxFile
;
}
@Override
public
Object
invoke
(
MethodInvocation
invocation
)
throws
Throwable
{
if
(
invocation
.
getMethod
().
getName
().
equals
(
"getResourceAsStream"
)
&&
invocation
.
getArguments
()[
0
].
equals
(
this
.
toolboxFile
))
{
InputStream
inputStream
=
(
InputStream
)
invocation
.
proceed
();
if
(
inputStream
==
null
)
{
try
{
inputStream
=
new
ClassPathResource
(
this
.
toolboxFile
,
Thread
.
currentThread
().
getContextClassLoader
())
.
getInputStream
();
}
catch
(
Exception
ex
)
{
// Ignore
}
}
return
inputStream
;
}
return
invocation
.
proceed
();
}
}
}
spring-boot/src/main/java/org/springframework/boot/web/servlet/view/velocity/EmbeddedVelocityViewResolver.java
0 → 100644
View file @
93a7dc21
/*
* Copyright 2012-2015 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
springframework
.
boot
.
web
.
servlet
.
view
.
velocity
;
import
org.springframework.web.servlet.view.velocity.VelocityView
;
import
org.springframework.web.servlet.view.velocity.VelocityViewResolver
;
/**
* Extended version of {@link VelocityViewResolver} that uses
* {@link EmbeddedVelocityToolboxView} when the {@link #setToolboxConfigLocation(String)
* toolboxConfigLocation} is set.
*
* @author Phillip Webb
* @since 1.2.5
*/
public
class
EmbeddedVelocityViewResolver
extends
VelocityViewResolver
{
private
String
toolboxConfigLocation
;
@Override
protected
void
initApplicationContext
()
{
if
(
this
.
toolboxConfigLocation
!=
null
)
{
if
(
VelocityView
.
class
.
equals
(
getViewClass
()))
{
this
.
logger
.
info
(
"Using EmbeddedVelocityToolboxView instead of "
+
"default VelocityView due to specified toolboxConfigLocation"
);
setViewClass
(
EmbeddedVelocityToolboxView
.
class
);
}
}
super
.
initApplicationContext
();
}
@Override
public
void
setToolboxConfigLocation
(
String
toolboxConfigLocation
)
{
super
.
setToolboxConfigLocation
(
toolboxConfigLocation
);
this
.
toolboxConfigLocation
=
toolboxConfigLocation
;
}
}
spring-boot/src/main/java/org/springframework/boot/web/servlet/view/velocity/package-info.java
0 → 100644
View file @
93a7dc21
/*
* Copyright 2012-2015 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @author pwebb
*/
package
org
.
springframework
.
boot
.
web
.
servlet
.
view
.
velocity
;
\ No newline at end of file
spring-boot/src/test/java/org/springframework/boot/web/servlet/view/velocity/EmbeddedVelocityToolboxViewTests.java
0 → 100644
View file @
93a7dc21
/*
* Copyright 2012-2015 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
springframework
.
boot
.
web
.
servlet
.
view
.
velocity
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
org.apache.struts.mock.MockHttpServletRequest
;
import
org.apache.struts.mock.MockHttpServletResponse
;
import
org.apache.struts.mock.MockServletContext
;
import
org.apache.velocity.tools.ToolContext
;
import
org.junit.Test
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.web.context.support.AnnotationConfigWebApplicationContext
;
import
org.springframework.web.servlet.view.velocity.VelocityConfigurer
;
import
static
org
.
hamcrest
.
Matchers
.
contains
;
import
static
org
.
hamcrest
.
Matchers
.
notNullValue
;
import
static
org
.
junit
.
Assert
.
assertThat
;
/**
* Tests for {@link EmbeddedVelocityToolboxView}.
*
* @author Phillip Webb
*/
public
class
EmbeddedVelocityToolboxViewTests
{
private
static
final
String
PATH
=
EmbeddedVelocityToolboxViewTests
.
class
.
getPackage
().
getName
().
replace
(
"."
,
"/"
);
@Test
public
void
loadsContextFromClassPath
()
throws
Exception
{
ToolContext
context
=
getToolContext
(
PATH
+
"/toolbox.xml"
);
assertThat
(
context
.
getToolbox
().
keySet
(),
contains
(
"math"
));
}
@Test
public
void
loadsWithoutConfig
()
throws
Exception
{
ToolContext
context
=
getToolContext
(
null
);
assertThat
(
context
,
notNullValue
());
}
private
ToolContext
getToolContext
(
String
toolboxConfigLocation
)
throws
Exception
{
AnnotationConfigWebApplicationContext
context
=
new
AnnotationConfigWebApplicationContext
();
context
.
setServletContext
(
new
MockServletContext
());
context
.
register
(
Config
.
class
);
context
.
refresh
();
EmbeddedVelocityToolboxView
view
=
context
.
getBean
(
EmbeddedVelocityToolboxView
.
class
);
view
.
setToolboxConfigLocation
(
toolboxConfigLocation
);
Map
<
String
,
Object
>
model
=
new
LinkedHashMap
<
String
,
Object
>();
HttpServletRequest
request
=
new
MockHttpServletRequest
();
HttpServletResponse
response
=
new
MockHttpServletResponse
();
ToolContext
toolContext
=
(
ToolContext
)
view
.
createVelocityContext
(
model
,
request
,
response
);
context
.
close
();
return
toolContext
;
}
@Configuration
static
class
Config
{
@Bean
public
EmbeddedVelocityToolboxView
view
()
{
EmbeddedVelocityToolboxView
view
=
new
EmbeddedVelocityToolboxView
();
view
.
setUrl
(
"http://example.com"
);
return
view
;
}
@Bean
public
VelocityConfigurer
velocityConfigurer
()
{
return
new
VelocityConfigurer
();
}
}
}
spring-boot/src/test/java/org/springframework/boot/web/servlet/view/velocity/EmbeddedVelocityViewResolverTests.java
0 → 100644
View file @
93a7dc21
/*
* Copyright 2012-2015 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
springframework
.
boot
.
web
.
servlet
.
view
.
velocity
;
import
org.apache.struts.mock.MockServletContext
;
import
org.junit.Test
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.test.util.ReflectionTestUtils
;
import
org.springframework.web.context.support.AnnotationConfigWebApplicationContext
;
import
org.springframework.web.servlet.view.velocity.VelocityConfigurer
;
import
org.springframework.web.servlet.view.velocity.VelocityView
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
/**
* Tests for {@link EmbeddedVelocityViewResolver}.
*
* @author Phillip Webb
*/
public
class
EmbeddedVelocityViewResolverTests
{
@Test
public
void
standardViewWithoutToolboxConfig
()
throws
Exception
{
ApplicationContext
context
=
loadContext
(
WithoutToolboxConfig
.
class
);
EmbeddedVelocityViewResolver
resolver
=
context
.
getBean
(
EmbeddedVelocityViewResolver
.
class
);
Object
viewClass
=
ReflectionTestUtils
.
getField
(
resolver
,
"viewClass"
);
assertEquals
(
VelocityView
.
class
,
viewClass
);
}
@Test
public
void
embeddedViewWithToolboxConfig
()
throws
Exception
{
ApplicationContext
context
=
loadContext
(
WithToolboxConfig
.
class
);
EmbeddedVelocityViewResolver
resolver
=
context
.
getBean
(
EmbeddedVelocityViewResolver
.
class
);
Object
viewClass
=
ReflectionTestUtils
.
getField
(
resolver
,
"viewClass"
);
assertEquals
(
EmbeddedVelocityToolboxView
.
class
,
viewClass
);
}
private
ApplicationContext
loadContext
(
Class
<?>
config
)
{
AnnotationConfigWebApplicationContext
context
=
new
AnnotationConfigWebApplicationContext
();
context
.
setServletContext
(
new
MockServletContext
());
context
.
register
(
config
);
context
.
refresh
();
return
context
;
}
@Configuration
static
class
WithoutToolboxConfig
{
@Bean
public
EmbeddedVelocityViewResolver
resolver
()
{
return
new
EmbeddedVelocityViewResolver
();
}
@Bean
public
VelocityConfigurer
velocityConfigurer
()
{
return
new
VelocityConfigurer
();
}
}
@Configuration
static
class
WithToolboxConfig
{
@Bean
public
EmbeddedVelocityViewResolver
resolver
()
{
EmbeddedVelocityViewResolver
resolver
=
new
EmbeddedVelocityViewResolver
();
resolver
.
setToolboxConfigLocation
(
"/toolbox.xml"
);
return
resolver
;
}
@Bean
public
VelocityConfigurer
velocityConfigurer
()
{
return
new
VelocityConfigurer
();
}
}
}
spring-boot/src/test/resources/org/springframework/boot/web/servlet/view/velocity/toolbox.xml
0 → 100644
View file @
93a7dc21
<?xml version="1.0"?>
<toolbox>
<tool>
<key>
math
</key>
<scope>
application
</scope>
<class>
org.apache.velocity.tools.generic.MathTool
</class>
</tool>
</toolbox>
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