Polish
This commit is contained in:
@@ -114,7 +114,7 @@ public class BasicBatchConfigurer implements BatchConfigurer {
|
||||
}
|
||||
factory.setTransactionManager(getTransactionManager());
|
||||
factory.afterPropertiesSet();
|
||||
return (JobRepository) factory.getObject();
|
||||
return factory.getObject();
|
||||
}
|
||||
|
||||
protected PlatformTransactionManager createTransactionManager() {
|
||||
|
||||
@@ -37,7 +37,7 @@ import org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguratio
|
||||
* Once in effect, the auto-configuration is the equivalent of importing the
|
||||
* {@link RepositoryRestMvcConfiguration}.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @author Rob Winch
|
||||
* @since 1.1.0
|
||||
*/
|
||||
|
||||
@@ -28,7 +28,6 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnNotWebApplication;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
|
||||
import org.springframework.boot.autoconfigure.template.TemplateViewResolverConfigurer;
|
||||
import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
@@ -45,7 +44,7 @@ import org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver;
|
||||
|
||||
/**
|
||||
* {@link EnableAutoConfiguration Auto-configuration} for FreeMarker.
|
||||
*
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
* @author Dave Syer
|
||||
* @since 1.1.0
|
||||
@@ -67,12 +66,10 @@ public class FreeMarkerAutoConfiguration {
|
||||
if (this.properties.isCheckTemplateLocation()) {
|
||||
Resource resource = this.resourceLoader.getResource(this.properties
|
||||
.getTemplateLoaderPath());
|
||||
Assert.state(
|
||||
resource.exists(),
|
||||
"Cannot find template location: "
|
||||
+ resource
|
||||
+ " (please add some templates, check your FreeMarker configuration, or set "
|
||||
+ "spring.freemarker.checkTemplateLocation=false)");
|
||||
Assert.state(resource.exists(), "Cannot find template location: " + resource
|
||||
+ " (please add some templates, "
|
||||
+ "check your FreeMarker configuration, or set "
|
||||
+ "spring.freemarker.checkTemplateLocation=false)");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,8 +125,7 @@ public class FreeMarkerAutoConfiguration {
|
||||
@ConditionalOnMissingBean(name = "freeMarkerViewResolver")
|
||||
public FreeMarkerViewResolver freeMarkerViewResolver() {
|
||||
FreeMarkerViewResolver resolver = new FreeMarkerViewResolver();
|
||||
new TemplateViewResolverConfigurer().configureTemplateViewResolver(resolver,
|
||||
this.properties);
|
||||
this.properties.applyToViewResolver(resolver);
|
||||
return resolver;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2013 the original author or authors.
|
||||
* Copyright 2012-2014 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.
|
||||
@@ -21,13 +21,13 @@ import java.util.Map;
|
||||
|
||||
import org.springframework.boot.autoconfigure.template.AbstractTemplateViewResolverProperties;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver;
|
||||
|
||||
/**
|
||||
* {@link ConfigurationProperties} for configuring FreeMarker
|
||||
*
|
||||
*
|
||||
* @author Dave Syer
|
||||
* @author Andy Wilkinson
|
||||
*
|
||||
* @since 1.1.0
|
||||
*/
|
||||
@ConfigurationProperties(prefix = "spring.freemarker")
|
||||
@@ -62,4 +62,12 @@ public class FreeMarkerProperties extends AbstractTemplateViewResolverProperties
|
||||
public void setTemplateLoaderPath(String templateLoaderPath) {
|
||||
this.templateLoaderPath = templateLoaderPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply the given properties to a {@link FreeMarkerViewResolver}.
|
||||
* @param resolver the resolver to apply the properties to.
|
||||
*/
|
||||
public void applyToViewResolver(FreeMarkerViewResolver resolver) {
|
||||
super.applyToViewResolver(resolver);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2013 the original author or authors.
|
||||
* Copyright 2012-2014 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.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2013 the original author or authors.
|
||||
* Copyright 2012-2014 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.
|
||||
@@ -22,6 +22,8 @@ import java.util.Map;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
* {@link ConfigurationProperties} for configuring Groovy templates.
|
||||
*
|
||||
* @author Dave Syer
|
||||
* @since 1.1.0
|
||||
*/
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2003-2012 the original author or authors.
|
||||
* Copyright 2012-2014 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.
|
||||
@@ -18,38 +18,43 @@ package org.springframework.boot.autoconfigure.groovy.template;
|
||||
import groovy.text.markup.MarkupTemplateEngine;
|
||||
import groovy.text.markup.TemplateConfiguration;
|
||||
import groovy.text.markup.TemplateResolver;
|
||||
import org.springframework.context.i18n.LocaleContextHolder;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
|
||||
import org.springframework.context.i18n.LocaleContextHolder;
|
||||
|
||||
/**
|
||||
* A custom {@link groovy.text.markup.TemplateResolver template resolver} which resolves templates using the locale
|
||||
* found in the thread locale. This resolver ignores the template engine configuration locale.
|
||||
*
|
||||
* A custom {@link groovy.text.markup.TemplateResolver template resolver} which resolves
|
||||
* templates using the locale found in the thread locale. This resolver ignores the
|
||||
* template engine configuration locale.
|
||||
*
|
||||
* @author Cédric Champeau
|
||||
* @since 1.1.0
|
||||
*/
|
||||
|
||||
public class GroovyTemplateResolver implements TemplateResolver {
|
||||
private ClassLoader templateClassLoader;
|
||||
private ClassLoader templateClassLoader;
|
||||
|
||||
@Override
|
||||
public void configure(final ClassLoader templateClassLoader, final TemplateConfiguration configuration) {
|
||||
this.templateClassLoader = templateClassLoader;
|
||||
}
|
||||
@Override
|
||||
public void configure(final ClassLoader templateClassLoader,
|
||||
final TemplateConfiguration configuration) {
|
||||
this.templateClassLoader = templateClassLoader;
|
||||
}
|
||||
|
||||
@Override
|
||||
public URL resolveTemplate(final String templatePath) throws IOException {
|
||||
MarkupTemplateEngine.TemplateResource templateResource = MarkupTemplateEngine.TemplateResource.parse(templatePath);
|
||||
URL resource = templateClassLoader.getResource(templateResource.withLocale(LocaleContextHolder.getLocale().toString().replace("-", "_")).toString());
|
||||
if (resource == null) {
|
||||
// no resource found with the default locale, try without any locale
|
||||
resource = templateClassLoader.getResource(templateResource.withLocale(null).toString());
|
||||
}
|
||||
if (resource == null) {
|
||||
throw new IOException("Unable to load template:" + templatePath);
|
||||
}
|
||||
return resource;
|
||||
}
|
||||
@Override
|
||||
public URL resolveTemplate(final String templatePath) throws IOException {
|
||||
MarkupTemplateEngine.TemplateResource templateResource = MarkupTemplateEngine.TemplateResource
|
||||
.parse(templatePath);
|
||||
URL resource = this.templateClassLoader.getResource(templateResource.withLocale(
|
||||
LocaleContextHolder.getLocale().toString().replace("-", "_")).toString());
|
||||
if (resource == null) {
|
||||
// no resource found with the default locale, try without any locale
|
||||
resource = this.templateClassLoader.getResource(templateResource.withLocale(
|
||||
null).toString());
|
||||
}
|
||||
if (resource == null) {
|
||||
throw new IOException("Unable to load template:" + templatePath);
|
||||
}
|
||||
return resource;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,9 +21,9 @@ import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.integration.config.EnableIntegration;
|
||||
|
||||
/**
|
||||
* {@link org.springframework.boot.autoconfigure.EnableAutoConfiguration Auto-configuration}
|
||||
* for Spring Integration.
|
||||
*
|
||||
* {@link org.springframework.boot.autoconfigure.EnableAutoConfiguration
|
||||
* Auto-configuration} for Spring Integration.
|
||||
*
|
||||
* @author Artem Bilan
|
||||
* @since 1.1
|
||||
*/
|
||||
|
||||
@@ -13,8 +13,10 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.autoconfigure.jdbc;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -22,7 +24,7 @@ import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Provides JDBC driver class name for given JDBC URL.
|
||||
*
|
||||
*
|
||||
* @author Maciej Walkowiak
|
||||
* @since 1.1.0
|
||||
*/
|
||||
@@ -30,50 +32,39 @@ class DriverClassNameProvider {
|
||||
|
||||
private static final String JDBC_URL_PREFIX = "jdbc";
|
||||
|
||||
private static final Map<String, String> driverMap = new HashMap<String, String>() {
|
||||
{
|
||||
put("db2", "com.ibm.db2.jcc.DB2Driver");
|
||||
put("derby", "org.apache.derby.jdbc.EmbeddedDriver");
|
||||
put("h2", "org.h2.Driver");
|
||||
put("hsqldb", "org.hsqldb.jdbcDriver");
|
||||
put("sqlite", "org.sqlite.JDBC");
|
||||
put("mysql", "com.mysql.jdbc.Driver");
|
||||
put("mariadb", "org.mariadb.jdbc.Driver");
|
||||
put("google", "com.google.appengine.api.rdbms.AppEngineDriver");
|
||||
put("oracle", "oracle.jdbc.OracleDriver");
|
||||
put("postgresql", "org.postgresql.Driver");
|
||||
put("jtds", "net.sourceforge.jtds.jdbc.Driver");
|
||||
put("sqlserver", "com.microsoft.sqlserver.jdbc.SQLServerDriver");
|
||||
|
||||
}
|
||||
};
|
||||
private static final Map<String, String> DRIVERS;
|
||||
static {
|
||||
Map<String, String> drivers = new HashMap<String, String>();
|
||||
drivers.put("derby", "org.apache.derby.jdbc.EmbeddedDriver");
|
||||
drivers.put("h2", "org.h2.Driver");
|
||||
drivers.put("hsqldb", "org.hsqldb.jdbcDriver");
|
||||
drivers.put("sqlite", "org.sqlite.JDBC");
|
||||
drivers.put("mysql", "com.mysql.jdbc.Driver");
|
||||
drivers.put("mariadb", "org.mariadb.jdbc.Driver");
|
||||
drivers.put("google", "com.google.appengine.api.rdbms.AppEngineDriver");
|
||||
drivers.put("oracle", "oracle.jdbc.OracleDriver");
|
||||
drivers.put("postgresql", "org.postgresql.Driver");
|
||||
drivers.put("jtds", "net.sourceforge.jtds.jdbc.Driver");
|
||||
drivers.put("sqlserver", "com.microsoft.sqlserver.jdbc.SQLServerDriver");
|
||||
DRIVERS = Collections.unmodifiableMap(drivers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to find JDBC driver class name based on given JDBC URL
|
||||
*
|
||||
* Find a JDBC driver class name based on given JDBC URL
|
||||
* @param jdbcUrl JDBC URL
|
||||
* @return driver class name or null if not found
|
||||
*/
|
||||
String getDriverClassName(final String jdbcUrl) {
|
||||
Assert.notNull(jdbcUrl, "JDBC URL cannot be null");
|
||||
|
||||
if (!jdbcUrl.startsWith(JDBC_URL_PREFIX)) {
|
||||
throw new IllegalArgumentException("JDBC URL should start with '"
|
||||
+ JDBC_URL_PREFIX + "'");
|
||||
}
|
||||
|
||||
Assert.notNull(jdbcUrl, "JdbcUrl must not be null");
|
||||
Assert.isTrue(jdbcUrl.startsWith(JDBC_URL_PREFIX), "JdbcUrl must start with '"
|
||||
+ JDBC_URL_PREFIX + "'");
|
||||
String urlWithoutPrefix = jdbcUrl.substring(JDBC_URL_PREFIX.length());
|
||||
String result = null;
|
||||
|
||||
for (Map.Entry<String, String> driver : driverMap.entrySet()) {
|
||||
for (Map.Entry<String, String> driver : DRIVERS.entrySet()) {
|
||||
if (urlWithoutPrefix.startsWith(":" + driver.getKey() + ":")) {
|
||||
result = driver.getValue();
|
||||
|
||||
break;
|
||||
return driver.getValue();
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ import com.mongodb.MongoClientOptions;
|
||||
|
||||
/**
|
||||
* {@link EnableAutoConfiguration Auto-configuration} for Mongo.
|
||||
*
|
||||
*
|
||||
* @author Dave Syer
|
||||
* @author Oliver Gierke
|
||||
* @author Phillip Webb
|
||||
|
||||
@@ -71,8 +71,6 @@ public class EntityManagerFactoryBuilder {
|
||||
|
||||
/**
|
||||
* An optional callback for new entity manager factory beans.
|
||||
*
|
||||
* @author Dave Syer
|
||||
*/
|
||||
public void setCallback(EntityManagerFactoryBeanCallback callback) {
|
||||
this.callback = callback;
|
||||
@@ -171,8 +169,6 @@ public class EntityManagerFactoryBuilder {
|
||||
|
||||
/**
|
||||
* A callback for new entity manager factory beans created by a Builder.
|
||||
*
|
||||
* @author Dave Syer
|
||||
*/
|
||||
public static interface EntityManagerFactoryBeanCallback {
|
||||
|
||||
|
||||
@@ -128,8 +128,8 @@ public class AuthenticationManagerConfiguration extends
|
||||
|
||||
User user = AuthenticationManagerConfiguration.this.security.getUser();
|
||||
if (user.isDefaultPassword()) {
|
||||
logger.info("\n\nUsing default security password: "
|
||||
+ user.getPassword() + "\n\n");
|
||||
logger.info("\n\nUsing default security password: " + user.getPassword()
|
||||
+ "\n\n");
|
||||
}
|
||||
|
||||
this.defaultAuth = new AuthenticationManagerBuilder(
|
||||
|
||||
@@ -17,12 +17,13 @@
|
||||
package org.springframework.boot.autoconfigure.template;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.web.servlet.view.AbstractTemplateViewResolver;
|
||||
|
||||
/**
|
||||
* Abstract base class for {@link ConfigurationProperties} for
|
||||
* {@link AbstractTemplateViewResolver view resolvers}.
|
||||
*
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
* @since 1.1.0
|
||||
*/
|
||||
@@ -155,4 +156,25 @@ public abstract class AbstractTemplateViewResolverProperties {
|
||||
public void setExposeSpringMacroHelpers(boolean exposeSpringMacroHelpers) {
|
||||
this.exposeSpringMacroHelpers = exposeSpringMacroHelpers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply the given properties to a {@link AbstractTemplateViewResolver}.
|
||||
* @param resolver the resolver to apply the properties to.
|
||||
*/
|
||||
protected void applyToViewResolver(AbstractTemplateViewResolver resolver) {
|
||||
resolver.setPrefix(getPrefix());
|
||||
resolver.setSuffix(getSuffix());
|
||||
resolver.setCache(isCache());
|
||||
resolver.setContentType(getContentType());
|
||||
resolver.setViewNames(getViewNames());
|
||||
resolver.setExposeRequestAttributes(isExposeRequestAttributes());
|
||||
resolver.setAllowRequestOverride(isAllowRequestOverride());
|
||||
resolver.setExposeSessionAttributes(isExposeSessionAttributes());
|
||||
resolver.setExposeSpringMacroHelpers(isExposeSpringMacroHelpers());
|
||||
resolver.setRequestContextAttribute(getRequestContextAttribute());
|
||||
// The resolver usually acts as a fallback resolver (e.g. like a
|
||||
// InternalResourceViewResolver) so it needs to have low precedence
|
||||
resolver.setOrder(Ordered.LOWEST_PRECEDENCE - 5);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2014 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.template;
|
||||
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.web.servlet.view.AbstractTemplateViewResolver;
|
||||
|
||||
/**
|
||||
* Helper class for use by configuration classes that provide an
|
||||
* {@link AbstractTemplateViewResolver} bean.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
public class TemplateViewResolverConfigurer {
|
||||
|
||||
/**
|
||||
* Configures the {@code resolver} using the given {@code properties} and defaults.
|
||||
*
|
||||
* @param resolver The resolver to configure
|
||||
* @param properties The properties to use to configure the resolver
|
||||
*/
|
||||
public void configureTemplateViewResolver(AbstractTemplateViewResolver resolver,
|
||||
AbstractTemplateViewResolverProperties properties) {
|
||||
|
||||
resolver.setPrefix(properties.getPrefix());
|
||||
resolver.setSuffix(properties.getSuffix());
|
||||
resolver.setCache(properties.isCache());
|
||||
resolver.setContentType(properties.getContentType());
|
||||
resolver.setViewNames(properties.getViewNames());
|
||||
resolver.setExposeRequestAttributes(properties.isExposeRequestAttributes());
|
||||
resolver.setAllowRequestOverride(properties.isAllowRequestOverride());
|
||||
resolver.setExposeSessionAttributes(properties.isExposeSessionAttributes());
|
||||
resolver.setExposeSpringMacroHelpers(properties.isExposeSpringMacroHelpers());
|
||||
resolver.setRequestContextAttribute(properties.getRequestContextAttribute());
|
||||
|
||||
// This resolver acts as a fallback resolver (e.g. like a
|
||||
// InternalResourceViewResolver) so it needs to have low precedence
|
||||
resolver.setOrder(Ordered.LOWEST_PRECEDENCE - 5);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -50,7 +50,7 @@ import org.thymeleaf.templateresolver.TemplateResolver;
|
||||
|
||||
/**
|
||||
* {@link EnableAutoConfiguration Auto-configuration} for Thymeleaf.
|
||||
*
|
||||
*
|
||||
* @author Dave Syer
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
|
||||
@@ -31,7 +31,6 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnNotWebApplication;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
|
||||
import org.springframework.boot.autoconfigure.template.TemplateViewResolverConfigurer;
|
||||
import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
@@ -48,7 +47,7 @@ import org.springframework.web.servlet.view.velocity.VelocityViewResolver;
|
||||
|
||||
/**
|
||||
* {@link EnableAutoConfiguration Auto-configuration} for Velocity.
|
||||
*
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
* @since 1.1.0
|
||||
*/
|
||||
@@ -69,11 +68,9 @@ public class VelocityAutoConfiguration {
|
||||
if (this.properties.isCheckTemplateLocation()) {
|
||||
Resource resource = this.resourceLoader.getResource(this.properties
|
||||
.getResourceLoaderPath());
|
||||
Assert.state(
|
||||
resource.exists(),
|
||||
"Cannot find template location: "
|
||||
+ resource
|
||||
+ " (please add some templates, check your Velocity configuration, or set spring.velocity.checkTemplateLocation=false)");
|
||||
Assert.state(resource.exists(), "Cannot find template location: " + resource
|
||||
+ " (please add some templates, check your Velocity configuration, "
|
||||
+ "or set spring.velocity.checkTemplateLocation=false)");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,6 +85,7 @@ public class VelocityAutoConfiguration {
|
||||
velocityProperties.putAll(this.properties.getProperties());
|
||||
factory.setVelocityProperties(velocityProperties);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@@ -127,12 +125,10 @@ public class VelocityAutoConfiguration {
|
||||
@ConditionalOnMissingBean(name = "velocityViewResolver")
|
||||
public VelocityViewResolver velocityViewResolver() {
|
||||
VelocityViewResolver resolver = new VelocityViewResolver();
|
||||
new TemplateViewResolverConfigurer().configureTemplateViewResolver(resolver,
|
||||
this.properties);
|
||||
resolver.setToolboxConfigLocation(this.properties.getToolboxConfigLocation());
|
||||
resolver.setDateToolAttribute(this.properties.getDateToolAttribute());
|
||||
resolver.setNumberToolAttribute(this.properties.getNumberToolAttribute());
|
||||
this.properties.applyToViewResolver(resolver);
|
||||
return resolver;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,12 +21,12 @@ import java.util.Map;
|
||||
|
||||
import org.springframework.boot.autoconfigure.template.AbstractTemplateViewResolverProperties;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.web.servlet.view.velocity.VelocityViewResolver;
|
||||
|
||||
/**
|
||||
* {@link ConfigurationProperties} for configuring Velocity
|
||||
*
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*
|
||||
* @since 1.1.0
|
||||
*/
|
||||
@ConfigurationProperties(prefix = "spring.velocity")
|
||||
@@ -91,4 +91,16 @@ public class VelocityProperties extends AbstractTemplateViewResolverProperties {
|
||||
public void setToolboxConfigLocation(String toolboxConfigLocation) {
|
||||
this.toolboxConfigLocation = toolboxConfigLocation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply the given properties to a {@link VelocityViewResolver}.
|
||||
* @param resolver the resolver to apply the properties to.
|
||||
*/
|
||||
public void applyToViewResolver(VelocityViewResolver resolver) {
|
||||
super.applyToViewResolver(resolver);
|
||||
resolver.setToolboxConfigLocation(getToolboxConfigLocation());
|
||||
resolver.setDateToolAttribute(getDateToolAttribute());
|
||||
resolver.setNumberToolAttribute(getNumberToolAttribute());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.springframework.util.ClassUtils;
|
||||
/**
|
||||
* {@link TemplateAvailabilityProvider} that provides availability information for
|
||||
* Velocity view templates
|
||||
*
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
* @since 1.1.0
|
||||
*/
|
||||
|
||||
@@ -231,7 +231,7 @@ public class BatchAutoConfigurationTests {
|
||||
public JobRepository getJobRepository() throws Exception {
|
||||
if (this.jobRepository == null) {
|
||||
this.factory.afterPropertiesSet();
|
||||
this.jobRepository = (JobRepository) this.factory.getObject();
|
||||
this.jobRepository = this.factory.getObject();
|
||||
}
|
||||
return this.jobRepository;
|
||||
}
|
||||
|
||||
@@ -16,13 +16,12 @@
|
||||
|
||||
package org.springframework.boot.autoconfigure.integration;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.integration.support.channel.HeaderChannelRegistry;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
* @since 1.1
|
||||
|
||||
@@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2012-2014 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.jdbc;
|
||||
|
||||
import org.junit.Test;
|
||||
@@ -6,7 +22,7 @@ import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Tests for {@link DataSourceProperties}.
|
||||
*
|
||||
*
|
||||
* @author Maciej Walkowiak
|
||||
*/
|
||||
public class DataSourcePropertiesTests {
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2014 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.jdbc;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
/**
|
||||
* Tests for {@link DriverClassNameProvider}.
|
||||
*
|
||||
* @author Maciej Walkowiak
|
||||
*/
|
||||
public class DriverClassNameProviderTest {
|
||||
private DriverClassNameProvider driverClassNameProvider = new DriverClassNameProvider();
|
||||
|
||||
@Test
|
||||
public void testGettingClassNameForKnownDatabase() {
|
||||
String driverClassName = driverClassNameProvider.getDriverClassName("jdbc:postgresql://hostname/dbname");
|
||||
|
||||
assertEquals("org.postgresql.Driver", driverClassName);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReturnsNullForUnknownDatabase() {
|
||||
String driverClassName = driverClassNameProvider.getDriverClassName("jdbc:unknowndb://hostname/dbname");
|
||||
|
||||
assertNull(driverClassName);
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testFailureOnNullJdbcUrl() {
|
||||
driverClassNameProvider.getDriverClassName(null);
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testFailureOnMalformedJdbcUrl() {
|
||||
driverClassNameProvider.getDriverClassName("malformed:url");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright 2012-2014 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.jdbc;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
/**
|
||||
* Tests for {@link DriverClassNameProvider}.
|
||||
*
|
||||
* @author Maciej Walkowiak
|
||||
*/
|
||||
public class DriverClassNameProviderTests {
|
||||
|
||||
private DriverClassNameProvider provider = new DriverClassNameProvider();
|
||||
|
||||
@Rule
|
||||
public ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
@Test
|
||||
public void classNameForKnownDatabase() {
|
||||
String driverClassName = this.provider
|
||||
.getDriverClassName("jdbc:postgresql://hostname/dbname");
|
||||
assertEquals("org.postgresql.Driver", driverClassName);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nullForUnknownDatabase() {
|
||||
String driverClassName = this.provider
|
||||
.getDriverClassName("jdbc:unknowndb://hostname/dbname");
|
||||
assertNull(driverClassName);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void failureOnNullJdbcUrl() {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("JdbcUrl must not be null");
|
||||
this.provider.getDriverClassName(null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void failureOnMalformedJdbcUrl() {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("JdbcUrl must start with");
|
||||
this.provider.getDriverClassName("malformed:url");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2013 the original author or authors.
|
||||
* Copyright 2012-2014 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.
|
||||
@@ -29,6 +29,8 @@ import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* Tests for {@link EntityManagerFactoryBuilder}.
|
||||
*
|
||||
* @author Dave Syer
|
||||
*/
|
||||
public class EntityManagerFactoryBuilderTests {
|
||||
|
||||
@@ -47,7 +47,7 @@ import static org.junit.Assert.assertThat;
|
||||
|
||||
/**
|
||||
* Tests for {@link VelocityAutoConfiguration}.
|
||||
*
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
public class VelocityAutoConfigurationTests {
|
||||
|
||||
@@ -27,7 +27,7 @@ import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* Tests for {@link VelocityTemplateAvailabilityProvider}.
|
||||
*
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
public class VelocityTemplateAvailabilityProviderTests {
|
||||
|
||||
Reference in New Issue
Block a user