Polish
This commit is contained in:
parent
e40acd81e4
commit
8bcda1bcbe
|
|
@ -61,7 +61,7 @@ import org.springframework.web.servlet.handler.AbstractHandlerMethodMapping;
|
|||
/**
|
||||
* {@link EnableAutoConfiguration Auto-configuration} for common management
|
||||
* {@link Endpoint}s.
|
||||
*
|
||||
*
|
||||
* @author Dave Syer
|
||||
* @author Phillip Webb
|
||||
* @author Greg Turnquist
|
||||
|
|
|
|||
|
|
@ -47,15 +47,15 @@ import org.springframework.data.redis.connection.RedisConnectionFactory;
|
|||
|
||||
/**
|
||||
* {@link EnableAutoConfiguration Auto-configuration} for {@link HealthIndicator}s.
|
||||
*
|
||||
*
|
||||
* @author Christian Dupuis
|
||||
* @since 1.1.0
|
||||
*/
|
||||
@Configuration
|
||||
@AutoConfigureBefore({ EndpointAutoConfiguration.class })
|
||||
@AutoConfigureAfter({ DataSourceAutoConfiguration.class, MongoAutoConfiguration.class,
|
||||
MongoDataAutoConfiguration.class, RedisAutoConfiguration.class,
|
||||
RabbitAutoConfiguration.class })
|
||||
MongoDataAutoConfiguration.class, RedisAutoConfiguration.class,
|
||||
RabbitAutoConfiguration.class })
|
||||
public class HealthIndicatorAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ import org.springframework.util.Assert;
|
|||
|
||||
/**
|
||||
* {@link Endpoint} to expose application health.
|
||||
*
|
||||
*
|
||||
* @author Dave Syer
|
||||
* @author Christian Dupuis
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ import org.springframework.util.StringUtils;
|
|||
/**
|
||||
* Default implementation of {@link PublicMetrics} that exposes all metrics from a
|
||||
* {@link MetricReader} along with memory information.
|
||||
*
|
||||
*
|
||||
* @author Dave Syer
|
||||
* @author Christian Dupuis
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -35,7 +35,8 @@ import org.springframework.util.StringUtils;
|
|||
*
|
||||
* @author Dave Syer
|
||||
*/
|
||||
public class SimpleDataSourceHealthIndicator implements HealthIndicator<Map<String, Object>> {
|
||||
public class SimpleDataSourceHealthIndicator implements
|
||||
HealthIndicator<Map<String, Object>> {
|
||||
|
||||
private DataSource dataSource;
|
||||
|
||||
|
|
@ -61,7 +62,8 @@ public class SimpleDataSourceHealthIndicator implements HealthIndicator<Map<Stri
|
|||
}
|
||||
|
||||
/**
|
||||
* Create a new {@link SimpleDataSourceHealthIndicator} using the specified datasource.
|
||||
* Create a new {@link SimpleDataSourceHealthIndicator} using the specified
|
||||
* datasource.
|
||||
* @param dataSource the data source
|
||||
*/
|
||||
public SimpleDataSourceHealthIndicator(DataSource dataSource) {
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ import static org.junit.Assert.assertTrue;
|
|||
|
||||
/**
|
||||
* Tests for {@link CrshAutoConfiguration}.
|
||||
*
|
||||
*
|
||||
* @author Christian Dupuis
|
||||
*/
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ import static org.junit.Assert.assertThat;
|
|||
|
||||
/**
|
||||
* Tests for {@link EndpointWebMvcAutoConfiguration}.
|
||||
*
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @author Greg Turnquist
|
||||
*/
|
||||
|
|
@ -84,8 +84,7 @@ public class EndpointWebMvcAutoConfigurationTests {
|
|||
@Test
|
||||
public void onSamePort() throws Exception {
|
||||
this.applicationContext.register(RootConfig.class, BaseConfiguration.class,
|
||||
ServerPortConfig.class,
|
||||
EndpointWebMvcAutoConfiguration.class);
|
||||
ServerPortConfig.class, EndpointWebMvcAutoConfiguration.class);
|
||||
this.applicationContext.refresh();
|
||||
assertContent("/controller", ports.get().server, "controlleroutput");
|
||||
assertContent("/endpoint", ports.get().server, "endpointoutput");
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ import static org.junit.Assert.assertEquals;
|
|||
|
||||
/**
|
||||
* Tests for {@link HealthIndicatorAutoConfiguration}.
|
||||
*
|
||||
*
|
||||
* @author Christian Dupuis
|
||||
*/
|
||||
public class HealthIndicatorAutoConfigurationTests {
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ import static org.junit.Assert.assertThat;
|
|||
|
||||
/**
|
||||
* Tests for {@link HealthEndpoint}.
|
||||
*
|
||||
*
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
public class HealthEndpointTests extends AbstractEndpointTests<HealthEndpoint> {
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ public class RedisServer implements TestRule {
|
|||
|
||||
/**
|
||||
* Perform cleanup of the {@link #resource} field, which is guaranteed to be non null.
|
||||
*
|
||||
*
|
||||
* @throws Exception any exception thrown by this method will be logged and swallowed
|
||||
*/
|
||||
protected void cleanupResource() throws Exception {
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ import static org.junit.Assert.assertEquals;
|
|||
|
||||
/**
|
||||
* Tests for {@link WebRequestTraceFilter}.
|
||||
*
|
||||
*
|
||||
* @author Dave Syer
|
||||
*/
|
||||
public class WebRequestTraceFilterTests {
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
@RestController
|
||||
class Application {
|
||||
|
||||
@Autowired
|
||||
String foo
|
||||
|
||||
@RequestMapping("/")
|
||||
String home() {
|
||||
"Hello ${foo}!"
|
||||
|
|
@ -10,4 +12,4 @@ class Application {
|
|||
|
||||
beans {
|
||||
foo String, "World"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -119,6 +119,7 @@ public class Shell {
|
|||
|
||||
private void attachSignalHandler() {
|
||||
SignalUtils.attachSignalHandler(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
handleSigInt();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ import org.codehaus.groovy.transform.ASTTransformation;
|
|||
/**
|
||||
* A base class for {@link ASTTransformation AST transformations} that are solely
|
||||
* interested in {@link AnnotatedNode AnnotatedNodes}.
|
||||
*
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
* @since 1.1.0
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -28,7 +28,7 @@ import org.codehaus.groovy.transform.ASTTransformation;
|
|||
* {@link ASTTransformation} to apply
|
||||
* {@link CompilerAutoConfiguration#applyDependencies(DependencyCustomizer) dependency
|
||||
* auto-configuration}.
|
||||
*
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @author Dave Syer
|
||||
* @author Andy Wilkinson
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -32,7 +32,7 @@ import org.springframework.boot.cli.compiler.dependencies.ArtifactCoordinatesRes
|
|||
* <p>
|
||||
* This class provides a fluent API for conditionally adding dependencies. For example:
|
||||
* {@code dependencies.ifMissing("com.corp.SomeClass").add(module)}.
|
||||
*
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -26,6 +26,8 @@ import org.springframework.boot.cli.compiler.grape.ManagedDependenciesFactory;
|
|||
import org.springframework.boot.dependency.tools.ManagedDependencies;
|
||||
|
||||
/**
|
||||
* Context used when resolving dependencies.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
* @since 1.1.0
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ import org.springframework.boot.groovy.GrabMetadata;
|
|||
|
||||
/**
|
||||
* {@link ASTTransformation} for processing {@link GrabMetadata @GrabMetadata}
|
||||
*
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
* @since 1.1.0
|
||||
*/
|
||||
|
|
@ -78,7 +78,6 @@ public class GrabMetadataTransformation extends AnnotatedNodeASTTransformation {
|
|||
|
||||
private void processGrabMetadataAnnotation(AnnotationNode annotationNode) {
|
||||
Expression valueExpression = annotationNode.getMember("value");
|
||||
|
||||
List<Map<String, String>> metadataDependencies = createDependencyMaps(valueExpression);
|
||||
updateArtifactCoordinatesResolver(metadataDependencies);
|
||||
}
|
||||
|
|
@ -86,32 +85,7 @@ public class GrabMetadataTransformation extends AnnotatedNodeASTTransformation {
|
|||
private List<Map<String, String>> createDependencyMaps(Expression valueExpression) {
|
||||
Map<String, String> dependency = null;
|
||||
|
||||
List<ConstantExpression> constantExpressions = new ArrayList<ConstantExpression>();
|
||||
|
||||
if (valueExpression instanceof ListExpression) {
|
||||
ListExpression listExpression = (ListExpression) valueExpression;
|
||||
for (Expression expression : listExpression.getExpressions()) {
|
||||
if (expression instanceof ConstantExpression
|
||||
&& ((ConstantExpression) expression).getValue() instanceof String) {
|
||||
constantExpressions.add((ConstantExpression) expression);
|
||||
}
|
||||
else {
|
||||
reportError(
|
||||
"Each entry in the array must be an inline string constant",
|
||||
expression);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (valueExpression instanceof ConstantExpression
|
||||
&& ((ConstantExpression) valueExpression).getValue() instanceof String) {
|
||||
constantExpressions = Arrays.asList((ConstantExpression) valueExpression);
|
||||
}
|
||||
else {
|
||||
reportError(
|
||||
"@GrabMetadata requires an inline constant that is a string or a string array",
|
||||
valueExpression);
|
||||
}
|
||||
|
||||
List<ConstantExpression> constantExpressions = getConstantExpressions(valueExpression);
|
||||
List<Map<String, String>> dependencies = new ArrayList<Map<String, String>>(
|
||||
constantExpressions.size());
|
||||
|
||||
|
|
@ -125,7 +99,6 @@ public class GrabMetadataTransformation extends AnnotatedNodeASTTransformation {
|
|||
dependency.put("module", components[1]);
|
||||
dependency.put("version", components[2]);
|
||||
dependency.put("type", "properties");
|
||||
|
||||
dependencies.add(dependency);
|
||||
}
|
||||
else {
|
||||
|
|
@ -137,6 +110,36 @@ public class GrabMetadataTransformation extends AnnotatedNodeASTTransformation {
|
|||
return dependencies;
|
||||
}
|
||||
|
||||
private List<ConstantExpression> getConstantExpressions(Expression valueExpression) {
|
||||
if (valueExpression instanceof ListExpression) {
|
||||
return getConstantExpressions((ListExpression) valueExpression);
|
||||
}
|
||||
|
||||
if (valueExpression instanceof ConstantExpression
|
||||
&& ((ConstantExpression) valueExpression).getValue() instanceof String) {
|
||||
return Arrays.asList((ConstantExpression) valueExpression);
|
||||
}
|
||||
|
||||
reportError("@GrabMetadata requires an inline constant that is a "
|
||||
+ "string or a string array", valueExpression);
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
private List<ConstantExpression> getConstantExpressions(ListExpression valueExpression) {
|
||||
List<ConstantExpression> expressions = new ArrayList<ConstantExpression>();
|
||||
for (Expression expression : valueExpression.getExpressions()) {
|
||||
if (expression instanceof ConstantExpression
|
||||
&& ((ConstantExpression) expression).getValue() instanceof String) {
|
||||
expressions.add((ConstantExpression) expression);
|
||||
}
|
||||
else {
|
||||
reportError("Each entry in the array must be an "
|
||||
+ "inline string constant", expression);
|
||||
}
|
||||
}
|
||||
return expressions;
|
||||
}
|
||||
|
||||
private void handleMalformedDependency(Expression expression) {
|
||||
Message message = createSyntaxErrorMessage(
|
||||
"The string must be of the form \"group:module:version\"\n", expression);
|
||||
|
|
@ -154,7 +157,7 @@ public class GrabMetadataTransformation extends AnnotatedNodeASTTransformation {
|
|||
managedDependencies.add(new PropertiesFileManagedDependencies(uri.toURL()
|
||||
.openStream()));
|
||||
}
|
||||
catch (IOException e) {
|
||||
catch (IOException ex) {
|
||||
throw new IllegalStateException("Failed to parse '" + uris[0]
|
||||
+ "'. Is it a valid properties file?");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,13 +56,13 @@ import org.springframework.boot.cli.util.ResourceUtils;
|
|||
* <li>{@link CompilerAutoConfiguration} strategies will be read from
|
||||
* <code>META-INF/services/org.springframework.boot.cli.compiler.CompilerAutoConfiguration</code>
|
||||
* (per the standard java {@link ServiceLoader} contract) and applied during compilation</li>
|
||||
*
|
||||
*
|
||||
* <li>Multiple classes can be returned if the Groovy source defines more than one Class</li>
|
||||
*
|
||||
*
|
||||
* <li>Generated class files can also be loaded using
|
||||
* {@link ClassLoader#getResource(String)}</li>
|
||||
* </ul>
|
||||
*
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @author Dave Syer
|
||||
* @author Andy Wilkinson
|
||||
|
|
@ -167,7 +167,7 @@ public class GroovyCompiler {
|
|||
* @throws IOException
|
||||
*/
|
||||
public Class<?>[] compile(String... sources) throws CompilationFailedException,
|
||||
IOException {
|
||||
IOException {
|
||||
|
||||
this.loader.clearCache();
|
||||
List<Class<?>> classes = new ArrayList<Class<?>>();
|
||||
|
|
@ -287,9 +287,9 @@ public class GroovyCompiler {
|
|||
classNode);
|
||||
}
|
||||
autoConfiguration
|
||||
.apply(GroovyCompiler.this.loader,
|
||||
GroovyCompiler.this.configuration, context, source,
|
||||
classNode);
|
||||
.apply(GroovyCompiler.this.loader,
|
||||
GroovyCompiler.this.configuration, context, source,
|
||||
classNode);
|
||||
}
|
||||
}
|
||||
importCustomizer.call(source, context, classNode);
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -31,12 +31,12 @@ import org.codehaus.groovy.transform.ASTTransformation;
|
|||
|
||||
/**
|
||||
* {@link ASTTransformation} to resolve {@link Grab} artifact coordinates.
|
||||
*
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
public class ResolveDependencyCoordinatesTransformation extends
|
||||
AnnotatedNodeASTTransformation {
|
||||
AnnotatedNodeASTTransformation {
|
||||
|
||||
private static final Set<String> GRAB_ANNOTATION_NAMES = Collections
|
||||
.unmodifiableSet(new HashSet<String>(Arrays.asList(Grab.class.getName(),
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -30,7 +30,7 @@ import org.springframework.boot.cli.compiler.GroovyCompilerConfiguration;
|
|||
|
||||
/**
|
||||
* {@link CompilerAutoConfiguration} for Spring.
|
||||
*
|
||||
*
|
||||
* @author Dave Syer
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
|
|
@ -39,7 +39,7 @@ public class SpringBootCompilerAutoConfiguration extends CompilerAutoConfigurati
|
|||
@Override
|
||||
public void applyDependencies(DependencyCustomizer dependencies) {
|
||||
dependencies.ifAnyMissingClasses("org.springframework.boot.SpringApplication")
|
||||
.add("spring-boot-starter");
|
||||
.add("spring-boot-starter");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import org.springframework.boot.cli.compiler.DependencyCustomizer;
|
|||
|
||||
/**
|
||||
* {@link CompilerAutoConfiguration} for Spring Integration.
|
||||
*
|
||||
*
|
||||
* @author Dave Syer
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import org.springframework.boot.dependency.tools.VersionManagedDependencies;
|
|||
|
||||
/**
|
||||
* {@link ArtifactCoordinatesResolver} backed by {@link ManagedDependencies}.
|
||||
*
|
||||
*
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
public class ManagedDependenciesArtifactCoordinatesResolver implements
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ import org.springframework.boot.cli.compiler.DependencyResolutionContext;
|
|||
* A {@link GrapeEngine} implementation that uses <a
|
||||
* href="http://eclipse.org/aether">Aether</a>, the dependency resolution system used by
|
||||
* Maven.
|
||||
*
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ import org.springframework.boot.cli.compiler.DependencyResolutionContext;
|
|||
|
||||
/**
|
||||
* Utility class to create a pre-configured {@link AetherGrapeEngine}.
|
||||
*
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
public abstract class AetherGrapeEngineFactory {
|
||||
|
|
@ -86,7 +86,7 @@ public abstract class AetherGrapeEngineFactory {
|
|||
for (RepositoryConfiguration repositoryConfiguration : repositoryConfigurations) {
|
||||
RemoteRepository.Builder builder = new RemoteRepository.Builder(
|
||||
repositoryConfiguration.getName(), "default", repositoryConfiguration
|
||||
.getUri().toASCIIString());
|
||||
.getUri().toASCIIString());
|
||||
|
||||
if (!repositoryConfiguration.getSnapshotsEnabled()) {
|
||||
builder.setSnapshotPolicy(new RepositoryPolicy(false,
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ import org.springframework.boot.dependency.tools.VersionManagedDependencies;
|
|||
/**
|
||||
* Factory to create Maven {@link Dependency} objects from Boot
|
||||
* {@link PomManagedDependencies}.
|
||||
*
|
||||
*
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
public class ManagedDependenciesFactory {
|
||||
|
|
|
|||
|
|
@ -24,12 +24,12 @@ import java.lang.annotation.Target;
|
|||
/**
|
||||
* Used to provide an alternative source of dependency metadata that is used to deduce
|
||||
* groups and versions when processing {@code @Grab} dependencies.
|
||||
*
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
* @since 1.1.0
|
||||
*/
|
||||
@Target({ ElementType.CONSTRUCTOR, ElementType.FIELD, ElementType.LOCAL_VARIABLE,
|
||||
ElementType.METHOD, ElementType.PARAMETER, ElementType.TYPE })
|
||||
ElementType.METHOD, ElementType.PARAMETER, ElementType.TYPE })
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface GrabMetadata {
|
||||
|
||||
|
|
@ -39,4 +39,5 @@ public @interface GrabMetadata {
|
|||
* default metadata.
|
||||
*/
|
||||
String[] value();
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ import static org.junit.Assert.fail;
|
|||
|
||||
/**
|
||||
* Integration tests for {@link GrabCommand}
|
||||
*
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
* @author Dave Syer
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -50,7 +50,7 @@ import static org.mockito.Mockito.when;
|
|||
|
||||
/**
|
||||
* Tests for {@link ResolveDependencyCoordinatesTransformation}
|
||||
*
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
public final class ResolveDependencyCoordinatesTransformationTests {
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ import static org.junit.Assert.assertEquals;
|
|||
|
||||
/**
|
||||
* Tests for {@link AetherGrapeEngine}.
|
||||
*
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
public class AetherGrapeEngineTests {
|
||||
|
|
@ -40,7 +40,7 @@ public class AetherGrapeEngineTests {
|
|||
private final AetherGrapeEngine grapeEngine = AetherGrapeEngineFactory.create(
|
||||
this.groovyClassLoader, Arrays.asList(new RepositoryConfiguration("central",
|
||||
URI.create("http://repo1.maven.org/maven2"), false)),
|
||||
new DependencyResolutionContext());
|
||||
new DependencyResolutionContext());
|
||||
|
||||
@Test
|
||||
public void dependencyResolution() {
|
||||
|
|
|
|||
|
|
@ -232,6 +232,8 @@ example:
|
|||
}
|
||||
----
|
||||
|
||||
|
||||
|
||||
[[build-tool-plugins-gradle-custom-version-management]]
|
||||
==== Custom version management
|
||||
If is possible to customize the versions used by the `ResolutionStrategy` if you need
|
||||
|
|
@ -257,6 +259,8 @@ the above example `mycorp-versions.properties` file might contain the following:
|
|||
The properties file takes precedence over Spring Boot's defaults, and can be used
|
||||
to override version numbers if necessary.
|
||||
|
||||
|
||||
|
||||
[[build-tool-plugins-gradle-packaging]]
|
||||
=== Packaging executable jar and war files
|
||||
Once the `spring-boot` plugin has been applied to your project it will automatically
|
||||
|
|
|
|||
|
|
@ -788,12 +788,10 @@ added.
|
|||
(defaults are both empty, but accessible for external configuration via
|
||||
`spring.view.prefix` and `spring.view.suffix`). It can be overridden by providing a
|
||||
bean of the same type.
|
||||
|
||||
* A `BeanNameViewResolver` with id ``beanNameViewResolver''. This is a useful member of the
|
||||
view resolver chain and will pick up any beans with the same name as the `View` being
|
||||
resolved. It can be overridden by providing a bean of the same type, but it's unlikely
|
||||
you will need to do that.
|
||||
|
||||
* A `ContentNegotiatingViewResolver` with id ``viewResolver'' is only added if there *are*
|
||||
actually beans of type `View` present. This is a ``master'' resolver, delegating to all
|
||||
the others and attempting to find a match to the ``Accept'' HTTP header sent by the
|
||||
|
|
@ -802,28 +800,23 @@ added.
|
|||
that you might like to study to learn more, and also look at the source code for detail.
|
||||
You can switch off the auto-configured
|
||||
`ContentNegotiatingViewResolver` by defining a bean named ``viewResolver''.
|
||||
|
||||
* If you use Thymeleaf you will also have a `ThymeleafViewResolver` with id
|
||||
``thymeleafViewResolver''. It looks for resources by surrounding the view name with a
|
||||
prefix and suffix (externalized to `spring.thymeleaf.prefix` and
|
||||
`spring.thymeleaf.suffix`, defaults ``classpath:/templates/'' and ``.html''
|
||||
respectively). It can be overridden by providing a bean of the same name.
|
||||
|
||||
* If you use FreeMarker you will also have a `FreeMarkerViewResolver` with id
|
||||
``freeMarkerViewResolver''. It looks for resources in a loader path (externalized to
|
||||
`spring.freemarker.templateLoaderPath`, default ``classpath:/templates/'') by
|
||||
surrounding the view name with a prefix and suffix (externalized to `spring.freemarker.prefix`
|
||||
and `spring.freemarker.suffix`, with empty and ``.ftl'' defaults respectively). It can be overriden
|
||||
by providing a bean of the same name.
|
||||
|
||||
and `spring.freemarker.suffix`, with empty and ``.ftl'' defaults respectively). It can
|
||||
be overridden by providing a bean of the same name.
|
||||
* If you use Groovy templates (actually if groovy-templates is on your classpath) you will
|
||||
also have a `Groovy TemplateViewResolver` with id
|
||||
``groovyTemplateViewResolver''. It looks for resources in a loader path by
|
||||
surrounding the view name with a prefix and suffix (externalized to
|
||||
`spring.groovy.template.prefix` and `spring.groovy.template.suffix`, defaults
|
||||
``classpath:/templates/'' and ``.tpl'' respectively). It can be overriden by providing a bean of
|
||||
the same name.
|
||||
|
||||
also have a `Groovy TemplateViewResolver` with id ``groovyTemplateViewResolver''. It
|
||||
looks for resources in a loader path by surrounding the view name with a prefix and
|
||||
suffix (externalized to `spring.groovy.template.prefix` and
|
||||
`spring.groovy.template.suffix`, defaults ``classpath:/templates/'' and ``.tpl''
|
||||
respectively). It can be overriden by providing a bean of the same name.
|
||||
* If you use Velocity you will also have a `VelocityViewResolver` with id ``velocityViewResolver''.
|
||||
It looks for resources in a loader path (externalized to `spring.velocity.resourceLoaderPath`,
|
||||
default ``classpath:/templates/'') by surrounding the view name with a prefix and suffix
|
||||
|
|
@ -831,7 +824,7 @@ added.
|
|||
defaults respectively). It can be overridden by providing a bean of the same name.
|
||||
|
||||
Check out {sc-spring-boot-autoconfigure}/web/WebMvcAutoConfiguration.{sc-ext}[`WebMvcAutoConfiguration`],
|
||||
{sc-spring-boot-autoconfigure}/thymeleaf/ThymeleafAutoConfiguration.{sc-ext}[`ThymeleafAutoConfiguration`],
|
||||
{sc-spring-boot-autoconfigure}/thymeleaf/ThymeleafAutoConfiguration.{sc-ext}[`ThymeleafAutoConfiguration`],
|
||||
{sc-spring-boot-autoconfigure}/freemarker/FreeMarkerAutoConfiguration.{sc-ext}[`FreeMarkerAutoConfiguration`],
|
||||
{sc-spring-boot-autoconfigure}/groovy/template/GroovyTemplateAutoConfiguration.{sc-ext}[`GroovyTemplateAutoConfiguration`] and
|
||||
{sc-spring-boot-autoconfigure}/velocity/VelocityAutoConfiguration.{sc-ext}[`VelocityAutoConfiguration`]
|
||||
|
|
@ -1400,6 +1393,7 @@ If you are using Thymeleaf, then set `spring.thymeleaf.cache` to `false`. See
|
|||
for other Thymeleaf customization options.
|
||||
|
||||
|
||||
|
||||
[[howto-reload-freemarker-content]]
|
||||
=== Reload FreeMarker templates without restarting the container
|
||||
If you are using FreeMarker, then set `spring.freemarker.cache` to `false`. See
|
||||
|
|
@ -1407,6 +1401,7 @@ If you are using FreeMarker, then set `spring.freemarker.cache` to `false`. See
|
|||
for other FreeMarker customization options.
|
||||
|
||||
|
||||
|
||||
[[howto-reload-groovy-template-content]]
|
||||
=== Reload Groovy templates without restarting the container
|
||||
If you are using Groovy templates, then set `spring.groovy.template.cache` to `false`. See
|
||||
|
|
@ -1414,6 +1409,7 @@ If you are using Groovy templates, then set `spring.groovy.template.cache` to `f
|
|||
for other Groovy customization options.
|
||||
|
||||
|
||||
|
||||
[[howto-reload-velocity-content]]
|
||||
=== Reload Velocity templates without restarting the container
|
||||
If you are using Velocity, then set `spring.velocity.cache` to `false`. See
|
||||
|
|
@ -1421,6 +1417,7 @@ If you are using Velocity, then set `spring.velocity.cache` to `false`. See
|
|||
for other Velocity customization options.
|
||||
|
||||
|
||||
|
||||
[[howto-reload-java-classes-without-restarting]]
|
||||
=== Reload Java classes without restarting the container
|
||||
Modern IDEs (Eclipse, IDEA, etc.) all support hot swapping of bytecode, so if you make a
|
||||
|
|
|
|||
|
|
@ -906,16 +906,16 @@ and it will be silently ignored by most build tools if you generate a jar.
|
|||
[[boot-features-spring-mvc-template-engines]]
|
||||
==== Template engines
|
||||
|
||||
As well as REST web services, you can also use Spring MVC to serve dynamic HTML content. Spring
|
||||
MVC supports a variety of templating technologies including Velocity, FreeMarker and JSPs. Many
|
||||
other templating engines also ship their own Spring MVC integrations.
|
||||
As well as REST web services, you can also use Spring MVC to serve dynamic HTML content.
|
||||
Spring MVC supports a variety of templating technologies including Velocity, FreeMarker
|
||||
and JSPs. Many other templating engines also ship their own Spring MVC integrations.
|
||||
|
||||
Spring Boot includes auto-configuration support for the following templating engines:
|
||||
|
||||
- http://freemarker.org/docs/[FreeMarker]
|
||||
- http://beta.groovy-lang.org/docs/groovy-2.3.0/html/documentation/markup-template-engine.html[Groovy]
|
||||
- http://www.thymeleaf.org[Thymeleaf]
|
||||
- http://velocity.apache.org[Velocity]
|
||||
* http://freemarker.org/docs/[FreeMarker]
|
||||
* http://beta.groovy-lang.org/docs/groovy-2.3.0/html/documentation/markup-template-engine.html[Groovy]
|
||||
* http://www.thymeleaf.org[Thymeleaf]
|
||||
* http://velocity.apache.org[Velocity]
|
||||
|
||||
When you're using one of these templating engines with the default configuration, your templates
|
||||
will be picked up automatically from `src/main/resources/templates`.
|
||||
|
|
@ -1131,8 +1131,8 @@ The basic features you get out of the box in a web application are:
|
|||
on by default.
|
||||
|
||||
All of the above can be switched on and off or modified using external properties
|
||||
(`security.*`). To override the access rules without changing any other autoconfigured
|
||||
features add a `@Bean` of type `WebConfigurerAdapter` with
|
||||
(`security.*`). To override the access rules without changing any other autoconfigured
|
||||
features add a `@Bean` of type `WebConfigurerAdapter` with
|
||||
`@Order(SecurityProperties.ACCESS_OVERRIDE_ORDER)`.
|
||||
|
||||
If the Actuator is also in use, you will find:
|
||||
|
|
@ -1142,10 +1142,10 @@ If the Actuator is also in use, you will find:
|
|||
* The default user will have the "ADMIN" role as well as the "USER" role.
|
||||
|
||||
The Actuator security features can be modified using external properties
|
||||
(`management.security.*`). To override the application access rules
|
||||
(`management.security.*`). To override the application access rules
|
||||
add a `@Bean` of type `WebConfigurerAdapter` and use
|
||||
`@Order(SecurityProperties.ACCESS_OVERRIDE_ORDER)` if you _don't_ want to override
|
||||
the actuator access rules, or `@Order(ManagementServerProperties.ACCESS_OVERRIDE_ORDER)`
|
||||
the actuator access rules, or `@Order(ManagementServerProperties.ACCESS_OVERRIDE_ORDER)`
|
||||
if you _do_ want to override the actuator access rules.
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -22,8 +22,8 @@ import org.junit.Test;
|
|||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.test.IntegrationTest;
|
||||
import org.springframework.boot.test.TestRestTemplate;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.TestRestTemplate;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
|
|
|
|||
|
|
@ -67,6 +67,7 @@ public class EndpointsPropertiesSampleActuatorApplicationTests {
|
|||
ResponseEntity<String> entity = new TestRestTemplate().getForEntity(
|
||||
"http://localhost:" + this.port + "/admin/health", String.class);
|
||||
assertEquals(HttpStatus.OK, entity.getStatusCode());
|
||||
assertTrue("Wrong body: " + entity.getBody(), entity.getBody().contains("\"status\":\"ok\""));
|
||||
assertTrue("Wrong body: " + entity.getBody(),
|
||||
entity.getBody().contains("\"status\":\"ok\""));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,7 +72,8 @@ public class ManagementAddressActuatorApplicationTests {
|
|||
"http://localhost:" + this.managementPort + "/admin/health",
|
||||
String.class);
|
||||
assertEquals(HttpStatus.OK, entity.getStatusCode());
|
||||
assertTrue("Wrong body: " + entity.getBody(), entity.getBody().contains("\"status\":\"ok\""));
|
||||
assertTrue("Wrong body: " + entity.getBody(),
|
||||
entity.getBody().contains("\"status\":\"ok\""));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -81,7 +81,8 @@ public class ManagementPortSampleActuatorApplicationTests {
|
|||
ResponseEntity<String> entity = new TestRestTemplate().getForEntity(
|
||||
"http://localhost:" + this.managementPort + "/health", String.class);
|
||||
assertEquals(HttpStatus.OK, entity.getStatusCode());
|
||||
assertTrue("Wrong body: " + entity.getBody(), entity.getBody().contains("\"status\":\"ok\""));
|
||||
assertTrue("Wrong body: " + entity.getBody(),
|
||||
entity.getBody().contains("\"status\":\"ok\""));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -130,7 +130,8 @@ public class SampleActuatorApplicationTests {
|
|||
ResponseEntity<String> entity = new TestRestTemplate().getForEntity(
|
||||
"http://localhost:" + this.port + "/health", String.class);
|
||||
assertEquals(HttpStatus.OK, entity.getStatusCode());
|
||||
assertTrue("Wrong body: " + entity.getBody(), entity.getBody().contains("\"status\":\"ok\""));
|
||||
assertTrue("Wrong body: " + entity.getBody(),
|
||||
entity.getBody().contains("\"status\":\"ok\""));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ import static org.junit.Assert.assertTrue;
|
|||
|
||||
/**
|
||||
* Tests for {@link SampleMongoApplication}.
|
||||
*
|
||||
*
|
||||
* @author Dave Syer
|
||||
*/
|
||||
public class SampleMongoApplicationTests {
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -39,7 +39,7 @@ public class SampleFlywayApplication implements CommandLineRunner {
|
|||
|
||||
@Override
|
||||
public void run(String... args) throws Exception {
|
||||
System.err.println(repository.findAll());
|
||||
System.err.println(this.repository.findAll());
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
|
@ -61,7 +61,7 @@ class Person {
|
|||
private String lastName;
|
||||
|
||||
public String getFirstName() {
|
||||
return firstName;
|
||||
return this.firstName;
|
||||
}
|
||||
|
||||
public void setFirstName(String firstName) {
|
||||
|
|
@ -69,7 +69,7 @@ class Person {
|
|||
}
|
||||
|
||||
public String getLastName() {
|
||||
return lastName;
|
||||
return this.lastName;
|
||||
}
|
||||
|
||||
public void setLastName(String lastname) {
|
||||
|
|
@ -78,7 +78,7 @@ class Person {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Person [firstName=" + firstName + ", lastName=" + lastName
|
||||
return "Person [firstName=" + this.firstName + ", lastName=" + this.lastName
|
||||
+ "]";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,8 +16,6 @@
|
|||
|
||||
package sample.flyway;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
|
@ -25,16 +23,19 @@ import org.springframework.boot.test.SpringApplicationConfiguration;
|
|||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SpringApplicationConfiguration(classes=SampleFlywayApplication.class)
|
||||
@SpringApplicationConfiguration(classes = SampleFlywayApplication.class)
|
||||
public class SampleFlywayApplicationTests {
|
||||
|
||||
|
||||
@Autowired
|
||||
private JdbcTemplate template;
|
||||
|
||||
|
||||
@Test
|
||||
public void testDefaultSettings() throws Exception {
|
||||
assertEquals(new Integer(1), template.queryForObject("SELECT COUNT(*) from PERSON", Integer.class));
|
||||
assertEquals(new Integer(1), this.template.queryForObject(
|
||||
"SELECT COUNT(*) from PERSON", Integer.class));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,4 +29,5 @@ public class SampleLiquibaseApplication {
|
|||
public static void main(String[] args) throws Exception {
|
||||
SpringApplication.run(SampleLiquibaseApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,14 +41,20 @@ public class SampleLiquibaseApplicationTests {
|
|||
}
|
||||
}
|
||||
String output = this.outputCapture.toString();
|
||||
assertTrue("Wrong output: " + output,
|
||||
output.contains("Successfully acquired change log lock") &&
|
||||
output.contains("Creating database history table with name: PUBLIC.DATABASECHANGELOG") &&
|
||||
output.contains("Table person created") &&
|
||||
output.contains("ChangeSet classpath:/db/changelog/db.changelog-master.yaml::1::marceloverdijk ran successfully") &&
|
||||
output.contains("New row inserted into person") &&
|
||||
output.contains("ChangeSet classpath:/db/changelog/db.changelog-master.yaml::2::marceloverdijk ran successfully") &&
|
||||
output.contains("Successfully released change log lock"));
|
||||
assertTrue(
|
||||
"Wrong output: " + output,
|
||||
output.contains("Successfully acquired change log lock")
|
||||
&& output.contains("Creating database history "
|
||||
+ "table with name: PUBLIC.DATABASECHANGELOG")
|
||||
&& output.contains("Table person created")
|
||||
&& output.contains("ChangeSet classpath:/db/"
|
||||
+ "changelog/db.changelog-master.yaml::1::"
|
||||
+ "marceloverdijk ran successfully")
|
||||
&& output.contains("New row inserted into person")
|
||||
&& output.contains("ChangeSet classpath:/db/changelog/"
|
||||
+ "db.changelog-master.yaml::2::"
|
||||
+ "marceloverdijk ran successfully")
|
||||
&& output.contains("Successfully released change log lock"));
|
||||
}
|
||||
|
||||
private boolean serverNotRunning(IllegalStateException ex) {
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ import static org.junit.Assert.assertTrue;
|
|||
|
||||
/**
|
||||
* Basic integration tests for FreeMarker application.
|
||||
*
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
|
|
@ -69,8 +69,8 @@ public class SampleWebFreeMarkerApplicationTests {
|
|||
HttpEntity<String> requestEntity = new HttpEntity<String>(headers);
|
||||
|
||||
ResponseEntity<String> responseEntity = new TestRestTemplate().exchange(
|
||||
"http://localhost:" +port+ "/does-not-exist", HttpMethod.GET, requestEntity,
|
||||
String.class);
|
||||
"http://localhost:" + port + "/does-not-exist", HttpMethod.GET,
|
||||
requestEntity, String.class);
|
||||
|
||||
assertEquals(HttpStatus.NOT_FOUND, responseEntity.getStatusCode());
|
||||
assertTrue("Wrong body:\n" + responseEntity.getBody(), responseEntity.getBody()
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -20,9 +20,6 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||
import java.util.concurrent.ConcurrentMap;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*/
|
||||
public class InMemoryMessageRespository implements MessageRepository {
|
||||
|
||||
private static AtomicLong counter = new AtomicLong();
|
||||
|
|
|
|||
|
|
@ -1,14 +1,17 @@
|
|||
/*
|
||||
* Copyright 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. You may obtain a copy of the License at
|
||||
* 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
|
||||
* 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.
|
||||
* 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 sample.ui;
|
||||
|
|
@ -17,9 +20,6 @@ import java.util.Date;
|
|||
|
||||
import org.hibernate.validator.constraints.NotEmpty;
|
||||
|
||||
/**
|
||||
* @author Rob Winch
|
||||
*/
|
||||
public class Message {
|
||||
|
||||
private Long id;
|
||||
|
|
|
|||
|
|
@ -1,21 +1,21 @@
|
|||
/*
|
||||
* Copyright 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. You may obtain a copy of the License at
|
||||
* 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
|
||||
* 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.
|
||||
* 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 sample.ui;
|
||||
|
||||
/**
|
||||
* @author Rob Winch
|
||||
*/
|
||||
public interface MessageRepository {
|
||||
|
||||
Iterable<Message> findAll();
|
||||
|
|
|
|||
|
|
@ -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,16 +1,18 @@
|
|||
/*
|
||||
* Copyright 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. You may obtain a copy of the License at
|
||||
* 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
|
||||
* 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.
|
||||
* 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 sample.ui.mvc;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
|
@ -33,9 +35,6 @@ import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
|||
import sample.ui.Message;
|
||||
import sample.ui.MessageRepository;
|
||||
|
||||
/**
|
||||
* @author Rob Winch
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/")
|
||||
public class MessageController {
|
||||
|
|
@ -81,7 +80,7 @@ public class MessageController {
|
|||
for (FieldError error : result.getFieldErrors()) {
|
||||
map.put(error.getField(), error);
|
||||
}
|
||||
return map ;
|
||||
return map;
|
||||
}
|
||||
|
||||
@RequestMapping("foo")
|
||||
|
|
|
|||
|
|
@ -16,13 +16,6 @@
|
|||
|
||||
package sample.ui;
|
||||
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.header;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.hamcrest.Description;
|
||||
|
|
@ -39,6 +32,13 @@ import org.springframework.test.web.servlet.MockMvc;
|
|||
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.header;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
/**
|
||||
* A Basic Spring MVC Test for the Sample Controller"
|
||||
*
|
||||
|
|
|
|||
|
|
@ -16,10 +16,6 @@
|
|||
|
||||
package sample.ui;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import org.junit.Test;
|
||||
|
|
@ -36,6 +32,10 @@ import org.springframework.test.context.web.WebAppConfiguration;
|
|||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* Basic integration tests for demo application.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -59,8 +59,7 @@ public class SampleMethodSecurityApplication extends WebMvcConfigurerAdapter {
|
|||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
new SpringApplicationBuilder(SampleMethodSecurityApplication.class)
|
||||
.run(args);
|
||||
new SpringApplicationBuilder(SampleMethodSecurityApplication.class).run(args);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -83,26 +82,23 @@ public class SampleMethodSecurityApplication extends WebMvcConfigurerAdapter {
|
|||
public void init(AuthenticationManagerBuilder auth) throws Exception {
|
||||
// @formatter:off
|
||||
auth.inMemoryAuthentication().withUser("admin").password("admin")
|
||||
.roles("ADMIN", "USER").and().withUser("user")
|
||||
.password("user").roles("USER");
|
||||
.roles("ADMIN", "USER").and().withUser("user").password("user")
|
||||
.roles("USER");
|
||||
// @formatter:on
|
||||
}
|
||||
}
|
||||
|
||||
@Order(SecurityProperties.ACCESS_OVERRIDE_ORDER)
|
||||
protected static class ApplicationSecurity extends
|
||||
WebSecurityConfigurerAdapter {
|
||||
protected static class ApplicationSecurity extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
// @formatter:off
|
||||
http.authorizeRequests().antMatchers("/login").permitAll()
|
||||
.anyRequest().fullyAuthenticated().and().formLogin()
|
||||
.loginPage("/login").failureUrl("/login?error").and()
|
||||
.logout()
|
||||
.logoutRequestMatcher(new AntPathRequestMatcher("/logout"))
|
||||
.and().exceptionHandling()
|
||||
.accessDeniedPage("/access?error");
|
||||
http.authorizeRequests().antMatchers("/login").permitAll().anyRequest()
|
||||
.fullyAuthenticated().and().formLogin().loginPage("/login")
|
||||
.failureUrl("/login?error").and().logout()
|
||||
.logoutRequestMatcher(new AntPathRequestMatcher("/logout")).and()
|
||||
.exceptionHandling().accessDeniedPage("/access?error");
|
||||
// @formatter:on
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,9 +16,6 @@
|
|||
|
||||
package sample.ui.method;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
|
@ -41,6 +38,9 @@ import org.springframework.test.context.web.WebAppConfiguration;
|
|||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* Basic integration tests for demo application.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -52,8 +52,8 @@ public class SampleWebSecureApplication extends WebMvcConfigurerAdapter {
|
|||
|
||||
public static void main(String[] args) throws Exception {
|
||||
// Set user password to "password" for demo purposes only
|
||||
new SpringApplicationBuilder(SampleWebSecureApplication.class)
|
||||
.properties("security.user.password=password").run(args);
|
||||
new SpringApplicationBuilder(SampleWebSecureApplication.class).properties(
|
||||
"security.user.password=password").run(args);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -67,13 +67,11 @@ public class SampleWebSecureApplication extends WebMvcConfigurerAdapter {
|
|||
}
|
||||
|
||||
@Order(SecurityProperties.ACCESS_OVERRIDE_ORDER)
|
||||
protected static class ApplicationSecurity extends
|
||||
WebSecurityConfigurerAdapter {
|
||||
protected static class ApplicationSecurity extends WebSecurityConfigurerAdapter {
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
http.authorizeRequests().anyRequest().fullyAuthenticated().and()
|
||||
.formLogin().loginPage("/login").failureUrl("/login?error")
|
||||
.permitAll();
|
||||
http.authorizeRequests().anyRequest().fullyAuthenticated().and().formLogin()
|
||||
.loginPage("/login").failureUrl("/login?error").permitAll();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ import static org.junit.Assert.assertTrue;
|
|||
|
||||
/**
|
||||
* Basic integration tests for Velocity application.
|
||||
*
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -129,5 +129,4 @@
|
|||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
|
|
|
|||
|
|
@ -30,8 +30,9 @@ import org.w3c.dom.NodeList;
|
|||
|
||||
/**
|
||||
* {@link ManagedDependencies} implementation backed a maven POM.
|
||||
*
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @author Andy Wilkinson
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public class PomManagedDependencies extends AbstractManagedDependencies {
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ import java.util.TreeMap;
|
|||
* {@link ManagedDependencies} backed by an external properties file (of the form created
|
||||
* by the Spring IO platform). The property key should be the groupId and artifactId (in
|
||||
* the form {@literal groupId:artifactId}) and the value should be the version.
|
||||
*
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @since 1.1.0
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import java.util.Collections;
|
|||
* {@link ManagedDependencies} used by various spring boot tools. Provides programmatic
|
||||
* access to 'spring-boot-dependencies' and can also support user defined version managed
|
||||
* dependencies.
|
||||
*
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @since 1.1.0
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ import static org.junit.Assert.assertThat;
|
|||
|
||||
/**
|
||||
* Tests for {@link PomManagedDependencies}.
|
||||
*
|
||||
*
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
public class PomManagedDependenciesTests {
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ import org.springframework.boot.loader.util.AsciiBytes;
|
|||
|
||||
/**
|
||||
* {@link java.net.JarURLConnection} used to support {@link JarFile#getUrl()}.
|
||||
*
|
||||
*
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
class JarURLConnection extends java.net.JarURLConnection {
|
||||
|
|
|
|||
|
|
@ -95,7 +95,8 @@ public abstract class AbstractDependencyFilterMojo extends AbstractMojo {
|
|||
}
|
||||
filters.addFilter(new ArtifactIdFilter("",
|
||||
cleanFilterConfig(this.excludeArtifactIds)));
|
||||
filters.addFilter(new MatchingGroupIdFilter(cleanFilterConfig(this.excludeGroupIds)));
|
||||
filters.addFilter(new MatchingGroupIdFilter(
|
||||
cleanFilterConfig(this.excludeGroupIds)));
|
||||
if (this.excludes != null) {
|
||||
filters.addFilter(new ExcludeFilter(this.excludes));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.maven;
|
||||
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
|
|
@ -6,10 +22,11 @@ import org.apache.maven.shared.artifact.filter.collection.AbstractArtifactFeatur
|
|||
/**
|
||||
* An {@link org.apache.maven.shared.artifact.filter.collection.ArtifactsFilter
|
||||
* ArtifactsFilter} that filters by matching groupId.
|
||||
*
|
||||
* Preferred over the {@link org.apache.maven.shared.artifact.filter.collection.GroupIdFilter} due
|
||||
* to that classes use of {@link String#startsWith} to match on prefix.
|
||||
*
|
||||
*
|
||||
* Preferred over the
|
||||
* {@link org.apache.maven.shared.artifact.filter.collection.GroupIdFilter} due to that
|
||||
* classes use of {@link String#startsWith} to match on prefix.
|
||||
*
|
||||
* @author Mark Ingram
|
||||
* @since 1.1
|
||||
*/
|
||||
|
|
@ -22,7 +39,9 @@ public class MatchingGroupIdFilter extends AbstractArtifactFeatureFilter {
|
|||
super("", exclude);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getArtifactFeature(Artifact artifact) {
|
||||
return artifact.getGroupId();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ import static org.mockito.BDDMockito.given;
|
|||
import static org.mockito.Mockito.mock;
|
||||
|
||||
/**
|
||||
* Tests for {@link AbstractDependencyFilterMojo}.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
|
|
@ -54,7 +55,7 @@ public class DependencyFilterMojoTests {
|
|||
@Test
|
||||
public void filterGroupIdExactMatch() throws MojoExecutionException {
|
||||
TestableDependencyFilterMojo mojo = new TestableDependencyFilterMojo(
|
||||
Collections.<Exclude>emptyList(), "com.foo", "");
|
||||
Collections.<Exclude> emptyList(), "com.foo", "");
|
||||
|
||||
Artifact artifact = createArtifact("com.foo.bar", "one");
|
||||
Set<Artifact> artifacts = mojo.filterDependencies(
|
||||
|
|
@ -91,5 +92,6 @@ public class DependencyFilterMojoTests {
|
|||
public void execute() throws MojoExecutionException, MojoFailureException {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,9 @@ import org.springframework.boot.context.embedded.AbstractEmbeddedServletContaine
|
|||
import org.springframework.util.SocketUtils;
|
||||
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.anyObject;
|
||||
import static org.mockito.Mockito.inOrder;
|
||||
|
|
|
|||
Loading…
Reference in New Issue