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
3fc1e443
Commit
3fc1e443
authored
Jan 12, 2015
by
Phillip Webb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish Mustache code
parent
bec5e96b
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
148 additions
and
48 deletions
+148
-48
MustacheAutoConfiguration.java
...oot/autoconfigure/mustache/MustacheAutoConfiguration.java
+4
-2
MustacheCompilerFactoryBean.java
...t/autoconfigure/mustache/MustacheCompilerFactoryBean.java
+10
-7
MustacheEnvironmentCollector.java
.../autoconfigure/mustache/MustacheEnvironmentCollector.java
+20
-0
MustacheProperties.java
...ework/boot/autoconfigure/mustache/MustacheProperties.java
+3
-2
MustacheResourceTemplateLoader.java
...utoconfigure/mustache/MustacheResourceTemplateLoader.java
+11
-12
MustacheTemplateAvailabilityProvider.java
...figure/mustache/MustacheTemplateAvailabilityProvider.java
+1
-1
MustacheView.java
...amework/boot/autoconfigure/mustache/web/MustacheView.java
+7
-4
MustacheViewResolver.java
...boot/autoconfigure/mustache/web/MustacheViewResolver.java
+15
-9
MustacheAutoConfigurationIntegrationTests.java
...e/mustache/MustacheAutoConfigurationIntegrationTests.java
+23
-2
MustacheStandaloneIntegrationTests.java
...onfigure/mustache/MustacheStandaloneIntegrationTests.java
+23
-2
MustacheViewResolverTests.java
...oot/autoconfigure/mustache/MustacheViewResolverTests.java
+3
-2
MustacheViewTests.java
...mework/boot/autoconfigure/mustache/MustacheViewTests.java
+3
-2
MustacheWebIntegrationTests.java
...t/autoconfigure/mustache/MustacheWebIntegrationTests.java
+25
-3
No files found.
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mustache/MustacheAutoConfiguration.java
View file @
3fc1e443
/*
/*
* Copyright 2013-201
4
the original author or authors.
* Copyright 2013-201
5
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.
...
@@ -19,6 +19,7 @@ package org.springframework.boot.autoconfigure.mustache;
...
@@ -19,6 +19,7 @@ package org.springframework.boot.autoconfigure.mustache;
import
javax.annotation.PostConstruct
;
import
javax.annotation.PostConstruct
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.autoconfigure.EnableAutoConfiguration
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnClass
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnClass
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication
;
...
@@ -38,9 +39,10 @@ import com.samskivert.mustache.Mustache.Compiler;
...
@@ -38,9 +39,10 @@ import com.samskivert.mustache.Mustache.Compiler;
import
com.samskivert.mustache.Mustache.TemplateLoader
;
import
com.samskivert.mustache.Mustache.TemplateLoader
;
/**
/**
* {@link EnableAutoConfiguration Auto-configuration} for Mustache.
*
* @author Dave Syer
* @author Dave Syer
* @since 1.2.2
* @since 1.2.2
*
*/
*/
@Configuration
@Configuration
@ConditionalOnClass
(
Mustache
.
class
)
@ConditionalOnClass
(
Mustache
.
class
)
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mustache/MustacheCompilerFactoryBean.java
View file @
3fc1e443
/*
/*
* Copyright 2012-201
3
the original author or authors.
* Copyright 2012-201
5
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.
...
@@ -26,23 +26,26 @@ import com.samskivert.mustache.Mustache.Formatter;
...
@@ -26,23 +26,26 @@ import com.samskivert.mustache.Mustache.Formatter;
import
com.samskivert.mustache.Mustache.TemplateLoader
;
import
com.samskivert.mustache.Mustache.TemplateLoader
;
/**
/**
* Factory for a Mustache compiler with custom strategies. For building a
* Factory for a Mustache compiler with custom strategies. For building a {@code @Bean}
* <code>@Bean</code> definition in Java it probably doesn't help to use this factory
* definition in Java it probably doesn't help to use this factory since the underlying
* since the underlying fluent API is actually richer.
* fluent API is actually richer.
*
* @see MustacheResourceTemplateLoader
*
*
* @author Dave Syer
* @author Dave Syer
* @since 1.2.2
* @since 1.2.2
*
*
@see MustacheResourceTemplateLoader
*/
*/
public
class
MustacheCompilerFactoryBean
implements
FactoryBean
<
Mustache
.
Compiler
>
{
public
class
MustacheCompilerFactoryBean
implements
FactoryBean
<
Mustache
.
Compiler
>
{
private
String
delims
;
private
String
delims
;
private
TemplateLoader
templateLoader
;
private
TemplateLoader
templateLoader
;
private
Formatter
formatter
;
private
Formatter
formatter
;
private
Escaper
escaper
;
private
Escaper
escaper
;
private
Collector
collector
;
private
Collector
collector
;
private
Compiler
compiler
;
private
Compiler
compiler
;
public
void
setDelims
(
String
delims
)
{
public
void
setDelims
(
String
delims
)
{
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mustache/MustacheEnvironmentCollector.java
View file @
3fc1e443
/*
* 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
.
autoconfigure
.
mustache
;
package
org
.
springframework
.
boot
.
autoconfigure
.
mustache
;
import
java.util.HashMap
;
import
java.util.HashMap
;
...
@@ -11,9 +27,12 @@ import org.springframework.core.env.Environment;
...
@@ -11,9 +27,12 @@ import org.springframework.core.env.Environment;
import
com.samskivert.mustache.DefaultCollector
;
import
com.samskivert.mustache.DefaultCollector
;
import
com.samskivert.mustache.Mustache
;
import
com.samskivert.mustache.Mustache
;
import
com.samskivert.mustache.Mustache.Collector
;
import
com.samskivert.mustache.Mustache.VariableFetcher
;
import
com.samskivert.mustache.Mustache.VariableFetcher
;
/**
/**
* Mustache {@link Collector} to expose properties from the Spring {@link Environment}.
*
* @author Dave Syer
* @author Dave Syer
* @since 1.2.2
* @since 1.2.2
*/
*/
...
@@ -21,6 +40,7 @@ public class MustacheEnvironmentCollector extends DefaultCollector implements
...
@@ -21,6 +40,7 @@ public class MustacheEnvironmentCollector extends DefaultCollector implements
EnvironmentAware
{
EnvironmentAware
{
private
ConfigurableEnvironment
environment
;
private
ConfigurableEnvironment
environment
;
private
Map
<
String
,
Object
>
target
;
private
Map
<
String
,
Object
>
target
;
@Override
@Override
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mustache/MustacheProperties.java
View file @
3fc1e443
/*
/*
* Copyright 2013-201
4
the original author or authors.
* Copyright 2013-201
5
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.
...
@@ -20,9 +20,10 @@ import org.springframework.boot.autoconfigure.template.AbstractViewResolverPrope
...
@@ -20,9 +20,10 @@ import org.springframework.boot.autoconfigure.template.AbstractViewResolverPrope
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
/**
/**
* {@link ConfigurationProperties} for Mustache.
*
* @author Dave Syer
* @author Dave Syer
* @since 1.2.2
* @since 1.2.2
*
*/
*/
@ConfigurationProperties
(
prefix
=
"spring.mustache"
)
@ConfigurationProperties
(
prefix
=
"spring.mustache"
)
public
class
MustacheProperties
extends
AbstractViewResolverProperties
{
public
class
MustacheProperties
extends
AbstractViewResolverProperties
{
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mustache/MustacheResourceTemplateLoader.java
View file @
3fc1e443
/*
/*
* Copyright 2012-201
3
the original author or authors.
* Copyright 2012-201
5
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.
...
@@ -32,24 +32,23 @@ import com.samskivert.mustache.Mustache.TemplateLoader;
...
@@ -32,24 +32,23 @@ import com.samskivert.mustache.Mustache.TemplateLoader;
* Resource abstraction to load a template from a file, classpath, URL etc. A
* Resource abstraction to load a template from a file, classpath, URL etc. A
* TemplateLoader is needed in the Compiler when you want to render partials (i.e.
* TemplateLoader is needed in the Compiler when you want to render partials (i.e.
* tiles-like fetaures).
* tiles-like fetaures).
*
*
* @see Mustache
* @see Resource
*
* @author Dave Syer
* @author Dave Syer
* @since 1.2.2
* @since 1.2.2
*
* @see Mustache
* @see Resource
*/
*/
public
class
MustacheResourceTemplateLoader
implements
TemplateLoader
,
ResourceLoaderAware
{
public
class
MustacheResourceTemplateLoader
implements
TemplateLoader
,
ResourceLoaderAware
{
private
String
prefix
=
""
;
private
String
prefix
=
""
;
private
String
suffix
=
""
;
private
String
suffix
=
""
;
private
String
charSet
=
"UTF-8"
;
private
String
charSet
=
"UTF-8"
;
private
ResourceLoader
resourceLoader
=
new
DefaultResourceLoader
();
private
ResourceLoader
resourceLoader
=
new
DefaultResourceLoader
();
public
MustacheResourceTemplateLoader
()
{
public
MustacheResourceTemplateLoader
()
{
}
}
...
@@ -58,7 +57,7 @@ public class MustacheResourceTemplateLoader implements TemplateLoader, ResourceL
...
@@ -58,7 +57,7 @@ public class MustacheResourceTemplateLoader implements TemplateLoader, ResourceL
this
.
prefix
=
prefix
;
this
.
prefix
=
prefix
;
this
.
suffix
=
suffix
;
this
.
suffix
=
suffix
;
}
}
/**
/**
* @param charSet the charSet to set
* @param charSet the charSet to set
*/
*/
...
@@ -76,8 +75,8 @@ public class MustacheResourceTemplateLoader implements TemplateLoader, ResourceL
...
@@ -76,8 +75,8 @@ public class MustacheResourceTemplateLoader implements TemplateLoader, ResourceL
@Override
@Override
public
Reader
getTemplate
(
String
name
)
throws
Exception
{
public
Reader
getTemplate
(
String
name
)
throws
Exception
{
return
new
InputStreamReader
(
resourceLoader
.
getResource
(
prefix
+
name
+
suffix
)
return
new
InputStreamReader
(
this
.
resourceLoader
.
getResource
(
.
getInputStream
(),
charSet
);
this
.
prefix
+
name
+
this
.
suffix
).
getInputStream
(),
this
.
charSet
);
}
}
}
}
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mustache/MustacheTemplateAvailabilityProvider.java
View file @
3fc1e443
/*
/*
* Copyright 2012-201
4
the original author or authors.
* Copyright 2012-201
5
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.
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mustache/web/MustacheView.java
View file @
3fc1e443
/*
/*
* Copyright 2012-201
3
the original author or authors.
* Copyright 2012-201
5
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,18 +21,21 @@ import java.util.Map;
...
@@ -21,18 +21,21 @@ import java.util.Map;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
org.springframework.web.servlet.View
;
import
org.springframework.web.servlet.view.AbstractTemplateView
;
import
org.springframework.web.servlet.view.AbstractTemplateView
;
import
com.samskivert.mustache.Template
;
import
com.samskivert.mustache.Template
;
/**
/**
*
@author Dave Syer
*
Spring MVC {@link View} using the Mustache template engine.
*
*
* @author Dave Syer
* @since 1.2.2
*/
*/
public
class
MustacheView
extends
AbstractTemplateView
{
public
class
MustacheView
extends
AbstractTemplateView
{
private
final
Template
template
;
private
final
Template
template
;
public
MustacheView
(
Template
template
)
{
public
MustacheView
(
Template
template
)
{
this
.
template
=
template
;
this
.
template
=
template
;
}
}
...
@@ -40,7 +43,7 @@ public class MustacheView extends AbstractTemplateView {
...
@@ -40,7 +43,7 @@ public class MustacheView extends AbstractTemplateView {
@Override
@Override
protected
void
renderMergedTemplateModel
(
Map
<
String
,
Object
>
model
,
protected
void
renderMergedTemplateModel
(
Map
<
String
,
Object
>
model
,
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
Exception
{
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
Exception
{
template
.
execute
(
model
,
response
.
getWriter
());
t
his
.
t
emplate
.
execute
(
model
,
response
.
getWriter
());
}
}
}
}
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mustache/web/MustacheViewResolver.java
View file @
3fc1e443
/*
/*
* Copyright 2012-201
3
the original author or authors.
* Copyright 2012-201
5
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.
...
@@ -23,6 +23,7 @@ import java.util.Locale;
...
@@ -23,6 +23,7 @@ import java.util.Locale;
import
org.springframework.beans.propertyeditors.LocaleEditor
;
import
org.springframework.beans.propertyeditors.LocaleEditor
;
import
org.springframework.core.io.Resource
;
import
org.springframework.core.io.Resource
;
import
org.springframework.web.servlet.View
;
import
org.springframework.web.servlet.View
;
import
org.springframework.web.servlet.ViewResolver
;
import
org.springframework.web.servlet.view.UrlBasedViewResolver
;
import
org.springframework.web.servlet.view.UrlBasedViewResolver
;
import
com.samskivert.mustache.Mustache
;
import
com.samskivert.mustache.Mustache
;
...
@@ -30,8 +31,10 @@ import com.samskivert.mustache.Mustache.Compiler;
...
@@ -30,8 +31,10 @@ import com.samskivert.mustache.Mustache.Compiler;
import
com.samskivert.mustache.Template
;
import
com.samskivert.mustache.Template
;
/**
/**
*
@author Dave Syer
*
Spring MVC {@link ViewResolver} for Mustache.
*
*
* @author Dave Syer
* @since 1.2.2
*/
*/
public
class
MustacheViewResolver
extends
UrlBasedViewResolver
{
public
class
MustacheViewResolver
extends
UrlBasedViewResolver
{
...
@@ -61,17 +64,20 @@ public class MustacheViewResolver extends UrlBasedViewResolver {
...
@@ -61,17 +64,20 @@ public class MustacheViewResolver extends UrlBasedViewResolver {
}
}
private
Template
createTemplate
(
Resource
resource
)
throws
IOException
{
private
Template
createTemplate
(
Resource
resource
)
throws
IOException
{
return
compiler
.
compile
(
new
InputStreamReader
(
resource
.
getInputStream
()));
return
this
.
compiler
.
compile
(
new
InputStreamReader
(
resource
.
getInputStream
()));
}
}
private
Resource
resolveResource
(
String
viewName
,
Locale
locale
)
{
private
Resource
resolveResource
(
String
viewName
,
Locale
locale
)
{
String
l10n
=
""
;
return
resolveFromLocale
(
viewName
,
getLocale
(
locale
));
if
(
locale
!=
null
)
{
}
LocaleEditor
localeEditor
=
new
LocaleEditor
();
localeEditor
.
setValue
(
locale
);
private
String
getLocale
(
Locale
locale
)
{
l10n
=
"_"
+
localeEditor
.
getAsText
();
if
(
locale
==
null
)
{
return
""
;
}
}
return
resolveFromLocale
(
viewName
,
l10n
);
LocaleEditor
localeEditor
=
new
LocaleEditor
();
localeEditor
.
setValue
(
locale
);
return
"_"
+
localeEditor
.
getAsText
();
}
}
private
Resource
resolveFromLocale
(
String
viewName
,
String
locale
)
{
private
Resource
resolveFromLocale
(
String
viewName
,
String
locale
)
{
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mustache/
AutoApplic
ationTests.java
→
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mustache/
MustacheAutoConfigurationIntegr
ationTests.java
View file @
3fc1e443
/*
* 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
.
autoconfigure
.
mustache
;
package
org
.
springframework
.
boot
.
autoconfigure
.
mustache
;
import
java.lang.annotation.Documented
;
import
java.lang.annotation.Documented
;
...
@@ -14,7 +30,7 @@ import org.junit.runner.RunWith;
...
@@ -14,7 +30,7 @@ import org.junit.runner.RunWith;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration
;
import
org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration
;
import
org.springframework.boot.autoconfigure.mustache.
AutoApplic
ationTests.Application
;
import
org.springframework.boot.autoconfigure.mustache.
MustacheAutoConfigurationIntegr
ationTests.Application
;
import
org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration
;
import
org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration
;
import
org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration
;
import
org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration
;
import
org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration
;
import
org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration
;
...
@@ -31,12 +47,17 @@ import org.springframework.web.bind.annotation.RequestMapping;
...
@@ -31,12 +47,17 @@ import org.springframework.web.bind.annotation.RequestMapping;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
/**
* Integration tests for {@link MustacheAutoConfiguration}.
*
* @author Dave Syer
*/
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@SpringApplicationConfiguration
(
classes
=
Application
.
class
)
@SpringApplicationConfiguration
(
classes
=
Application
.
class
)
@IntegrationTest
({
"server.port:0"
,
@IntegrationTest
({
"server.port:0"
,
"spring.mustache.prefix:classpath:/mustache-templates/"
})
"spring.mustache.prefix:classpath:/mustache-templates/"
})
@WebAppConfiguration
@WebAppConfiguration
public
class
AutoApplic
ationTests
{
public
class
MustacheAutoConfigurationIntegr
ationTests
{
@Autowired
@Autowired
private
EmbeddedWebApplicationContext
context
;
private
EmbeddedWebApplicationContext
context
;
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mustache/Mustache
TemplateStandalone
Tests.java
→
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mustache/Mustache
StandaloneIntegration
Tests.java
View file @
3fc1e443
/*
* 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
.
autoconfigure
.
mustache
;
package
org
.
springframework
.
boot
.
autoconfigure
.
mustache
;
import
java.util.Collections
;
import
java.util.Collections
;
...
@@ -6,7 +22,7 @@ import org.junit.Test;
...
@@ -6,7 +22,7 @@ import org.junit.Test;
import
org.junit.runner.RunWith
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration
;
import
org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration
;
import
org.springframework.boot.autoconfigure.mustache.Mustache
TemplateStandalone
Tests.Application
;
import
org.springframework.boot.autoconfigure.mustache.Mustache
StandaloneIntegration
Tests.Application
;
import
org.springframework.boot.test.IntegrationTest
;
import
org.springframework.boot.test.IntegrationTest
;
import
org.springframework.boot.test.SpringApplicationConfiguration
;
import
org.springframework.boot.test.SpringApplicationConfiguration
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
...
@@ -17,10 +33,15 @@ import com.samskivert.mustache.Mustache;
...
@@ -17,10 +33,15 @@ import com.samskivert.mustache.Mustache;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
/**
* Integration Tests for {@link MustacheAutoConfiguration} outside of a web application.
*
* @author Dave Syer
*/
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@SpringApplicationConfiguration
(
classes
=
Application
.
class
)
@SpringApplicationConfiguration
(
classes
=
Application
.
class
)
@IntegrationTest
({
"spring.main.web_environment=false"
,
"env.foo=Heaven"
,
"foo=World"
})
@IntegrationTest
({
"spring.main.web_environment=false"
,
"env.foo=Heaven"
,
"foo=World"
})
public
class
Mustache
TemplateStandalone
Tests
{
public
class
Mustache
StandaloneIntegration
Tests
{
@Autowired
@Autowired
private
Mustache
.
Compiler
compiler
;
private
Mustache
.
Compiler
compiler
;
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mustache/MustacheViewResolverTests.java
View file @
3fc1e443
/*
/*
* Copyright 2012-201
3
the original author or authors.
* Copyright 2012-201
5
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.
...
@@ -28,8 +28,9 @@ import static org.junit.Assert.assertNotNull;
...
@@ -28,8 +28,9 @@ import static org.junit.Assert.assertNotNull;
import
static
org
.
junit
.
Assert
.
assertNull
;
import
static
org
.
junit
.
Assert
.
assertNull
;
/**
/**
*
@author Dave Syer
*
Tests for {@link MustacheViewResolver}.
*
*
* @author Dave Syer
*/
*/
public
class
MustacheViewResolverTests
{
public
class
MustacheViewResolverTests
{
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mustache/MustacheViewTests.java
View file @
3fc1e443
/*
/*
* Copyright 2012-201
3
the original author or authors.
* Copyright 2012-201
5
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.
...
@@ -32,8 +32,9 @@ import com.samskivert.mustache.Mustache;
...
@@ -32,8 +32,9 @@ import com.samskivert.mustache.Mustache;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
/**
/**
*
@author Dave Syer
*
Tests for {@link MustacheView}.
*
*
* @author Dave Syer
*/
*/
public
class
MustacheViewTests
{
public
class
MustacheViewTests
{
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mustache/
Applic
ationTests.java
→
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mustache/
MustacheWebIntegr
ationTests.java
View file @
3fc1e443
/*
* 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
.
autoconfigure
.
mustache
;
package
org
.
springframework
.
boot
.
autoconfigure
.
mustache
;
import
java.lang.annotation.Documented
;
import
java.lang.annotation.Documented
;
...
@@ -15,8 +31,8 @@ import org.junit.runner.RunWith;
...
@@ -15,8 +31,8 @@ import org.junit.runner.RunWith;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration
;
import
org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration
;
import
org.springframework.boot.autoconfigure.mustache.Mustache
ResourceTemplateLoader
;
import
org.springframework.boot.autoconfigure.mustache.Mustache
WebIntegrationTests.Application
;
import
org.springframework.boot.autoconfigure.mustache.
ApplicationTests.Application
;
import
org.springframework.boot.autoconfigure.mustache.
web.MustacheView
;
import
org.springframework.boot.autoconfigure.mustache.web.MustacheViewResolver
;
import
org.springframework.boot.autoconfigure.mustache.web.MustacheViewResolver
;
import
org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration
;
import
org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration
;
import
org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration
;
import
org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration
;
...
@@ -39,11 +55,17 @@ import com.samskivert.mustache.Template;
...
@@ -39,11 +55,17 @@ import com.samskivert.mustache.Template;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
/**
* Integration Tests for {@link MustacheAutoConfiguration}, {@link MustacheViewResolver}
* and {@link MustacheView}.
*
* @author Dave Syer
*/
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@SpringApplicationConfiguration
(
classes
=
Application
.
class
)
@SpringApplicationConfiguration
(
classes
=
Application
.
class
)
@IntegrationTest
(
"server.port:0"
)
@IntegrationTest
(
"server.port:0"
)
@WebAppConfiguration
@WebAppConfiguration
public
class
Applic
ationTests
{
public
class
MustacheWebIntegr
ationTests
{
@Autowired
@Autowired
private
EmbeddedWebApplicationContext
context
;
private
EmbeddedWebApplicationContext
context
;
...
...
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